From b969a86d38e1e3f7baf49345c597d8416c9c9806 Mon Sep 17 00:00:00 2001 From: zipg Date: Wed, 16 Sep 2026 23:22:42 +0800 Subject: [PATCH] fix(ai): isolate provider test results between edits --- .../src/components/editor/EditorSettingsDialog.vue | 3 +++ .../EditorSettingsDialog.aiTestIsolation.spec.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 apps/desktop/src/components/editor/__tests__/EditorSettingsDialog.aiTestIsolation.spec.ts diff --git a/apps/desktop/src/components/editor/EditorSettingsDialog.vue b/apps/desktop/src/components/editor/EditorSettingsDialog.vue index 95d41c5f8c..6dcb7bbd01 100644 --- a/apps/desktop/src/components/editor/EditorSettingsDialog.vue +++ b/apps/desktop/src/components/editor/EditorSettingsDialog.vue @@ -4677,6 +4677,8 @@ function aiSelectProvider(presetId: string) { if (isWeb && CLI_AI_PROVIDERS.has(provider)) return; if (presetId === aiEditProviderPresetId.value) return; + syncAiEditState(); + // Apply new provider's preset defaults to edit state aiEditProviderPresetId.value = presetId; aiEditProvider.value = provider; @@ -4706,6 +4708,7 @@ function aiEnterListMode() { } function aiEnterEditMode(configId?: string) { + syncAiEditState(); aiConfigListMode.value = "edit"; aiEditConfigId.value = configId || null; diff --git a/apps/desktop/src/components/editor/__tests__/EditorSettingsDialog.aiTestIsolation.spec.ts b/apps/desktop/src/components/editor/__tests__/EditorSettingsDialog.aiTestIsolation.spec.ts new file mode 100644 index 0000000000..1afcd9592a --- /dev/null +++ b/apps/desktop/src/components/editor/__tests__/EditorSettingsDialog.aiTestIsolation.spec.ts @@ -0,0 +1,14 @@ +import { describe, expect, it } from "vitest"; +import { readFileSync } from "node:fs"; + +const dialogSource = readFileSync(new URL("../EditorSettingsDialog.vue", import.meta.url), "utf8"); + +describe("EditorSettingsDialog AI test result isolation", () => { + it("clears the previous test result when opening another configuration", () => { + expect(dialogSource).toMatch(/function aiEnterEditMode\(configId\?: string\) \{\s*syncAiEditState\(\);/); + }); + + it("clears the previous test result when changing provider in the editor", () => { + expect(dialogSource).toMatch(/if \(presetId === aiEditProviderPresetId\.value\) return;\s*\n\s*syncAiEditState\(\);/); + }); +});