feat: add lock API config checkbox to Settings Providers tab

Adds a discoverable "Use the same configuration for all modes" checkbox
to the Providers section in Settings. This mirrors the existing lock
icon hidden inside the API Configuration popover, making it much easier
to find.

- Checkbox in Providers tab reads from cachedState and persists on save
- i18n strings added for all 18 locales
- Tests added for render and toggle+save behavior

Addresses #12237
This commit is contained in:
Roo Code 2026-04-30 13:15:40 +00:00
parent ad25634905
commit 15b066cc9c
20 changed files with 102 additions and 0 deletions

View file

@ -60,6 +60,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"
@ -203,6 +204,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
includeCurrentTime,
includeCurrentCost,
maxGitStatusFiles,
lockApiConfigAcrossModes,
} = cachedState
const apiConfiguration = useMemo(() => cachedState.apiConfiguration ?? {}, [cachedState.apiConfiguration])
@ -430,6 +432,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
vscode.postMessage({ type: "upsertApiConfiguration", text: currentApiConfigName, apiConfiguration })
vscode.postMessage({ type: "telemetrySetting", text: telemetrySetting })
vscode.postMessage({ type: "debugSetting", bool: cachedState.debug })
vscode.postMessage({ type: "lockApiConfigAcrossModes", bool: !!lockApiConfigAcrossModes })
setChangeDetected(false)
}
@ -766,6 +769,19 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
})
}
/>
<div className="flex flex-col gap-1 mt-4 mb-2">
<Checkbox
checked={!!lockApiConfigAcrossModes}
onChange={(checked: boolean) =>
setCachedStateField("lockApiConfigAcrossModes", checked)
}
data-testid="lock-api-config-checkbox">
{t("settings:providers.lockApiConfigAcrossModes")}
</Checkbox>
<div className="text-sm text-vscode-descriptionForeground ml-6">
{t("settings:providers.lockApiConfigAcrossModesDescription")}
</div>
</div>
<ApiOptions
uriScheme={uriScheme}
apiConfiguration={apiConfiguration}

View file

@ -10,6 +10,20 @@ import SettingsView from "../SettingsView"
vi.mock("@src/utils/vscode", () => ({ vscode: { postMessage: vi.fn() } }))
vi.mock("vscrui", () => ({
Checkbox: ({ children, checked, onChange, "data-testid": dataTestId }: any) => (
<label>
<input
type="checkbox"
checked={checked}
onChange={(e) => onChange(e.target.checked)}
data-testid={dataTestId}
/>
{children}
</label>
),
}))
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,
}),
)
})
})

View file

@ -288,6 +288,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",

View file

@ -288,6 +288,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",

View file

@ -351,6 +351,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",

View file

@ -288,6 +288,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",

View file

@ -288,6 +288,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",

View file

@ -288,6 +288,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": "मॉडल",

View file

@ -288,6 +288,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",

View file

@ -288,6 +288,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",

View file

@ -288,6 +288,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": "モデル",

View file

@ -288,6 +288,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": "모델",

View file

@ -288,6 +288,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",

View file

@ -288,6 +288,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",

View file

@ -288,6 +288,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",

View file

@ -288,6 +288,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": "Модель",

View file

@ -288,6 +288,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",

View file

@ -288,6 +288,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",

View file

@ -288,6 +288,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": "模型",

View file

@ -298,6 +298,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": "模型",