Skip to content

Commit c765440

Browse files
committed
Hide Gemini checkboxes on the welcome view
1 parent f49d8bc commit c765440

File tree

3 files changed

+77
-21
lines changed

3 files changed

+77
-21
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,11 @@ const ApiOptions = ({
448448
)}
449449

450450
{selectedProvider === "gemini" && (
451-
<Gemini apiConfiguration={apiConfiguration} setApiConfigurationField={setApiConfigurationField} />
451+
<Gemini
452+
apiConfiguration={apiConfiguration}
453+
setApiConfigurationField={setApiConfigurationField}
454+
fromWelcomeView={fromWelcomeView}
455+
/>
452456
)}
453457

454458
{selectedProvider === "openai" && (

webview-ui/src/components/settings/providers/Gemini.tsx

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import { inputEventTransform } from "../transforms"
1212
type GeminiProps = {
1313
apiConfiguration: ProviderSettings
1414
setApiConfigurationField: (field: keyof ProviderSettings, value: ProviderSettings[keyof ProviderSettings]) => void
15+
fromWelcomeView?: boolean
1516
}
1617

17-
export const Gemini = ({ apiConfiguration, setApiConfigurationField }: GeminiProps) => {
18+
export const Gemini = ({ apiConfiguration, setApiConfigurationField, fromWelcomeView }: GeminiProps) => {
1819
const { t } = useAppTranslation()
1920

2021
const [googleGeminiBaseUrlSelected, setGoogleGeminiBaseUrlSelected] = useState(
@@ -73,26 +74,30 @@ export const Gemini = ({ apiConfiguration, setApiConfigurationField }: GeminiPro
7374
/>
7475
)}
7576

76-
<Checkbox
77-
className="mt-6"
78-
data-testid="checkbox-url-context"
79-
checked={!!apiConfiguration.enableUrlContext}
80-
onChange={(checked: boolean) => setApiConfigurationField("enableUrlContext", checked)}>
81-
{t("settings:providers.geminiParameters.urlContext.title")}
82-
</Checkbox>
83-
<div className="text-sm text-vscode-descriptionForeground mb-3 mt-1.5">
84-
{t("settings:providers.geminiParameters.urlContext.description")}
85-
</div>
77+
{!fromWelcomeView && (
78+
<>
79+
<Checkbox
80+
className="mt-6"
81+
data-testid="checkbox-url-context"
82+
checked={!!apiConfiguration.enableUrlContext}
83+
onChange={(checked: boolean) => setApiConfigurationField("enableUrlContext", checked)}>
84+
{t("settings:providers.geminiParameters.urlContext.title")}
85+
</Checkbox>
86+
<div className="text-sm text-vscode-descriptionForeground mb-3 mt-1.5">
87+
{t("settings:providers.geminiParameters.urlContext.description")}
88+
</div>
8689

87-
<Checkbox
88-
data-testid="checkbox-grounding-search"
89-
checked={!!apiConfiguration.enableGrounding}
90-
onChange={(checked: boolean) => setApiConfigurationField("enableGrounding", checked)}>
91-
{t("settings:providers.geminiParameters.groundingSearch.title")}
92-
</Checkbox>
93-
<div className="text-sm text-vscode-descriptionForeground mb-3 mt-1.5">
94-
{t("settings:providers.geminiParameters.groundingSearch.description")}
95-
</div>
90+
<Checkbox
91+
data-testid="checkbox-grounding-search"
92+
checked={!!apiConfiguration.enableGrounding}
93+
onChange={(checked: boolean) => setApiConfigurationField("enableGrounding", checked)}>
94+
{t("settings:providers.geminiParameters.groundingSearch.title")}
95+
</Checkbox>
96+
<div className="text-sm text-vscode-descriptionForeground mb-3 mt-1.5">
97+
{t("settings:providers.geminiParameters.groundingSearch.description")}
98+
</div>
99+
</>
100+
)}
96101
</div>
97102
</>
98103
)

webview-ui/src/components/settings/providers/__tests__/Gemini.spec.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,51 @@ describe("Gemini", () => {
127127
expect(mockSetApiConfigurationField).toHaveBeenCalledWith("enableGrounding", true)
128128
})
129129
})
130+
131+
describe("fromWelcomeView prop", () => {
132+
it("should hide URL context and grounding checkboxes when fromWelcomeView is true, but keep custom base URL", () => {
133+
render(
134+
<Gemini
135+
apiConfiguration={defaultApiConfiguration}
136+
setApiConfigurationField={mockSetApiConfigurationField}
137+
fromWelcomeView={true}
138+
/>,
139+
)
140+
141+
// Should still render custom base URL checkbox
142+
expect(screen.getByTestId("checkbox-custom-base-url")).toBeInTheDocument()
143+
// Should not render URL context and grounding checkboxes
144+
expect(screen.queryByTestId("checkbox-url-context")).not.toBeInTheDocument()
145+
expect(screen.queryByTestId("checkbox-grounding-search")).not.toBeInTheDocument()
146+
})
147+
148+
it("should show all checkboxes when fromWelcomeView is false", () => {
149+
render(
150+
<Gemini
151+
apiConfiguration={defaultApiConfiguration}
152+
setApiConfigurationField={mockSetApiConfigurationField}
153+
fromWelcomeView={false}
154+
/>,
155+
)
156+
157+
// Should render all checkboxes
158+
expect(screen.getByTestId("checkbox-custom-base-url")).toBeInTheDocument()
159+
expect(screen.getByTestId("checkbox-url-context")).toBeInTheDocument()
160+
expect(screen.getByTestId("checkbox-grounding-search")).toBeInTheDocument()
161+
})
162+
163+
it("should show all checkboxes when fromWelcomeView is undefined (default behavior)", () => {
164+
render(
165+
<Gemini
166+
apiConfiguration={defaultApiConfiguration}
167+
setApiConfigurationField={mockSetApiConfigurationField}
168+
/>,
169+
)
170+
171+
// Should render all checkboxes (default behavior)
172+
expect(screen.getByTestId("checkbox-custom-base-url")).toBeInTheDocument()
173+
expect(screen.getByTestId("checkbox-url-context")).toBeInTheDocument()
174+
expect(screen.getByTestId("checkbox-grounding-search")).toBeInTheDocument()
175+
})
176+
})
130177
})

0 commit comments

Comments
 (0)