Chat transcript snaps back to bottom / jumps while scrolling up — content-visibility:auto placeholder heights conflict with the auto-scroll logic

Open Beginner friendly
#1,905 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
css, react, typescript

Research direction

Find the .chat-message CSS rule that sets content-visibility: auto and check the transcript scroll and auto-scroll behavior described in the issue. The report identifies removing that declaration as a locally verified fix; start by locating the source CSS and reproducing the long-transcript case with images or code blocks. Done when scrolling up stays in place, including while messages stream or render.

Written by the indexing model from the issue text.

Description

NP OSS

Describe the bug

While scrolling up in a chat session, the transcript repeatedly snaps back to the bottom, and the scroll position jumps by large distances (hundreds to thousands of px) at once. The problem is worst around user messages containing pasted screenshots or long code blocks. In long sessions (100k+ tokens) this makes reviewing history nearly impossible.

To Reproduce

Open a chat session with a long transcript containing user messages with pasted screenshots / large code blocks
Scroll up slowly from the bottom through the history
Optionally: while an answer is still streaming in, scroll up away from the bottom
See: the view snaps back to the bottom, or jumps a large distance in one step — especially right after passing user messages with images
Expected behavior

Scrolling up should stay exactly where the user scrolls. The transcript must not snap back to the bottom and must not shift under the cursor, even while new messages arrive or off-screen messages render for the first time.

Error message

None — pure UI behavior issue, no console errors.

Desktop (please complete the following information):

OS: Windows 11 (23H2, build 22631)
Browser: Edge (Chromium)
Version: 158.0.4370.45
App: CloudCLI 1.37.11 (a distribution of claudecodeui — the same CSS/JS ships in the upstream build)
Smartphone (please complete the following information):

Device: N/A (not tested; #1890 reports a related iOS scrolling issue)
Additional context

Root cause analysis (verified against the shipped build). .chat-message ships with:

.chat-message {
contain: layout style paint;
content-visibility: auto;
contain-intrinsic-size: auto 180px;
}
Off-screen messages render as ~180px placeholders. While scrolling up, those placeholders progressively render at their real height (a user message with images is easily 1000–3000px), so content above the viewport grows by huge amounts mid-gesture:

the scroll container's near-bottom check (scrollHeight - scrollTop - clientHeight < 50px) briefly becomes true during these shifts, marking the user as "at the bottom";
on the next message-list change, the scroll effect then forces scrollTop = scrollHeight — the snap-back;
while messages stream in, the previous position is restored from a raw pixel offset (saved top), which is wrong once heights above the viewport changed — the large jumps.
Browser scroll anchoring can't compensate because the app overrides scrollTop manually on every list update. User messages are the worst case: pasted screenshots make the placeholder→real delta enormous.

Suggested fix: drop content-visibility: auto for .chat-message. The chat already renders only a window of recent messages (older history is opt-in), so the virtualization benefit is small while the scroll instability is severe. If it must stay, position restoration should use an anchor element (the "load older messages" flow already does this) instead of raw pixel offsets, and auto-scroll should only fire when the user is genuinely at the bottom.

Verified locally: removing the single content-visibility: auto; declaration from the built CSS eliminated all three symptoms, with no noticeable rendering cost on long sessions.

Related issues: #1633, #1635, #1652, #1890

Dominant language
TypeScript
Stars
13.9k
Forks
2k
Avg merge
22h 45m
Merged PRs (30d)
44

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from siteboon/claudecodeui

All issues in siteboon/claudecodeui

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.