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

Commit 468cb3f

Browse files
committed
feat(ExperimentalSettings): add "key configured" placeholder and i18n strings
1 parent d08f26c commit 468cb3f

21 files changed

Lines changed: 48 additions & 10 deletions

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type ExperimentalSettingsProps = HTMLAttributes<HTMLDivElement> & {
2121
apiConfiguration?: any
2222
setApiConfigurationField?: any
2323
imageGenerationProvider?: ImageGenerationProvider
24-
openRouterImageApiKey?: string
24+
openRouterImageApiKeyConfigured: boolean
2525
openRouterImageGenerationSelectedModel?: string
2626
setImageGenerationProvider?: (provider: ImageGenerationProvider) => void
2727
setOpenRouterImageApiKey?: (apiKey: string) => void
@@ -34,7 +34,7 @@ export const ExperimentalSettings = ({
3434
apiConfiguration,
3535
setApiConfigurationField,
3636
imageGenerationProvider,
37-
openRouterImageApiKey,
37+
openRouterImageApiKeyConfigured,
3838
openRouterImageGenerationSelectedModel,
3939
setImageGenerationProvider,
4040
setOpenRouterImageApiKey,
@@ -74,7 +74,7 @@ export const ExperimentalSettings = ({
7474
setExperimentEnabled(EXPERIMENT_IDS.IMAGE_GENERATION, enabled)
7575
}
7676
imageGenerationProvider={imageGenerationProvider}
77-
openRouterImageApiKey={openRouterImageApiKey}
77+
openRouterImageApiKeyConfigured={openRouterImageApiKeyConfigured}
7878
openRouterImageGenerationSelectedModel={openRouterImageGenerationSelectedModel}
7979
setImageGenerationProvider={setImageGenerationProvider}
8080
setOpenRouterImageApiKey={setOpenRouterImageApiKey}

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface ImageGenerationSettingsProps {
77
enabled: boolean
88
onChange: (enabled: boolean) => void
99
imageGenerationProvider?: ImageGenerationProvider
10-
openRouterImageApiKey?: string
10+
openRouterImageApiKeyConfigured: boolean
1111
openRouterImageGenerationSelectedModel?: string
1212
setImageGenerationProvider: (provider: ImageGenerationProvider) => void
1313
setOpenRouterImageApiKey: (apiKey: string) => void
@@ -18,7 +18,7 @@ export const ImageGenerationSettings = ({
1818
enabled,
1919
onChange,
2020
imageGenerationProvider,
21-
openRouterImageApiKey,
21+
openRouterImageApiKeyConfigured,
2222
openRouterImageGenerationSelectedModel,
2323
setImageGenerationProvider,
2424
setOpenRouterImageApiKey,
@@ -88,7 +88,7 @@ export const ImageGenerationSettings = ({
8888
}
8989

9090
const requiresApiKey = currentProvider === "openrouter"
91-
const isConfigured = !requiresApiKey || (requiresApiKey && openRouterImageApiKey)
91+
const isConfigured = !requiresApiKey || openRouterImageApiKeyConfigured
9292

9393
return (
9494
<div className="space-y-4">
@@ -133,9 +133,14 @@ export const ImageGenerationSettings = ({
133133
{t("settings:experimental.IMAGE_GENERATION.openRouterApiKeyLabel")}
134134
</label>
135135
<VSCodeTextField
136-
value={openRouterImageApiKey || ""}
137136
onInput={(e: any) => handleApiKeyChange(e.target.value)}
138-
placeholder={t("settings:experimental.IMAGE_GENERATION.openRouterApiKeyPlaceholder")}
137+
placeholder={
138+
openRouterImageApiKeyConfigured
139+
? t(
140+
"settings:experimental.IMAGE_GENERATION.openRouterApiKeyConfiguredPlaceholder",
141+
)
142+
: t("settings:experimental.IMAGE_GENERATION.openRouterApiKeyPlaceholder")
143+
}
139144
className="w-full"
140145
type="password"
141146
/>

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe("ImageGenerationSettings", () => {
1919
enabled: false,
2020
onChange: mockOnChange,
2121
imageGenerationProvider: undefined,
22-
openRouterImageApiKey: undefined,
22+
openRouterImageApiKeyConfigured: false,
2323
openRouterImageGenerationSelectedModel: undefined,
2424
setImageGenerationProvider: mockSetImageGenerationProvider,
2525
setOpenRouterImageApiKey: mockSetOpenRouterImageApiKey,
@@ -44,7 +44,7 @@ describe("ImageGenerationSettings", () => {
4444
render(
4545
<ImageGenerationSettings
4646
{...defaultProps}
47-
openRouterImageApiKey="existing-key"
47+
openRouterImageApiKeyConfigured={true}
4848
openRouterImageGenerationSelectedModel="google/gemini-2.5-flash-image"
4949
/>,
5050
)
@@ -90,6 +90,21 @@ describe("ImageGenerationSettings", () => {
9090
).toBeInTheDocument()
9191
})
9292

93+
it("should show configured placeholder when openRouterImageApiKeyConfigured is true", () => {
94+
const { getByPlaceholderText } = render(
95+
<ImageGenerationSettings
96+
{...defaultProps}
97+
enabled={true}
98+
imageGenerationProvider="openrouter"
99+
openRouterImageApiKeyConfigured={true}
100+
/>,
101+
)
102+
103+
expect(
104+
getByPlaceholderText("settings:experimental.IMAGE_GENERATION.openRouterApiKeyConfiguredPlaceholder"),
105+
).toBeInTheDocument()
106+
})
107+
93108
it("should not render API key field when provider is roo", () => {
94109
const { queryByPlaceholderText } = render(
95110
<ImageGenerationSettings {...defaultProps} enabled={true} imageGenerationProvider="roo" />,

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

Lines changed: 1 addition & 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: 1 addition & 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,7 @@
866866
"providerDescription": "Select which provider to use for image generation.",
867867
"openRouterApiKeyLabel": "OpenRouter API Key",
868868
"openRouterApiKeyPlaceholder": "Enter your OpenRouter API key",
869+
"openRouterApiKeyConfiguredPlaceholder": "API key configured — type to replace",
869870
"getApiKeyText": "Get your API key from",
870871
"modelSelectionLabel": "Image Generation Model",
871872
"modelSelectionDescription": "Select the model to use for image generation",

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

Lines changed: 1 addition & 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: 1 addition & 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: 1 addition & 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: 1 addition & 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)