Launch agent host terminals as login shells on macOS#312057
Merged
anthonykim1 merged 3 commits intomicrosoft:mainfrom Apr 23, 2026
Merged
Launch agent host terminals as login shells on macOS#312057anthonykim1 merged 3 commits intomicrosoft:mainfrom
anthonykim1 merged 3 commits intomicrosoft:mainfrom
Conversation
On macOS, the agent host terminal manager was spawning zsh/bash without --login, resulting in /etc/zprofile and ~/.zprofile not being sourced. This could cause missing PATH entries (e.g. homebrew, nvm, pyenv) since macOS relies on path_helper in /etc/zprofile for standard PATH setup. The regular VS Code terminal already handles this via the profile resolver, but the agent host bypasses that layer and spawns shells directly via node-pty. This adds the same --login logic inline. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the agent host’s terminal spawning logic to better match VS Code’s integrated terminal behavior on macOS by launching zsh/bash as login shells, ensuring standard profile scripts are sourced and PATH is correctly initialized.
Changes:
- Detect zsh/bash on macOS and pass
--loginwhen spawning the shell vianode-pty. - Plumb the computed shell args through
getShellIntegrationInjectionso shell integration can translate login intent appropriately.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/agentHost/node/agentHostTerminalManager.ts | Adds macOS login-shell argument handling for zsh/bash before shell integration injection and PTY spawn. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
Address review feedback: - Use regex match /(zsh|bash)/ instead of strict equality to handle versioned shell names like bash-5.2 (matching the profile resolver) - Reuse getSystemShell() from src/vs/base/node/shell.ts instead of a custom _getDefaultShell(), which handles edge cases like /bin/false fallback and userInfo().shell when $SHELL is unset Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
anthonykim1
commented
Apr 23, 2026
| return process.env['COMSPEC'] || 'cmd.exe'; | ||
| } | ||
| return process.env['SHELL'] || '/bin/sh'; | ||
| private _getDefaultShell(): Promise<string> { |
Contributor
Author
There was a problem hiding this comment.
match
vscode/src/vs/platform/terminal/node/ptyService.ts
Lines 499 to 500 in 0a8abf6
anthonykim1
commented
Apr 23, 2026
| let shellArgs: string[] = []; | ||
| if (platform.isMacintosh) { | ||
| const shellName = pathParse(shell).name; | ||
| if (shellName.match(/(zsh|bash)/)) { |
Contributor
Author
There was a problem hiding this comment.
TylerLeonhardt
previously approved these changes
Apr 23, 2026
roblourens
approved these changes
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #312059 + shell detection (see my review comments
The agent host terminal manager spawns zsh/bash without
--loginon macOS, which means things like zprofile and bash profile do not run and can lead to missing reference for node, cargo, etc.This is what we do in terminal profile:
vscode/src/vs/workbench/contrib/terminal/browser/terminalProfileResolverService.ts
Lines 245 to 247 in 0a8abf6
However, the agent host was passing empty args here, skipping the login variant:
vscode/src/vs/platform/agentHost/node/agentHostTerminalManager.ts
Lines 214 to 217 in 0a8abf6
The shell integration injection maps empty args to
-iinstead of-ilvscode/src/vs/platform/terminal/node/terminalEnvironment.ts
Lines 197 to 205 in 0a8abf6
/cc @meganrogge @connor4312