Skip to content

Copilot CLI with Agent Host should respect user shell from terminal profile when running shell commands #313679

Merged
anthonykim1 merged 17 commits into
mainfrom
anthonykim1/betterTerminalAhp
May 5, 2026
Merged

Copilot CLI with Agent Host should respect user shell from terminal profile when running shell commands #313679
anthonykim1 merged 17 commits into
mainfrom
anthonykim1/betterTerminalAhp

Conversation

@anthonykim1
Copy link
Copy Markdown
Contributor

@anthonykim1 anthonykim1 commented May 1, 2026

Resolves: #313160

Existing behavior we already have with Copilot CLI in chat:

existingRespect Shows that we respect user's default terminal profile setting.

Achievement with the PR:

New terminal agent host terminal that will be first priority:
agentHostProfileSupercedeDefaultProfile

If above is not set, we use user's default terminal profile:
agentHostUseDefaultProfile

Allow Agent Host (local) to respect profile (more like path executable since args and env are ignored atm) :
image

anthonykim1 and others added 2 commits April 30, 2026 08:33
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@anthonykim1 anthonykim1 added this to the 1.119.0 milestone May 1, 2026
@anthonykim1 anthonykim1 self-assigned this May 1, 2026
Copilot AI review requested due to automatic review settings May 1, 2026 06:53
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Base: 43c1c17c Current: f8ec82d7

No screenshot changes.

Co-authored-by: Copilot <copilot@github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an agent-host–specific terminal profile setting and plumbing so that Copilot CLI shell tools running via the Agent Host use the user’s preferred terminal profile (instead of hardcoded shells), with fallback to the existing integrated terminal default profile.

Changes:

  • Introduces terminal.integrated.agentHostProfile.<os> settings and corresponding resolver support (allowAgentHostShell) to prefer that profile when resolving the default.
  • Bridges the resolved default shell from the workbench into the agent host root config (defaultShell) and consumes it in the agent-host terminal manager.
  • Updates Copilot shell tools to use the terminal manager’s resolved default shell and adds/updates unit tests around shell resolution/classification.
Show a summary per file
File Description
src/vs/workbench/contrib/terminal/common/terminal.ts Adds allowAgentHostShell resolve option to support agent-host-specific profile preference.
src/vs/workbench/contrib/terminal/browser/terminalProfileResolverService.ts Prefers agent host profile (when allowed) during default profile resolution.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostTerminalContribution.ts Resolves the agent-host shell profile and pushes the executable path to agent host root config.
src/vs/platform/terminal/common/terminalPlatformConfiguration.ts Registers new terminal.integrated.agentHostProfile.<os> settings with schema and descriptions.
src/vs/platform/terminal/common/terminal.ts Adds TerminalSettingId.AgentHostProfile* constants.
src/vs/platform/agentHost/common/agentHostCustomizationConfig.ts Adds AgentHostConfigKey.DefaultShell to agent host root-config schema.
src/vs/platform/agentHost/node/agentService.ts Plumbs configuration service into AgentHostTerminalManager construction.
src/vs/platform/agentHost/node/agentHostTerminalManager.ts Implements getDefaultShell() honoring root-config defaultShell with fallback to system shell.
src/vs/platform/agentHost/node/copilot/copilotShellTools.ts Resolves shell executable from terminal manager, makes tool factory async, and adds shell classification helpers + redirect tool.
src/vs/platform/agentHost/node/copilot/copilotAgent.ts Adjusts session config building to await async shell tool creation.
src/vs/platform/agentHost/test/node/copilotShellTools.test.ts Expands tests to cover terminal-manager-resolved executable and shell classification helpers.
src/vs/platform/agentHost/test/node/copilotAgent.test.ts Updates terminal manager test stub to implement getDefaultShell().

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/platform/agentHost/node/agentHostTerminalManager.ts:205

  • Even after receiving AgentHostConfigKey.DefaultShell, createTerminal can only use the executable path; any profile-specific arguments are not representable (beyond the hard-coded macOS --login behavior). If we want agent host terminals to truly respect terminal profiles, consider supporting configured default shell arguments (and potentially env) in the root config and using them here when spawning the PTY.
		const shell = options?.shell ?? await this.getDefaultShell();
		const name = platform.isWindows ? 'cmd' : 'xterm-256color';

		this._logService.info(`[TerminalManager] Creating terminal ${uri}: shell=${shell}, cwd=${cwd}, cols=${cols}, rows=${rows}`);

  • Files reviewed: 12/12 changed files
  • Comments generated: 3

