fix(web): LadybugDB getAllRows, loadServerGraph, BM25, highlight clearing#474
Conversation
…ring - Replace result.getAll() with result.getAllRows() across lbug-adapter (getAll doesn't exist in LadybugDB WASM v0.15.1) - Add loadServerGraph worker method that pipes server data through initLbug/loadGraphToLbug for in-browser querying - Extract finalizePipeline helper (shared by runPipeline, runPipelineFromFiles) - Fix buildBM25Index called with graph object instead of fileContents Map - Fix 'Turn off all highlights' to clear sigma selection, AI tool/citation highlights, and blast radius Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds .githooks/pre-commit mirroring CI checks: - gitnexus-web/: tsc -b --noEmit + vitest run (if web files staged) - gitnexus/: tsc --noEmit + vitest run --project default (if CLI files staged) Activated via git config core.hooksPath in the prepare script. Skip with git commit --no-verify. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@jreakin is attempting to deploy a commit to the NexusCore Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
This PR restores server-connect mode in the web UI by ensuring server-provided graphs are fully hydrated into the worker-side indexes (LadybugDB + BM25) and by improving highlight/selection clearing behavior, plus adds a local pre-commit hook setup.
Changes:
- Add a worker API to load server graphs into LadybugDB and build BM25 indexes (and refactor shared “post-pipeline” finalization).
- Update app state + server-connect flow to call the new worker loader and clear additional AI highlight state.
- Add/auto-enable a pre-commit hook that runs typecheck + unit tests for affected packages.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
gitnexus/package.json |
Extends prepare to set core.hooksPath for the new git hooks. |
gitnexus-web/src/workers/ingestion.worker.ts |
Adds finalizePipeline and loadServerGraph to hydrate LadybugDB + BM25 in server mode. |
gitnexus-web/src/hooks/useAppState.tsx |
Exposes loadServerGraph and adds clearing for AI citation highlights during repo switch. |
gitnexus-web/src/components/GraphCanvas.tsx |
“Turn off all highlights” now clears AI tool/citation highlights, blast radius, and selection. |
gitnexus-web/src/App.tsx |
Updates server-connect handling to use loadServerGraph and adjusts repo list fetching. |
.githooks/pre-commit |
Adds a pre-commit hook running typecheck + unit tests based on staged package changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Can we use husky for precommits? |
Per maintainer request. Husky is activated via `cd .. && husky` in the prepare script. The pre-commit hook mirrors CI: typecheck + unit tests for both packages when relevant files are staged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@magyargergo Done — switched from custom The |
|
Claude finished @magyargergo's task in 2m 30s —— View job PR Review: fix(web) LadybugDB getAllRows, loadServerGraph, BM25, highlight clearing
Verdict: Almost ready — one real bug to fix before merging, the rest are minor Architectural Fit ✅The structure is sound across all four fixes:
Highlight clearing ( Performance ✅No new regressions introduced. The server graph data (nodes/relationships/fileContents) does pass through structured-clone twice (server → main thread → worker), but that was true before this PR. The BM25 fallback in the catch block is correct — if LadybugDB fails, text search still works. Split from PR #303 ✅The split is clean and appropriately scoped. This PR contains only:
Security, CSV/schema, perf, CI/tests, and docs are all deferred to PRs 2–6 per the stack description. No leakage from those areas detected in the diff. Issues🔴 Real bug — should fix before merging Stale progress indicator after initial server connect ( The connectToServer(...).then(async (result) => {
await handleServerConnect(result); // transitions to 'exploring'
setServerBaseUrl(baseUrl);
fetchRepos(baseUrl)... // ← progress is still set from download phase
})
Fix: call 🟡 Minor — address in this PR or a follow-up Unconditional } catch (err) {
console.warn('LadybugDB load failed (non-fatal, continuing without it):', err);The Misleading comment ( // Run connect and repo list in parallel (avoid waterfall)
await handleServerConnect(result); // ← awaited first
fetchRepos(baseUrl).then(...) // ← starts afterThis is sequential, not parallel. The comment is inaccurate (though the behavior is intentional and correct — graph must load before showing UI). Worth updating to avoid confusion for future contributors. Copilot Comments Assessment
SummaryThe four core bug fixes are correct, well-placed, and architecturally consistent. The |
- Clear progress after handleServerConnect in both auto-connect and DropZone paths (fixes frozen progress bar on StatusBar) - Replace shell-based prepare script with Node scripts/prepare.cjs for Windows cmd.exe compatibility - Gate LadybugDB load warning behind import.meta.env.DEV (consistent with finalizePipeline's silent catch) - Remove misleading "parallel" comment (fetch is sequential after connect) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
All review items addressed in
|
CI Report✅ All checks passed Pipeline
Tests
✅ All 3692 tests passed across 1060 files 18 test(s) skipped
Coverage
📋 Full run · Coverage from Ubuntu · Generated by CI |
|
@claude recommend testing this change reliably with positive and negative tests. |
|
Claude finished @magyargergo's task in 2m 11s —— View job Test Recommendations for PR #474The PR has two existing test files that cover parts of the fix. Below is a gap analysis and concrete test cases for each of the four bugs — including positive (happy path) and negative (failure/edge case) tests. Fix 1 —
|
| Priority | Test | Reason |
|---|---|---|
| 🔴 High | BM25 regression guard (non-Map input) | Documents original silent failure mode |
| 🔴 High | BM25 still builds when LadybugDB throws | Covers the catch branch, critical fallback |
| 🟡 Medium | getQueryRows — getAllRows throws propagates |
Error visibility for query failures |
| 🟡 Medium | Highlight clear — negative case (toggle-on path) | Guards against scope creep in the handler |
| 🟡 Medium | setProgress(null) in error path |
Stale UI state regression |
| 🟢 Low | buildPipelineResultFromSerialized no cross-contamination |
State isolation on repeated connects |
| 🟢 Low | Malformed relationship IDs don't throw | Defensive — server data may be inconsistent |
16 tests covering the data structures and logic underlying each fix: createKnowledgeGraph (loadServerGraph data flow): + nodes stored correctly via addNode + relationships stored correctly via addRelationship + deduplication by ID + nodeCount reflects unique count - empty graph has zero counts - relationships with non-existent nodes still stored loadServerGraph data flow: + server data reconstructs into valid KnowledgeGraph + fileContents Map built from server entries - empty server data produces empty graph - fileContents replaces (not accumulates) on reload BM25 index argument type: + Map<string, string> has entries() for BM25 - KnowledgeGraph does NOT have entries() (the original bug) Highlight clearing: + clearing Set produces empty set + independent highlight sources cleared separately - clearing highlights doesn't affect node selection - toggling AI ON doesn't clear process highlights Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@magyargergo Added 16 positive and negative tests in createKnowledgeGraph / loadServerGraph data flow:
Server data reconstruction:
BM25 index argument type (the original bug):
Highlight clearing:
Test coverage across the full stack:
|
|
@claude I don't think we need to run husky for the prepare... we should be able to simplify that, right? |
|
Claude finished @magyargergo's task in 1m 36s —— View job
What was done
"prepare": "npm run build"And
The commit is ready locally ( git fetch # or cherry-pick 08c9247
# In gitnexus/package.json, change:
# "prepare": "node scripts/prepare.cjs"
# to:
# "prepare": "npm run build"
# Then delete gitnexus/scripts/prepare.cjs |
|
@jreakin could you please address this? after that change, I'll merge this PR :) |
.husky/pre-commit is committed to the repo — developers get the hook by cloning, not by running npm install. prepare only needs to build TypeScript for npm publish/pack. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Applied in
|
…er-highlights fix(web): LadybugDB getAllRows, loadServerGraph, BM25, highlight clearing
Summary
Fixes 4 critical bugs that broke server-connect mode entirely. Split from #303 per maintainer request (PR 1 of 6).
Bug Fixes
getAll()→getAllRows()— LadybugDB WASM v0.15.1 hasgetAllRows(), notgetAll(). Every Cypher query in the web UI silently failed, breaking Processes View, lightbulb highlights, Nexus AI, and all graph queries.loadServerGraphworker method — Server connections bypassed LadybugDB entirely. The graph rendered in sigma.js but the in-browser database was never loaded. Adds worker method that pipes server data throughinitLbug/loadGraphToLbug.buildBM25Indexwas called with the graph object instead of thefileContentsMap, silently breaking text search for server connections.selectedNodeRef, AI tool/citation highlights, and blast radius (not just process highlights).Pre-commit hook
.githooks/pre-commitruns typecheck + unit tests for both packages before every commit, mirroring CI. Activated viagit config core.hooksPathin thepreparescript.Test plan
gitnexus serve— Nexus AI initializes without "Database not ready"cd gitnexus-web && npx tsc --noEmit— cleancd gitnexus && npx tsc --noEmit— clean🤖 Generated with Claude Code