fix(tui): prevent End hint showing when already at bottom#118
Merged
Conversation
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 OverviewGreptile SummaryFixed the '↓ End' scroll hint incorrectly appearing when the user is already at the bottom of the chat. Changes:
Impact: Confidence Score: 5/5
|
| 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the '↓ End' hint incorrectly appearing when the user is already at the bottom of the chat.
Problem
The
scroll_chatmethod was unconditionally settingchat_scroll_pinned_bottom = false, which caused the hint to incorrectly appear when:Solution
Check if
chat_scrollis 0 (at bottom) after the scroll operation and maintainchat_scroll_pinned_bottom = truein that case.Testing