Skip to content

automations: fix: honor worktree and provider session configuration - #335018

Merged
Ulugbek Abdullaev (ulugbekna) merged 15 commits into
mainfrom
ulugbekna/agents/disable-new-worktree-automations
Sep 10, 2026
Merged

automations: fix: honor worktree and provider session configuration#335018
Ulugbek Abdullaev (ulugbekna) merged 15 commits into
mainfrom
ulugbekna/agents/disable-new-worktree-automations

Conversation

@ulugbekna

@ulugbekna Ulugbek Abdullaev (ulugbekna) commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

An automation stores two different kinds of state. Its target identifies the provider, agent/session type, workspace, isolation mode, and base branch. Its provider-owned session template stores model selection and model options, a custom agent, and native configuration such as Mode and Approvals.

Both must survive editing and later execution. The browser can dispatch a legacy automation, while a migrated automation runs directly in the Agent Host, including after a host restart. Saved preferences are not permission grants: the current provider schema and managed policy still determine effective behavior.

What was broken

The Automation dialog gated New Worktree on a Copilot-CLI-only declaration, even though worktree isolation is implemented by the shared host for other agents, including Claude and Codex. It also asked the local Git extension for every target's repository. That extension rejects remote workspace URIs, so merely enabling the checkbox would not fix remote automations.

Several adjacent configuration paths were also incomplete:

  • Generic provider configuration lived in the ordinary composer's repository toolbar, which the Automation dialog did not render.
  • Cloud model restoration updated the displayed model but bypassed the extension's model option. A late option catalogue could therefore disagree with the displayed selection.
  • Cloud Sandbox routing came from an unrelated ordinary-composer preference rather than the saved automation.
  • Restored fallback-CLI approval preferences overwrote the initially policy-clamped value.
  • A host automation inherited its creation-time model into the first message, but not its selected custom agent.
  • Host-generated session IDs were marked worktree-pending too late to prevent Codex prewarming in the source checkout.
  • Codex workspace-agent URI matching did not account for worktree execution, especially when subsequent or restored turns repeated the original agent selection.

How the fixes work

Provider-owned worktree discovery

ISessionsProvider.getWorktreeOptions now exposes workspace-specific worktree support, the current branch, initial branch choices, and an optional loader for incomplete result sets.

Agent Host providers resolve these choices on the selected host. Branch searches reuse that resolved configuration rather than re-resolving the full schema for every query. Providers without the operation retain the existing local Git path.

This keeps shared Automation UI provider-neutral. The static Agent Host declaration no longer singles out Copilot; the host's workspace schema determines whether worktrees can actually be chosen.

Remote completion windows are not treated as complete branch inventories. A saved or searched branch outside the initial window is not falsely marked unavailable. Search immediately removes selectable stale results, exposes loading, and supports retry. Related target/provider notifications are coalesced before starting repository work. Shared IME cancellation behavior is explicitly outside this PR's scope.

If a saved Worktree target becomes unsupported, its checkbox can still be unchecked. After opting out, normal repository availability checks must pass before Worktree can be enabled again. Explicit worktree targets submitted through the automation tool also resolve workspace-specific support before persistence.

Provider-native session controls and preferences

The Automation controls reuse native provider configuration pickers. Generic enum/boolean settings are available alongside dedicated provider Mode and Approvals controls, without duplicating worktree/branch controls or exposing transient/session-only fields.

Cloud automations can display and save the existing Sandbox choice. Restoration does not rewrite ordinary-composer defaults. Explicit picker changes retain the existing shared-default semantics.

Cloud model selection now synchronizes its extension option through the same path for interactive changes, template restoration, and late option discovery. Canonical values take precedence over compatibility aliases, and unknown provider preferences remain intact.

Fallback CLI approvals retain the saved preference separately from the policy-effective observable value. Display and execution use the effective value; capture preserves unchanged intent.

Execution and custom agents

The first host automation message inherits creation-time model and agent selections independently, while preserving explicit message overrides.

Session IDs are allocated before provider creation, so both supplied and generated IDs are worktree-pending before eager provider work can start. Failure paths clear the pending state.

Codex resolves original workspace-agent selections at customization launch using host worktree metadata and canonical repository roots. It preserves the original persisted selection rather than rewriting protocol identity. Regression coverage includes repeated changeAgent calls, provider reload, linked source checkouts, and plugin/external selections that must not be redirected.