Comment thread src/vs/platform/agentHost/node/copilot/copilotShellTools.ts Outdated
anthonykim1 and others added 3 commits May 1, 2026 00:30
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
stasyu2009-ux

This comment was marked as spam.

anthonykim1 and others added 2 commits May 1, 2026 08:48
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@anthonykim1 anthonykim1 moved this to In Progress in Agent Host Protocol May 1, 2026
stasyu2009-ux

This comment was marked as spam.

@anthonykim1 anthonykim1 changed the title Copilot CLI with Agent Host should respect user setting when running shell commands Copilot CLI with Agent Host should respect user shell from terminal profile when running shell commands May 1, 2026
return;
}

this._agentHostService.dispatch({
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should make sure the agent host has a AgentHostConfigKey.DefaultShell in its rootState.config.schema prior to pushing down the config. You may need to wait until onDidChange for the root state to get hydrated.

We'd also need to dispatch to the connections in IRemoteAgentHostService, this is only the local service that you're listning to right now

Copy link
Copy Markdown
Contributor Author

@anthonykim1 anthonykim1 May 4, 2026

Choose a reason for hiding this comment

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

Thanks! this makes sense.
Remote one is tricky - I think I'd need to figure out how to get remote profile resolver, since we can't just use remoteAuthority

The schema-gating piece has been addressed per feedback in 40ba2c1:

  • _pushDefaultShell now no-ops until the local host root config schema advertises AgentHostConfigKey.DefaultShell, retries when rootState hydrates/changes.
  • has tests covering the hydrated/missing-schema cases.

I also clarified the setting wording in cf72e32 so it does not imply full profile fidelity or remote support.

  • It now says this currently applies to the local agent host, and notes that remote agent hosts need remote-side shell configuration because local resolved paths may be invalid on the remote.

I split the remaining pieces into follow-ups so this PR can stay focused:

@connor4312 Does that split match what you had in mind?

Co-authored-by: Copilot <copilot@github.com>
anthonykim1 and others added 2 commits May 1, 2026 15:28
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
anthonykim1 and others added 3 commits May 1, 2026 15:52
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
stasyu2009-ux

This comment was marked as spam.

@microsoft microsoft deleted a comment from stasyu2009-ux May 4, 2026
@microsoft microsoft deleted a comment from stasyu2009-ux May 4, 2026
@microsoft microsoft deleted a comment from stasyu2009-ux May 4, 2026
@microsoft microsoft deleted a comment from stasyu2009-ux May 4, 2026
@microsoft microsoft deleted a comment from stasyu2009-ux May 4, 2026
@microsoft microsoft deleted a comment from stasyu2009-ux May 4, 2026
@microsoft microsoft deleted a comment from stasyu2009-ux May 4, 2026
@microsoft microsoft deleted a comment from stasyu2009-ux May 4, 2026
@microsoft microsoft deleted a comment from stasyu2009-ux May 4, 2026
@microsoft microsoft deleted a comment from stasyu2009-ux May 4, 2026
@anthonykim1 anthonykim1 marked this pull request as ready for review May 4, 2026 04:18
@anthonykim1 anthonykim1 requested a review from connor4312 May 4, 2026 04:18
@anthonykim1 anthonykim1 modified the milestones: 1.119.0, 1.120.0 May 4, 2026
@anthonykim1 anthonykim1 merged commit 8b28f91 into main May 5, 2026
26 checks passed
@anthonykim1 anthonykim1 deleted the anthonykim1/betterTerminalAhp branch May 5, 2026 05:49
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Agent Host Protocol May 5, 2026
@sheetsync
Copy link
Copy Markdown

@anthonykim1 @connor4312 Thank you both enormously for this! It's a small change, but it'll make a huge difference to us as we don't have modern Powershell running on our locked-down corporate build, so having the Agents UI respect the terminal choice from the IDE means (hopefully) that the Agents UI is actually usable.

I'm super pleased about this. Thanks again.

Copy link
Copy Markdown

@stasyu2009-ux stasyu2009-ux left a comment

Choose a reason for hiding this comment

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

Код правильно працює

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Respect the user's preferred shell in agent host terminals

6 participants