Skip to content

Pipe terminal-profile args (and decide on env) to the agent host #313790

@anthonykim1

Description

@anthonykim1

Follow-up to #313160 / #313679.

#313679 made the agent host respect the user's preferred shell executable by piping terminal.integrated.agentHostProfile.<os> (with fallback to defaultProfile.<os>) down to the agent host as AgentHostConfigKey.DefaultShell. Only the path is honored today — args and env from the profile are silently dropped.

That means a user with, say:

"terminal.integrated.profiles.windows": {
    "Git Bash": { "source": "Git Bash", "args": ["--login", "-i"] }
}

…gets bash.exe spawned in the agent host without --login -i, so their ~/.bash_profile doesn't run, PATH tweaks/aliases/exports the user expects don't apply. Same story for --noprofile, custom --rcfile, oh-my-zsh-style -i, etc. macOS bash/zsh --login is the only argument added automatically today (in AgentHostTerminalManager.createTerminal).

Reasons we deferred this on #313679:

  1. Args splicing has order-sensitivity with shell-integration injection. getShellIntegrationInjection overwrites shellArgs with its own newArgs (e.g. --init-file … for bash, -NoProfile -Command "& …" for pwsh). Mixing user args needs per-shell-family rules (before the integration script for bash, before -Command for pwsh, etc.).
  2. Env merging needs an explicit precedence policy with the agent host's curated env. We already set LC_ALL=C.UTF-8, PAGER='', GIT_TERMINAL_PROMPT=0, DEBIAN_FRONTEND=noninteractive, VSCODE_PREVENT_SHELL_HISTORY, plus shell integration's envMixin. User-profile env (e.g. LC_ALL=en_US.UTF-8, PAGER=less, custom PROMPT_COMMAND) can break agent output parsing if merged naively.
  3. The single-string defaultShell wire shape stays clean for headless code agent-host and SSH/tunnel agent hosts, where workbench profile semantics don't apply.

What this issue should cover:

  • Extend the AHP root-config schema to carry args (AgentHostConfigKey.DefaultShellArgs as a sibling string-array key, keeping DefaultShell as-is for back-compat).
  • Workbench bridge in AgentHostTerminalContribution._pushDefaultShell resolves and pushes both keys.
  • AgentHostTerminalManager.createTerminal reads the configured args from root config and splices them in correctly relative to shell-integration injection.
  • Decide on env policy. Options: (a) ignore profile env entirely (current behavior), (b) whitelist a small set, (c) merge with agent-host curated env winning. Probably (a) or (b).
  • Update setting descriptions and AgentHostConfigKey.DefaultShell JSDoc to remove the "args/env are ignored" caveat (or update it to reflect the new behavior).
  • Tests for args splicing per shell family.

/cc #313160 #313679

Metadata

Metadata

Assignees

Labels

agent-hostIssues for the agent-host implementation (not the protocol)feature-requestRequest for new features or functionalityterminalGeneral terminal issues that don't fall under another label

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions