Skip to content

perf(renderer): project terminal topology consumers - #16171

Merged
nwparker merged 1 commit into
mainfrom
nwparker/perf-renderer-topology-consumers
Aug 24, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/perf-renderer-topology-consumers

Conversation

@nwparker

@nwparker nwparker commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​242 $\color{#cf222e}{\Huge{\mathbf{−}}}$​37 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​205
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​180 $\color{#cf222e}{\Huge{\mathbf{−}}}$​199 $\color{#cf222e}{\Huge{\mathbf{−}}}$​19

Problem

Display-only terminal title publications replaced the outer terminal maps. Remaining renderer consumers treated that publication as a fleet transition, rebuilding retained-agent snapshots, re-running sidebar all-tab activity projection, reconsidering Terminal root parking/topology, and waking session persistence even though only leaf chrome changed.

At 300 worktrees, a fast agent spinner could repeatedly fan one label update across the entire fleet.

What

  • Add a reusable per-worktree semantic bucket projection that structurally reuses unchanged buckets and the outer result when semantics are unchanged.
  • Gate retained-agent synchronization on tab identity/ownership topology, then read fresh tab objects when a real agent or topology transition runs.
  • Project sidebar activity to stable tab IDs and inspect only the changed source bucket.
  • Project Terminal root inputs to mount/parking semantics (tab ID/order, worktree ownership, PTY, pending spawn, generation, startup CWD) instead of live titles.
  • Keep title UI live through the active legacy titlebar leaf subscription; split layouts keep their existing per-group live model.
  • Project terminal and unified tabs to durable session semantics, ignoring only decorative agent-title frames and transient pending-activation spawn state; session patches still build from fresh store state.
  • Remove the fleet-wide JSON parking key.

ELI5

A terminal title can wiggle many times a second like an animated name tag. Before, every wiggle made Orca recount every workspace, reconsider parking terminals, rebuild retained-agent snapshots, and wake session saving. Now the animated name tag updates only its small label. Orca revisits the fleet only when a terminal is actually added, removed, moved, connected to a PTY, queued to spawn, remounted, or durably renamed.

Proof / no regression

  • Focused validation: 5 test files, 65 tests passed.
  • typecheck:web passed.
  • 300-worktree counting coverage proves a title-only publication causes:
    • zero retained-agent fleet snapshots,
    • zero parking dependency changes/effects,
    • zero session persistence timers,
    • only the changed sidebar bucket to be leaf-inspected.
  • Add/remove/move, PTY, pending-spawn, generation/startup, durable-title, and real agent transitions remain covered.
  • Retained snapshots explicitly preserve the freshest title after skipped decorative frames.
  • Functional review: CLEAN.
  • Security review: CLEAN.
  • Readiness review: CLEAN.

User tradeoffs

  • Outer-record changes still require O(W) outer-key reconciliation to detect worktree add/remove, but unchanged buckets perform no leaf inspection and there is no whole-fleet stringify.
  • The projection relies on the store's existing immutable-publication contract for outer records and worktree arrays.
  • No user-visible tradeoff: title labels remain live, and durable transitions retain their existing behavior.

Readiness verdict

CLEAN — P0: 0, P1: 0, P2: 0.

All seven review sections are CLEAN with P0=0, P1=0, P2=0:

  1. Correctness and data integrity — CLEAN (P0/P1/P2: 0/0/0)
  2. Security and trust boundaries — CLEAN (P0/P1/P2: 0/0/0)
  3. Performance and scalability — CLEAN (P0/P1/P2: 0/0/0)
  4. Reliability and lifecycle behavior — CLEAN (P0/P1/P2: 0/0/0)
  5. Maintainability and architecture — CLEAN (P0/P1/P2: 0/0/0)
  6. Tests and regression evidence — CLEAN (P0/P1/P2: 0/0/0)
  7. Release and operational readiness — CLEAN (P0/P1/P2: 0/0/0)

Mobile

No mobile-facing surface. This changes renderer-side desktop/web-client subscription and persistence gating only; protocols and mobile UI are unchanged.

Residual risk

  • Semantic bucket reuse assumes immutable outer-record and bucket-array publication, matching the current Zustand mutation contract.
  • Real outer-record changes retain an O(W) key pass; the removed cost is whole-fleet leaf comparison/stringification and downstream effects.
  • PTY class, pending spawn, topology, durable title, folder workspace, split layout, SSH, and paired-runtime behavior remain explicit invalidation boundaries.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change introduces a reusable memoized projection for worktree tab buckets. Session persistence, sidebar activity inputs, terminal parking, terminal rendering, and retained-agent synchronization now consume projected tab data. Equivalent title-only updates reuse existing projections. Tests cover large worktree maps, selective bucket inspection, terminal topology changes, persistence suppression, and retained-agent tab freshness.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, design, scope, tradeoffs, and validation, but it omits several required template sections and a valid linked issue. Add a valid issue link, complete Visual Proof and Testing, and fill or explicitly mark the remaining required template sections.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
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 summarizes the main change: optimizing renderer consumers by projecting terminal topology.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
src/renderer/src/lib/session-write-subscriber.ts (1)

106-109: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Shorten this rationale comment.

Reduce this comment to one concise line. It repeats implementation detail.

As per coding guidelines: “Comments must be concise, non-obvious, and brief—prefer one line.”

Proposed change
-  // Why: the subscriber fires on every store update (agent status, usage
-  // refreshes, runtime title ticks, …). Without this gate each fire reset
-  // the debounce, and when it finally expired buildWorkspaceSessionPayload
-  // crossed 70-110ms with many tabs, tripping setTimeout violations. Terminal
-  // and unified maps use durable per-worktree projections, so display frames
-  // reuse the prior identity while a real session change keeps fresh tabs for
-  // the eventual getState() patch build. `null` makes the first fire proceed.
+  // Ignore display-only tab updates so they do not reset persistence debounce.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 072c7aa2-4970-4ab8-848d-0acde6f1dc78

📥 Commits

Reviewing files that changed from the base of the PR and between 0a613d5 and 2f2f78b.

📒 Files selected for processing (10)
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/dashboard/useRetainedAgents.test.ts
  • src/renderer/src/components/dashboard/useRetainedAgents.ts
  • src/renderer/src/components/sidebar/visible-worktree-activity-inputs.test.ts
  • src/renderer/src/components/sidebar/visible-worktree-activity-inputs.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.test.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.ts
  • src/renderer/src/lib/session-write-subscriber.test.ts
  • src/renderer/src/lib/session-write-subscriber.ts
  • src/renderer/src/lib/worktree-tab-bucket-projection.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.

@nwparker
nwparker merged commit a117bff into main Aug 24, 2026
48 checks passed
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 25, 2026
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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