Skip to content

Bottom-edge scroll snap-back when agent notes are attached #234

@aldevv

Description

@aldevv

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

  1. hunk diff <range> on a multi-file diff
  2. Attach agent notes to one or more files (hunk session comment apply ...)
  3. Scroll all the way to the last line of the last file
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions