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
This commit is contained in:
Classic298 authored and GitHub committed 2026-11-23 18:09:54 +04:00
1 parent bd150cdf66
commit 347aceaf50
2 files changed
+10 -5

No files matched your search

+7 -2
View File
@@ -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}`);
@@ -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;