Repository navigation
perf: probe requested pane keys instead of enumerating records - #19494
Conversation
Probing the pane keys still beat enumerating the record, but materializing the requested set allocated on every call including the common no-match path, where a dozen records are swept per retirement. Copy lazily on first match instead, and cover the set-disagreement and prototype-key cases.
|
Warning Review limit reachedNext included review available in 26 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
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.
✅ No new issues found.
Reviewed changes
removePaneKeysrework —src/renderer/src/store/slices/agent-status-pane-keyed-records.tsnow probes the requestedpaneKeysset viaObject.prototype.propertyIsEnumerableinstead of enumerating the whole record withObject.keys, spreading a copy only on the first actual match and returning the same reference on the no-op path.- Regression coverage —
agent-status-pane-keyed-records.test.tspins the no-op reference identity, absence of record enumeration (via aProxyownKeystrap that fails under the old code), non-enumerable/inherited-key safety (toString,__proto__,constructor), and survivor key-order preservation.
I traced the equivalence against the old implementation: propertyIsEnumerable is own+enumerable only, so it matches Object.keys exactly for the string pane keys this helper receives; delete order is irrelevant to survivor order; and every caller passes a small key set, so the probe direction is the right one. The removePaneKeysByTabPrefix path is unaffected (it still derives its set from Object.keys). No behavioral or performance regressions found.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

ELI5
When you close a terminal tab, Orca has to forget everything it was tracking about the panes in that tab — unread markers, agent status, launch settings and about a dozen other bookkeeping lists.
The old way of forgetting worked backwards: for each of those dozen lists, Orca read out every entry in the list and checked each one against the handful of panes being closed. If a list held a thousand panes and you closed one, that's a thousand checks to find one match — repeated for every list, most of which had nothing to forget at all.
Now Orca goes the other way round: it takes the few panes being closed and asks each list directly "do you have this one?" That's a handful of quick lookups instead of a full read-out.
Two follow-on refinements are included. Orca only makes a copy of a list once it finds something to actually remove, so the common case — a list that holds none of the closed panes — now does no copying and no allocation at all, and hands back the exact same list object, which is what stops the UI from re-rendering needlessly. And the lookup deliberately only matches a list's own entries, so built-in JavaScript property names like
toStringor__proto__can never be mistaken for a pane and deleted.Behaviour is unchanged: the same entries are removed, the survivors stay in the same order, and the same lists are handed back untouched. That was compared against the old code on 6,000 generated cases — including keys present in the list but not requested, requested but not present, hidden entries, and inherited property names — with no differences.
What Changed / Why
This PR contains only this focused change and its regression coverage. It targets
mainindependently of the other desktop audit PRs. Measurements describe operation/allocation reductions, not end-to-end latency gains.Linked Issue
User-requested desktop performance audit; no issue supplied.
Visual Proof
N/A — no visual design change. Behavior and performance invariants are checked by automated regression tests.
Testing
pnpm tcpassed on this branch.git diff --cached --checkpassed.ORCA_BACKGROUND_LAUNCH=1. No visible test window was launched.Test files:
src/renderer/src/store/slices/agent-status-pane-keyed-records.test.tsAgent skill upstream boundary
Checklist