From 9c90105b6cfede0f3327169718300c649bb0531a Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Fri, 19 Jun 2026 15:31:57 +0900 Subject: fix: silence state_referenced_locally warning + sync draft model on catalog fetch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use DEFAULT_MODEL directly when creating the initial draft store instead of reading the $state activeModel in a non-reactive context (init-time read only captures the initial value — semantically identical since activeModel === DEFAULT_MODEL at that point, but silences the Svelte state_referenced_locally warning). - Sync the draft store's model when the model catalog fetch corrects activeModel (default not in catalog). Without this, chat.send would use the stale DEFAULT_MODEL while the UI showed the corrected model. --- src/app/store.svelte.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/store.svelte.ts b/src/app/store.svelte.ts index 05577a6..e8bb5e1 100644 --- a/src/app/store.svelte.ts +++ b/src/app/store.svelte.ts @@ -231,7 +231,7 @@ export function createAppStore(opts?: CreateAppStoreOptions): AppStore { } const initialDraftId = randomId(); - let draftStore: ChatStore = createChatFor(initialDraftId, activeModel); + let draftStore: ChatStore = createChatFor(initialDraftId, DEFAULT_MODEL); let draftConversationId: string = initialDraftId; let activeChat = $state(draftStore as ChatStore); @@ -446,6 +446,7 @@ export function createAppStore(opts?: CreateAppStoreOptions): AppStore { const first = data.models[0]; if (first !== undefined) { activeModel = first; + draftStore.setModel(first); } } }) -- cgit v1.2.3