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>
This commit is contained in:
co-authored by
Claude Opus 5
parent
2f73aaa333
commit
d1e3be0feb
@@ -404,10 +404,13 @@ class StructureGraphView(QWidget):
|
||||
if project is not None:
|
||||
self.path_edit.setText(str(project.workspace_dir()))
|
||||
if project_changed:
|
||||
# Mark it and scan on the next visit rather than now. The rail's
|
||||
# project picker made switching a one-click thing from any screen,
|
||||
# and each switch rebuilt this graph — a folder walk plus a force
|
||||
# layout plus a full setHtml of the D3 page — for a tab that was
|
||||
# usually not even on screen. auto_scan_and_fit() picks the flag up
|
||||
# when GraphRAG is actually opened.
|
||||
self._needs_scan = True
|
||||
if self.web is not None:
|
||||
self._needs_scan = False
|
||||
self._scan()
|
||||
|
||||
# ---- helpers -----------------------------------------------------
|
||||
def _pick(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user