Skip to content

fix(tab-group): measure fallback pane geometry once per tab group, only while visible - #23592

Merged
brennanb2025 merged 2 commits into
mainfrom
sta-7431-shared-pane-geometry
Sep 28, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
sta-7431-shared-pane-geometry

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​235 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​235
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​200 $\color{#cf222e}{\Huge{\mathbf{−}}}$​68 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​132

ELI5

In the browser version of Orca, every open chat or terminal tab kept its own ruler and re-measured its split pane on every frame of a window resize, even tabs you could not see. Now each split pane is measured once, and only while a tab in it is on screen; all the tabs in that pane read the same measurement.

What Changed

Before: when Orca runs in a browser (the paired web client), it cannot use the CSS feature the desktop app uses to pin chat and terminal tabs over their split pane, so it falls back to measuring the pane with JavaScript. Every tab did that measuring on its own: each one set up its own resize watcher and its own window-resize listener, and on every resize searched the whole page for its pane and read two element sizes. Hidden tabs did all of this too, even though they are not drawn. With many chat tabs open across worktrees, dragging the window edge meant tabs × page-size work per frame.

After: the pane itself is the thing measured. The tab-group panel registers its body element under its group id when it mounts, which replaces the whole-page search. A small shared module keeps one resize watcher per group and one window-resize listener for the whole app, measures the pane once per change, and hands the same result to every tab in that group. A tab subscribes only while it is visible (or, for a terminal still starting up in the background, while it is allowed to measure hidden), and reads the current size the moment it subscribes, so a tab shown after a resize starts at the right size. When the last tab in a group stops listening, that group's watcher is removed, and the window listener goes away when no group is being measured.

Nothing changes on the desktop app, which keeps using the CSS positioning path and never runs this code. The sub-pixel jitter guard that prevents a resize/refit loop is kept, now in the shared measurement.

Why

The geometry belongs to the split pane, not to each tab, so measuring it per tab duplicated the same work N times per pane. Only skipping hidden tabs would have removed part of the cost but still left every visible tab in a group watching the same elements, so the measurement was moved to the owner instead of adding another check beside the per-tab code. Registering the pane element directly also means a pane that mounts after its tabs is picked up immediately, instead of waiting for the next window resize to be found by a page search.

Linked Issue

Linear: STA-7431

Visual Proof

No visual change intended: panes sit exactly where they did. Web client in headless Chromium, two split panes after the last divider drag (before = main, after = this branch):

Before (main) After (this PR)
web-before web-after

Desktop app on this branch (unchanged path), terminals and agent chats across two split panes after resizes and divider drags:

Terminals Agent chats
desktop-after desktop-after-chats

Measured in the web client with 10 terminal tabs in 2 split panes: window resize listeners 23 on main vs 14 here (the remaining growth is one per terminal from the terminal library, untouched by this PR); resize watchers on a pane body 10 vs 2 (none for hidden tabs); 200 synthetic resize events 12.6 ms vs 3.4 ms (median of 3).

Testing

  • New unit tests for the shared measurement: one watcher per group and one window listener across groups, both removed when the last subscriber leaves; changes under one pixel do not notify; the pane element being mounted, replaced and unmounted is followed, and a late unregister from a replaced panel does not drop the live one.

  • New host tests: three visible tabs in one group create one watcher and one window listener and are all updated by a single measurement; a hidden tab creates nothing and picks up the current size when shown; a hidden terminal allowed to measure while hidden still follows size changes.

  • The two host tests fail on main (3 watchers instead of 1; the hidden tab creates a watcher).

  • To try it by hand: build the web client (pnpm build:web), start the desktop app, open Settings, create a web client link from the runtime pairing section and open it in Chrome. Open several terminal tabs across two split panes (agent chats are not shown in the web client), then drag the window edge and move the split divider: tabs should stay over their pane, and a background tab shown afterwards should already be the right size. In the DevTools console, getEventListeners(window).resize still grows by one per terminal (the terminal library's own listener), but no longer by the extra one per tab that main adds.

  • Live, on a separate Mac: desktop app with 10 terminals and 4 agent chats across two split panes, resized through 4 sizes and 3 divider drags; every visible pane stayed 0 px off its pane body, and each of 14 hidden tabs shown afterwards had the right size in its first frame. The paired web client ran the same steps on main and on this branch with the same result (web client covers terminal panes; agent chats are not shown in the web client).

  • Platforms: unit tests and web typecheck on macOS.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Renderer only. Nothing is stored or sent between devices, so SSH, mobile and mixed-version setups are unaffected. Desktop Electron takes the CSS anchor path and does not run this code.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 2 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: f2b993c6-bf4c-48dd-9edb-12846c7cda9e

📥 Commits

Reviewing files that changed from the base of the PR and between a68d629 and b17ebc4.

📒 Files selected for processing (6)
  • src/renderer/src/components/tab-group/RetainedPaneHost.test.tsx
  • src/renderer/src/components/tab-group/RetainedPaneHost.tsx
  • src/renderer/src/components/tab-group/TabGroupPanel.tsx
  • src/renderer/src/components/tab-group/tab-group-body-geometry.test.ts
  • src/renderer/src/components/tab-group/tab-group-body-geometry.ts
  • src/renderer/src/components/terminal-pane/TerminalPaneOverlayLayer.react185.test.tsx

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.

…m the source map

The map already drops empty groups, so a separate counter was a second copy that could disagree.

@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

  • Shared pane geometry module — tab-group-body-geometry.ts centralizes the web-client fallback measurement: one ResizeObserver per (groupId, container) source and one app-wide window resize listener (attached on the 0→1 source transition, removed on 1→0), with the sub-pixel jitter guard preserved in isSameRect/measureSource.
  • Body registration replaces the whole-document search — TabGroupPanel.tsx now registers its data-tab-group-body-id element through registerTabGroupBody from the merged setBodyRef ref callback, so a pane that mounts after its tabs is picked up immediately instead of on the next window resize.
  • Host subscribes to the shared source only while it can display — RetainedPaneHost.tsx gates on isVisible || measureWhileHidden and passes setMeasuredFallbackRect directly, dropping the per-host observer/listener and the local rect type.
  • Tests — new unit tests for the shared module (one observer per group, one window listener across groups, sub-pixel suppression, mount/replace/unmount of the body with late-unregister protection) plus host tests for one-measurement-per-group and hidden/hidden-startup behavior, and updated fixtures for the refactor.

Verification

  • The three changed test files pass (12 tests); pnpm tc:web and pnpm run check:code-quality:changed both pass.
  • Lifecycle review found no reclamation gap: the window listener is balanced 0→1/1→0, sourceCount tracks live sources, released sources have no listeners, unsubscribe is idempotent, and the late-unregister guard handles a replaced panel mounting before the old one unmounts.
  • Confirmed against React 19.2.8 ref-cleanup semantics that the merged setBodyRef cleanup runs on detach (the null call is skipped), and that dnd-kit's setNodeRef is stable, so the merged ref does not churn register/unregister.

One non-blocking design note: dedup is per (groupId, container), so a group whose hosts ever live under different overlay parents would get one source per container. Each source is still measured relative to its own container, so this is only more watchers than the ELI5 implies, not a positioning defect.

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

@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 (incremental: 8ca9ee1 → b17ebc4)

  • Resize-listener lifetime derived from the source map — tab-group-body-geometry.ts drops the sourceCount counter. acquireSource attaches the shared window listener when sourcesByGroupId.size === 0 (checked before inserting the new group) and releaseSource removes it after deleting the emptied group. The asymmetry — add before insert, remove after delete — makes the empty-map check equivalent to "no live sources," and sourcesByGroupId never retains an empty set, so the attach/detach transitions still bracket exactly the 0→1/1→0 boundaries the tests pin.

Verified on the new head: the three changed test files pass (12 tests), and the refactor is behaviorally equivalent to the counter it replaced.

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready to merge

Verdict: ready. Two independent review loops came back clean, and live QA on a separate Mac passed for both the desktop app and the paired web client. CI is green.

What was wrong, and whether it's fixed: without CSS anchor positioning (the paired web client), every chat and terminal tab measured its split pane on its own, hidden tabs included. Each had its own resize watcher and window listener, and searched the whole page on every resize. This PR moves the measurement to the split pane: one watcher per pane, one window listener for the app, and only while a tab in that pane can be seen. The duplicated work is removed, not guarded around. The desktop app keeps the CSS path and does not run this code.

Change pushed during review: b17ebc4cfbd works out when to remove the shared window listener from the set of watched panes, instead of keeping a separate counter that could drift out of sync. A test covers it: breaking the check makes it fail.

Checks:

  • Unit tests for the new module and for the pane host. The host tests fail on main.
  • Lint on changed files, and the web typecheck on b17ebc4cfbd.
  • Readiness checklist at the start and at the end: nothing blocking.
  • The design follows the usual pattern for this problem: a shared registry, measuring only while visible, one global resize listener. Scope stayed on the ticket.

Live QA (web client, main vs this branch): 10 terminal tabs across 2 split panes, 4 viewport sizes and 3 divider drags. Every visible pane stayed 0 px off its pane body. Each of 14 hidden tabs shown afterwards had the right size in its first frame. Window resize listeners went from 23 to 14 (the rest are one per terminal from the terminal library, which this PR doesn't touch). Resize watchers on a pane body went from 10 to 2, with none for hidden tabs. 200 resize events took 12.6 ms before and 3.4 ms after. Screenshots are in the description.

Live QA (desktop app, this branch): 10 terminals and 4 agent chats across 2 split panes, through the same resize and drag steps. Every visible pane stayed 0 px off its pane body, and every tab shown afterwards was the right size.

Known gaps, none caused by this PR:

  • A pane body that moves without changing size is not re-measured. Main had the same gap, and no case in the app hits it.
  • The real desktop window frame was not resized: QA resized the viewport instead, which fires the same resize events.
  • Agent chats are not shown in the paired web client, so web QA covered terminal tabs. Chats were checked on the desktop app.

@brennanb2025
brennanb2025 merged commit e794012 into main Sep 28, 2026
34 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