Skip to content

perf: probe requested pane keys instead of enumerating records - #19494

Merged
nwparker merged 2 commits into
mainfrom
OrcaWin/perf-split-53-pane-key-removal
Sep 9, 2026
Merged

nwparker merged 2 commits into
mainfrom
OrcaWin/perf-split-53-pane-key-removal

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​48 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​47
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​12 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5

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 toString or __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

  • 200 absent removals across 1,000 records: full-record enumeration eliminated; inherited and nonenumerable keys preserved

This PR contains only this focused change and its regression coverage. It targets main independently 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

  • 13 tests across 1 suite(s) passed on this isolated branch on macOS.
  • Full pnpm tc passed on this branch.
  • Commit hooks passed: oxlint, React Doctor lint and formatting; git diff --cached --check passed.
  • All tests ran with ORCA_BACKGROUND_LAUNCH=1. No visible test window was launched.
  • Full build and Windows/Linux/live SSH validation remain for CI; host/provider contracts are preserved.

Test files:

  • src/renderer/src/store/slices/agent-status-pane-keyed-records.test.ts

Agent skill upstream boundary

  • No upstream skill-installer material copied or translated.

Checklist

  • Focused change with regression evidence.
  • Typecheck and pre-commit checks passed independently.
  • Cross-platform, folder-workspace and SSH ownership considered.
  • Full CI build and repository checks pass.

m4air and others added 2 commits September 7, 2026 19:48
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.
@nwparker
nwparker marked this pull request as ready for review September 8, 2026 04:53
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 26 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 9a5e3652-15fd-4486-b261-e1418e92495e

📥 Commits

Reviewing files that changed from the base of the PR and between 6642053 and 268c388.

📒 Files selected for processing (2)
  • src/renderer/src/store/slices/agent-status-pane-keyed-records.test.ts
  • src/renderer/src/store/slices/agent-status-pane-keyed-records.ts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • removePaneKeys rework — src/renderer/src/store/slices/agent-status-pane-keyed-records.ts now probes the requested paneKeys set via Object.prototype.propertyIsEnumerable instead of enumerating the whole record with Object.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.ts pins the no-op reference identity, absence of record enumeration (via a Proxy ownKeys trap 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.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit bf1e1b9 into main Sep 9, 2026
102 of 128 checks passed
@nwparker
nwparker deleted the OrcaWin/perf-split-53-pane-key-removal branch September 9, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants