fix: Model Selector choice sync (#21628)

This commit is contained in:
Aleksander Grygier 2026-04-09 09:46:27 +02:00 committed by GitHub
parent 3ee9da0e4f
commit 9949ad08f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 61 additions and 52 deletions

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,7 @@
<div style="display: contents"> <div style="display: contents">
<script> <script>
{ {
__sveltekit_nl4lme = { __sveltekit_6n4hpv = {
base: new URL('.', location).pathname.slice(0, -1) base: new URL('.', location).pathname.slice(0, -1)
}; };

View File

@ -62,10 +62,14 @@
chatStore.getConversationModel(activeMessages() as DatabaseMessage[]) chatStore.getConversationModel(activeMessages() as DatabaseMessage[])
); );
let lastSyncedConversationModel: string | null = null;
$effect(() => { $effect(() => {
if (conversationModel) { if (conversationModel && conversationModel !== lastSyncedConversationModel) {
lastSyncedConversationModel = conversationModel;
modelsStore.selectModelByName(conversationModel); modelsStore.selectModelByName(conversationModel);
} else if (isRouter && !modelsStore.selectedModelId && modelsStore.loadedModelIds.length > 0) { } else if (isRouter && !modelsStore.selectedModelId && modelsStore.loadedModelIds.length > 0) {
lastSyncedConversationModel = null;
// auto-select the first loaded model only when nothing is selected yet // auto-select the first loaded model only when nothing is selected yet
const first = modelOptions().find((m) => modelsStore.loadedModelIds.includes(m.model)); const first = modelOptions().find((m) => modelsStore.loadedModelIds.includes(m.model));
if (first) modelsStore.selectModelById(first.id); if (first) modelsStore.selectModelById(first.id);

View File

@ -77,6 +77,11 @@
!modelsStore.isModelLoaded(modelsStore.selectedModelName) !modelsStore.isModelLoaded(modelsStore.selectedModelName)
) { ) {
modelsStore.clearSelection(); modelsStore.clearSelection();
const first = modelOptions().find((m) => modelsStore.loadedModelIds.includes(m.model));
if (first) {
await modelsStore.selectModelById(first.id);
}
} }
// Handle URL params only if we have ?q= or ?model= or ?new_chat=true // Handle URL params only if we have ?q= or ?model= or ?new_chat=true