Repository navigation
fix(tab-group): measure fallback pane geometry once per tab group, only while visible - #23592
Conversation
|
Warning Review limit reachedNext included review available in 2 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 (6)
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 |
…m the source map The map already drops empty groups, so a separate counter was a second copy that could disagree.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Shared pane geometry module —
tab-group-body-geometry.tscentralizes the web-client fallback measurement: oneResizeObserverper(groupId, container)source and one app-widewindowresize listener (attached on the 0→1 source transition, removed on 1→0), with the sub-pixel jitter guard preserved inisSameRect/measureSource. - Body registration replaces the whole-document search —
TabGroupPanel.tsxnow registers itsdata-tab-group-body-idelement throughregisterTabGroupBodyfrom the mergedsetBodyRefref 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.tsxgates onisVisible || measureWhileHiddenand passessetMeasuredFallbackRectdirectly, 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:webandpnpm run check:code-quality:changedboth pass. - Lifecycle review found no reclamation gap: the window listener is balanced 0→1/1→0,
sourceCounttracks 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
setBodyRefcleanup runs on detach (thenullcall is skipped), and that dnd-kit'ssetNodeRefis 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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (incremental: 8ca9ee1 → b17ebc4)
- Resize-listener lifetime derived from the source map —
tab-group-body-geometry.tsdrops thesourceCountcounter.acquireSourceattaches the sharedwindowlistener whensourcesByGroupId.size === 0(checked before inserting the new group) andreleaseSourceremoves it after deleting the emptied group. The asymmetry — add before insert, remove after delete — makes the empty-map check equivalent to "no live sources," andsourcesByGroupIdnever 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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Review status: ready to mergeVerdict: 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: Checks:
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:
|

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):
Desktop app on this branch (unchanged path), terminals and agent chats across two split panes after resizes and divider drags:
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).resizestill 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
docs/reference/agent-skill-sharing-upstream-boundary.mdand 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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)