Skip to content

automations: fix: enable supported worktree targets - #335593

Open
Ulugbek Abdullaev (ulugbekna) wants to merge 8 commits into
mainfrom
ulugbekna/fix-automation-worktree-gating
Open

automations: fix: enable supported worktree targets#335593
Ulugbek Abdullaev (ulugbekna) wants to merge 8 commits into
mainfrom
ulugbekna/fix-automation-worktree-gating

Conversation

@ulugbekna

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

Copy link
Copy Markdown
Contributor

Fix falsely disabled automation worktree selection

Contents

Stack and purpose

This is the smaller replacement for the worktree portion of #335018.

It is based on the revert branch in #335591, not directly on main, so this PR's diff contains only the seven worktree/startup fixes. Review and land the revert first, then this PR. The remaining provider configuration changes are held in draft #335595, stacked on this branch.

The goal is that New Worktree is selectable for a supported Codex, Claude, or other Agent Host automation target, while unavailable or non-repository targets are rejected instead of silently promising isolation.

Root cause

The automation dialog read a session-type capability that was hard-coded to Copilot CLI. Codex and Claude therefore appeared unsupported even though the Agent Host owns worktree isolation for their sessions.

The dialog also used the local Git extension to discover every target's repository and branches. That cannot discover repositories on a remote Agent Host. Merely removing the Copilot-only flag would leave remote targets incorrectly unavailable.

Included fixes

  1. Advertise host-owned worktree configuration for all advertised Agent Host agents. Workspace-specific support still comes from the host's schema.
  2. Obtain workspace support, current branch, and branch choices through a provider-owned operation. Remote search reuses the resolved context, and partial completion results do not falsely mark saved branches unavailable.
  3. Allow opting out of a saved Worktree selection when support disappears.
  4. After opting out, require normal repository availability before Worktree can be selected again; a retained branch is not a bypass.
  5. Validate workspace-specific worktree support when the configure tool creates or changes an explicit worktree target. Unsupported/missing options reject the target, cancellation makes no changes, and provider errors are not silently treated as success. Legacy providers without the optional operation retain their previous behavior.
  6. Coalesce duplicate repository lookups from related target/provider notifications.
  7. Mark generated session IDs worktree-pending before eager provider startup. This prevents Codex prewarming in the source checkout before host isolation is ready; failed creation cleans the pending state.

The implementation remains provider-neutral in shared Sessions code. Tests cover supported provider choices, remote branch discovery/search, unavailable targets, cancellation and recovery, and startup ordering.

Explicit exclusions

This PR does not change:

  • Cloud model restoration, compatibility fields, or Sandbox routing;
  • fallback CLI approval-policy preference handling;
  • custom-agent first-turn inheritance or Codex custom-agent restoration;
  • provider-native configuration toolbars;
  • the shared ActionList implementation or its tests.

Those provider-configuration and custom-agent fixes are held for separate draft review. The shared IME fix is independently tracked in #335578.

Until that IME fix lands, cancelling composition during a pending remote branch search without changing the query can leave the picker loading. Changing the query or reopening it remains the workaround. This smaller PR does not claim to fix that shared-component edge case.

Validation

  • 977 targeted unit tests passed, with 27 existing pending tests.
  • Five strict real-provider replay scenarios passed, covering host branch configuration, Copilot/Claude/Codex working directories, and automation configuration after host restart.
  • npm run typecheck-client passed.
  • Changed-file ESLint, git diff --check, and normal commit hygiene passed.
  • The diff is seven focused commits across 12 files, with no Cloud provider, custom-agent execution, native configuration-picker, or ActionList files.
  • The source changes are reintroduced from the previously reviewed worktree fixes. A Cloud-only regression was moved to the draft remainder rather than pulling its unrelated suite into this PR.
  • Full Code OSS, Component Fixtures and CodeQL pull-request workflows target main/release branches; they do not run against this stacked feature-branch base. After the revert lands, retarget this PR to main and require the normal CI before landing.

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
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
@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

Base automatically changed from ulugbekna/revert-automation-config-scope to main September 10, 2026 23:47
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.

2 participants