ui : stop the conversation model from switching backends

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash
This commit is contained in:
Aleksander Grygier
2026-09-16 20:13:29 +02:00
parent aa2cbf033a
commit 48e50e12ed
2 changed files with 19 additions and 3 deletions
@@ -1,7 +1,13 @@
<script lang="ts">
import { ModelsSelectorDropdown, ModelsSelectorSheet } from '$lib/components/app';
import { useBackendAvailability } from '$lib/hooks/use-backend-availability.svelte';
import { conversationsStore, deviceStore, modelsStore, serverStore } from '$lib/stores';
import {
backendsStore,
conversationsStore,
deviceStore,
modelsStore,
serverStore
} from '$lib/stores';
import { getConversationModel } from '$lib/utils';
interface Props {
@@ -54,10 +60,16 @@
$effect(() => {
if (conversationModel && conversationModel !== lastSyncedConversationModel) {
if (modelsStore.models.some((m) => m.model === conversationModel)) {
const option = modelsStore.models.find((m) => m.model === conversationModel);
// only sync models served by the active backend; a model from another
// backend must not yank the active tab (and trigger a full backend
// switch) just because the conversation used it. sends resolve their
// backend explicitly via ensureModelBackend
if (option && option.backendId === backendsStore.active.id) {
modelsStore.selectedModelName = conversationModel;
modelsStore.selectModelByName(conversationModel);
} else {
} else if (!option) {
modelsStore.selectedModelName = null;
modelsStore.clearSelection();
}
@@ -164,6 +164,10 @@ export class ModelPropsManager {
// /props only exists on llama.cpp servers
if (!serverStore.capabilities.props) return null;
// props not loaded yet (mid backend switch): the server role and model
// load state are not trustworthy, so do not guess
if (!serverStore.props) return null;
const cached = this.cache.get(modelId);
if (cached) return cached;