Skip to content

agentHost: add setting to disable worktreeCreated task auto-dispatch#318243

Merged
roblourens merged 3 commits into
mainfrom
agents/vsckb-implement-connor-recently-added-this-featu-045d19df
May 26, 2026
Merged

agentHost: add setting to disable worktreeCreated task auto-dispatch#318243
roblourens merged 3 commits into
mainfrom
agents/vsckb-implement-connor-recently-added-this-featu-045d19df

Conversation

@roblourens
Copy link
Copy Markdown
Member

@roblourens roblourens commented May 25, 2026

Adds a new setting chat.agentHost.runWorktreeCreatedTasks (default false) that gates the WorktreeCreatedTaskDispatcher for agent host sessions.

What this changes

  • New setting chat.agentHost.runWorktreeCreatedTasks (boolean, default false, application-scoped) registered in src/vs/sessions/contrib/chat/browser/chat.contribution.ts.
  • WorktreeCreatedTaskDispatcher now injects IConfigurationService and ISessionsProvidersService. Inside _dispatchWorktreeCreatedTasks, if the session's provider is an agent host provider (via isAgentHostProvider) and the setting is false, the dispatch is logged at trace level and skipped.

What is NOT affected

  • Non-agent-host sessions (e.g. the workbench fallback runner for local file workspaces) — the setting is checked only when isAgentHostProvider(provider).
  • Manual Run Task invocations on agent-host sessions — the gate is in the auto-dispatch path, not in AgentHostSessionTaskRunner. Users can still trigger worktreeCreated-tagged tasks by hand.

Tests

Three new tests added to worktreeCreatedTaskDispatcher.test.ts:

  • Agent host session + setting disabled (default) → skipped.
  • Agent host session + setting enabled → runs.
  • Non-agent-host session + setting disabled → still runs.

Validation

  • npm run compile-check-ts-native
  • npm run valid-layers-check

(Written by Copilot)

Adds `chat.agentHost.runWorktreeCreatedTasks` (default `false`) which
gates `WorktreeCreatedTaskDispatcher` for agent host sessions. The
generic dispatcher now consults the setting before dispatching and skips
agent host sessions when it's disabled. Non-agent-host sessions and
manual `Run Task` invocations are unaffected.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 25, 2026 19:28
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

Adds an application-scoped setting to gate automatic dispatch of worktreeCreated-tagged tasks specifically for agent-host backed sessions in the Agents window, disabling that auto-dispatch by default while related issues are addressed.

Changes:

  • Introduces chat.agentHost.runWorktreeCreatedTasks (default false) and registers it in sessions chat contributions.
  • Updates WorktreeCreatedTaskDispatcher to skip auto-dispatch for agent-host sessions when the setting is disabled.
  • Extends unit tests to cover default-skip, enabled-run, and non-agent-host unaffected behavior.
Show a summary per file
File Description
src/vs/sessions/contrib/chat/test/browser/worktreeCreatedTaskDispatcher.test.ts Adds tests and stubs for configuration/providers to validate the new gating behavior.
src/vs/sessions/contrib/chat/browser/worktreeCreatedTaskDispatcher.ts Adds setting constant and gating logic before auto-dispatching worktreeCreated tasks.
src/vs/sessions/contrib/chat/browser/chat.contribution.ts Registers the new chat.agentHost.runWorktreeCreatedTasks setting in the configuration registry.

Copilot's findings

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

Comment thread src/vs/sessions/contrib/chat/browser/worktreeCreatedTaskDispatcher.ts Outdated
Comment thread src/vs/sessions/contrib/chat/browser/chat.contribution.ts Outdated
Comment thread src/vs/sessions/contrib/chat/test/browser/worktreeCreatedTaskDispatcher.test.ts Outdated
roblourens and others added 2 commits May 25, 2026 12:55
The 3 new agent-host gating tests were creating sessions that already had
a worktree at the time of the 'added' event. _trackSession returns early
in that case (the session isn't 'pending'), so the dispatcher's gate was
never exercised. Match the existing pattern: start with hasWorktree=false,
fire the added event, then set the workspace.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Drop ISessionsProvidersService injection from the dispatcher; check
  session.providerId directly via a new isAgentHostProviderId() helper.
- Improve setting description: quote the actual tasks.json JSON shape.
- await TestConfigurationService.setUserConfiguration in the new test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@roblourens roblourens marked this pull request as ready for review May 25, 2026 21:30
@roblourens roblourens enabled auto-merge (squash) May 25, 2026 21:30
@roblourens roblourens merged commit 631ba38 into main May 26, 2026
25 checks passed
@roblourens roblourens deleted the agents/vsckb-implement-connor-recently-added-this-featu-045d19df branch May 26, 2026 00:51
@vs-code-engineering vs-code-engineering Bot added this to the 1.122.0 milestone May 26, 2026
anthonykim1 added a commit that referenced this pull request May 26, 2026
Squashed cherry-pick of 10 commits from main that are included in the
Insiders build (183159e) people are verifying:

- agentHost: show fetched URL for web_fetch (#318240)
- Fix SSH remote agent host passphrase auth (#318244)
- agentHost: add setting to disable worktreeCreated task auto-dispatch (#318243)
- Agent host: clearer worktree git timeout errors and 60s budget (#318242)
- Normalize LF to CRLF in agent host terminal tool output (#318257)
- sessions: restore X-button removal of SSH remote agent host entries (#318262)
- chat: fix duplicate command registration for agent-host-copilotcli (#318273)
- launch: build copilot in compile; wait for CDP in launch.sh (#318272)
- Preserve unread state across remote host disconnect (#318267)
- Add more codenotify for terminal (#318285)
dileepyavan pushed a commit that referenced this pull request May 27, 2026
Squashed cherry-pick of 10 commits from main that are included in the
Insiders build (183159e) people are verifying:

- agentHost: show fetched URL for web_fetch (#318240)
- Fix SSH remote agent host passphrase auth (#318244)
- agentHost: add setting to disable worktreeCreated task auto-dispatch (#318243)
- Agent host: clearer worktree git timeout errors and 60s budget (#318242)
- Normalize LF to CRLF in agent host terminal tool output (#318257)
- sessions: restore X-button removal of SSH remote agent host entries (#318262)
- chat: fix duplicate command registration for agent-host-copilotcli (#318273)
- launch: build copilot in compile; wait for CDP in launch.sh (#318272)
- Preserve unread state across remote host disconnect (#318267)
- Add more codenotify for terminal (#318285)
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