From 347aceaf504f7efd0245390b9a66446ace5febff Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 23 Nov 2026 15:09:54 +0100 Subject: [PATCH] fix: generated titles of router model chats come from a model the router did not pick (#34900) Generate in a router model chat's title editor or in its sidebar rename asked the router again, which matched its rules against the built-in title instructions instead of the conversation, so the title could come from a model unrelated to the chat and each click could cost a Decisions API call. It now comes from the model the router picked for the latest reply, as in a direct chat with that model. The automatic title, tags and follow-ups after a reply are fixed in #34895. Refs #34887 --- src/lib/components/chat/Chat.svelte | 9 +++++++-- src/lib/components/layout/Sidebar/ChatItem.svelte | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 5cc01ed267..84574cb9bd 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -4552,13 +4552,18 @@ const id = $chatId; generatingTitle = true; titleDraft = ''; - const messages = createMessagesList(history, history.currentId).map((message) => ({ + const branch = createMessagesList(history, history.currentId); + const messages = branch.map((message) => ({ role: message.role, content: getOutputText(message.output) || message.content || '' })); + const modelId = selectedModels.find((modelId: string) => modelId) ?? ''; + const responseMessage = branch + .filter((message) => message.role === 'assistant' && message.model === modelId) + .at(-1); const generatedTitle = await generateTitle( localStorage.token, - selectedModels.find((modelId: string) => modelId) ?? '', + responseMessage?.selectedModelId ?? modelId, messages ).catch((error) => { toast.error(`${error}`); diff --git a/src/lib/components/layout/Sidebar/ChatItem.svelte b/src/lib/components/layout/Sidebar/ChatItem.svelte index e6af32bc98..99a9f5914f 100644 --- a/src/lib/components/layout/Sidebar/ChatItem.svelte +++ b/src/lib/components/layout/Sidebar/ChatItem.svelte @@ -567,13 +567,13 @@ } catch {} } - if (!model && history?.messages && history?.currentId) { + if (history?.messages && history?.currentId) { let currentId = history.currentId; while (currentId) { const msg = history.messages[currentId]; if (!msg) break; - if (msg.role === 'assistant' && msg.model) { - model = msg.model; + if (msg.role === 'assistant' && msg.model && (!model || msg.model === model)) { + model = msg.selectedModelId ?? msg.model; break; } currentId = msg.parentId;