Repository navigation
Keep diff panel card heights stable while scrolling - #6494
Merged
Merged
Conversation
Dragging the Diff tab scrollbar jumped between distant files because the virtualizer kept measuring transient card heights. Each remounted card rendered a 168px skeleton until an IntersectionObserver fired, replacing its cached real height, and content-visibility sized off-screen bodies at 600px. The total height swung between ~15k and ~90k px mid-drag, so the thumb mapped to different content on every move. Render card bodies as soon as they mount (the virtualizer already limits mounting), keep content-visibility only for the unvirtualized timeline card, estimate every changed line and the on-demand notice, key measurements by collapsed state, and reserve the estimated height while a patch loads. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Dragging the Diff tab scrollbar jumped between distant files instead of following the mouse. The thumb maps to
fraction × total height, and the virtualized list's total height kept changing mid-drag, between about 15k and 90k px on a 42-file diff. Three things fed the virtualizer heights that weren't real:content-visibility: autowithcontain-intrinsic-size: 0 600pxsized every off-screen body at 600 px, its real height on screen, and 600 px again once it left the screen.What changed
packages/shared-ui/.../GitDiffCardBody.tsx: removed therenderBeforeVisibleIntersectionObserver gate, so bodies render on mount. The list virtualizer already limits what mounts, and the timeline card already passedtrue. Added adefersOffscreenRenderingprop: the unvirtualized timeline card (apps/app/.../GitDiffCard.tsx) keepscontent-visibility, and the Diff tab turns it off.plugins/git/ui/diff/diffFilesStore.ts: estimates count every changed line, use the notice height foron_demand/too_largefiles, and use the measured 33 px header and 17 px body padding. Each write now replaces the per-diff state map so the panel can subscribe to it (useDiffFileCardStates).plugins/git/ui/diff/DiffFilesPanel.tsx: estimates use the current collapsed state, the measurement key includes that state so collapsed and expanded heights are cached separately, and rows receivecollapsedfrom the panel.plugins/git/ui/diff/DiffFileCard.tsx: the skeleton shown while a patch loads reserves the estimated body height.How you verified
scrollTopfrom the thumb fraction against the currentscrollHeight, as Chromium does on each mouse move.scrollHeightwent 14.8k → 56.9k px on the first drag and kept shifting on the second, as far as 79k → 17k with scroll clamping.pnpm exec turbo run typecheck lint --filter=@bb/shared-ui --filter=bb-plugin-bb--git --filter=@bb/apppasses.pnpm exec turbo run testpasses for shared-ui (75), the git plugin (249), and the app's git-diff and timeline suites (420). The store test that asserted the 80-line cap now checks per-line scaling and the on-demand notice estimate.pnpm start:worktreewith the fixture, checked in the browser.🤖 Generated with Claude Code