Repository navigation
Conversation
…ject header Collapsing and expanding projects left a header-sized gap under one project, made another project appear to jump above its neighbour, and hid the true first project row entirely. The active project header is rendered in normal flow at the top of the list and its own virtual slot is left empty, which is only correct when the pinned header is the first row. Which header pins is derived from TanStack's remembered scrollOffset. TanStack 3.17 books every size correction into that offset before the element scrolls and only re-reads the element on a scroll event. Orca's shouldAdjustScrollPositionOnItemSizeChange returned true for every card resize, including rows below the fold, so a card growing under a project in a list shorter than the viewport moved the believed offset (~70px) while the element stayed at 0. The header at that offset then pinned over row 0 and left its slot blank; expanding a project shifted the indices and a different header pinned. - Apply TanStack's fold rule inside the sidebar predicate: correct only rows above the viewport top (first measure) or entirely above it (remeasure, not scrolling backward), on top of the existing input-quiet gates. This also removes the visible jump when a card below the viewport grows in a scrollable list. - Reconcile a believed offset the element cannot reach back to the element after layout and re-render so range and sticky slots follow the DOM. - Cover the predicate, the reconcile, and the drift itself against the real Virtualizer with an unscrollable element.
0568ca4 to
2403c49
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 0568ca49a92aeb8ccb5e9ebda4690088e296f2be and 2c59a69. 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe worktree sidebar now uses row geometry, measurement state, and scroll direction to decide when size changes can adjust scroll position. New helpers reconcile unreachable virtualizer offsets with the actual scroll element. The row measurement hook applies this correction during a layout effect and triggers a render when needed. Tests cover fold-aware adjustment, unscrollable sidebars, offset clamping, tolerance, and sticky-header restoration. Merge Risk: ⚪ Minimal · up to This change keeps sidebar virtual scroll state aligned with the actual scroll position, preventing incorrect sticky project headers and layout gaps during project resizing. The targeted behavior and integration coverage indicate no remaining merge-blocking risk. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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: Team
Run ID: cec9b500-6254-42a1-a542-e30553b89152
📥 Commits
Reviewing files that changed from the base of the PR and between 0d2375a and 0568ca49a92aeb8ccb5e9ebda4690088e296f2be.
📒 Files selected for processing (7)
src/renderer/src/components/sidebar/worktree-list/viewport/scroll-adjustment.test.tssrc/renderer/src/components/sidebar/worktree-list/viewport/scroll-offset-drift.test.tssrc/renderer/src/components/sidebar/worktree-list/viewport/scroll-offset-reconcile.test.tssrc/renderer/src/components/sidebar/worktree-list/viewport/scroll-offset-reconcile.tssrc/renderer/src/components/sidebar/worktree-list/viewport/use-row-measurement.tssrc/renderer/src/components/sidebar/worktree-list/viewport/use-scroll-suppression.tssrc/renderer/src/components/sidebar/worktree-list/viewport/use-virtualizer.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
The reconcile is skipped while a scroll is in flight, but the effect had no dependency that would rerun it when isScrolling flips back, so a belief that went unreachable mid-scroll could survive until the next structural change. Extract the body into reconcileVirtualizerScrollOffset, depend on isScrolling, and cover the in-flight to settled transition.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Fold-aware scroll-adjustment predicate —
shouldAdjustWorktreeSidebarMeasuredRowScrollnow layers TanStack Virtual's fold rule over the existingisScrolling/suppressUntilgates, so a row at or below the viewport top no longer books a scroll write the element can't honor. - Offset reconciliation — a new
getReconciledVirtualScrollOffsetplus auseLayoutEffectinuse-row-measurement.tssnap an unreachable believedscrollOffsetback to the element'sscrollTopand re-render so range and sticky-header math follow the DOM. - Tests — fold-rule predicate cases, reconcile rules, and a real-
Virtualizerdrift harness that proves the old predicate driftsscrollOffsetwhile the new one holds 0.
I traced the predicate against the vendored @tanstack/virtual-core 3.17.8 source (resizeItem → defaultShouldAdjust). The first-measure branch (itemStart < scrollOffsetWithAdj) and re-measure branch (itemStart + itemSize <= scrollOffsetWithAdj && scrollDirection !== 'backward') match the PR's itemStart/itemEnd conditions exactly, including the itemSize === item.end - item.start equivalence for the lazy measurementsCache view. The reconcile's guard (believedOffset <= scrollHeight - clientHeight + 1) correctly leaves reachable in-flight scroll writes alone and only touches beliefs the element provably cannot reach, so a legitimate scrollToIndex (whose target is clamped to getMaxScrollOffset()) can't be falsely corrected. The re-render path (useReducer + updated scrollOffsetRef) reads the corrected offset on the next getVirtualItems()/sticky-index pass, and the effect's deps (totalSize, renderRowKeySignature) mean it fires whenever a size correction books an offset but doesn't loop. The direct virtualizer.scrollOffset/scrollAdjustments write is undocumented, but there is no public setter, and the PR documents it honestly.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (since 0568ca4)
reconcileVirtualizerScrollOffset— the mutation is extracted into a testable helper that separates the puregetReconciledVirtualScrollOffsetmath from thescrollOffset/scrollAdjustments/scrollOffsetRefwrites and returns whether anything changed.- Re-run on scroll settle —
virtualizer.isScrollingis read during render (isVirtualizerScrolling) and added to theuseLayoutEffectdeps, so a reconcile skipped mid-scroll runs again once scrolling settles (TanStack's debouncedobserveElementOffsetfallback flipsisScrolling → falseand firesmaybeNotify, which triggers the re-render that re-arms the effect). - Tests — the new
reconcileVirtualizerScrollOffsetsuite covers the in-flight → settled transition and the already-correct no-op case, both with exact assertions.
The fix is sound: the isScrolling transition is observable (it feeds maybeNotify's memo deps), so the effect re-runs without polling, and the scrollOffset write doesn't change any of the effect's deps, so the useReducer-driven re-render can't loop. No further concerns.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Thanks @ccueto36 for the thorough investigation into the drifted virtualizer offset! This is already fixed on main by #20883 (3af09f8): |

ELI5
The sidebar keeps a note of how far it thinks it has scrolled. When a workspace card grew in a list too short to scroll, that note moved even though the list did not. The pinned project header is chosen from that note, so the wrong project got pinned over the first row and left a hole where it should have been. Now the note only moves for rows that are actually above the top of the list, and if it ever ends up somewhere the list cannot reach, it is snapped back to where the list really is.
What Changed
use-scroll-suppression.ts/use-virtualizer.ts:shouldAdjustScrollPositionOnItemSizeChangenow applies TanStack's fold rule on top of the existing scrolling and suppression gates. A first measurement corrects only when the row's top is above the viewport top; a re-measurement only when the row is entirely above it and the scroll direction is not backward.scroll-offset-reconcile.ts(new) +use-row-measurement.ts: after layout, a believed offset the element cannot reach (beyondscrollHeight - clientHeight) is snapped back to the element'sscrollTopand the list re-renders so range and sticky slots follow the DOM. Only an unreachable belief is touched; a reachable difference can be an in-flight scroll write whose event has not landed yet. The effect depends onisScrollingso a check skipped mid-scroll reruns once scrolling settles.scroll-adjustment.test.ts(fold-aware predicate),scroll-offset-reconcile.test.ts(reconcile rules, the reported scenario, the in-flight → settled transition),scroll-offset-drift.test.ts(drives the realVirtualizeragainst an unscrollable element and shows the old predicate driftingscrollOffsetwhile the new one holds 0).Why
The active project header renders
stickyin normal flow at the top of the list and its own virtual slot is left empty. That is only right when the pinned header is the first row. Which header pins is derived from the virtualizer's rememberedscrollOffset(getActiveStickyIndexesForScrolland the range extractor'sstartIndex).TanStack Virtual 3.17 books every size correction into
scrollOffsetbefore the element scrolls (applyScrollAdjustment) and only re-reads the element on a scroll event. The sidebar predicate returnedtruefor every measured resize, replacing TanStack's default "only rows above the fold" rule with "always" (its intent, per #2175, was only to stay quiet during wheel input). So a card growing under a project, in a list shorter than the viewport, moved the believed offset to roughly 70 px while the element stayed at 0, and no scroll event ever corrected it. The header at that offset pinned over row 0 and left its slot blank; expanding a project shifted the indices and a different header pinned, which reads as a reorder.Two reviewer notes: the predicate change also removes a pre-existing visible jump when a card below the viewport grows in a scrollable list, and the reconcile writes
virtualizer.scrollOffsetdirectly, which is a public field but not a documented mutation path.Linked Issue
Fixes #18667
Visual Proof
Before: 12s screen recording of the bug. Project names are redacted to "Project A" through "Project E"; Project A is the one being collapsed and expanded. Watch for the blank band under Project A while it is collapsed, and Project A jumping above Project B when it is expanded. There are six projects in the list; the sixth is never visible because the mis-pinned header sits over it.
Screencast_20260904_091046_redacted.webm
After: not captured on a packaged build. The behavior is pinned by
scroll-offset-drift.test.ts, which runs the real TanStackVirtualizeragainst an unscrollable element and asserts the offset stays at 0 under the new predicate, and by the scenario test that shows index 0 pinning once the offset is reconciled.Testing
Linux only. Automated, not a manual run of a packaged build:
tsc --noEmit -p config/tsconfig.tc.web.jsoncleanoxlint,oxfmt --check, andcheck-changed-code-quality.mjscleanvitestoversrc/renderer/src/components/sidebar: 294 files, 2501 tests passing before the follow-up commit; viewport +WorktreeListsuites re-run after it, 131 tests passingI manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Diagnosed and implemented with Claude Code (Claude Fable 5.1): frame extraction from the screen recording, tracing the sticky-header and TanStack scroll-offset behaviour, the code changes, and the tests. The author reviewed the diagnosis and the diff, directed the fix and the review follow-up, and ran the verification listed above.
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 change in the sidebar virtualizer; no platform, SSH, path, or wire-format surface is touched. Performance: the reconcile runs in an existing layout effect, reads three properties of the scroll element, and re-renders only when it corrects something.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)