@@ -994,6 +994,9 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
994994 m.bangCancel = nil
995995 }
996996 // Complete the pending shell item if it exists, otherwise create a new one.
997+ // During session creation the pending item lives in m.pendingShellItem
998+ // rather than the chat list, so check both locations.
999+ completed := false
9971000 if msg.PendingID != "" {
9981001 if item := m.chat.MessageItem(msg.PendingID); item != nil {
9991002 if shellItem, ok := item.(*chat.ShellItem); ok {
@@ -1001,14 +1004,29 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
10011004 if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
10021005 cmds = append(cmds, cmd)
10031006 }
1004− break
1007+ completed = true
1008+ }
1009+ }
1010+ if !completed && m.pendingShellItem != nil && m.pendingShellItem.ID() == msg.PendingID {
1011+ m.pendingShellItem.Complete(msg.Output, msg.ExitCode)
1012+ // The item is still stashed; it will be appended when the
1013+ // session load handler fires. Append it now so the result
1014+ // is visible immediately and clear the stash to prevent
1015+ // a duplicate append later.
1016+ m.chat.AppendMessages(m.pendingShellItem)
1017+ if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
1018+ cmds = append(cmds, cmd)
10051019 }
1020+ m.pendingShellItem = nil
1021+ completed = true
10061022 }
10071023 }
1008− item := chat.NewShellItem(m.com.Styles, msg.Command, msg.Output, msg.ExitCode)
1009− m.chat.AppendMessages(item)
1010− if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
1011− cmds = append(cmds, cmd)
1024+ if !completed {
1025+ item := chat.NewShellItem(m.com.Styles, msg.Command, msg.Output, msg.ExitCode)
1026+ m.chat.AppendMessages(item)
1027+ if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
1028+ cmds = append(cmds, cmd)
1029+ }
10121030 }
10131031 case hyperRefreshDoneMsg:
10141032 if cmd := m.handleSelectModel(msg.action); cmd != nil {