|
1 | | -import { HTMLAttributes, useState, useCallback, useEffect, useId } from "react" |
| 1 | +import { HTMLAttributes, useState, useCallback, useEffect } from "react" |
2 | 2 | import { useAppTranslation } from "@/i18n/TranslationContext" |
3 | 3 | import { vscode } from "@/utils/vscode" |
4 | | -import { VSCodeCheckbox, VSCodeLink, VSCodeButton } from "@vscode/webview-ui-toolkit/react" |
| 4 | +import { VSCodeCheckbox, VSCodeLink } from "@vscode/webview-ui-toolkit/react" |
5 | 5 | import { Trans } from "react-i18next" |
6 | 6 | import { buildDocLink } from "@src/utils/docLinks" |
7 | 7 | import { useEvent, useMount } from "react-use" |
8 | 8 |
|
9 | 9 | import { type ExtensionMessage, type TerminalOutputPreviewSize } from "@roo-code/types" |
10 | 10 |
|
11 | 11 | import { cn } from "@/lib/utils" |
12 | | -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Slider } from "@/components/ui" |
| 12 | +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Slider, Button } from "@/components/ui" |
13 | 13 |
|
14 | 14 | import { SetCachedStateField } from "./types" |
15 | 15 | import { SectionHeader } from "./SectionHeader" |
@@ -67,10 +67,6 @@ export const TerminalSettings = ({ |
67 | 67 | const [inheritEnv, setInheritEnv] = useState<boolean>(true) |
68 | 68 | const [profileNames, setProfileNames] = useState<string[]>([]) |
69 | 69 | const [isProfilesLoaded, setIsProfilesLoaded] = useState(false) |
70 | | - const profileModeId = useId() |
71 | | - const defaultProfileId = `${profileModeId}-default` |
72 | | - const overrideProfileId = `${profileModeId}-override` |
73 | | - const isProfileOverrideSelected = !!terminalProfile && (!isProfilesLoaded || profileNames.includes(terminalProfile)) |
74 | 70 | const isVSCodeTerminalEnabled = terminalShellIntegrationDisabled === false |
75 | 71 |
|
76 | 72 | useMount(() => { |
@@ -166,111 +162,7 @@ export const TerminalSettings = ({ |
166 | 162 | </div> |
167 | 163 | </div> |
168 | 164 | <div className="flex flex-col gap-3 pl-3 border-l-2 border-vscode-button-background"> |
169 | | - {/* Profile override — only applies when VS Code integrated terminal is active |
170 | | - (shell integration enabled). Hidden in Execa/inline mode since getProfileShell() |
171 | | - is not wired there. */} |
172 | | - {isVSCodeTerminalEnabled && ( |
173 | | - <SearchableSetting |
174 | | - settingId="terminal-profile" |
175 | | - section="terminal" |
176 | | - label={t("settings:terminal.profile.label")}> |
177 | | - <label className="block font-medium mb-1">{t("settings:terminal.profile.label")}</label> |
178 | | - |
179 | | - {/* Level 1: Default (recommended) */} |
180 | | - <div className="flex items-center gap-2 mb-2"> |
181 | | - <input |
182 | | - type="radio" |
183 | | - id={defaultProfileId} |
184 | | - name={profileModeId} |
185 | | - checked={!isProfileOverrideSelected} |
186 | | - onChange={() => setCachedStateField("terminalProfile", undefined)} |
187 | | - data-testid="terminal-profile-default-radio" |
188 | | - /> |
189 | | - <label htmlFor={defaultProfileId} className="cursor-pointer"> |
190 | | - {t("settings:terminal.profile.default")} |
191 | | - </label> |
192 | | - <VSCodeButton |
193 | | - appearance="secondary" |
194 | | - onClick={() => { |
195 | | - onTerminalProfilePickerOpened?.() |
196 | | - vscode.postMessage({ type: "openTerminalProfilePicker" }) |
197 | | - }} |
198 | | - data-testid="terminal-profile-configure-button"> |
199 | | - {t("settings:terminal.profile.configureButton")} |
200 | | - </VSCodeButton> |
201 | | - </div> |
202 | | - |
203 | | - {/* Level 2: Override */} |
204 | | - <div className="flex items-center gap-2 mb-2"> |
205 | | - <input |
206 | | - type="radio" |
207 | | - id={overrideProfileId} |
208 | | - name={profileModeId} |
209 | | - checked={isProfileOverrideSelected} |
210 | | - disabled={profileNames.length === 0} |
211 | | - onChange={() => { |
212 | | - if (!terminalProfile && profileNames.length > 0) { |
213 | | - setCachedStateField("terminalProfile", profileNames[0]) |
214 | | - } |
215 | | - }} |
216 | | - data-testid="terminal-profile-override-radio" |
217 | | - /> |
218 | | - <label |
219 | | - htmlFor={overrideProfileId} |
220 | | - className={ |
221 | | - profileNames.length === 0 |
222 | | - ? "cursor-not-allowed text-vscode-disabledForeground" |
223 | | - : "cursor-pointer" |
224 | | - }> |
225 | | - {t("settings:terminal.profile.overrideLabel")} |
226 | | - </label> |
227 | | - {profileNames.length === 0 && ( |
228 | | - <span |
229 | | - className="text-vscode-descriptionForeground text-xs" |
230 | | - data-testid="terminal-profile-no-profiles-hint"> |
231 | | - {t("settings:terminal.profile.noProfiles")} |
232 | | - </span> |
233 | | - )} |
234 | | - </div> |
235 | | - |
236 | | - {isProfileOverrideSelected && profileNames.length > 0 && ( |
237 | | - <Select |
238 | | - value={terminalProfile || DEFAULT_PROFILE_VALUE} |
239 | | - data-testid="terminal-profile-dropdown" |
240 | | - onValueChange={(value) => |
241 | | - setCachedStateField( |
242 | | - "terminalProfile", |
243 | | - value === DEFAULT_PROFILE_VALUE ? undefined : value, |
244 | | - ) |
245 | | - }> |
246 | | - <SelectTrigger className="w-full ml-6"> |
247 | | - <SelectValue placeholder={t("settings:common.select")} /> |
248 | | - </SelectTrigger> |
249 | | - <SelectContent> |
250 | | - {profileNames.map((name) => ( |
251 | | - <SelectItem key={name} value={name}> |
252 | | - {name} |
253 | | - </SelectItem> |
254 | | - ))} |
255 | | - </SelectContent> |
256 | | - </Select> |
257 | | - )} |
258 | | - |
259 | | - <div className="text-vscode-descriptionForeground text-sm mt-1"> |
260 | | - <Trans i18nKey="settings:terminal.profile.description"> |
261 | | - <VSCodeLink |
262 | | - href={buildDocLink( |
263 | | - "features/shell-integration", |
264 | | - "settings_terminal_profile", |
265 | | - )} |
266 | | - style={{ display: "inline" }}> |
267 | | - {" "} |
268 | | - </VSCodeLink> |
269 | | - </Trans> |
270 | | - </div> |
271 | | - </SearchableSetting> |
272 | | - )} |
273 | | - |
| 165 | + {/* "Use Inline Terminal" checkbox — ALWAYS at the top */} |
274 | 166 | <SearchableSetting |
275 | 167 | settingId="terminal-shell-integration-disabled" |
276 | 168 | section="terminal" |
@@ -300,6 +192,76 @@ export const TerminalSettings = ({ |
300 | 192 |
|
301 | 193 | {isVSCodeTerminalEnabled && ( |
302 | 194 | <> |
| 195 | + {/* Profile override — unified dropdown, now below checkbox */} |
| 196 | + <SearchableSetting |
| 197 | + settingId="terminal-profile" |
| 198 | + section="terminal" |
| 199 | + label={t("settings:terminal.profile.label")}> |
| 200 | + <label className="block font-medium mb-1"> |
| 201 | + {t("settings:terminal.profile.label")} |
| 202 | + </label> |
| 203 | + |
| 204 | + <Select |
| 205 | + value={terminalProfile || DEFAULT_PROFILE_VALUE} |
| 206 | + onValueChange={(value) => |
| 207 | + setCachedStateField( |
| 208 | + "terminalProfile", |
| 209 | + value === DEFAULT_PROFILE_VALUE ? undefined : value, |
| 210 | + ) |
| 211 | + } |
| 212 | + data-testid="terminal-profile-dropdown"> |
| 213 | + <SelectTrigger className="w-full"> |
| 214 | + <SelectValue placeholder={t("settings:common.select")} /> |
| 215 | + </SelectTrigger> |
| 216 | + <SelectContent> |
| 217 | + <SelectItem value={DEFAULT_PROFILE_VALUE}> |
| 218 | + {t("settings:terminal.profile.followVscode")} |
| 219 | + </SelectItem> |
| 220 | + {profileNames.map((name) => ( |
| 221 | + <SelectItem key={name} value={name}> |
| 222 | + {name} |
| 223 | + </SelectItem> |
| 224 | + ))} |
| 225 | + </SelectContent> |
| 226 | + </Select> |
| 227 | + |
| 228 | + {!terminalProfile && ( |
| 229 | + <div className="mt-2"> |
| 230 | + <Button |
| 231 | + variant="secondary" |
| 232 | + size="sm" |
| 233 | + onClick={() => { |
| 234 | + onTerminalProfilePickerOpened?.() |
| 235 | + vscode.postMessage({ type: "openTerminalProfilePicker" }) |
| 236 | + }} |
| 237 | + data-testid="terminal-profile-configure-button"> |
| 238 | + {t("settings:terminal.profile.configureButton")} |
| 239 | + </Button> |
| 240 | + </div> |
| 241 | + )} |
| 242 | + |
| 243 | + {profileNames.length === 0 && ( |
| 244 | + <div |
| 245 | + className="text-vscode-descriptionForeground text-xs mt-1" |
| 246 | + data-testid="terminal-profile-no-profiles-hint"> |
| 247 | + {t("settings:terminal.profile.noProfiles")} |
| 248 | + </div> |
| 249 | + )} |
| 250 | + |
| 251 | + <div className="text-vscode-descriptionForeground text-sm mt-1"> |
| 252 | + <Trans i18nKey="settings:terminal.profile.description"> |
| 253 | + <VSCodeLink |
| 254 | + href={buildDocLink( |
| 255 | + "features/shell-integration", |
| 256 | + "settings_terminal_profile", |
| 257 | + )} |
| 258 | + style={{ display: "inline" }}> |
| 259 | + {" "} |
| 260 | + </VSCodeLink> |
| 261 | + </Trans> |
| 262 | + </div> |
| 263 | + </SearchableSetting> |
| 264 | + |
303 | 265 | <SearchableSetting |
304 | 266 | settingId="terminal-inherit-env" |
305 | 267 | section="terminal" |
|
0 commit comments