Files
cowork-local/ui
Nam Pham Dinh ThanhandClaude Opus 5 d1e3be0feb GraphRAG rebuilds when opened, not on every project switch
Measured what a visit costs: 140ms to construct the QWebEngineView the first
time, 485ms to walk the folder and lay the graph out, and a setHtml of the whole
D3 page to show it. The setHtml is the flash — the page really is reloaded.

Once built it is not repeated: three round trips in and out rescanned nothing.
What did repeat was project switching. _refresh_project_combo scanned
immediately on any change, and the rail's picker put that one click away from
every screen — so the graph was rebuilt again and again for a tab usually not on
screen, and the visit after a switch always paid for a reload.

It now marks _needs_scan and lets auto_scan_and_fit() pick it up when GraphRAG
is actually opened: two switches from Cowork cost 0 scans, and opening it after
costs exactly 1.

The first visit per run still builds the browser view and scans, which is the
lazy construction the code chose deliberately to keep startup light. That one is
a trade, not a bug; say if you would rather pay it at startup.

check_graphrag_rescan covers all three: no rebuild on an unchanged re-entry, no
scan while off-screen, exactly one on opening.

24/24 checkers pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 20:34:08 +09:00
..