Summary
With agent notes attached to a session, scrolling to the very bottom of the diff snaps back upward by ~the height of the note rows on files that just left the top of the viewport. Without notes, the bottom edge is stable. Repros in vanilla 0.10.0.
Repro
hunk diff <range> on a multi-file diff
- Attach agent notes to one or more files (
hunk session comment apply ...)
- Scroll all the way to the last line of the last file
- Try to scroll one line further → viewport snaps up by 1–2 lines (matches the note-row count of files that just scrolled off the top)
Without step 2 the bottom edge is stable.
Likely cause (read-only inspection of src/ui/components/panes/DiffPane.tsx)
sectionGeometry (line 439) measures with visibleAgentNotesByFile and falls back to notes-less baseSectionGeometry for files outside the viewport.
visibleAgentNotesByFile (line 415) is keyed off visibleViewportFileIds, which depends on scrollViewport.top.
totalContentHeight (line 478) is derived from this geometry, so it shrinks by the height of off-top note rows as you scroll past them.
clampReviewScrollTop (line 481) uses totalContentHeight. As content height shrinks, maxScrollTop shrinks, and any settle / clamp pass yanks the viewport upward.
The "off-screen optimization" that excludes notes from measurement is correct for rendering (don't paint hidden cards) but wrong for measurement — total content height needs to be stable regardless of scroll position. Files with notes attached should always have their note rows included in sectionGeometry, even when off-screen.
Suggested fix
Use allAgentNotesByFile (not visibleAgentNotesByFile) for measurement at line 442 — keep visibleAgentNotesByFile for the render call at line 1115.
Related
Different bug from #233 (max update depth), but same file. Both surface around viewport / scroll bookkeeping under agent annotations.
Summary
With agent notes attached to a session, scrolling to the very bottom of the diff snaps back upward by ~the height of the note rows on files that just left the top of the viewport. Without notes, the bottom edge is stable. Repros in vanilla 0.10.0.
Repro
hunk diff <range>on a multi-file diffhunk session comment apply ...)Without step 2 the bottom edge is stable.
Likely cause (read-only inspection of
src/ui/components/panes/DiffPane.tsx)sectionGeometry(line 439) measures withvisibleAgentNotesByFileand falls back to notes-lessbaseSectionGeometryfor files outside the viewport.visibleAgentNotesByFile(line 415) is keyed offvisibleViewportFileIds, which depends onscrollViewport.top.totalContentHeight(line 478) is derived from this geometry, so it shrinks by the height of off-top note rows as you scroll past them.clampReviewScrollTop(line 481) usestotalContentHeight. As content height shrinks,maxScrollTopshrinks, and any settle / clamp pass yanks the viewport upward.The "off-screen optimization" that excludes notes from measurement is correct for rendering (don't paint hidden cards) but wrong for measurement — total content height needs to be stable regardless of scroll position. Files with notes attached should always have their note rows included in
sectionGeometry, even when off-screen.Suggested fix
Use
allAgentNotesByFile(notvisibleAgentNotesByFile) for measurement at line 442 — keepvisibleAgentNotesByFilefor the render call at line 1115.Related
Different bug from #233 (max update depth), but same file. Both surface around viewport / scroll bookkeeping under agent annotations.