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
@@ -50,24 +50,39 @@ def main() -> int:
|
||||
win.show()
|
||||
app.processEvents()
|
||||
st, w = win.structure, win.workspace
|
||||
fails = []
|
||||
fails: list[str] = []
|
||||
|
||||
# first visit builds the view and scans once
|
||||
win._goto(win._ROW_WORKSPACE, w._graphrag_tab_idx)
|
||||
# startup itself must not build any of it
|
||||
if st.web is not None or st._graph is not None:
|
||||
fails.append("dung san do thi ngay luc khoi dong — startup phai nhe")
|
||||
|
||||
# the idle warm-up builds the browser view and the first graph off the
|
||||
# click path (MainWindow fires this on a 3s timer; call it directly here)
|
||||
win._prewarm_graph()
|
||||
deadline = time.monotonic() + 30
|
||||
while st._graph is None and time.monotonic() < deadline:
|
||||
app.processEvents()
|
||||
time.sleep(0.02)
|
||||
if st._graph is None:
|
||||
print("FAIL lan dau khong dung duoc do thi")
|
||||
print("FAIL lam nong khong dung duoc do thi")
|
||||
sys.stdout.flush()
|
||||
os._exit(1)
|
||||
print(f"sau khi lam nong: web={'co' if st.web else 'chua'} do thi={'co' if st._graph else 'chua'}")
|
||||
|
||||
calls = {"scan": 0, "html": 0}
|
||||
real_scan, real_html = st._scan, st._render_d3
|
||||
st._scan = lambda: (calls.__setitem__("scan", calls["scan"] + 1), real_scan())[1]
|
||||
st._render_d3 = lambda: (calls.__setitem__("html", calls["html"] + 1), real_html())[1]
|
||||
|
||||
# ...so the click itself does nothing but show it — this is the flash
|
||||
t0 = time.monotonic()
|
||||
win._goto(win._ROW_WORKSPACE, w._graphrag_tab_idx)
|
||||
app.processEvents()
|
||||
print(f"bam vao GraphRAG: {(time.monotonic() - t0) * 1000:.0f}ms "
|
||||
f"_scan={calls['scan']} setHtml={calls['html']}")
|
||||
if calls["scan"] or calls["html"]:
|
||||
fails.append("bam vao GraphRAG van phai quet/nap lai trang — con chop trang")
|
||||
|
||||
# re-entering an unchanged graph must not rebuild anything
|
||||
for _ in range(3):
|
||||
win._goto(win._ROW_WORKSPACE, w._project_tab_idx)
|
||||
|
||||
Reference in New Issue
Block a user