Automations: Add branch picker#325514
Draft
benvillalobos wants to merge 10 commits into
Draft
Conversation
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.
Contributor
There was a problem hiding this comment.
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
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a branch picker to the automation dialog when the worktree checkbox is selected
Fixes Microsoft/vscode-internalbacklog#8308