@@ -556,6 +556,11 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
556 case tea.WindowSizeMsg:
556 case tea.WindowSizeMsg:
557 m.width, m.height = msg.Width, msg.Height
557 m.width, m.height = msg.Width, msg.Height
558 m.updateLayoutAndSize()
558 m.updateLayoutAndSize()
559+ if m.state == uiChat && m.chat.Follow() {
560+ if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
561+ cmds = append(cmds, cmd)
559 case tea.KeyboardEnhancementsMsg:
564 case tea.KeyboardEnhancementsMsg:
560 m.keyenh = msg
565 m.keyenh = msg
561 if msg.SupportsKeyDisambiguation() {
566 if msg.SupportsKeyDisambiguation() {
@@ -680,7 +685,11 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
680 cmds = append(cmds, cmd)
685 cmds = append(cmds, cmd)
682 if !m.chat.SelectedItemInView() {
687 if !m.chat.SelectedItemInView() {
688+ if m.chat.AtBottom() {
683− m.chat.SelectNext()
691+ m.chat.SelectNext()
684 if cmd := m.chat.ScrollToSelectedAndAnimate(); cmd != nil {
693 if cmd := m.chat.ScrollToSelectedAndAnimate(); cmd != nil {
685 cmds = append(cmds, cmd)
694 cmds = append(cmds, cmd)
@@ -692,6 +701,11 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
692 if cmd := m.chat.Animate(msg); cmd != nil {
701 if cmd := m.chat.Animate(msg); cmd != nil {
693 cmds = append(cmds, cmd)
702 cmds = append(cmds, cmd)
704+ if m.chat.Follow() {
705+ if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
706+ cmds = append(cmds, cmd)
696 case spinner.TickMsg:
710 case spinner.TickMsg:
697 if m.dialog.HasDialogs() {
711 if m.dialog.HasDialogs() {
@@ -822,7 +836,7 @@ func (m *UI) setSessionMessages(msgs []message.Message) tea.Cmd {
822 cmds = append(cmds, cmd)
836 cmds = append(cmds, cmd)
824 m.chat.SelectLast()
838 m.chat.SelectLast()
825− return tea.Batch(cmds...)
839+ return tea.Sequence(cmds...)
828// loadNestedToolCalls recursively loads nested tool calls for agent/agentic_fetch tools.
842// loadNestedToolCalls recursively loads nested tool calls for agent/agentic_fetch tools.
@@ -950,7 +964,7 @@ func (m *UI) appendSessionMessage(msg message.Message) tea.Cmd {
953− return tea.Batch(cmds...)
967+ return tea.Sequence(cmds...)
956func (m *UI) handleClickFocus(msg tea.MouseClickMsg) (cmd tea.Cmd) {
970func (m *UI) handleClickFocus(msg tea.MouseClickMsg) (cmd tea.Cmd) {
@@ -1029,16 +1043,16 @@ func (m *UI) updateSessionMessage(msg message.Message) tea.Cmd {
1029 if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
1043 if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
1030 cmds = append(cmds, cmd)
1044 cmds = append(cmds, cmd)
1046+ m.chat.SelectLast()
1034− return tea.Batch(cmds...)
1049+ return tea.Sequence(cmds...)
1037// handleChildSessionMessage handles messages from child sessions (agent tools).
1052// handleChildSessionMessage handles messages from child sessions (agent tools).
1038func (m *UI) handleChildSessionMessage(event pubsub.Event[message.Message]) tea.Cmd {
1053func (m *UI) handleChildSessionMessage(event pubsub.Event[message.Message]) tea.Cmd {
1039 var cmds []tea.Cmd
1054 var cmds []tea.Cmd
1041− atBottom := m.chat.AtBottom()
1042 // Only process messages with tool calls or results.
1056 // Only process messages with tool calls or results.
1043 if len(event.Payload.ToolCalls()) == 0 && len(event.Payload.ToolResults()) == 0 {
1057 if len(event.Payload.ToolCalls()) == 0 && len(event.Payload.ToolResults()) == 0 {
1044 return nil
1058 return nil
@@ -1118,13 +1132,14 @@ func (m *UI) handleChildSessionMessage(event pubsub.Event[message.Message]) tea.
1118 // Update the chat so it updates the index map for animations to work as expected
1132 // Update the chat so it updates the index map for animations to work as expected
1119 m.chat.UpdateNestedToolIDs(toolCallID)
1133 m.chat.UpdateNestedToolIDs(toolCallID)
1121− if atBottom {
1135+ if m.chat.Follow() {
1122 if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
1136 if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
1123 cmds = append(cmds, cmd)
1137 cmds = append(cmds, cmd)
1139+ m.chat.SelectLast()
1127− return tea.Batch(cmds...)
1142+ return tea.Sequence(cmds...)
1130func (m *UI) handleDialogMsg(msg tea.Msg) tea.Cmd {
1145func (m *UI) handleDialogMsg(msg tea.Msg) tea.Cmd {
@@ -1804,7 +1819,7 @@ func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
1804 handleGlobalKeys(msg)
1819 handleGlobalKeys(msg)
1807− return tea.Batch(cmds...)
1822+ return tea.Sequence(cmds...)
1810// drawHeader draws the header section of the UI.
1825// drawHeader draws the header section of the UI.