From 15d09e21ca38752658efab27cf66a07917fa85cd Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Tue, 28 Jul 2026 23:10:33 +0200 Subject: [PATCH] fix: keep the selected model in sync when regenerating a response Switching the model in the dropdown and regenerating a response left the chat's stored model list pointing at the model that was used when the user message was first sent. Leaving the chat and coming back restored that stale entry, so the dropdown kept snapping back to the original model (and could even show a model that is no longer used by any response in the chat, or one that no longer exists). The chat's model list is persisted from the user message's `models` field, which is written when the message is created and was never refreshed afterwards. Regeneration is the one send path that reuses an existing user message, so it now refreshes that field from the current selection. Side-by-side turns are left untouched: those regenerate the clicked column and keep their full model list, which is also what the column grouping in MultiResponseMessages relies on. Fixes #25052 --- src/lib/components/chat/Chat.svelte | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 686613cca9..7a33c5163b 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -3554,6 +3554,12 @@ scrollToBottom(); } + // Single-model turns follow the current selection; side-by-side turns regenerate the clicked column. + const isSideBySideTurn = (userMessage.models ?? selectedModels).length > 1; + if (!isSideBySideTurn) { + userMessage.models = selectedModels; + } + await sendMessage(history, userMessage.id, { ...(suggestionPrompt ? { @@ -3561,9 +3567,8 @@ regenerationPrompt: suggestionPrompt } : {}), - ...((userMessage?.models ?? [...selectedModels]).length > 1 + ...(isSideBySideTurn ? { - // If multiple models are selected, use the model from the message modelId: message.model, modelIdx: message.modelIdx }