Repository navigation
perf(renderer): cache structured chat presence by snapshot identity - #34774
Merged
Merged
Conversation
OrcaWin
force-pushed
the
OrcaWin/perf-chat-presence-cache
branch
from
October 28, 2026 07:30
dbb8fa0 to
a4b1c33
Compare
OrcaWin
marked this pull request as ready for review
October 28, 2026 07:30
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 9 minutes. View limit details
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Unrelated terminal title updates repeatedly recalculate whether every visible workspace has an awake chat. Reuse the answer until that workspace's chats or sleep state changes.
What Changed
Unrelated terminal pane-title writes currently make each mounted sidebar, parent-picker, and Cmd+J status reader rescan its structured chat bucket. Each visited chat computes
structuredAgentSessionPaneKey, which runs synchronous JavaScript SHA-256, before Zustand/React equality can suppress an unchanged status render.Cache the awake/unknown predicates by the exact immutable tab bucket and sleep-map snapshots. Both keys use WeakMaps, so the cache introduces no subscription, timer, IPC, or strong historical ownership. Missing sleep state uses a shared frozen empty snapshot. Cold reads and actual tab/sleep changes still recompute the predicate; explicit sleep, explicit wake, unknown, working, and done priorities are preserved.
Why
The relevant writers replace published inputs: tab create/close/move/drop/patch, hydration/reconciliation, title batches, local layout frames, and remote tab projection replace changed buckets; batch writers only mutate private record copies.
setStructuredChatSleptAtreplaces its map on an actual change.This shares results across mounted readers and unrelated store updates without adding a new owner or invalidation subscription. Checking only React render counts misses the synchronous work performed before equality checks.
Linked Issue
N/A — internal performance audit; no pre-existing issue.
Visual Proof
N/A — status values and interactions are unchanged; this removes repeated selector work.
Testing
Measured with the existing live Zustand store + mounted production reader benchmark, using a real
setRuntimePaneTitleaction after warm-up. The fixture has explicitly slept chats, so the false predicate visits the full bucket; an awake/unknown chat can short-circuit earlier on the base:These are deterministic operation counts from Linux, Node 26.8.1, Vitest/happy-dom development tests against base
32a50856ac388a419ffa18b2295a76d1744f7ec5. Palette counts include its four selector/snapshot visits per reader. This establishes removed synchronous renderer work; it does not establish packaged Electron frame latency, CPU, or heap savings. No new runtime instrumentation or machine-dependent timing threshold is shipped.ORCA_BACKGROUND_LAUNCH=1 pnpm --config.verifyDepsBeforeRun=false check:changed --maxWorkers=2: passed all 21 checks in 3170.6s on the published commit. All 34 focused tests and baseline-failing operation counts also passed.Rerun the changed regressions with
ORCA_BACKGROUND_LAUNCH=1 pnpm test src/renderer/src/components/terminal-pane/pane-title-update-global-scan-budget.test.tsx src/renderer/src/store/slices/structured-chat-slept-at.test.ts --maxWorkers=2.Tests ran in the background with
ORCA_BACKGROUND_LAUNCH=1. No native-focus or visible-window test was run.AI Disclosure
Review
Reviewed immutable input ownership, cache invalidation, status priority, folder workspace inputs, and remote tab projection writers. The cache uses weak snapshot ownership and adds no runtime resource lifecycle.
Agent skill upstream boundary
Notes
Pure renderer selectors have no platform-specific code or protocol changes. Native macOS/Windows, live remote transport, forced-GC retention, and packaged Electron performance were not measured. The cold scan remains proportional to the changed workspace bucket; an actual global sleep-map change invalidates each observed bucket.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)The required local changed-file gate is recorded above; the full build is left to CI.