on main help sign in
fix(ui): ensure we anchor the chat view to the bottom when toggling (#2117)

an item at the bottom of the chat When toggling an item in the chat, if that item is at the bottom of the chat, we want to ensure that we stay anchored to the bottom. This prevents a gap from appearing at the bottom of the chat when toggling an item that is currently selected and at the bottom.

commit3bda767c6700db1ead64af01471b3e7b868a569f authorAyman Bagabas <ayman.bagabas@gmail.com> dateWed 4 Feb 2026, 14:53 (8 months ago) parentf53402d
2 files changed+7−1
internal/ui/list/list.go+1−1 internal/ui/model/chat.go+6
internal/ui/list/list.go+1−1
@@ -79,7 +79,7 @@ func (l *List) Gap() int {
7979func (l *List) AtBottom() bool {
8080 const margin = 2
8181
82− if len(l.items) == 0 {
82+ if len(l.items) == 0 || l.offsetIdx >= len(l.items)-1 {
8383 return true
8484 }
8585
internal/ui/model/chat.go+6
@@ -439,6 +439,9 @@ func (m *Chat) ToggleExpandedSelectedItem() {
439439 if expandable, ok := m.list.SelectedItem().(chat.Expandable); ok {
440440 expandable.ToggleExpanded()
441441 m.list.ScrollToIndex(m.list.Selected())
442+ if m.list.AtBottom() {
443+ m.list.ScrollToBottom()
444+ }
442445 }
443446}
444447
@@ -547,6 +550,9 @@ func (m *Chat) HandleDelayedClick(msg DelayedClickMsg) bool {
547550 expandable.ToggleExpanded()
548551 }
549552 m.list.ScrollToIndex(m.list.Selected())
553+ if m.list.AtBottom() {
554+ m.list.ScrollToBottom()
555+ }
550556 return handled
551557 }
552558