Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Sep 11, 2025

Description

This PR addresses Issue #7892 by implementing support for VSCode's automation profile settings when creating terminals. Previously, Roo would use the default terminal profile, which could be incompatible with automation tools. Now it respects the terminal.integrated.automationProfile settings.

Changes

  • Added getAutomationShell() function to retrieve automation profile settings for all platforms (Windows, macOS, Linux)
  • Modified the Terminal class constructor to use the automation shell when available
  • Added comprehensive test coverage for the new functionality
  • Ensures security by validating automation shell paths against the existing allowlist

Testing

  • ✅ All existing tests pass
  • ✅ Added new tests for automation profile functionality
  • ✅ TypeScript type checking passes
  • ✅ Linting passes

How it works

When creating a new terminal, Roo will now:

  1. Check for platform-specific automation profile settings (terminal.integrated.automationProfile.{platform})
  2. Validate the shell path against the security allowlist
  3. Use the automation shell if configured and valid
  4. Fall back to default behavior if no automation profile is set

This allows users to configure a different shell for automation tools without changing their default terminal shell.

Fixes #7892


Important

This PR adds support for using VSCode's automation profile settings in terminal creation, ensuring compatibility with automation tools and validating shell paths against an allowlist.

  • Behavior:
    • Terminal class in Terminal.ts now uses getAutomationShell() to retrieve and use automation profile settings for terminal creation.
    • Falls back to default terminal profile if no automation profile is set.
    • Validates shell paths against an allowlist for security.
  • Functions:
    • Adds getAutomationShell() in shell.ts to retrieve automation profile settings for Windows, macOS, and Linux.
    • Modifies getShell() in shell.ts to include automation profile handling.
  • Testing:
    • Adds tests in TerminalRegistry.spec.ts and shell.spec.ts to cover automation profile functionality and shell path validation.
    • Tests include scenarios for different platforms and error handling.

This description was created by Ellipsis for 0010aef. You can customize this summary. It will automatically update as commits are pushed.

- Add getAutomationShell() function to retrieve automation profile settings
- Modify Terminal class to use automation profile when creating terminals
- Add comprehensive tests for automation profile functionality
- Respects terminal.integrated.automationProfile settings for all platforms

Fixes #7892
@roomote roomote bot requested review from cte, jr and mrubens as code owners September 11, 2025 10:49
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Sep 11, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote this code 3 minutes ago and already found 5 things wrong with it. Classic.

const iconPath = new vscode.ThemeIcon("rocket")
this.terminal = terminal ?? vscode.window.createTerminal({ cwd, name: "Roo Code", iconPath, env })

// Try to get the automation shell first, fall back to default behavior if not configured
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment accurate? The fallback to default behavior actually happens in VSCode's createTerminal when shellPath is undefined, not in our getAutomationShell() function. Maybe we should clarify this to avoid confusion?

this.terminal = terminal ?? vscode.window.createTerminal({ cwd, name: "Roo Code", iconPath, env })

// Try to get the automation shell first, fall back to default behavior if not configured
const shellPath = getAutomationShell() || undefined
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we simplify this to just shellPath: getAutomationShell() since getAutomationShell() already returns null? The || undefined conversion seems redundant unless VSCode's TerminalOptions specifically requires undefined over null.

* This is used for automation tools and should respect the automationProfile settings.
* Falls back to the default shell if no automation profile is configured.
*/
export function getAutomationShell(): string | null {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function works well, but could benefit from more detailed JSDoc comments explaining:

  • When it returns null vs a string
  • The precedence of automation profile over default profile
  • The security validation that happens

This would help other developers understand the function's behavior without reading the implementation.

}
})

it("uses automation profile shell when configured", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a test case for when getAutomationShell() throws an exception? It would be good to ensure the Terminal constructor handles this gracefully and falls back to default behavior.

// --------------------------------------------------------------------------
// Automation Shell Detection Tests
// --------------------------------------------------------------------------
describe("Automation Shell Detection", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The automation shell tests have great coverage! Though for consistency with the main shell detection tests above, we could consider reorganizing these into more structured platform-specific describe blocks. Not critical, but might improve readability.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 11, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Sep 12, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Sep 12, 2025
@daniel-lxs
Copy link
Member

Closing this PR as the approach doesn't align with the proper solution. The fix should allow users to select a terminal profile from settings rather than automatically using the automation profile. See issue #7892 for the detailed solution.

@daniel-lxs daniel-lxs closed this Sep 12, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 12, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Sep 12, 2025
@daniel-lxs daniel-lxs deleted the fix/use-automation-profile-for-terminals branch September 12, 2025 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Needs Preliminary Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Use VS Code automationProfile for spawned terminals (avoid default shell mismatch)

4 participants