diff --git a/webview-ui/src/components/settings/SettingsView.tsx b/webview-ui/src/components/settings/SettingsView.tsx index f86c86e0ec..0ef75c6d9c 100644 --- a/webview-ui/src/components/settings/SettingsView.tsx +++ b/webview-ui/src/components/settings/SettingsView.tsx @@ -59,6 +59,7 @@ import { StandardTooltip, } from "@src/components/ui" +import { Checkbox } from "vscrui" import { Tab, TabContent, TabHeader, TabList, TabTrigger } from "../common/Tab" import { SetCachedStateField, SetExperimentEnabled } from "./types" import { SectionHeader } from "./SectionHeader" @@ -201,6 +202,7 @@ const SettingsView = forwardRef(({ onDone, t includeCurrentTime, includeCurrentCost, maxGitStatusFiles, + lockApiConfigAcrossModes, } = cachedState const apiConfiguration = useMemo(() => cachedState.apiConfiguration ?? {}, [cachedState.apiConfiguration]) @@ -416,6 +418,7 @@ const SettingsView = forwardRef(({ onDone, t // by the `updateSettings` message. vscode.postMessage({ type: "upsertApiConfiguration", text: currentApiConfigName, apiConfiguration }) vscode.postMessage({ type: "debugSetting", bool: cachedState.debug }) + vscode.postMessage({ type: "lockApiConfigAcrossModes", bool: !!lockApiConfigAcrossModes }) setChangeDetected(false) } @@ -752,6 +755,19 @@ const SettingsView = forwardRef(({ onDone, t }) } /> +
+ + setCachedStateField("lockApiConfigAcrossModes", checked) + } + data-testid="lock-api-config-checkbox"> + {t("settings:providers.lockApiConfigAcrossModes")} + +
+ {t("settings:providers.lockApiConfigAcrossModesDescription")} +
+
({ vscode: { postMessage: vi.fn() } })) +vi.mock("vscrui", () => ({ + Checkbox: ({ children, checked, onChange, "data-testid": dataTestId }: any) => ( + + ), +})) + vi.mock("../ApiConfigManager", () => ({ __esModule: true, default: ({ currentApiConfigName }: any) => ( @@ -714,3 +728,39 @@ describe("SettingsView - Duplicate Commands", () => { ) }) }) + +describe("SettingsView - Lock API Config Across Modes", () => { + beforeEach(() => { + vi.clearAllMocks() + }) + + it("renders lock API config checkbox unchecked by default on the providers tab", () => { + const { getSettingsContent } = renderSettingsView() + + const content = getSettingsContent() + const lockCheckbox = within(content).getByTestId("lock-api-config-checkbox") + expect(lockCheckbox).not.toBeChecked() + }) + + it("toggles lock API config and sends lockApiConfigAcrossModes message on save", () => { + const { getSettingsContent } = renderSettingsView() + + const content = getSettingsContent() + const lockCheckbox = within(content).getByTestId("lock-api-config-checkbox") + + // Enable the lock + fireEvent.click(lockCheckbox) + expect(lockCheckbox).toBeChecked() + + // Click Save + const saveButton = screen.getByTestId("save-button") + fireEvent.click(saveButton) + + expect(vscode.postMessage).toHaveBeenCalledWith( + expect.objectContaining({ + type: "lockApiConfigAcrossModes", + bool: true, + }), + ) + }) +}) diff --git a/webview-ui/src/i18n/locales/ca/settings.json b/webview-ui/src/i18n/locales/ca/settings.json index 787c169e75..0af9b213ab 100644 --- a/webview-ui/src/i18n/locales/ca/settings.json +++ b/webview-ui/src/i18n/locales/ca/settings.json @@ -283,6 +283,8 @@ "providerDocumentation": "Documentació de {{provider}}", "configProfile": "Perfil de configuració", "description": "Deseu diferents configuracions d'API per canviar ràpidament entre proveïdors i configuracions.", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "Proveïdor d'API", "apiProviderDocs": "Documentació del proveïdor", "model": "Model", diff --git a/webview-ui/src/i18n/locales/de/settings.json b/webview-ui/src/i18n/locales/de/settings.json index ea1c8f9d25..a92f19c48e 100644 --- a/webview-ui/src/i18n/locales/de/settings.json +++ b/webview-ui/src/i18n/locales/de/settings.json @@ -283,6 +283,8 @@ "providerDocumentation": "{{provider}}-Dokumentation", "configProfile": "Konfigurationsprofil", "description": "Speichern Sie verschiedene API-Konfigurationen, um schnell zwischen Anbietern und Einstellungen zu wechseln.", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "API-Anbieter", "apiProviderDocs": "Anbieter-Dokumentation", "model": "Modell", diff --git a/webview-ui/src/i18n/locales/en/settings.json b/webview-ui/src/i18n/locales/en/settings.json index 01b6cd3e91..59b15cbb10 100644 --- a/webview-ui/src/i18n/locales/en/settings.json +++ b/webview-ui/src/i18n/locales/en/settings.json @@ -345,6 +345,8 @@ "providerDocumentation": "{{provider}} documentation", "configProfile": "Configuration Profile", "description": "Save different API configurations to quickly switch between providers and settings.", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "API Provider", "apiProviderDocs": "Provider Docs", "model": "Model", diff --git a/webview-ui/src/i18n/locales/es/settings.json b/webview-ui/src/i18n/locales/es/settings.json index a3344361ec..d50122eff1 100644 --- a/webview-ui/src/i18n/locales/es/settings.json +++ b/webview-ui/src/i18n/locales/es/settings.json @@ -283,6 +283,8 @@ "providerDocumentation": "Documentación de {{provider}}", "configProfile": "Perfil de configuración", "description": "Guarde diferentes configuraciones de API para cambiar rápidamente entre proveedores y ajustes.", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "Proveedor de API", "apiProviderDocs": "Documentación del Proveedor", "model": "Modelo", diff --git a/webview-ui/src/i18n/locales/fr/settings.json b/webview-ui/src/i18n/locales/fr/settings.json index 027f8c0584..08402d5090 100644 --- a/webview-ui/src/i18n/locales/fr/settings.json +++ b/webview-ui/src/i18n/locales/fr/settings.json @@ -283,6 +283,8 @@ "providerDocumentation": "Documentation {{provider}}", "configProfile": "Profil de configuration", "description": "Enregistrez différentes configurations d'API pour basculer rapidement entre les fournisseurs et les paramètres.", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "Fournisseur d'API", "apiProviderDocs": "Documentation du Fournisseur", "model": "Modèle", diff --git a/webview-ui/src/i18n/locales/hi/settings.json b/webview-ui/src/i18n/locales/hi/settings.json index 4663b1d23d..adb4ddb1aa 100644 --- a/webview-ui/src/i18n/locales/hi/settings.json +++ b/webview-ui/src/i18n/locales/hi/settings.json @@ -283,6 +283,8 @@ "providerDocumentation": "{{provider}} दस्तावेज़ीकरण", "configProfile": "कॉन्फिगरेशन प्रोफाइल", "description": "विभिन्न API कॉन्फ़िगरेशन सहेजें ताकि प्रदाताओं और सेटिंग्स के बीच त्वरित रूप से स्विच कर सकें।", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "API प्रदाता", "apiProviderDocs": "प्रदाता डॉक्स", "model": "मॉडल", diff --git a/webview-ui/src/i18n/locales/id/settings.json b/webview-ui/src/i18n/locales/id/settings.json index 54fb50151e..4b0f49ee26 100644 --- a/webview-ui/src/i18n/locales/id/settings.json +++ b/webview-ui/src/i18n/locales/id/settings.json @@ -283,6 +283,8 @@ "providerDocumentation": "Dokumentasi {{provider}}", "configProfile": "Profil Konfigurasi", "description": "Simpan konfigurasi API yang berbeda untuk beralih dengan cepat antara provider dan pengaturan.", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "Provider API", "apiProviderDocs": "Dokumentasi Penyedia", "model": "Model", diff --git a/webview-ui/src/i18n/locales/it/settings.json b/webview-ui/src/i18n/locales/it/settings.json index 874729560d..ba0cec3ace 100644 --- a/webview-ui/src/i18n/locales/it/settings.json +++ b/webview-ui/src/i18n/locales/it/settings.json @@ -283,6 +283,8 @@ "providerDocumentation": "Documentazione {{provider}}", "configProfile": "Profilo di configurazione", "description": "Salva diverse configurazioni API per passare rapidamente tra fornitori e impostazioni.", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "Fornitore API", "apiProviderDocs": "Documentazione del Provider", "model": "Modello", diff --git a/webview-ui/src/i18n/locales/ja/settings.json b/webview-ui/src/i18n/locales/ja/settings.json index 4f2278a6ff..4c56907e8f 100644 --- a/webview-ui/src/i18n/locales/ja/settings.json +++ b/webview-ui/src/i18n/locales/ja/settings.json @@ -283,6 +283,8 @@ "providerDocumentation": "{{provider}}のドキュメント", "configProfile": "設定プロファイル", "description": "異なるAPI設定を保存して、プロバイダーと設定をすばやく切り替えることができます。", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "APIプロバイダー", "apiProviderDocs": "プロバイダードキュメント", "model": "モデル", diff --git a/webview-ui/src/i18n/locales/ko/settings.json b/webview-ui/src/i18n/locales/ko/settings.json index 0966de993c..1d69391129 100644 --- a/webview-ui/src/i18n/locales/ko/settings.json +++ b/webview-ui/src/i18n/locales/ko/settings.json @@ -283,6 +283,8 @@ "providerDocumentation": "{{provider}} 문서", "configProfile": "구성 프로필", "description": "다양한 API 구성을 저장하여 제공자와 설정 간에 빠르게 전환할 수 있습니다.", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "API 제공자", "apiProviderDocs": "공급자 문서", "model": "모델", diff --git a/webview-ui/src/i18n/locales/nl/settings.json b/webview-ui/src/i18n/locales/nl/settings.json index bba93459cb..c49e9a3a3d 100644 --- a/webview-ui/src/i18n/locales/nl/settings.json +++ b/webview-ui/src/i18n/locales/nl/settings.json @@ -283,6 +283,8 @@ "providerDocumentation": "{{provider}} documentatie", "configProfile": "Configuratieprofiel", "description": "Sla verschillende API-configuraties op om snel te wisselen tussen providers en instellingen.", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "API-provider", "apiProviderDocs": "Providerdocumentatie", "model": "Model", diff --git a/webview-ui/src/i18n/locales/pl/settings.json b/webview-ui/src/i18n/locales/pl/settings.json index 0c384f5d64..115a5c7a47 100644 --- a/webview-ui/src/i18n/locales/pl/settings.json +++ b/webview-ui/src/i18n/locales/pl/settings.json @@ -283,6 +283,8 @@ "providerDocumentation": "Dokumentacja {{provider}}", "configProfile": "Profil konfiguracji", "description": "Zapisz różne konfiguracje API, aby szybko przełączać się między dostawcami i ustawieniami.", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "Dostawca API", "apiProviderDocs": "Dokumentacja dostawcy", "model": "Model", diff --git a/webview-ui/src/i18n/locales/pt-BR/settings.json b/webview-ui/src/i18n/locales/pt-BR/settings.json index 4e5b6a1690..d273e364e3 100644 --- a/webview-ui/src/i18n/locales/pt-BR/settings.json +++ b/webview-ui/src/i18n/locales/pt-BR/settings.json @@ -283,6 +283,8 @@ "providerDocumentation": "Documentação do {{provider}}", "configProfile": "Perfil de configuração", "description": "Salve diferentes configurações de API para alternar rapidamente entre provedores e configurações.", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "Provedor de API", "apiProviderDocs": "Documentação do Provedor", "model": "Modelo", diff --git a/webview-ui/src/i18n/locales/ru/settings.json b/webview-ui/src/i18n/locales/ru/settings.json index 7dc78f049c..acacd2ee49 100644 --- a/webview-ui/src/i18n/locales/ru/settings.json +++ b/webview-ui/src/i18n/locales/ru/settings.json @@ -283,6 +283,8 @@ "providerDocumentation": "Документация {{provider}}", "configProfile": "Профиль конфигурации", "description": "Сохраняйте различные конфигурации API для быстрого переключения между провайдерами и настройками.", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "Провайдер API", "apiProviderDocs": "Документация провайдера", "model": "Модель", diff --git a/webview-ui/src/i18n/locales/tr/settings.json b/webview-ui/src/i18n/locales/tr/settings.json index 66cbb44ca7..bb8cf2fffc 100644 --- a/webview-ui/src/i18n/locales/tr/settings.json +++ b/webview-ui/src/i18n/locales/tr/settings.json @@ -283,6 +283,8 @@ "providerDocumentation": "{{provider}} Dokümantasyonu", "configProfile": "Yapılandırma Profili", "description": "Sağlayıcılar ve ayarlar arasında hızlıca geçiş yapmak için farklı API yapılandırmalarını kaydedin.", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "API Sağlayıcı", "apiProviderDocs": "Sağlayıcı Belgeleri", "model": "Model", diff --git a/webview-ui/src/i18n/locales/vi/settings.json b/webview-ui/src/i18n/locales/vi/settings.json index f4114549d7..5575950873 100644 --- a/webview-ui/src/i18n/locales/vi/settings.json +++ b/webview-ui/src/i18n/locales/vi/settings.json @@ -283,6 +283,8 @@ "providerDocumentation": "Tài liệu {{provider}}", "configProfile": "Hồ sơ cấu hình", "description": "Lưu các cấu hình API khác nhau để nhanh chóng chuyển đổi giữa các nhà cung cấp và cài đặt.", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "Nhà cung cấp API", "apiProviderDocs": "Tài liệu Nhà cung cấp", "model": "Mẫu", diff --git a/webview-ui/src/i18n/locales/zh-CN/settings.json b/webview-ui/src/i18n/locales/zh-CN/settings.json index b151ea7c39..41d32aebfa 100644 --- a/webview-ui/src/i18n/locales/zh-CN/settings.json +++ b/webview-ui/src/i18n/locales/zh-CN/settings.json @@ -283,6 +283,8 @@ "providerDocumentation": "{{provider}} 文档", "configProfile": "配置文件", "description": "保存多组API配置便于快速切换", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "API提供商", "apiProviderDocs": "提供商文档", "model": "模型", diff --git a/webview-ui/src/i18n/locales/zh-TW/settings.json b/webview-ui/src/i18n/locales/zh-TW/settings.json index 7f9328595f..ab89344104 100644 --- a/webview-ui/src/i18n/locales/zh-TW/settings.json +++ b/webview-ui/src/i18n/locales/zh-TW/settings.json @@ -293,6 +293,8 @@ "providerDocumentation": "{{provider}} 說明文件", "configProfile": "設定檔", "description": "儲存不同的 API 設定以快速切換供應商和設定。", + "lockApiConfigAcrossModes": "Use the same configuration for all modes", + "lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.", "apiProvider": "API 供應商", "apiProviderDocs": "供應商說明文件", "model": "模型",