Skip to content

fix(ui): long-session scroll geometry — endless upward scroll, and remount landing mid-document #827

Description

@Astro-Han

Context

.maka-turn uses content-visibility: auto + contain-intrinsic-size: auto 250px (maka-tokens.css), so off-screen turns occupy a 250px placeholder until first laid out. On a ~24-turn session the un-warmed transcript underestimates true height ~2x (measured on mount: scrollHeight 14640 vs 31872 real).

Behavior today

  • Endless upward scroll: each viewport arrival inflates a placeholder to its real height; scroll anchoring compensates; the top keeps receding (~51 viewport-sized steps to reach the top vs an honest ~23).
  • Remount lands mid-document: opening a long session pins to bottom once, but placeholder inflation then grows the document with no DOM mutation and no scroll event; the mutation-only follower strands the viewport mid-document (observed scrollTop 5408, far from bottom).
  • Any fix that pre-records sizes must measure the final layout: fallback font metrics and the lazy-markdown Suspense fallback (~7.5px taller per turn) otherwise re-create per-arrival drift.

Fix direction (implemented in the linked PR)

  • Chunked bottom-up idle-time warm-up so every turn's remembered size replaces the placeholder.
  • A ResizeObserver channel in the pinned-bottom follower for mutation-less growth.
  • Warm-up gated on final layout (fonts ready + no pending markdown) and re-run when a mode switch rebuilds the transcript DOM.

Acceptance

  • A settled long session scrolls to the top in the honest number of viewport steps with a single stable scrollHeight.
  • Opening a long session stays pinned to bottom (distance 0) while geometry settles, locked by E2E against a deterministic long-transcript fixture.

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