Skip to content

Conversation

@linw1995
Copy link
Owner

Overview

This PR fixes issue #154 where the chat TUI does not scroll all the way to the bottom when new messages are displayed. Previously, users had to manually scroll down to see the latest messages during conversations.

Changes Made

File: crates/coco-tui/src/components/messages.rs

  1. Added scroll_to_bottom() method (line 335-337):

    • Resets the offset to 0 to scroll to the bottom
    • Provides a clean API for auto-scrolling behavior
  2. Auto-scroll on message operations:

    • extend(): Calls scroll_to_bottom() when adding multiple messages (line 87-88)
    • push(): Calls scroll_to_bottom() when adding a single message (line 99-100)
    • append_stream_text(): Calls scroll_to_bottom() during text streaming (line 181-182)
  3. Added comprehensive tests:

    • auto_scroll_to_bottom_after_push(): Verifies auto-scroll after pushing messages
    • scroll_to_bottom_method(): Tests the scroll_to_bottom() method explicitly
    • auto_scroll_after_stream_text(): Ensures streaming text also triggers auto-scroll

Behavior

Now the chat view automatically scrolls to the bottom whenever:

  • A new message is sent (via push())
  • New messages are received in batch (via extend())
  • Text is being streamed character by character (via append_stream_text())

This ensures users always see the most recent content without manual intervention, improving the experience during long conversations and AI response generation.

Fixes #154

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.54%. Comparing base (a46f02c) to head (4d548e1).
⚠️ Report is 11 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #155      +/-   ##
==========================================
- Coverage   50.22%   47.54%   -2.69%     
==========================================
  Files          93       99       +6     
  Lines       25033    27359    +2326     
==========================================
+ Hits        12574    13008     +434     
- Misses      12459    14351    +1892     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@linw1995 linw1995 added the bug Something isn't working label Jan 29, 2026
@linw1995 linw1995 merged commit 30059d4 into dev Jan 29, 2026
3 checks passed
@linw1995 linw1995 deleted the fix/chat-auto-scroll branch January 29, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Chat interface does not auto-scroll to bottom when new messages appear

3 participants