Skip to content

fix(tui): prevent End hint showing when already at bottom#118

Merged
echobt merged 1 commit intomainfrom
fix/end-hint-at-bottom
Feb 5, 2026
Merged

fix(tui): prevent End hint showing when already at bottom#118
echobt merged 1 commit intomainfrom
fix/end-hint-at-bottom

Conversation

@echobt
Copy link
Contributor

@echobt echobt commented Feb 5, 2026

Summary

Fixes the '↓ End' hint incorrectly appearing when the user is already at the bottom of the chat.

Problem

The scroll_chat method was unconditionally setting chat_scroll_pinned_bottom = false, which caused the hint to incorrectly appear when:

  • Scrolling down (mouse wheel or Page Down) while already at the bottom
  • Pressing End key when already at the bottom

Solution

Check if chat_scroll is 0 (at bottom) after the scroll operation and maintain chat_scroll_pinned_bottom = true in that case.

Testing

  • The '↓ End' hint should NOT appear when the user is already at the bottom of the chat
  • Scrolling down when at the bottom should not show the hint
  • The hint should still correctly appear when the user has scrolled up from the bottom

The scroll_chat method was unconditionally setting chat_scroll_pinned_bottom
to false, which caused the '↓ End' hint to incorrectly appear when:
- Scrolling down while already at the bottom
- Pressing End key while at the bottom

Now we check if chat_scroll is 0 (at bottom) after the scroll operation
and keep pinned_bottom=true in that case.
@greptile-apps
Copy link

greptile-apps bot commented Feb 5, 2026

Greptile Overview

Greptile Summary

Fixed the '↓ End' scroll hint incorrectly appearing when the user is already at the bottom of the chat.

Changes:

  • Modified scroll_chat() method to conditionally update chat_scroll_pinned_bottom based on scroll position
  • Changed from unconditionally setting chat_scroll_pinned_bottom = false to chat_scroll_pinned_bottom = self.chat_scroll == 0
  • When chat_scroll is 0 (at bottom), the pinned state is maintained as true, preventing the hint from showing
  • When scrolled away from bottom (chat_scroll > 0), the pinned state becomes false, correctly showing the hint

Impact:
The hint display logic (render_scroll_to_bottom_hint) checks is_chat_at_bottom() which returns chat_scroll_pinned_bottom, so this fix ensures the hint only appears when genuinely scrolled up from the bottom.

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The fix is a simple, focused logic correction that solves the exact problem described. The change is minimal (one line), well-commented, and the logic is sound: when chat_scroll equals 0 (at bottom), keep pinned_bottom as true; otherwise set it to false. This aligns perfectly with the rendering logic that checks is_chat_at_bottom() to decide whether to show the hint
  • No files require special attention

Important Files Changed

Filename Overview
src/cortex-tui/src/app/state.rs Fixed scroll pinning logic to prevent '↓ End' hint showing when already at bottom

Sequence Diagram

sequenceDiagram
    participant User
    participant EventHandler
    participant scroll_chat
    participant State
    participant UI

    User->>EventHandler: Mouse wheel / PageDown / End key
    EventHandler->>scroll_chat: scroll_chat(delta)
    
    scroll_chat->>scroll_chat: Calculate new chat_scroll value
    Note over scroll_chat: if delta < 0: saturating_sub<br/>else: saturating_add
    
    scroll_chat->>scroll_chat: Check if chat_scroll == 0
    alt chat_scroll == 0 (at bottom)
        scroll_chat->>State: chat_scroll_pinned_bottom = true
        Note over State: No hint will be shown
    else chat_scroll > 0 (scrolled up)
        scroll_chat->>State: chat_scroll_pinned_bottom = false
        Note over State: '↓ End' hint will be shown
    end
    
    scroll_chat->>scroll_chat: show_scrollbar()
    scroll_chat-->>EventHandler: Return
    
    EventHandler->>UI: Render UI
    UI->>State: is_chat_at_bottom()?
    State-->>UI: chat_scroll_pinned_bottom
    
    alt !chat_scroll_pinned_bottom
        UI->>UI: render_scroll_to_bottom_hint()
        Note over UI: Show '↓ End' hint
    end
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@echobt echobt merged commit e6658f8 into main Feb 5, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant