Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 15b066c

Browse files
committed
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
1 parent ad25634 commit 15b066c

20 files changed

Lines changed: 102 additions & 0 deletions

webview-ui/src/components/settings/SettingsView.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import {
6060
StandardTooltip,
6161
} from "@src/components/ui"
6262

63+
import { Checkbox } from "vscrui"
6364
import { Tab, TabContent, TabHeader, TabList, TabTrigger } from "../common/Tab"
6465
import { SetCachedStateField, SetExperimentEnabled } from "./types"
6566
import { SectionHeader } from "./SectionHeader"
@@ -203,6 +204,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
203204
includeCurrentTime,
204205
includeCurrentCost,
205206
maxGitStatusFiles,
207+
lockApiConfigAcrossModes,
206208
} = cachedState
207209

208210
const apiConfiguration = useMemo(() => cachedState.apiConfiguration ?? {}, [cachedState.apiConfiguration])
@@ -430,6 +432,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
430432
vscode.postMessage({ type: "upsertApiConfiguration", text: currentApiConfigName, apiConfiguration })
431433
vscode.postMessage({ type: "telemetrySetting", text: telemetrySetting })
432434
vscode.postMessage({ type: "debugSetting", bool: cachedState.debug })
435+
vscode.postMessage({ type: "lockApiConfigAcrossModes", bool: !!lockApiConfigAcrossModes })
433436

434437
setChangeDetected(false)
435438
}
@@ -766,6 +769,19 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
766769
})
767770
}
768771
/>
772+
<div className="flex flex-col gap-1 mt-4 mb-2">
773+
<Checkbox
774+
checked={!!lockApiConfigAcrossModes}
775+
onChange={(checked: boolean) =>
776+
setCachedStateField("lockApiConfigAcrossModes", checked)
777+
}
778+
data-testid="lock-api-config-checkbox">
779+
{t("settings:providers.lockApiConfigAcrossModes")}
780+
</Checkbox>
781+
<div className="text-sm text-vscode-descriptionForeground ml-6">
782+
{t("settings:providers.lockApiConfigAcrossModesDescription")}
783+
</div>
784+
</div>
769785
<ApiOptions
770786
uriScheme={uriScheme}
771787
apiConfiguration={apiConfiguration}

webview-ui/src/components/settings/__tests__/SettingsView.spec.tsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ import SettingsView from "../SettingsView"
1010

1111
vi.mock("@src/utils/vscode", () => ({ vscode: { postMessage: vi.fn() } }))
1212

13+
vi.mock("vscrui", () => ({
14+
Checkbox: ({ children, checked, onChange, "data-testid": dataTestId }: any) => (
15+
<label>
16+
<input
17+
type="checkbox"
18+
checked={checked}
19+
onChange={(e) => onChange(e.target.checked)}
20+
data-testid={dataTestId}
21+
/>
22+
{children}
23+
</label>
24+
),
25+
}))
26+
1327
vi.mock("../ApiConfigManager", () => ({
1428
__esModule: true,
1529
default: ({ currentApiConfigName }: any) => (
@@ -714,3 +728,39 @@ describe("SettingsView - Duplicate Commands", () => {
714728
)
715729
})
716730
})
731+
732+
describe("SettingsView - Lock API Config Across Modes", () => {
733+
beforeEach(() => {
734+
vi.clearAllMocks()
735+
})
736+
737+
it("renders lock API config checkbox unchecked by default on the providers tab", () => {
738+
const { getSettingsContent } = renderSettingsView()
739+
740+
const content = getSettingsContent()
741+
const lockCheckbox = within(content).getByTestId("lock-api-config-checkbox")
742+
expect(lockCheckbox).not.toBeChecked()
743+
})
744+
745+
it("toggles lock API config and sends lockApiConfigAcrossModes message on save", () => {
746+
const { getSettingsContent } = renderSettingsView()
747+
748+
const content = getSettingsContent()
749+
const lockCheckbox = within(content).getByTestId("lock-api-config-checkbox")
750+
751+
// Enable the lock
752+
fireEvent.click(lockCheckbox)
753+
expect(lockCheckbox).toBeChecked()
754+
755+
// Click Save
756+
const saveButton = screen.getByTestId("save-button")
757+
fireEvent.click(saveButton)
758+
759+
expect(vscode.postMessage).toHaveBeenCalledWith(
760+
expect.objectContaining({
761+
type: "lockApiConfigAcrossModes",
762+
bool: true,
763+
}),
764+
)
765+
})
766+
})

webview-ui/src/i18n/locales/ca/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/de/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/en/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@
351351
"providerDocumentation": "{{provider}} documentation",
352352
"configProfile": "Configuration Profile",
353353
"description": "Save different API configurations to quickly switch between providers and settings.",
354+
"lockApiConfigAcrossModes": "Use the same configuration for all modes",
355+
"lockApiConfigAcrossModesDescription": "When enabled, switching modes (e.g. Code, Architect, Ask) will keep the current API configuration instead of switching to a mode-specific one.",
354356
"apiProvider": "API Provider",
355357
"apiProviderDocs": "Provider Docs",
356358
"model": "Model",

webview-ui/src/i18n/locales/es/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/fr/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/hi/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/id/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/it/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)