Skip to content

Automations: Add branch picker#325514

Draft
benvillalobos wants to merge 10 commits into
mainfrom
bv/automations-isolation-checkbox
Draft

Automations: Add branch picker#325514
benvillalobos wants to merge 10 commits into
mainfrom
bv/automations-isolation-checkbox

Conversation

@benvillalobos

@benvillalobos benvillalobos commented Jul 12, 2026

Copy link
Copy Markdown
Member

Adds a branch picker to the automation dialog when the worktree checkbox is selected

image

Fixes Microsoft/vscode-internalbacklog#8308

Replace the folder/worktree isolation dropdown with a Worktree checkbox
(checked = worktree, unchecked = folder) in the automations dialog,
matching the pattern established in the new chat widget isolation picker
(#325249).

The checkbox uses the same Checkbox widget with defaultCheckboxStyles,
size 14, whole-row hit target via Gesture + click/tap. Removes the
IActionWidgetService dependency from the isolation group action view item.

CSS updated in aiCustomizationManagement.css to replace the old chip
rules with checkbox-compatible rules matching the sessions isolation
checkbox styling.
Adds an interactive branch picker chip next to the isolation checkbox.
Branches are loaded from IGitService.openRepository().getRefs() directly,
without creating a draft session. Picker is enabled only in worktree
isolation mode. Filter input shown when branch count exceeds 10.

Filters out copilot-worktree- prefixed branches to match the new chat
widget behavior.
The autorun watching repo.state.HEAD was calling renderBranchChip() which
created new DOM elements and event listeners on every fire without disposing
the previous ones. Over time this accumulated orphaned disposables.

Fix: follow the codebase convention (BranchPicker, IsolationPicker,
SessionTypePicker, PermissionPicker, AgentHostModePicker) of splitting
render into create-once and lightweight-update:

- render() creates the trigger element and wires up listeners once
- updateBranchLabel() only mutates existing DOM (text, icons, aria)
- autorun calls updateBranchLabel() instead of recreating everything

Also fixes indentation in the actionViewItemProvider block and removes
an obvious comment.
The worktree isolation checkbox now requires a workspace selection before
it can be toggled. Without a workspace there is no git repo to branch
from, so the checkbox starts disabled and enables once the user picks a
workspace. Click and onChange handlers are also guarded to prevent
interaction while disabled.
Clear state.branch and update the UI immediately when a new workspace
is selected, before the async git lookup resolves. Prevents stale
branch names from the previous workspace persisting in the picker.
When the user unchecks the Worktree checkbox, clear state.branch
and update the label so it no longer shows a stale branch selection.
Extract IsolationGroupModel into common/ with pure state logic:
- Model owns only user intent (worktreeRequested, selectedBranch) plus
  reactive headBranch from git observable
- Single recompute() derives isolationMode and effectiveBranch
- Branches fetched lazily on picker click, not pre-cached
- Fixes: edit dialog preserving stale branch across workspace switches
- Fixes: branch not resetting to HEAD when unchecking worktree

View item delegates to model, observes repo.state for HEAD updates,
and fetches branches on demand from IGitService.

Includes 26-test unit suite covering all state transitions.
Copilot AI review requested due to automatic review settings July 12, 2026 23:10
@benvillalobos benvillalobos changed the title automations: refactor isolation group to intent-based state model Automations: Add branch picker Jul 12, 2026

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

Refactors automation worktree isolation into a testable intent-based model with reactive Git state.

Changes:

  • Adds and tests IsolationGroupModel.
  • Adds lazy branch loading and reactive HEAD tracking.
  • Updates checkbox and branch-picker UI styling.
Show a summary per file
File Description
isolationGroupModel.ts Implements isolation state transitions.
isolationGroupModel.test.ts Tests model behavior.
automationDialog.ts Integrates the model and branch picker.
aiCustomizationManagement.css Styles the new controls.

Review details

  • Files reviewed: 4/4 changed files
  • Comments generated: 8
  • Review effort level: Medium

Comment thread src/vs/sessions/contrib/automations/common/isolationGroupModel.ts Outdated
Comment thread src/vs/sessions/contrib/automations/browser/automationDialog.ts
Comment thread src/vs/sessions/contrib/automations/browser/automationDialog.ts
benvillalobos and others added 2 commits July 12, 2026 17:52
- Fix stale branch leak: constructor only preserves selectedBranch
  when persisted mode is worktree (not workspace HEAD at save time)
- Fix disposal race: increment branchRequestId in dispose() to
  invalidate pending getRefs() before teardown
- Switch chevron to chevronDownCompact matching sibling pickers
- Add touch-action: manipulation on clickable targets
- Gate hover styles on :not(.disabled), add disabled cursor
- Add :focus-visible outline on branch chip
- Bump chevron font-size to 12px (compact codicon tier)
- Add regression test for workspace-mode branch leak
The branch chip appeared enabled before openRepository resolved (or when
the folder was not a git repo), but clicking it silently no-oped. Add a
hasRepository flag to IsolationGroupModel so branchPickerEnabled reflects
actual repo availability. Also add ensureNoDisposablesAreLeakedInTestSuite
to the test suite.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b8b006b8-af33-483d-b040-f1960f2daa71
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