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\(\);/); + }); +});