Skip to content

Commit dc76e7b

Browse files
committed
🤖 Fix 8s freeze: Defer auto-resume check to not block UI
PROBLEM: resumeStream IPC takes 8 seconds when resuming interrupted streams on first launch. Even though it's async, calling it immediately in useEffect blocks the UI from becoming interactive. Timeline from logs: - 1347ms: attemptResume started for cmux-stable-ids - 9408ms: resumeStream IPC completed (8061ms blocked) SOLUTION: Defer initial resume check with setTimeout(0), same pattern as GitStatusStore fix. IMPACT: - UI becomes interactive immediately on first launch - Auto-resume still works, just starts after React finishes mounting - Subsequent reloads already fast (no interrupted streams to resume)
1 parent b60b7ad commit dc76e7b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/hooks/useResumeManager.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,14 @@ export function useResumeManager() {
175175
};
176176

177177
useEffect(() => {
178-
// Initial scan on mount - check all workspaces for interrupted streams
179-
for (const [workspaceId] of workspaceStatesRef.current) {
180-
void attemptResume(workspaceId);
181-
}
178+
// Defer initial scan to not block UI rendering
179+
// Same pattern as GitStatusStore - let React finish mounting first
180+
setTimeout(() => {
181+
console.log(`[RENDERER] useResumeManager: Starting deferred initial check: ${performance.now()}ms`);
182+
for (const [workspaceId] of workspaceStatesRef.current) {
183+
void attemptResume(workspaceId);
184+
}
185+
}, 0);
182186

183187
// Listen for resume check requests (primary mechanism)
184188
const handleResumeCheck = (event: Event) => {

0 commit comments

Comments
 (0)