-
Notifications
You must be signed in to change notification settings - Fork 69
feat(terminal): allow choosing the terminal profile for inline execution (#119) #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a16d82e
27a3b2f
8653b3c
4f45c7c
cb3734f
bee49f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -726,6 +726,8 @@ export const webviewMessageHandler = async ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (value !== undefined) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Terminal.setTerminalZdotdir(value as boolean) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (key === "terminalProfile") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Terminal.setTerminalProfile(value as string | undefined) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
edelauna marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (key === "execaShellPath") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Terminal.setExecaShellPath(value as string | undefined) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (key === "mcpEnabled") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1510,6 +1512,38 @@ export const webviewMessageHandler = async ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "requestTerminalProfiles": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Allowlisted request: read VS Code's terminal profiles server-side and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // return only the sanitized profile names. The terminal profile dropdown | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // only needs names, so this avoids routing it through the generic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // `getVSCodeSetting` handler (which reads any key the webview supplies). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const names = new Set<string>() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (const platform of ["windows", "osx", "linux"] as const) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const profiles = vscode.workspace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .getConfiguration("terminal.integrated.profiles") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .get<Record<string, unknown>>(platform) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (profiles && typeof profiles === "object") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (const name of Object.keys(profiles)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| names.add(name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await provider.postMessageToWebview({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "terminalProfiles", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| profiles: Array.from(names).sort(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1523
to
+1538
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Limit returned profile names to the active platform. Collecting from Proposed fix- const names = new Set<string>()
-
- for (const platform of ["windows", "osx", "linux"] as const) {
- const profiles = vscode.workspace
- .getConfiguration("terminal.integrated.profiles")
- .get<Record<string, unknown>>(platform)
-
- if (profiles && typeof profiles === "object") {
- for (const name of Object.keys(profiles)) {
- names.add(name)
- }
- }
- }
+ const platform =
+ process.platform === "win32" ? "windows" : process.platform === "darwin" ? "osx" : "linux"
+ const profiles = vscode.workspace
+ .getConfiguration("terminal.integrated.profiles")
+ .get<Record<string, unknown>>(platform)
+ const names =
+ profiles && typeof profiles === "object" ? Object.keys(profiles).sort() : []
await provider.postMessageToWebview({
type: "terminalProfiles",
- profiles: Array.from(names).sort(),
+ profiles: names,
})📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error("Failed to get terminal profiles:", error) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await provider.postMessageToWebview({ type: "terminalProfiles", profiles: [] }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1515
to
+1545
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "mode": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await provider.handleModeSwitch(message.text as Mode) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -161,6 +161,7 @@ export abstract class BaseTerminal implements RooTerminal { | |||||||||||||||
| private static terminalZshOhMy: boolean = false | ||||||||||||||||
| private static terminalZshP10k: boolean = false | ||||||||||||||||
| private static terminalZdotdir: boolean = false | ||||||||||||||||
| private static terminalProfile: string | undefined = undefined | ||||||||||||||||
| private static execaShellPath: string | undefined = undefined | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
|
|
@@ -296,6 +297,24 @@ export abstract class BaseTerminal implements RooTerminal { | |||||||||||||||
| return BaseTerminal.terminalZdotdir | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * Sets the name of the VS Code terminal profile to use for the inline | ||||||||||||||||
| * (shell-integration) terminal. An empty/undefined value falls back to | ||||||||||||||||
| * VS Code's default terminal behavior. | ||||||||||||||||
| * @param profile The terminal profile name, or undefined for the default | ||||||||||||||||
| */ | ||||||||||||||||
| public static setTerminalProfile(profile: string | undefined): void { | ||||||||||||||||
| BaseTerminal.terminalProfile = profile && profile.trim().length > 0 ? profile : undefined | ||||||||||||||||
| } | ||||||||||||||||
|
Comment on lines
+306
to
+308
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Persist the normalized profile name, not the raw input. Line 307 validates with Suggested fix public static setTerminalProfile(profile: string | undefined): void {
- BaseTerminal.terminalProfile = profile && profile.trim().length > 0 ? profile : undefined
+ const normalized = profile?.trim()
+ BaseTerminal.terminalProfile = normalized && normalized.length > 0 ? normalized : undefined
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * Gets the name of the VS Code terminal profile to use for the inline terminal. | ||||||||||||||||
| * @returns The terminal profile name, or undefined when the default should be used | ||||||||||||||||
| */ | ||||||||||||||||
| public static getTerminalProfile(): string | undefined { | ||||||||||||||||
| return BaseTerminal.terminalProfile | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| public static setExecaShellPath(shellPath: string | undefined): void { | ||||||||||||||||
| BaseTerminal.execaShellPath = shellPath | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.