Agent transcript: opening a line at the very bottom pushes the text up

Merged
TE
3d ago
+378-18

Leo (2026-11-02): "AND NOBODY FING DID WHAT I ASKED FOR / YOU EXPAND UP WHILE YOUR SCCROLL IS AT THE VERY BOTTOM AKA YOU FING PUSH THE TEXT UP VISUALLY INSTEAD OF EXPANDING DOWN LIKE USUAL / JUST THAT CASE"

What changed

With the agent transcript scrolled to its very bottom, opening any line now keeps the bottom pinned: what opens pushes the text above it up, and the rows under it stay on their pixels. Anywhere else nothing changes: the clicked line stays put and its body grows down (#28780). Closing is unchanged.

  • The bottom stack fold (#29686, #29857) took only tool and work lines (.cv-tool.is-toggle, .cv-worked, .cv-subagents). It now also takes any line that opens (opensBody in conversation/foldAnchor.ts): a closed aria-expanded control, a header toggle's own button (the edits card), or a closed <summary>. That covers a long prompt's Show more, the edits card's header, an agent message line and the like. Closing them keeps the established row anchor and its room.
  • "At the bottom" stays base's: the offset at (or within 4px of) the end of a transcript that scrolls.
  • Gallery scene agent-pane.expand-at-bottom (variants shipped: "Ran 2 commands" at the bottom; prompt: a long prompt's Show more at the bottom).
  • Two older tests asserted that a message opened at the latest row stays on its pixel. They now assert Leo's rule (it pushes the text up, the view stays at the end, and closing keeps the line): received-message-fold-browser.test.ts, incoming-message-disclosure-browser.test.ts. The away-from-the-end received-message case gets two more turns under it, so it is clearly off the end. agent-pane-fold-keeps-place.test.ts's opening case now starts 48px above the end.
  • Spec: leo-workspace design/chat-transcript.md, "Bottom expansion" (merged).

Tests

cmux-ci test -- bun test test/transcript-expand-at-bottom.test.ts (Chromium, fast-checks runner):

  • Without the fix (the opensBody branch removed): (fail) at the very bottom, a long prompt's Show more opens it by pushing the text above up. The bottom moved 386px, so it expanded down.
  • With it: 3 of 3 pass. "Ran 2 commands" at the bottom: still at the end, the last row's foot unchanged, the line pushed up. Show more at the bottom: same. An earlier turn's line away from the bottom: on its pixel, offset unchanged, the chat grows down.
  • At ba0801f8/bbd555b3: foldAnchor (48), transcript-expand-at-bottom (3), transcript-fold-anchor-browser (16), agent-pane-fold-keeps-place (2), agent-pane-show-less-keeps-place (2), received-message-fold-browser (4) and incoming-message-disclosure-browser (6) all pass.
  • bun run check: exit 0 at ba0801f8.

Observed / Not run

  • Observed: the runs above on the fast-checks runner (Chromium).
  • Not run: a NEXT DEV build in WKWebView. The "Ran 2 commands" case already pushed up on base in Chromium, so if Leo's build still expands down there, the cause is WebKit-specific or a state this scene doesn't reach.

Changelog

  • Fixed: Opening a collapsed line in an agent chat scrolled to the very bottom pushes the text above up, instead of expanding down.

Agent session: agent session

šŸ¤– Generated with Claude Code