app/ui: fix model picker showing stale model after switching chats (#15280)

* app/ui: fix model picker showing stale model after switching chats

Optimistic messages created during streaming were storing the full
Model object instead of the model name string. When switching back
to a chat with cached streaming data, the restore effect read an
object where it expected a string, causing the model picker to fail
matching and remain stuck on the previous chat's model.

* app/ui: fix two more instances of Model object passed as model name

Fix the same bug at lines 523 and 536 in the assistant_with_tools
event handler, where selectedModel (object) was used instead of
selectedModel.model (string).
This commit is contained in:
Matteo Celani 2026-04-21 21:08:06 +02:00 committed by GitHub
parent 0c65ed33bc
commit fb36a01ffe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -381,7 +381,7 @@ export const useSendMessage = (chatId: string) => {
role: "assistant", role: "assistant",
content: "", content: "",
thinking: "", thinking: "",
model: effectiveModel, model: effectiveModel.model,
}), }),
); );
lastMessage = newMessages[newMessages.length - 1]; lastMessage = newMessages[newMessages.length - 1];
@ -433,7 +433,7 @@ export const useSendMessage = (chatId: string) => {
role: "assistant", role: "assistant",
content: "", content: "",
thinking: "", thinking: "",
model: effectiveModel, model: effectiveModel.model,
}), }),
); );
lastMessage = newMessages[newMessages.length - 1]; lastMessage = newMessages[newMessages.length - 1];
@ -520,7 +520,7 @@ export const useSendMessage = (chatId: string) => {
thinkingTimeStart: thinkingTimeStart:
lastMessage.thinkingTimeStart || event.thinkingTimeStart, lastMessage.thinkingTimeStart || event.thinkingTimeStart,
thinkingTimeEnd: event.thinkingTimeEnd, thinkingTimeEnd: event.thinkingTimeEnd,
model: selectedModel, model: selectedModel.model,
}); });
newMessages[newMessages.length - 1] = updatedMessage; newMessages[newMessages.length - 1] = updatedMessage;
} else { } else {
@ -533,7 +533,7 @@ export const useSendMessage = (chatId: string) => {
tool_calls: event.toolCalls, tool_calls: event.toolCalls,
thinkingTimeStart: event.thinkingTimeStart, thinkingTimeStart: event.thinkingTimeStart,
thinkingTimeEnd: event.thinkingTimeEnd, thinkingTimeEnd: event.thinkingTimeEnd,
model: selectedModel, model: selectedModel.model,
}), }),
); );
} }
@ -699,7 +699,7 @@ export const useSendMessage = (chatId: string) => {
queryClient.setQueryData(["chat", newId], { queryClient.setQueryData(["chat", newId], {
chat: new Chat({ chat: new Chat({
id: newId, id: newId,
model: effectiveModel, model: effectiveModel.model,
messages: [ messages: [
new Message({ new Message({
role: "user", role: "user",