Provider coverage and intentional limits

Provider Worktree behavior Configuration coverage
Local/remote Agent Host Copilot CLI Host schema and host branch discovery Model/options, custom agent, native Mode/Approvals, opaque template values
Local/remote Agent Host Claude Same host-owned isolation path Model/options, custom agent, native permission-mode configuration
Local/remote Agent Host Codex Same path, with pending-start and agent-restoration repairs Model/options, custom agent, native mode/approval presets
Other schema-driven Agent Hosts Capability comes from the workspace schema, not the provider name Generic supported controls remain provider-owned
Fallback Copilot CLI Existing local Git/worktree path Model/options, custom modes/agents, saved versus effective approvals
Copilot Cloud Worktrees remain unsupported Cloud model option and saved Sandbox routing

Cloud custom agents and workspace-less Cloud sessions remain unsupported. Transient local Dev Container handoff controls are not newly made into Automation template fields; selecting an existing remote/container host continues through the remote-provider boundary. No new protocol fields, user settings, dependencies, or policy channels are introduced.

Shared ActionList scope

This PR makes no changes to src/vs/platform/actionWidget/browser/actionList.ts or its tests. The two shared IME fixes have been removed from this branch and are delivered separately in #335578.

This deliberately allows the provider/worktree fixes to land without changing a component consumed by many unrelated surfaces. Until the separate IME fix lands, cancelling IME composition during a pending remote branch search while retaining the same query can leave that picker loading. Changing the query or reopening the picker remains the workaround. That edge case is not claimed fixed by this PR.

Resolved follow-up fixes

The two worktree follow-up fixes remain in this PR. The shared IME follow-up has moved to separate delivery:

  1. Workspace validation in the tool (ad39403b982): explicit worktree targets use the selected provider's getWorktreeOptions before creation or update. Missing repositories and unsupported results become tool input errors. Registered legacy providers without the optional operation keep their previous behavior. Cancellation interrupts a pending lookup without writing; provider errors propagate rather than becoming successful targets. Non-worktree and unrelated partial updates do not perform repository discovery.
  2. Unavailable Worktree recovery (1729876db3a): the saved-branch exception applies only while Worktree is active. Users can still opt out, but cannot turn Worktree back on while repository discovery is missing, loading, failed, or empty.
  3. Narrow shared IME retries: removed from this PR together with the initial shared IME fix, for independent component-level review and landing.

All four Astra lenses reviewed the complete six-file follow-up diff and returned Ship, with no findings or file modifications.

Rebase on current main

The original fixes were subsequently rebased onto 5559183ea8eeb0fda5cdce67967f9bdc3af6e2e5. Resolutions preserve upstream combobox/type-to-filter tests, Codex workspace-less customization filtering and telemetry, relocated Dev Container controls, and updated provider imports. The reload regression now answers the upstream thread metadata read before resume. Test adaptations remain folded into the owning fixes.

The later extraction removed exactly the two ActionList commits: both shared files match the base, and every other file is byte-for-byte identical to the pre-extraction branch. Both handled Copilot review threads remain resolved.

Validation

After removing the shared ActionList changes:

  • 308 targeted tests passed across automation tools/dialog/model, upstream ActionWidget suites, and existing dynamic-picker consumers.
  • Confirmed that both ActionList files have zero diff against the PR base.
  • Confirmed that every other file is unchanged from the previously tested branch.
  • The remaining history contains 15 focused fix commits.

Rebase validation:

  • 1,408 affected unit tests passed, with 27 existing pending tests.
  • After the final upstream Codex image-attachment update, 103 focused Codex tests passed, including worktree/prewarm coverage. These overlap the earlier selection and are not an additional unique-test total.
  • Five strict real-provider replay scenarios passed again on the final rebased tree.
  • TypeScript, layering, changed-file lint, diff checks, and normal commit hygiene passed with dependencies restored from the current main lockfile.

Follow-up validation:

  • 232 targeted tests passed across the automation tool/dialog/isolation model, shared ActionWidget suites, and both existing Agent Host dynamic-picker consumers.
  • Regression-first testing reproduced the four invalid re-enablement states and both completed-search retry states before their fixes.
  • npm run typecheck-client, six-file ESLint, git diff --check, and each commit's normal hygiene hook passed.

