Skip to content

Commit bee49f4

Browse files
fix(terminal): hide inline profile picker when inline execution is off
The terminal-profile dropdown only affects inline execution, which is active when shell integration is disabled. It previously stayed visible and editable even when inline mode was off, where it has no effect. Guard it with terminalShellIntegrationDisabled (defaulting to shown, matching the checkbox), mirroring the inline-only settings below. Addresses PR #277 review (edelauna).
1 parent cb3734f commit bee49f4

2 files changed

Lines changed: 47 additions & 31 deletions

File tree

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

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -151,37 +151,43 @@ export const TerminalSettings = ({
151151
</div>
152152
</div>
153153
<div className="flex flex-col gap-3 pl-3 border-l-2 border-vscode-button-background">
154-
<SearchableSetting
155-
settingId="terminal-profile"
156-
section="terminal"
157-
label={t("settings:terminal.profile.label")}>
158-
<label className="block font-medium mb-1">{t("settings:terminal.profile.label")}</label>
159-
<Select
160-
value={terminalProfile || DEFAULT_PROFILE_VALUE}
161-
onValueChange={(value) =>
162-
setCachedStateField(
163-
"terminalProfile",
164-
value === DEFAULT_PROFILE_VALUE ? undefined : value,
165-
)
166-
}>
167-
<SelectTrigger className="w-full" data-testid="terminal-profile-dropdown">
168-
<SelectValue placeholder={t("settings:common.select")} />
169-
</SelectTrigger>
170-
<SelectContent>
171-
<SelectItem value={DEFAULT_PROFILE_VALUE}>
172-
{t("settings:terminal.profile.default")}
173-
</SelectItem>
174-
{profileNames.map((name) => (
175-
<SelectItem key={name} value={name}>
176-
{name}
154+
{/* The profile picker only affects inline execution, which is active when shell
155+
integration is disabled. Hide it otherwise so it isn't shown but ineffective
156+
(mirrors the inline-only settings guarded below). Defaults to shown, matching
157+
the checkbox's `?? true`. See PR #277 review. */}
158+
{(terminalShellIntegrationDisabled ?? true) && (
159+
<SearchableSetting
160+
settingId="terminal-profile"
161+
section="terminal"
162+
label={t("settings:terminal.profile.label")}>
163+
<label className="block font-medium mb-1">{t("settings:terminal.profile.label")}</label>
164+
<Select
165+
value={terminalProfile || DEFAULT_PROFILE_VALUE}
166+
onValueChange={(value) =>
167+
setCachedStateField(
168+
"terminalProfile",
169+
value === DEFAULT_PROFILE_VALUE ? undefined : value,
170+
)
171+
}>
172+
<SelectTrigger className="w-full" data-testid="terminal-profile-dropdown">
173+
<SelectValue placeholder={t("settings:common.select")} />
174+
</SelectTrigger>
175+
<SelectContent>
176+
<SelectItem value={DEFAULT_PROFILE_VALUE}>
177+
{t("settings:terminal.profile.default")}
177178
</SelectItem>
178-
))}
179-
</SelectContent>
180-
</Select>
181-
<div className="text-vscode-descriptionForeground text-sm mt-1">
182-
{t("settings:terminal.profile.description")}
183-
</div>
184-
</SearchableSetting>
179+
{profileNames.map((name) => (
180+
<SelectItem key={name} value={name}>
181+
{name}
182+
</SelectItem>
183+
))}
184+
</SelectContent>
185+
</Select>
186+
<div className="text-vscode-descriptionForeground text-sm mt-1">
187+
{t("settings:terminal.profile.description")}
188+
</div>
189+
</SearchableSetting>
190+
)}
185191

186192
<SearchableSetting
187193
settingId="terminal-shell-integration-disabled"

webview-ui/src/components/settings/__tests__/TerminalSettings.profile.spec.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@ describe("TerminalSettings inline terminal profile (#119)", () => {
7272
postMessageMock.mockClear()
7373
})
7474

75+
// Inline execution is active when shell integration is disabled, which is when the
76+
// profile picker is shown; render in that state for the picker-behavior tests.
7577
const setup = (terminalProfile?: string) => {
7678
const setCachedStateField = vi.fn()
7779
render(
7880
<TerminalSettings
79-
terminalShellIntegrationDisabled={false}
81+
terminalShellIntegrationDisabled={true}
8082
terminalProfile={terminalProfile}
8183
setCachedStateField={setCachedStateField}
8284
/>,
@@ -123,4 +125,12 @@ describe("TerminalSettings inline terminal profile (#119)", () => {
123125

124126
expect(setCachedStateField).toHaveBeenCalledWith("terminalProfile", undefined)
125127
})
128+
129+
it("hides the profile picker when inline execution is off (shell integration enabled)", () => {
130+
render(<TerminalSettings terminalShellIntegrationDisabled={false} setCachedStateField={vi.fn()} />)
131+
// The picker is inline-only: with shell integration enabled it must not render.
132+
expect(screen.queryByTestId("option-__default__")).not.toBeInTheDocument()
133+
// But the names are still requested on mount (cheap, harmless, keeps state warm).
134+
expect(postMessageMock.mock.calls.map((c) => c[0]?.type)).toContain("requestTerminalProfiles")
135+
})
126136
})

0 commit comments

Comments
 (0)