feat(ai): support Kimi model configuration deletion
This commit is contained in:
8 files changed
+111
-10
No files matched your search
@@ -3907,12 +3907,6 @@ function aiDeleteConfig(id: string) {
|
||||
|
||||
async function aiConfirmDeleteConfig() {
|
||||
if (aiDeleteConfigId.value) {
|
||||
if (settingsStore.activeModel?.configId === aiDeleteConfigId.value) {
|
||||
toast(t("ai.cannotDeleteActiveConfig"), 5000);
|
||||
aiDeleteConfirmOpen.value = false;
|
||||
aiDeleteConfigId.value = null;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await settingsStore.deleteAiConfig(aiDeleteConfigId.value);
|
||||
} catch (e: any) {
|
||||
@@ -7089,7 +7083,7 @@ onUnmounted(() => {
|
||||
<Button type="button" size="sm" variant="ghost" @click="aiEnterEditMode(config.id)">
|
||||
{{ t("common.edit") }}
|
||||
</Button>
|
||||
<Button v-if="!config.isDefault" type="button" size="sm" variant="ghost" class="text-destructive" @click="aiDeleteConfig(config.id)">
|
||||
<Button type="button" size="sm" variant="ghost" class="text-destructive" @click="aiDeleteConfig(config.id)">
|
||||
{{ t("common.delete") }}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
+22
-1
@@ -16,6 +16,7 @@ describe("orderAiConfigsForDisplay", () => {
|
||||
{ id: "openai", provider: "openai" },
|
||||
{ id: "gemini", provider: "gemini" },
|
||||
{ id: "deepseek", provider: "deepseek" },
|
||||
{ id: "kimi", provider: "kimi" },
|
||||
{ id: "qwen", provider: "qwen" },
|
||||
{ id: "minimax", provider: "minimax" },
|
||||
{ id: "ollama", provider: "ollama" },
|
||||
@@ -30,7 +31,27 @@ describe("orderAiConfigsForDisplay", () => {
|
||||
{ id: "custom", provider: "custom" },
|
||||
];
|
||||
|
||||
expect(orderAiConfigsForDisplay(configs).map((config) => config.id)).toEqual(["claude", "openai", "gemini", "deepseek", "qwen", "minimax", "ollama", "anthropic-compatible", "openai-compatible", "claude-code-1", "codex", "opencode", "cursor", "codebuddy", "qoder", "grok", "pi", "custom"]);
|
||||
expect(orderAiConfigsForDisplay(configs).map((config) => config.id)).toEqual([
|
||||
"claude",
|
||||
"openai",
|
||||
"gemini",
|
||||
"deepseek",
|
||||
"kimi",
|
||||
"qwen",
|
||||
"minimax",
|
||||
"ollama",
|
||||
"anthropic-compatible",
|
||||
"openai-compatible",
|
||||
"claude-code-1",
|
||||
"codex",
|
||||
"opencode",
|
||||
"cursor",
|
||||
"codebuddy",
|
||||
"qoder",
|
||||
"grok",
|
||||
"pi",
|
||||
"custom",
|
||||
]);
|
||||
});
|
||||
|
||||
it("preserves creation order for configs from the same provider", () => {
|
||||
|
||||
+41
-1
@@ -1,7 +1,18 @@
|
||||
import { createPinia, setActivePinia } from "pinia";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { isProxy } from "vue";
|
||||
import { DEFAULT_EDITOR_SETTINGS, EXECUTE_MODE_CURRENT_DEFAULT_VERSION, enforceRightSidebarPanelExclusivity, normalizeAiConfig, normalizeDesktopSettings, normalizeEditorSettings, normalizeMcpGlobalPolicy, type RightSidebarPanelState, transitionRightSidebarPanels } from "@/stores/settingsStore";
|
||||
import {
|
||||
AI_PROVIDER_PRESETS,
|
||||
DEFAULT_EDITOR_SETTINGS,
|
||||
EXECUTE_MODE_CURRENT_DEFAULT_VERSION,
|
||||
enforceRightSidebarPanelExclusivity,
|
||||
normalizeAiConfig,
|
||||
normalizeDesktopSettings,
|
||||
normalizeEditorSettings,
|
||||
normalizeMcpGlobalPolicy,
|
||||
type RightSidebarPanelState,
|
||||
transitionRightSidebarPanels,
|
||||
} from "@/stores/settingsStore";
|
||||
import type { AiConfigItem } from "@/types/ai";
|
||||
|
||||
describe("normalizeEditorSettings", () => {
|
||||
@@ -608,6 +619,17 @@ describe("settingsStore AI API key normalization", () => {
|
||||
expect(normalizeAiConfig({ provider: "openai", apiKey: " secret " }).apiKey).toBe("secret");
|
||||
});
|
||||
|
||||
it("provides Kimi defaults and recognizes legacy Kimi configurations", () => {
|
||||
expect(AI_PROVIDER_PRESETS.kimi).toMatchObject({
|
||||
provider: "kimi",
|
||||
endpoint: "https://api.moonshot.cn/v1",
|
||||
apiStyle: "completions",
|
||||
authMethod: "bearer",
|
||||
requiresApiKey: true,
|
||||
});
|
||||
expect(normalizeAiConfig({ endpoint: "https://api.moonshot.cn/v1", model: "kimi-k2.5" }).provider).toBe("kimi");
|
||||
});
|
||||
|
||||
it("normalizes OpenCode CLI path and environment settings", () => {
|
||||
expect(
|
||||
normalizeAiConfig({
|
||||
@@ -1423,6 +1445,24 @@ describe("settingsStore activeModel lifecycle", () => {
|
||||
expect(store.activeEffort).toBeNull();
|
||||
});
|
||||
|
||||
it("deletes the active default config and clears the active selection when it was the last config", async () => {
|
||||
const deleteAiConfig = vi.fn().mockResolvedValue(undefined);
|
||||
const saveAiChatSelection = vi.fn().mockResolvedValue(undefined);
|
||||
vi.doMock("@/lib/backend/api", () => ({ deleteAiConfig, saveAiChatSelection }));
|
||||
|
||||
const { useSettingsStore } = await import("@/stores/settingsStore");
|
||||
const store = useSettingsStore();
|
||||
store.aiConfigs = [makeTestConfig({ id: "c1", model: "model-a", isDefault: true })];
|
||||
store.updateActiveModel({ configId: "c1", modelId: "model-a" });
|
||||
|
||||
await store.deleteAiConfig("c1");
|
||||
|
||||
expect(deleteAiConfig).toHaveBeenCalledWith("c1");
|
||||
expect(store.aiConfigs).toEqual([]);
|
||||
expect(store.activeModel).toBeNull();
|
||||
await vi.waitFor(() => expect(saveAiChatSelection).toHaveBeenCalledWith(expect.objectContaining({ active: undefined })));
|
||||
});
|
||||
|
||||
it("preserves the active model and effort when connection details change within the same provider", async () => {
|
||||
const saveAiConfigItem = vi.fn().mockResolvedValue(undefined);
|
||||
const saveAiChatSelection = vi.fn().mockResolvedValue(undefined);
|
||||
|
||||
@@ -224,6 +224,15 @@ export const AI_PROVIDER_PRESETS: Record<AiProvider, AiProviderPreset> = {
|
||||
authMethod: "bearer",
|
||||
requiresApiKey: true,
|
||||
},
|
||||
kimi: {
|
||||
label: "Kimi",
|
||||
provider: "kimi",
|
||||
endpoint: "https://api.moonshot.cn/v1",
|
||||
model: "",
|
||||
apiStyle: "completions",
|
||||
authMethod: "bearer",
|
||||
requiresApiKey: true,
|
||||
},
|
||||
qwen: {
|
||||
label: "Qwen",
|
||||
iconSlug: "alibabacloud",
|
||||
@@ -490,6 +499,7 @@ function inferAiProviderFromConfig(config: Partial<AiConfig> | null | undefined)
|
||||
const endpoint = config?.endpoint?.toLowerCase() ?? "";
|
||||
const model = config?.model?.toLowerCase() ?? "";
|
||||
if (endpoint.includes("deepseek") || model.includes("deepseek")) return "deepseek";
|
||||
if (endpoint.includes("moonshot") || endpoint.includes("kimi.com") || model.includes("kimi")) return "kimi";
|
||||
if (endpoint.includes("dashscope") || endpoint.includes("aliyuncs") || model.includes("qwen")) return "qwen";
|
||||
if (endpoint.includes("generativelanguage.googleapis.com") || model.includes("gemini")) return "gemini";
|
||||
if (endpoint.includes("minimax.io") || endpoint.includes("minimaxi.com") || model.includes("minimax")) return "minimax";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type AiProvider = "claude" | "openai" | "gemini" | "deepseek" | "qwen" | "minimax" | "ollama" | "anthropic-compatible" | "openai-compatible" | "claude-code-cli" | "pi-agent-cli" | "codex-cli" | "opencode-cli" | "cursor-cli" | "grok-cli" | "codebuddy-cli" | "qoder-cli" | "custom";
|
||||
export type AiProvider = "claude" | "openai" | "gemini" | "deepseek" | "kimi" | "qwen" | "minimax" | "ollama" | "anthropic-compatible" | "openai-compatible" | "claude-code-cli" | "pi-agent-cli" | "codex-cli" | "opencode-cli" | "cursor-cli" | "grok-cli" | "codebuddy-cli" | "qoder-cli" | "custom";
|
||||
export type AiApiStyle = "completions" | "responses" | "anthropic-messages";
|
||||
export type AiAuthMethod = "api-key" | "bearer";
|
||||
export type AiEffortLevel = "low" | "medium" | "high" | "xhigh" | "max";
|
||||
|
||||
Reference in new issue
Block a user