File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed
Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change 3131
3232function M .switch_session (session_id )
3333 local selected_session = session .get_by_id (session_id )
34- -- clear the model so it can be set by the session. If it doesn't get set
35- -- then core.get_model() will reset it to the default
34+
3635 state .current_model = nil
36+ state .current_mode = nil
37+ M .ensure_current_mode ()
38+
3739 state .active_session = selected_session
3840 if state .windows then
3941 state .restore_points = {}
@@ -73,8 +75,11 @@ function M.open(opts)
7375 if opts .new_session then
7476 state .active_session = nil
7577 state .last_sent_context = nil
76- -- clear current_model here so it can be reset to the default (if one is set)
78+
7779 state .current_model = nil
80+ state .current_mode = nil
81+ M .ensure_current_mode ()
82+
7883 state .active_session = M .create_new_session ()
7984 else
8085 if not state .active_session then
Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ function M._render_full_session_data(session_data)
177177 end
178178
179179 if set_mode_from_messages then
180- M ._set_model_from_messages ()
180+ M ._set_model_and_mode_from_messages ()
181181 end
182182 M .scroll_to_bottom ()
183183
@@ -213,17 +213,22 @@ function M.on_emit_events_finished()
213213end
214214
215215--- Find the most recently used model from the messages
216- function M ._set_model_from_messages ()
216+ function M ._set_model_and_mode_from_messages ()
217217 if not state .messages then
218218 return
219219 end
220220
221221 for i = # state .messages , 1 , - 1 do
222222 local message = state .messages [i ]
223223
224- if message and message .info and message .info .modelID and message .info .providerID then
225- state .current_model = message .info .providerID .. ' /' .. message .info .modelID
226- return
224+ if message and message .info then
225+ if message .info .modelID and message .info .providerID then
226+ state .current_model = message .info .providerID .. ' /' .. message .info .modelID
227+ if message .info .mode then
228+ state .current_mode = message .info .mode
229+ end
230+ return
231+ end
227232 end
228233 end
229234
You can’t perform that action at this time.
0 commit comments