fix(panel): prevent UI freeze when opening panel during extraction

Root cause: onStreamProgress callback fires 20-50x/sec during LLM streaming,
each calling setLastExtractionStatus with syncRuntime=true (default), which
triggers setRuntimeStatus -> refreshPanelLiveState() -> _refreshDashboard().
_refreshDashboard iterates all graph nodes (.filter x2) and performs heavy
DOM updates each time. When the panel is open, this blocks the main thread.

Fixes:
1. panel.js: Add requestAnimationFrame throttle to refreshLiveState() with
   minimum 80ms gap between actual DOM refreshes. Rapid calls are collapsed
   into a single animation frame, preventing main thread saturation.
2. extraction-controller.js: Change onStreamProgress to use syncRuntime=false
   so streaming updates no longer trigger setRuntimeStatus (which would also
   update the floating ball on each chunk).
3. recall-controller.js: Same fix for recall onStreamProgress which had
   the identical syncRuntime=true issue.
This commit is contained in:
Youzini-afk
2026-04-29 17:03:41 +08:00
parent aa89428777
commit a070e04e56
3 changed files with 38 additions and 11 deletions

View File

@@ -843,7 +843,7 @@ export async function executeExtractionBatchController(
"AI 生成中",
`${preview} [${receivedChars}字]`,
"running",
{ noticeMarquee: true },
{ syncRuntime: false, noticeMarquee: true },
);
},
});