From 3c5e7968f0b5130890e17f1f2a2a52297cb145a6 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Tue, 19 May 2026 21:48:44 +0400 Subject: [PATCH] refac --- src/lib/components/layout/Sidebar/ChatItem.svelte | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib/components/layout/Sidebar/ChatItem.svelte b/src/lib/components/layout/Sidebar/ChatItem.svelte index 29c483ec47..7900ca8067 100644 --- a/src/lib/components/layout/Sidebar/ChatItem.svelte +++ b/src/lib/components/layout/Sidebar/ChatItem.svelte @@ -340,9 +340,7 @@ const generateTitleHandler = async () => { generating = true; - if (!chat) { - chat = await getChatById(localStorage.token, id); - } + chat = await getChatById(localStorage.token, id); const chatContent = chat.chat; @@ -367,7 +365,13 @@ // active branch. This avoids using the stale top-level `models` // array which may reference a model from an older edit. let model = ''; - if (history?.messages && history?.currentId) { + + // For the active chat, prefer the live dropdown selection. + if (id === $chatId) { + try { model = JSON.parse(sessionStorage.selectedModels || '[]').find((m) => m) ?? ''; } catch {} + } + + if (!model && history?.messages && history?.currentId) { let currentId = history.currentId; while (currentId) { const msg = history.messages[currentId];