Earlier validation of the original implementation:

  • 1,195 unit tests passed, with 27 existing pending tests, across the affected Automation, provider, Codex, and shared ActionWidget suites.
  • Five strict replay E2E scenarios passed using the real bundled runtimes and AHP:
    • Host session configuration resolves and completes Git branches.
    • Correct working-directory creation for Copilot CLI, Claude, and Codex.
    • Copilot automation Mode and Approvals survive a host restart and run.
  • npm run typecheck-client passed.
  • npm run valid-layers-check passed.
  • Changed-file ESLint and git diff --check passed.

The replay scenarios use committed model traffic, not live model services. Cloud and arbitrary remote deployment behavior is covered at the provider-adapter boundary; no paid Cloud runs or live third-party remote-host jobs were launched.

Review

Two complete independent four-lens Astra reviews covered architecture, performance, UI/UX, and correctness/simplicity. All findings were addressed with regressions. Astra then independently verified the final IME-cancellation and duplicate-lookup follow-ups and reported no remaining evidence-backed issues in those repairs.

Later Copilot review identified two worktree validation issues, and a shared-component scope review identified the completed-request retry concern. A complete four-lens Astra review of the follow-up fixes returned Ship in every lens. The two worktree fixes remain here; the reviewed shared-component fixes have since been deliberately extracted for independent landing.

Copilot AI balanced review requested due to automatic review settings September 8, 2026 09:09

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.

Copilot review overview

🟡 Changes recommended

Workspace-specific worktree validation remains incomplete, allowing unsupported targets to be re-enabled or created through the Automation tool.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 2 Medium severity

New issues introduced by this change (2)
Severity Finding
Medium severity src/​vs/​sessions/​contrib/​automations/​browser/​automationDialog.ts — This does not fully prevent re-enabling an unsupported saved target. After unchecking Worktree,…
Medium severity src/​vs/​sessions/​services/​sessions/​common/​sessionsProvider.ts — The new workspace-specific capability is not consulted by ConfigureAutomationTool:…
What changed in this PR

This PR preserves provider-owned worktree and session configuration across Automation editing, execution, and Agent Host restarts.

Changes:

  • Adds workspace-specific provider worktree discovery and remote branch filtering.
  • Persists models, agents, sandbox, modes, and effective approval preferences correctly.
  • Fixes Agent Host worktree initialization and Codex custom-agent routing.
File Description
src/​vs/​sessions/​SESSIONS.md Documents provider-owned worktree discovery.
src/​vs/​sessions/​services/​sessions/​common/​sessionsProvider.ts Adds the worktree-options provider API.
src/​vs/​sessions/​contrib/​automations/​browser/​automationDialog.ts Integrates provider branch and capability discovery.
src/​vs/​sessions/​contrib/​automations/​test/​browser/​automationDialog.test.ts Covers Automation worktree behavior.
src/​vs/​sessions/​contrib/​chat/​browser/​branchPicker.ts Adds asynchronous branch filtering states.
src/​vs/​platform/​actionWidget/​browser/​actionList.ts Handles canceled IME-driven dynamic filtering.
src/​vs/​platform/​actionWidget/​test/​browser/​actionList.test.ts Tests dynamic-filter restart behavior.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​baseAgentHostSessionsProvider.ts Implements Agent Host worktree options and template capture.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​agentHostSessionConfigPicker.ts Exposes provider configuration in Automations.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​agentHostSessionConfigPicker.test.ts Tests Automation configuration controls.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​localAgentHostSessionsProvider.test.ts Covers local Agent Host configuration persistence.
src/​vs/​sessions/​contrib/​providers/​remoteAgentHost/​test/​browser/​remoteAgentHostSessionsProvider.test.ts Tests remote worktree discovery.
src/​vs/​sessions/​contrib/​providers/​copilotChatSessions/​browser/​copilotChatSessionsProvider.ts Preserves Cloud and fallback CLI preferences.
src/​vs/​sessions/​contrib/​providers/​copilotChatSessions/​browser/​copilotChatSessionsActions.ts Adds Sandbox to Automation controls.
src/​vs/​sessions/​contrib/​providers/​copilotChatSessions/​test/​browser/​copilotChatSessionsProvider.test.ts Tests model, sandbox, agent, and approval restoration.
src/​vs/​sessions/​contrib/​providers/​copilotChatSessions/​test/​browser/​sandboxPicker.test.ts Verifies Sandbox menu visibility.
src/​vs/​platform/​agentHost/​node/​agentService.ts Marks generated sessions worktree-pending before creation.
src/​vs/​platform/​agentHost/​test/​node/​agentService.test.ts Tests pending-state timing and cleanup.
src/​vs/​platform/​agentHost/​node/​agentHostAutomationService.ts Inherits initial model and agent selections.
src/​vs/​platform/​agentHost/​test/​node/​agentHostAutomationService.test.ts Tests first-message selection inheritance.
src/​vs/​platform/​agentHost/​node/​codex/​codexAgent.ts Resolves workspace agents inside worktrees.
src/​vs/​platform/​agentHost/​test/​node/​codex/​codexPrewarmEviction.test.ts Covers Codex prewarming and agent restoration.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/vs/sessions/contrib/automations/browser/automationDialog.ts
Comment thread src/vs/sessions/services/sessions/common/sessionsProvider.ts
@ulugbekna
Ulugbek Abdullaev (ulugbekna) force-pushed the ulugbekna/agents/disable-new-worktree-automations branch from 5e63915 to 174a44d Compare September 8, 2026 09:41
@ulugbekna
Ulugbek Abdullaev (ulugbekna) force-pushed the ulugbekna/agents/disable-new-worktree-automations branch from 80d9e48 to 48230e4 Compare September 10, 2026 16:38
@ulugbekna
Ulugbek Abdullaev (ulugbekna) marked this pull request as ready for review September 10, 2026 21:49
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Sandeep Somavarapu (@sandy081)

Matched files:

  • src/vs/sessions/services/sessions/common/sessionsProvider.ts

Ladislau Szomoru (@lszomoru)

Matched files:

  • src/vs/sessions/services/sessions/common/sessionsProvider.ts

@ulugbekna
Ulugbek Abdullaev (ulugbekna) force-pushed the ulugbekna/agents/disable-new-worktree-automations branch from 48230e4 to f824999 Compare September 10, 2026 21:58
@ulugbekna
Ulugbek Abdullaev (ulugbekna) marked this pull request as draft September 10, 2026 22:01
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e4e70d7c-fbe2-487b-a6c5-177af2abae2f
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e4e70d7c-fbe2-487b-a6c5-177af2abae2f
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e4e70d7c-fbe2-487b-a6c5-177af2abae2f
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e4e70d7c-fbe2-487b-a6c5-177af2abae2f
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e4e70d7c-fbe2-487b-a6c5-177af2abae2f
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e4e70d7c-fbe2-487b-a6c5-177af2abae2f
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e4e70d7c-fbe2-487b-a6c5-177af2abae2f
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e4e70d7c-fbe2-487b-a6c5-177af2abae2f
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e4e70d7c-fbe2-487b-a6c5-177af2abae2f
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e4e70d7c-fbe2-487b-a6c5-177af2abae2f
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e4e70d7c-fbe2-487b-a6c5-177af2abae2f
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e4e70d7c-fbe2-487b-a6c5-177af2abae2f
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e4e70d7c-fbe2-487b-a6c5-177af2abae2f
Consult provider-owned workspace capabilities before accepting an explicit worktree target. Preserve legacy providers and unrelated edits, propagate lookup failures, and cancel pending validation without writing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e4e70d7c-fbe2-487b-a6c5-177af2abae2f
Keep the saved-branch exception only while Worktree is already selected. After opting out, require available repository branches before enabling isolation again.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e4e70d7c-fbe2-487b-a6c5-177af2abae2f
@ulugbekna
Ulugbek Abdullaev (ulugbekna) merged commit 1328607 into main Sep 10, 2026
33 checks passed
@ulugbekna
Ulugbek Abdullaev (ulugbekna) deleted the ulugbekna/agents/disable-new-worktree-automations branch September 10, 2026 23:01
@vs-code-engineering vs-code-engineering Bot added this to the 1.138.0 milestone Sep 10, 2026
Ulugbek Abdullaev (ulugbekna) added a commit that referenced this pull request Sep 10, 2026
Revert 1328607 (#335018) so the worktree availability fix and unrelated provider configuration changes can be reviewed separately. Preserve subsequent main changes and the independent ActionList PR.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e4e70d7c-fbe2-487b-a6c5-177af2abae2f
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