@@ -465,7 +465,13 @@ func (m *Chat) ScrollToTop() tea.Cmd {
465// ScrollBy scrolls the chat view by the given number of line deltas.
465// ScrollBy scrolls the chat view by the given number of line deltas.
466func (m *Chat) ScrollBy(lines int) tea.Cmd {
466func (m *Chat) ScrollBy(lines int) tea.Cmd {
467 m.list.ScrollBy(lines)
467 m.list.ScrollBy(lines)
468− m.follow = lines > 0 && m.AtBottom() // Disable follow mode if user scrolls up
468+ if lines < 0 {
469+ // Scrolling up always disables follow mode.
471+ } else if m.AtBottom() {
472+ // Scrolling down re-enables follow when we reach the bottom.
469 return m.showScrollbar()
475 return m.showScrollbar()
@@ -700,10 +706,11 @@ func (m *Chat) MessageItem(id string) chat.MessageItem {
700// ToggleExpandedSelectedItem expands the selected message item if it is expandable.
706// ToggleExpandedSelectedItem expands the selected message item if it is expandable.
701func (m *Chat) ToggleExpandedSelectedItem() {
707func (m *Chat) ToggleExpandedSelectedItem() {
702 if expandable, ok := m.list.SelectedItem().(chat.Expandable); ok {
708 if expandable, ok := m.list.SelectedItem().(chat.Expandable); ok {
709+ wasFollowing := m.follow
703 if !expandable.ToggleExpanded() {
710 if !expandable.ToggleExpanded() {
704 m.ScrollToIndex(m.list.Selected())
711 m.ScrollToIndex(m.list.Selected())
706− if m.AtBottom() {
713+ if wasFollowing {
707 m.ScrollToBottom()
714 m.ScrollToBottom()
@@ -830,14 +837,15 @@ func (m *Chat) HandleDelayedClick(msg DelayedClickMsg) bool {
830 // toggling expansion for clicks outside the clickable area.
837 // toggling expansion for clicks outside the clickable area.
831 if handled {
838 if handled {
832 if expandable, ok := selectedItem.(chat.Expandable); ok {
839 if expandable, ok := selectedItem.(chat.Expandable); ok {
840+ wasFollowing := m.follow
833 if !expandable.ToggleExpanded() {
841 if !expandable.ToggleExpanded() {
834 m.ScrollToIndex(m.list.Selected())
842 m.ScrollToIndex(m.list.Selected())
841 return handled
849 return handled