fix(ui): resolve workspace model ID to base model on delete from model selector (#26819)

This commit is contained in:
G30 authored and GitHub committed 2026-07-24 00:03:31 -05:00
1 parent a35b37adcd
commit e212e3c7f4
1 file changed
+19 -5
@@ -13,6 +13,7 @@
import { createEventDispatcher, onMount, getContext, tick } from 'svelte'; import { createEventDispatcher, onMount, getContext, tick } from 'svelte';
import { deleteModel, getOllamaVersion, pullModel } from '$lib/apis/ollama'; import { deleteModel, getOllamaVersion, pullModel } from '$lib/apis/ollama';
import { deleteModelById } from '$lib/apis/models';
import { unloadModel } from '$lib/apis'; import { unloadModel } from '$lib/apis';
import { import {
@@ -629,12 +630,25 @@
const model = deleteModelTarget; const model = deleteModelTarget;
if (!model) return; if (!model) return;
const res = await deleteModel(localStorage.token, model.id).catch((error) => { let success = false;
toast.error($i18n.t('Error deleting model: {{error}}', { error }));
});
if (res) { if (model?.info?.base_model_id) {
// $i18n.t('Model {{modelId}} not found') // Workspace model: only delete the workspace model record, not the underlying base model
const res = await deleteModelById(localStorage.token, model.id).catch((error) => {
toast.error($i18n.t('Error deleting model: {{error}}', { error }));
return null;
});
success = !!res;
} else {
// Base Ollama model: delete from Ollama directly
const res = await deleteModel(localStorage.token, model.id).catch((error) => {
toast.error($i18n.t('Error deleting model: {{error}}', { error }));
return null;
});
success = !!res;
}
if (success) {
toast.success( toast.success(
$i18n.t('Model {{modelName}} deleted successfully', { modelName: model.name ?? model.id }) $i18n.t('Model {{modelName}} deleted successfully', { modelName: model.name ?? model.id })
); );