@@ -873,6 +873,7 @@ func (m *UI) appendSessionMessage(msg message.Message) tea.Cmd {
873873func (m *UI) updateSessionMessage(msg message.Message) tea.Cmd {
874874 var cmds []tea.Cmd
875875 existingItem := m.chat.MessageItem(msg.ID)
876+ atBottom := m.chat.list.AtBottom()
876877
877878 if existingItem != nil {
878879 if assistantItem, ok := existingItem.(*chat.AssistantMessageItem); ok {
@@ -893,9 +894,6 @@ func (m *UI) updateSessionMessage(msg message.Message) tea.Cmd {
893894 if infoItem := m.chat.MessageItem(chat.AssistantInfoID(msg.ID)); infoItem == nil {
894895 newInfoItem := chat.NewAssistantInfoItem(m.com.Styles, &msg, time.Unix(m.lastUserMessageTime, 0))
895896 m.chat.AppendMessages(newInfoItem)
896− if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
897− cmds = append(cmds, cmd)
898− }
899897 }
900898 }
901899
@@ -922,9 +920,12 @@ func (m *UI) updateSessionMessage(msg message.Message) tea.Cmd {
922920 }
923921 }
924922 }
923+
925924 m.chat.AppendMessages(items...)
926− if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
927− cmds = append(cmds, cmd)
925+ if atBottom {
926+ if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
927+ cmds = append(cmds, cmd)
928+ }
928929 }
929930
930931 return tea.Batch(cmds...)
@@ -934,6 +935,7 @@ func (m *UI) updateSessionMessage(msg message.Message) tea.Cmd {
934935func (m *UI) handleChildSessionMessage(event pubsub.Event[message.Message]) tea.Cmd {
935936 var cmds []tea.Cmd
936937
938+ atBottom := m.chat.list.AtBottom()
937939 // Only process messages with tool calls or results.
938940 if len(event.Payload.ToolCalls()) == 0 && len(event.Payload.ToolResults()) == 0 {
939941 return nil
@@ -1013,6 +1015,12 @@ func (m *UI) handleChildSessionMessage(event pubsub.Event[message.Message]) tea.
10131015 // Update the chat so it updates the index map for animations to work as expected
10141016 m.chat.UpdateNestedToolIDs(toolCallID)
10151017
1018+ if atBottom {
1019+ if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
1020+ cmds = append(cmds, cmd)
1021+ }
1022+ }
1023+
10161024 return tea.Batch(cmds...)
10171025}
10181026
@@ -2905,7 +2913,7 @@ func (m *UI) runMCPPrompt(clientID, promptID string, arguments map[string]string
29052913}
29062914
29072915func (m *UI) copyChatHighlight() tea.Cmd {
2908− text := m.chat.HighlighContent()
2916+ text := m.chat.HighlightContent()
29092917 return tea.Sequence(
29102918 tea.SetClipboard(text),
29112919 func() tea.Msg {