Repository navigation
perf(tab-bar): scrolling the tab strip no longer re-renders every tab - #24240
Conversation
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. Review configuration: ⚙️ Run configuration
📥 CommitsReviewing files that changed from the base of the PR and between 57ee293e9f74f62de1788def3d425c18b8669848 and 44808e5. 📒 Files selected for processing (8)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 9d00b5a26f869d3c980a23a30994d409688161db and 57ee293e9f74f62de1788def3d425c18b8669848. 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe tab strip now keeps overflow and scroll-direction flags separate from thumb size and position. The scroll indicator calculates thumb layout from the live scroll container and updates it on scroll and resize events. Tests check thumb tracking, drag positioning, and tab rendering during scroll. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The thumb tracks live scroll dimensions without storing geometry in tab-bar state. No actionable merge-blocking issue is established; merge readiness remains subject to normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The assessed change remains confined to tab-strip presentation, with no demonstrated expansion of privileged access. Subscription cleanup and interrupted dragging have explicit cleanup paths. Unusual element-replacement behavior and broader security coverage remain incompletely established. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 3cea7338-30a8-4722-b0df-5498db9942f6
📥 Commits
Reviewing files that changed from the base of the PR and between 3ab3c92 and 922fde8e1e0107be1e3fc7d8a5e0d6d5536b387f.
📒 Files selected for processing (8)
src/renderer/src/components/tab-bar/TabStripScrollIndicator.test.tsxsrc/renderer/src/components/tab-bar/TabStripScrollIndicator.tsxsrc/renderer/src/components/tab-bar/tab-bar-surface.tsxsrc/renderer/src/components/tab-bar/tab-strip-growth-scroll.test.tsxsrc/renderer/src/components/tab-bar/tab-strip-overflow-navigation.tssrc/renderer/src/components/tab-bar/tab-strip-scroll-metrics.test.tssrc/renderer/src/components/tab-bar/tab-strip-scroll-metrics.tstests/e2e/tab-strip-scroll-render-isolation.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Thumb position leaves React state —
TabStripScrollIndicatorwrites the thumb'swidthandtransformdirectly to the DOM from the strip'sscrollevent, aResizeObserveron the track, andbindTabStripContentResizeObservers, so a scroll or pane resize no longer commitsTabBarand every tab. - Overflow state trimmed —
TabStripScrollMetricsbecomesTabStripOverflowStatewith onlyhasOverflow/canScrollStart/canScrollEnd; the thumb fractions and theirsame*comparison leave the scroll path. - Thumb math reads the scroll element —
computeTabStripThumbLayout(trackWidthPx, el)derives size/offset from the container'sscrollWidth/clientWidth/scrollLeft, and the drag and track-click handlers measure the thumb at press time so the drag math matches what is drawn. - Tests — reworked unit tests for the new signatures and E2E spec
tab-strip-scroll-render-isolation.spec.ts, which records per-commit tab renders through the always-installed__REACT_DEVTOOLS_GLOBAL_HOOK__and checks the thumb geometry after scroll, tab growth, and a narrowed pane. I ran the three changed unit test files locally; all 36 pass, and the strip-render-count test is a real regression guard (it fails on the per-frame state update this replaces).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the two commits pushed since the prior Pullfrog review (922fde8 → 77a23e2).
- Scroll thumb shares the strip's resize observers —
TabStripScrollIndicatorno longer binds its ownbindTabStripContentResizeObservers; the navigation hook exposessubscribeToStripResizeand notifies subscribers from its existing content-resize/mutation observer, removing the duplicate set that watched every tab. - E2E spec reworked to not wait on frames —
tab-strip-scroll-render-isolation.spec.tspolls thumb geometry, dispatches wheel events in-page, and records tab renders through typedWindowglobals, replacing theReflect.getcalls the anti-slop lint flagged. - Coverage for the shared resize path — a nav-hook unit test asserts subscribers fire when a tab opens without a scroll, and the indicator unit test asserts subscribe-on-overflow and unsubscribe-on-unmount.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the two commits pushed since the prior Pullfrog review (77a23e2 → 9d00b5a). Both are test-only; no production code changed in this delta.
- Direct-DOM-write invariant pinned —
TabStripScrollIndicator.test.tsxnow asserts that a hover re-render leaves the same thumb element in place with itswidthandtransformuntouched, guarding the contract that keeps the thumb geometry out of React's control. - E2E scroll-start setup hardened —
tab-strip-scroll-render-isolation.spec.tssets the mid-strip start position after recording begins, polls until the position holds (the pin-release scroll event only lands with the next frame in CI's hidden window), and discards the edge-flip commit that scroll causes before the wheel sweep, so it can't be mistaken for the scroll under test.
I ran TabStripScrollIndicator.test.tsx locally — 11/11 pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
9d00b5a to
57ee293
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the branch head 57ee293, which is the previously reviewed PR content rebased onto the current main (3aa2d3a). No production or test code authored by the PR changed in this delta.
- Rebase onto newer
main— the only differences in the tab-strip files since the prior review at9d00b5aaremain's tab-strip scrollbar restyle (trackh-[3px]idle /h-[4px]expanded,bg-muted-foreground/15; thumbbg-muted-foreground/60–/80withbg-foreground/70on drag) and the matching color test that landed with it. Both came frommainand are correctly outside the PR's merge-base diff —diffPathshows them as context, not additions. - Prior findings stand —
TabStripScrollIndicator.tsxstill writes the thumb'swidth/transformstraight to the DOM behindhasOverflow, andtab-strip-overflow-navigation.tsstill fans strip-resize notifications throughsubscribeToStripResize. - Verification at HEAD — the three tab-bar unit suites pass (38 tests),
oxlintis clean on the six changed files,tc:webis clean, and the new e2e spec has no type errors.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Thanks Kelvin, I reviewed and tested this one. The approach is right. The tab bar keeps only the edge flags in state, and the scroll bar moves its own thumb, so a scroll in the middle of the strip no longer touches the tabs. I checked it in a hidden window with 71 tabs. A 30-step wheel scroll went from 90 commits (30 of them re-rendering all 71 tabs) to 1 commit with no tab re-renders. A pane resize went from 56 commits and 994 tab re-renders to 2 commits and none. The thumb lands within a fraction of a pixel of where it should after scrolling, resizing and opening tabs. Thanks for rebasing past #24276. CI is green, and this looks good to me. |
The thumb moved every scroll and resize frame, re-rendering every tab with it. Fixes stablyai#24012
The thumb had its own observer on every tab, on top of the tab bar's.
CI's hidden window draws about one frame a second, so real wheel input timed out. Also drops Reflect.get for the anti-slop audit.
…y alone The thumb's width and transform live outside React, so the element must survive a hover re-render with its geometry intact.
…ling Opening the tabs leaves the strip pinned to its end, and the scroll event that releases that pin only lands with the next frame - about a second in CI's hidden window. A tab retitling inside that window re-pinned the strip to the end, so the wheel sweep would start at an edge and every step would flip the edge flags.
57ee293 to
44808e5
Compare
nwparker
left a comment
There was a problem hiding this comment.
Scroll thumb geometry avoids per-scroll React state while retaining reactive overflow controls. Resize subscriptions, content growth, drag and close cleanup reviewed; 588 tab-bar tests including render-count regressions pass, plus web typecheck and quality gates.
Required PR Checks verify passed on this exact commit: 44808e5.
|
Pre-merge bot audit on 44808e5: both review threads are resolved and their fixes remain present. The scroll indicator subscribes to the existing navigation observer; its separate observer watches only the indicator track. The E2E test uses checked Window property access instead of Reflect.get. The docstring-coverage suggestion is declined under AGENTS.md's concise, non-obvious-comment policy; comments explain the geometry and observer ownership where needed. Focused tab-bar validation passed 588 tests, and all current CI checks passed. |

ELI5
The thin scroll bar under the tabs kept its position in the tab bar's state. Every time it moved a pixel, the whole tab bar and every tab in it redrew. With 50 tabs open, scrolling stuttered. Now the scroll bar moves itself and the tabs stay put.
What Changed
Before: once the strip overflowed, every scroll step (wheel, trackpad, the arrow buttons, dragging the scroll bar) and every frame of a pane resize re-rendered
TabBarand every tab in it, three React commits per scroll step. With 50 tabs a smooth scroll dropped frames, and with the CPU slowed 4x it ran at about 12 fps.After: scrolling and resizing re-render nothing in the tab bar until the strip reaches an edge, where the arrow buttons and edge fades change. The scroll bar looks and behaves the same.
How:
TabBar's overflow state keeps onlyhasOverflow,canScrollStartandcanScrollEnd. Those flip at the edges, not every frame.TabStripScrollIndicatorworks out the thumb's size and position from the strip'sscrollLeft,scrollWidthandclientWidth, and writeswidthandtransformstraight to the thumb element. It updates on the strip's scroll event, a ResizeObserver on its track, and the resize notificationTabBaralready gets from its own observers (subscribeToStripResize), because tabs opening, closing or getting longer titles change the strip's width without a scroll event. The thumb has no Reactstyleprop, so a hover re-render can't move it back to an old position.Why
The thumb position is the only value here that changes every frame, and only the scroll bar draws it. Keeping it in React state made every frame pay for the whole tab bar. Radix ScrollArea moves its thumb the same way, by writing the style directly. That component doesn't fit here, because its viewport wraps the tabs in an extra element, which breaks the sticky active-tab dock.
Other options I looked at:
TabBarand its hooks would still render three times per scroll step, and the tabs get fresh callbacks on every render, so memo would miss. It's still worth doing for agent-status and title updates, and it's listed as a follow-up below.animation-timeline). That runs no JS per frame, but the thumb width still needs JS, the track is a sibling of the strip so it needstimeline-scope, and it can't be unit tested.The thumb moves with
transformand haswill-change-transform. Of the three variants I traced (left,transform, andtransformwithwill-change), that one used the least main-thread time, andWorkspaceKanbanAreaSelectionOverlayalready moves its overlay the same way.Linked Issue
Fixes #24012
Visual Proof
N/A for screenshots: the scroll bar looks and moves exactly as before. The change is in how much work each frame does, measured in a hidden Orca window on macOS with 50 terminal tabs (production build). React commits were counted through the DevTools commit hook, and frames and main-thread time come from Chrome traces.
Timings vary by machine, so they are reported here and not asserted in a test.
Testing
tab-strip-growth-scroll.test.tsx: the strip does not re-render for a scroll that stays between the edges. Fails on main.TabStripScrollIndicator.test.tsx: the thumb gets its size when overflow appears, follows scrolling, and shrinks when the strip reports a resize without a scroll event.tab-strip-growth-scroll.test.tsxchecks that the strip sends that report when a tab opens.tests/e2e/tab-strip-scroll-render-isolation.spec.ts: in the real app, a 20-step wheel scroll across the middle of a long strip may not produce any React commit that re-renders three or more tabs. On main, all 20 steps re-render 61 tabs each. The wheel events are dispatched in the page, because CI's hidden window draws about one frame a second and real wheel input waits a frame per step. The spec also checks the thumb's position after scrolling, after tabs open, and after the pane narrows. A tab switch at the end acts as a control, so the render recorder can't quietly stop seeing renders.TabStripScrollIndicator.test.tsxalso pins the invariant the thumb's position depends on: a hover re-render must leave the same thumb element in place with its width and transform untouched.The e2e spec sets its mid-strip start position after the new terminals stop retitling, and re-sets it until it holds. Opening the tabs leaves the strip pinned to its right edge, and the scroll event that releases that pin only lands with the next frame — about a second in CI's hidden window. A retitle inside that window re-pinned the strip to the end, which would have started the wheel sweep at an edge and flipped the edge flags on every step.
Tested on macOS. The change is renderer layout code with no platform branches, and SSH and remote worktrees use the same tab bar.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Worth a close look: the layout effect in
TabStripScrollIndicator.tsx. The indicator renders nothing until the strip overflows, so the effect is keyed onhasOverflow. It binds to the thumb when overflow appears and rebinds when overflow goes away and comes back.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 change. No new strings, settings, wire fields or persisted data, and nothing changes for SSH, mobile or older clients.
Follow-ups, not in this PR:
tests/e2e/tab-strip-active-dock.spec.tsstops adding tabs at 40, which isn't enough to overflow twice in a wide window, so it fails on main there.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)