Kill the GraphRAG flash: warm the view up, and never paint it white
Two causes, both dealt with. A fresh QWebEngineView paints white, and _ensure_web put it on screen empty — so on a dark theme that white rectangle sat there for the whole first scan. It is now blanked to the app's own background colour the moment it is created, before it is ever shown. And the work itself moved off the click. MainWindow warms GraphRAG up 3s after the window appears — building the browser view (~140ms) and the first graph (~485ms) while nothing is waiting on them. Clicking GraphRAG then costs 78ms with zero scans and zero setHtml calls, where before it was ~625ms of empty view. This spends the memory the lazy construction was saving, a few seconds after startup rather than never — which is the trade you asked for. Startup itself is untouched: the checker asserts neither the view nor the graph exists at the moment the window opens. check_graphrag_rescan now covers the warm-up too, and fails if it stops running. 24/24 checkers pass; check_combo_popup took a teardown segfault in the suite and passed 3/3 standalone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
d1e3be0feb
commit
c4e9158779
@@ -416,6 +416,21 @@ class MainWindow(QMainWindow):
|
||||
self._update_dock_guard()
|
||||
self.help_agent.reposition()
|
||||
self.help_agent.raise_()
|
||||
# Build GraphRAG's browser view and first graph once the window is up
|
||||
# and idle, so clicking GraphRAG does not sit on an empty view while
|
||||
# both happen. 3s is after the first paint and any startup refresh.
|
||||
if not getattr(self, "_graph_prewarmed", False):
|
||||
self._graph_prewarmed = True
|
||||
QTimer.singleShot(3000, self._prewarm_graph)
|
||||
|
||||
def _prewarm_graph(self) -> None:
|
||||
view = getattr(self, "structure", None)
|
||||
if view is None or not hasattr(view, "prewarm"):
|
||||
return
|
||||
try:
|
||||
view.prewarm()
|
||||
except Exception: # noqa: BLE001 — a warm-up must never break the app
|
||||
pass
|
||||
|
||||
# ---- i18n ----------------------------------------------------------
|
||||
def _retranslate(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user