Repository navigation
perf: bound repeated watcher, Session History, and terminal work - #12828
Conversation
📝 WalkthroughWalkthroughThe changes extend the AI Vault cache to 60 seconds and revise refresh behavior for panel entry, refocus, and new agent sessions. The parcel watcher fuse now latches after three crashes within two minutes. Worktree watcher failures use per-watch refresh cooldowns and structural polling fallback. Terminal retention limits and durations are reduced. Pane fitting now cancels retries for panes hidden with 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/right-sidebar/ai-vault-session-refresh.ts (1)
193-212: 🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick winRecalculate the delay when the queued timer fires.
Line 208 schedules a forced scan using the current throttle timestamp. A manual
refresh({ force: true })can updatelastForcedRescanAtbefore that timer fires. Lines 210-211 then start another forced scan at the old deadline. This can bypass the 30-second forced-rescan budget.Clear the timer reference and call
requestForcedRescan()again so it calculates the remaining delay. Add a test for a manual forced refresh while a trailing agent-session refresh is pending.Proposed fix
forcedRescanTimerRef.current = setTimeout(() => { forcedRescanTimerRef.current = null - lastForcedRescanAt = Date.now() - void refresh({ background: true, force: true }) + requestForcedRescan() }, waitMs)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0ea569af-32ff-4504-83bc-b49a2e066b43
📒 Files selected for processing (20)
src/main/ai-vault/cached-session-list.tssrc/main/ipc/parcel-watcher-crash-fuse.test.tssrc/main/ipc/parcel-watcher-crash-fuse.tssrc/main/ipc/parcel-watcher-process.test.tssrc/main/ipc/worktree-base-directory-change-collector.tssrc/main/ipc/worktree-base-directory-watcher.test.tssrc/main/ipc/worktree-base-directory-watcher.tssrc/main/ipc/worktree-watcher-failure-refresh-cooldown.tssrc/main/runtime/rpc/methods/ai-vault.test.tssrc/renderer/src/components/right-sidebar/ai-vault-session-refresh.test.tssrc/renderer/src/components/right-sidebar/ai-vault-session-refresh.tssrc/renderer/src/components/terminal-pane/pty-connection.test.tssrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/components/terminal-pane/terminal-hidden-view-parking.tssrc/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.tssrc/renderer/src/components/terminal-pane/terminal-webgl-atlas-recovery.test.tssrc/renderer/src/components/terminal-pane/terminal-webgl-atlas-recovery.tssrc/renderer/src/lib/pane-manager/pane-display-visibility.tssrc/renderer/src/lib/pane-manager/pane-fit.test.tssrc/renderer/src/lib/pane-manager/pane-fit.ts
Final review: land after fixesA same-model senior review was repeated until the fourth pass returned CLEAN. The review added three narrowly scoped fixes:
No refactors or speculative cleanup were added. Expected user impact
These are workload-dependent estimates, not a universal percentage for every user. Final Electron evidenceValidated the exact PR head Validation also includes 769 focused tests, the 2,486-test terminal reliability gate (1 skipped), both typechecks, changed-path quality/format/max-lines checks, and green CI across Node 24/26, compatibility, and macOS/Windows packaging. |
…blyai#12828) * perf: bound repeated watcher, vault, and terminal work * fix(terminal): preserve redraw recovery while bounding fit retries * fix(watcher): retain structural fallback after crash fuse * fix(ai-vault): preserve forced scan budget


Summary
display:nonepanesPerformance evidence
Measured production baseline
A five-minute production trace captured during the reported lag contained:
aiVault.scangit worktreegit statusFixed-build Electron measurement
I loaded this branch through Electron/CDP, opened Session History, and dispatched 14 refocus/visibility events six seconds apart—the event path that previously forced transcript scans.
The fixed scan processed 1,574 candidates and read 6.1MB. No Electron page errors occurred during the run. This removes the dominant measured source of main-process work: repeated refocus events now reuse the shared 60-second scan cache instead of repeatedly reparsing session transcripts.
The same Electron soak opened the watcher fuse under repeated canary starvation. More than three minutes after it opened—past the old sliding-window expiry—activating another workspace still did not fork a watcher child. The deterministic supervisor test also simulates crashes at 0s/40s/80s and a new subscription at 10 minutes; the fork count remains capped at three.
Deterministic work reductions
display:nonepaneExisting captured-Vim regression coverage continues to require debounced/rate-limited atlas recovery; routine alternate-screen correctness is preserved.
Regression sources
Validation
pnpm typecheck:nodepnpm typecheck:web