ollama - ✅(Solved) Fix app/ui: chat content scrolls out of view while waiting for response [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#15557Fetched 2026-04-15 06:20:13
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
cross-referenced ×1labeled ×1referenced ×1

Fix Action

Fixed

PR fix notes

PR #15562: app/ui: fix chat content scrolling past viewport during response loading

Description (problem / solution / changelog)

When sending a message, the loading indicator appears and the user can scroll down past the content, causing the conversation to disappear above the viewport.

The spacer calculation in useMessageAutoscroll did not account for all visible content (dots, download progress, padding), creating extra scrollable space. The hook also had unused refs, state that was not reset between interactions, and observers that were recreated on every message update. Simplified the hook to address these issues.

Changes:

  • app/ui/app/src/hooks/useMessageAutoscroll.ts: simplified spacer calculation and scroll logic
  • app/ui/app/src/components/Chat.tsx: added overflow-anchor: auto to the scroll container

How scroll works now:

  1. User sends a message — it scrolls to the top of the viewport. A spacer div fills the remaining space below so maxScroll lands exactly with the user message at the top.
  2. The response streams below the user message. The spacer shrinks as the response grows. Auto-scroll follows the tail.
  3. If the user scrolls up, auto-scroll pauses. If they return to the bottom (within 50px), it resumes.
  4. When the response fills the viewport the spacer reaches 0 and auto-scroll tracks naturally.
  5. After the response completes the spacer stays — the user message remains at the top until the next message or chat change.

What was fixed:

  • Spacer now uses container.scrollHeight - spacerInDOM for actual content height — accounts for dots, download, padding automatically
  • Removed unused scroll tracking refs (lastScrollHeightRef, lastScrollTopRef)
  • Replaced isActiveInteraction / hasSubmittedMessage useState pair with a single ref (avoids cascading re-renders)
  • Observers no longer recreated on every message update
  • Replaced double requestAnimationFrame with useLayoutEffect + single requestAnimationFrame so the scroll runs after React applies the spacer to the DOM
  • Removed 40% extra spacer height during streaming (containerHeight * 0.4) that amplified overscroll
  • getLastUserIndex depends on messages.length instead of messages — not recreated on every streaming token
  • paddingTop cached in a ref to avoid getComputedStyle reflow

Fixes #15557

Changed files

  • app/ui/app/src/components/Chat.tsx (modified, +1/-1)
  • app/ui/app/src/hooks/useMessageAutoscroll.ts (modified, +120/-271)
RAW_BUFFERClick to expand / collapse

What is the issue?

When sending a message in a chat, the loading indicator (three dots) appears at the bottom. At this point, it is possible to scroll down well past the actual content, causing the entire conversation to disappear above the viewport. The user is left looking at an empty area with no way to understand what happened unless they scroll back up.

Steps to reproduce

  1. Open a chat and send a message
  2. While the loading indicator (three dots) is visible, scroll down manually
  3. The chat content moves above the viewport and becomes completely invisible

Video

https://github.com/user-attachments/assets/12f2f01b-c26f-4994-9d46-3f6cea8014e8

Relevant log output

OS

No response

GPU

No response

CPU

No response

Ollama version

0.20.6

extent analysis

TL;DR

The issue can likely be fixed by preventing the chat content from scrolling out of view while the loading indicator is visible.

Guidance

  • Investigate the CSS or layout management code that handles the chat content and loading indicator to identify why the content is scrolling out of view.
  • Consider adding a temporary fix to disable scrolling or lock the content in place while the loading indicator is visible.
  • Review the JavaScript code that handles the scrolling and loading indicator to ensure it is correctly managing the viewport and content positioning.
  • Test the chat functionality with different screen sizes and devices to ensure the issue is not specific to a particular setup.

Example

No code example can be provided without more information about the implementation, but the fix might involve adding a CSS class to lock the content in place or using JavaScript to prevent scrolling while the loading indicator is visible.

Notes

The exact solution will depend on the specific implementation details of the chat functionality, which are not provided in the issue. Further investigation and debugging will be necessary to determine the root cause and implement a fix.

Recommendation

Apply a workaround to prevent scrolling while the loading indicator is visible, as this is likely to be a quicker fix than rewriting the underlying layout management code.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING