Skip to content

sessions: use OS-specific task overrides for local agent host tasks#322336

Merged
benibenj merged 2 commits into
mainfrom
agents/fix-windows-bat-script-integration-86a93295
Jun 22, 2026
Merged

sessions: use OS-specific task overrides for local agent host tasks#322336
benibenj merged 2 commits into
mainfrom
agents/fix-windows-bat-script-integration-86a93295

Conversation

@benibenj

Copy link
Copy Markdown
Contributor

What

The agent host session task runner (used by the Run Script action in the Agents window titlebar) always emitted the POSIX (.sh) command when resolving a task, ignoring the windows/osx/linux overrides declared in tasks.json.

On Windows this meant Run and Compile Agents - OSS ran:

npm run transpile-client && ./scripts/code.sh --agents ...

instead of the Windows variant using .\scripts\code.bat.

Why

AgentHostSessionTaskRunner.runTask called resolveTaskCommand(task, ...) without a targetOS, so taskCommand.ts never selected the OS-specific command/args overrides.

Changes

  • taskCommand.ts: added an exported pure helper osToTaskTargetOS(os) mapping OperatingSystem → the windows/osx/linux keys used in tasks.json.
  • agentHostSessionTaskRunner.ts: pass targetOS to resolveTaskCommand. For the local agent host (runs on the same machine as the renderer) it uses the renderer's OS, so on Windows the .bat override is picked. Remote hosts (OS unknown here) keep falling back to the task's default command. Also extracted the __local__ sentinel into a LOCAL_AGENT_HOST_ADDRESS constant.
  • Added unit tests for the OS mapping and for OS-specific override resolution in the runner.

Notes for reviewers

  • Remote agent hosts do not expose their OS to the renderer, so the default (POSIX) command is kept for them — a follow-up could plumb remote OS through if needed.
  • The build/typecheck toolchain (tsgo) was not available in the dev environment, but the pre-commit hygiene hook passed.

The agent host session task runner always emitted the POSIX (.sh) command
when resolving tasks, ignoring the windows/osx/linux overrides in tasks.json.
On Windows this meant 'Run and Compile Agents - OSS' ran ./scripts/code.sh
instead of .\scripts\code.bat.

Pass targetOS to resolveTaskCommand for the local agent host (which runs on
the same machine as the renderer) so the renderer's OS picks the right
override. Remote hosts, whose OS is unknown here, keep falling back to the
task's default command.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 22, 2026 08:29
@benibenj benibenj enabled auto-merge (squash) June 22, 2026 08:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes task command resolution for the Agents window’s Run Script flow so that OS-specific tasks.json overrides (windows/osx/linux) are honored for local agent host sessions (where the renderer OS matches the host OS), while keeping the existing default-command behavior for remote agent hosts (OS unknown at this layer).

Changes:

  • Add an OperatingSystemtasks.json OS key mapping helper (osToTaskTargetOS) in taskCommand.ts.
  • Pass targetOS into resolveTaskCommand for local agent host sessions in AgentHostSessionTaskRunner, and replace the inline local-host sentinel with a named constant.
  • Add unit tests covering the OS mapping and local-session OS-specific override behavior.
Show a summary per file
File Description
src/vs/sessions/contrib/chat/browser/taskCommand.ts Adds osToTaskTargetOS helper to map OperatingSystem to tasks.json override keys.
src/vs/sessions/contrib/terminal/browser/agentHostSessionTaskRunner.ts Uses renderer OS to pick OS-specific command overrides for local agent host task execution; introduces LOCAL_AGENT_HOST_ADDRESS constant.
src/vs/sessions/contrib/chat/test/browser/taskCommand.test.ts Adds unit test verifying osToTaskTargetOS mapping.
src/vs/sessions/contrib/terminal/test/browser/agentHostSessionTaskRunner.test.ts Adds unit test verifying OS-specific overrides apply for local agent host sessions.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 1

Comment thread src/vs/sessions/contrib/chat/browser/taskCommand.ts
Add a default branch so the function always returns a TaskTargetOS,
satisfying noImplicitReturns and avoiding undefined for unexpected
enum values.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@benibenj benibenj closed this Jun 22, 2026
auto-merge was automatically disabled June 22, 2026 09:28

Pull request was closed

@benibenj benibenj reopened this Jun 22, 2026
@benibenj benibenj enabled auto-merge (squash) June 22, 2026 09:29
@benibenj benibenj merged commit d1a5e5e into main Jun 22, 2026
45 of 53 checks passed
@benibenj benibenj deleted the agents/fix-windows-bat-script-integration-86a93295 branch June 22, 2026 09:41
@vs-code-engineering vs-code-engineering Bot added this to the 1.127.0 milestone Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants