Skip to content

perf: group Space decision inputs by workspace - #26297

Merged
nwparker merged 1 commit into
mainfrom
nwparker/perf-space-decision-input-grouping
Oct 8, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/perf-space-decision-input-grouping

Conversation

@nwparker

@nwparker nwparker commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

The Space view repeatedly searched every agent record and open file for each workspace whenever a terminal title changed. It now groups those records once and gives each workspace only its relevant inputs, keeping the same display and deletion decisions.

What Changed

The existing Space decision hook memoizes an index of live agents, migration warnings, retained agents and open files by workspace. It rebuilds when their source records, tabs or scan rows change. The existing decision code still evaluates freshness, title activity, dirty drafts, host identity and deletion readiness. The index reuses the existing pane-key parser, including legacy keys, and retains no state outside the mounted hook.

Why

Repeated global scans multiply work by the number of scanned workspaces. Grouping source references removes that repeated work without changing status authority, dropping records, limiting visible rows or caching freshness verdicts.

A hidden Electron check mounted the actual complete Space page and panel with production components, controllers and store actions. With 300 generated workspaces, 500 retained agents and 40 live agents, five alternating paired trials reduced median complete-panel title publication from 30.1 to 21.0 ms. Both versions made the same 300 controlled Git-status requests. Complete rendered text and status, retention, draft and freshness controls matched; before/after screenshots are byte-identical.

An isolated production-React hook check reduced title publication from 11.6 to 0.19 ms at the same size, and 1.65 to 0.095 ms with 100 workspaces. Empty and one-workspace cases were essentially unchanged. This is a Space-view improvement; it does not establish the cause of the intermittent Codex typing pause.

Linked Issue

Performance audit; no existing issue linked.

Visual Proof

Before:

Space before

After:

Space after

These hidden-renderer screenshots use the same generated fixture and are byte-identical. The timing above measures the complete panel’s response to real title publications.

Testing

  • Manually validated the full production Space page/panel through Playwright CDP in a freshly built, background hidden Electron renderer on macOS. All owned processes, profiles, sessions and fixture frames were removed.
  • Added five mounted-hook regressions using the existing test store and real title, status, retention and draft actions. They cover source/tab changes, special own keys, duplicate workspace IDs across hosts, shared tab ownership, migration warnings with missing workspace IDs, empty scans and freshness expiry. The original implementation fails the read-count regression: five title updates read 1,000 live and 4,000 retained records; the fix reads 50 and 200.
  • All 36 focused hook, presentation and host-routing tests pass in Bun and Node. All-project typechecks, fresh desktop build, formatting and the four-file changed-code quality gate pass. The combined 42-change branch also passes 115 focused removal, authorization and Space cases, all-project typechecks, a fresh desktop build and the 128-file changed-code quality gate.
  • A separate 7,500-case comparison against the original decision helper and 13 mounted controls preserved complete results, including legacy/malformed keys, own __proto__ keys, migration workspace-or-tab ownership and deferred metadata refreshes. The formatted production modules emit identical code to the measured proposal.

Native timing was macOS/Electron with generated scan rows and controlled Git-status responses; it did not exercise a real PTY, Git scan or connected SSH host. Existing host-aware decision and deletion logic is unchanged and covered by routing tests. No Windows/Linux timing claim.

Review

Independent source, regression and native-evidence review found no blocker. The change reads the existing agent-status store and preserves its presentation rules. It adds no polling, global cache, status producer, remote protocol, design-system changes or freshness delay.

Agent skill upstream boundary

  • Not applicable.

Checklist

  • Small and focused.
  • Explained the user-facing change, mechanism and choice of approach.
  • Before/after screenshots attached.
  • Self-reviewed for correctness, security and performance.
  • Cross-platform, folder and SSH behavior considered.
  • Relevant tests, typechecks, changed-code quality and fresh build pass. All selected hosted checks pass, including Node unit and relay integration tests, static/type checks and Linux/Windows packaging.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 98b09e12-951a-4510-9770-ed812e793ce3
📥 Commits

Reviewing files that changed from the base of the PR and between 7f43d9b and d0b7ddd.

📒 Files selected for processing (4)
  • src/renderer/src/components/status-bar/use-workspace-space-decision-projection.test.tsx
  • src/renderer/src/components/status-bar/use-workspace-space-decision-projection.ts
  • src/renderer/src/components/status-bar/workspace-space-decision-inputs.ts
  • src/renderer/src/components/status-bar/workspace-space-presentation.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The projection now groups agent statuses, migration entries, retained agents, and open files by worktree. It passes each worktree’s grouped inputs to getWorkspaceDecisionDetails. New tests cover input updates, worktree ownership, special keys, empty scan rows, and agent-status epoch changes.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to d0b7d

This change groups the inputs used by the Space decision logic by workspace to reduce repeated scans. It is not expected to change what the page displays or deletes. No merge-blocking risk was identified.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description covers the required explanation, changes, rationale, visual proof, testing, limitations, review notes, and checklist. However, the required Linked Issue section has no issue link and s… Add a link to the issue addressed by this pull request. If the author is a maintainer and the repository exception applies, state that the maintainer exception is being used and confirm that no issue is required.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: grouping Space decision inputs by workspace to improve performance.
Full details: Description check

Explanation

The description covers the required explanation, changes, rationale, visual proof, testing, limitations, review notes, and checklist. However, the required Linked Issue section has no issue link and states that no existing issue is linked.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@nwparker
nwparker merged commit b4e99fc into main Oct 8, 2026
30 checks passed
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.

1 participant