feat(governance): delete a model or alias from /settings/models (#2090)

This commit is contained in:
sam committed 2026-11-22 02:03:24 +11:00
1 parent 48d0212784
commit 763cd0e581
5 files changed
+88 -1

No files matched your search

+2
View File
@@ -228,6 +228,8 @@ export const api = {
agentModels: () => request<Record<string, AgentModel>>("/api/settings/agent-models"),
putAgentModel: (alias: string, model: AgentModel) =>
request<AgentModel>("/api/settings/agent-model" + qs({ alias }), { method: "PUT", body: model }),
deleteAgentModel: (alias: string) =>
request<void>("/api/settings/agent-model" + qs({ alias }), { method: "DELETE", parse: false }),
testAgentModel: (model: AgentModel) =>
request<{ answer: string; model: string }>("/api/settings/agent-model/test", { method: "POST", body: model, timeoutMs: 60_000 }),
policyText: (kind: PolicyKind, version?: number) =>
+31 -1
View File
@@ -5,6 +5,7 @@ import { computed, onMounted, ref } from "vue";
import PageHeader from "@/base/PageHeader.vue";
import { Button } from "@/components/ui/button";
import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog";
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
@@ -91,6 +92,20 @@ async function save(): Promise<void> {
busy.value = false;
}
}
const pending = ref<Row | null>(null);
const removeError = ref("");
async function remove(row: Row): Promise<void> {
busy.value = true;
removeError.value = "";
try {
await api.deleteAgentModel(row.alias === "default" ? "" : row.alias);
await reload();
} catch (cause) {
removeError.value = describeError(cause, errors.common.unknown);
} finally {
busy.value = false;
}
}
</script>
<template>
@@ -107,11 +122,26 @@ async function save(): Promise<void> {
<template #cell-base="{ row }"><span class="font-mono text-caption">{{ row.base_url }}</span></template>
<template #cell-key="{ row }">{{ row.api_key_credential }}</template>
<template #actions="{ row }">
<MoreMenu :label="`${row.alias} actions`"><DropdownMenuItem @select="open(row)">Edit</DropdownMenuItem></MoreMenu>
<MoreMenu :label="`${row.alias} actions`"><DropdownMenuItem @select="open(row)">Edit</DropdownMenuItem><DropdownMenuItem class="text-danger" @select="pending = row">Delete</DropdownMenuItem></MoreMenu>
</template>
<template #empty><Empty><EmptyHeader><EmptyTitle>No models</EmptyTitle></EmptyHeader></Empty></template>
</DataTable>
<p v-if="removeError" role="alert" class="pt-2 text-caption text-danger">{{ removeError }}</p>
<AlertDialog :open="pending !== null" @update:open="(v: boolean) => { if (!v) pending = null; }">
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete model?</AlertDialogTitle>
<AlertDialogDescription>Delete the alias "{{ pending?.alias }}"? Workflows that name it will fail.</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction @click="if (pending) { const row = pending; pending = null; void remove(row); }">Delete model</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
<Dialog v-model:open="editing">
<DialogContent class="sm:max-w-2xl">
<DialogHeader><DialogTitle>{{ isNew ? "Add model" : `Edit ${form.alias}` }}</DialogTitle></DialogHeader>