File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,11 @@ func (m *messagesComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
171
171
m .showThinkingBlocks = ! m .showThinkingBlocks
172
172
m .app .State .ShowThinkingBlocks = & m .showThinkingBlocks
173
173
return m , tea .Batch (m .renderView (), m .app .SaveState ())
174
- case app.SessionLoadedMsg , app.SessionClearedMsg :
174
+ case app.SessionLoadedMsg :
175
+ m .tail = true
176
+ m .loading = true
177
+ return m , m .renderView ()
178
+ case app.SessionClearedMsg :
175
179
m .cache .Clear ()
176
180
m .tail = true
177
181
m .loading = true
@@ -183,6 +187,21 @@ func (m *messagesComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
183
187
return m , m .renderView ()
184
188
}
185
189
case app.SessionSelectedMsg :
190
+ currentParent := m .app .Session .ParentID
191
+ if currentParent == "" {
192
+ currentParent = m .app .Session .ID
193
+ }
194
+
195
+ targetParent := msg .ParentID
196
+ if targetParent == "" {
197
+ targetParent = msg .ID
198
+ }
199
+
200
+ // Clear cache only if switching between different session families
201
+ if currentParent != targetParent {
202
+ m .cache .Clear ()
203
+ }
204
+
186
205
m .viewport .GotoBottom ()
187
206
case app.MessageRevertedMsg :
188
207
if msg .Session .ID == m .app .Session .ID {
Original file line number Diff line number Diff line change @@ -621,14 +621,19 @@ func (a Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
621
621
},
622
622
}
623
623
case app.SessionSelectedMsg :
624
+ updated , cmd := a .messages .Update (msg )
625
+ a .messages = updated .(chat.MessagesComponent )
626
+ cmds = append (cmds , cmd )
627
+
624
628
messages , err := a .app .ListMessages (context .Background (), msg .ID )
625
629
if err != nil {
626
630
slog .Error ("Failed to list messages" , "error" , err .Error ())
627
631
return a , toast .NewErrorToast ("Failed to open session" )
628
632
}
629
633
a .app .Session = msg
630
634
a .app .Messages = messages
631
- return a , util .CmdHandler (app.SessionLoadedMsg {})
635
+ cmds = append (cmds , util .CmdHandler (app.SessionLoadedMsg {}))
636
+ return a , tea .Batch (cmds ... )
632
637
case app.SessionCreatedMsg :
633
638
a .app .Session = msg .Session
634
639
case dialog.ScrollToMessageMsg :
You can’t perform that action at this time.
0 commit comments