sessions: refactor branch/isolation pickers to use session as source of truth#305128
Merged
sessions: refactor branch/isolation pickers to use session as source of truth#305128
Conversation
…ate isolation mode handling in IsolationPicker
…branch handling and loading logic
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the Copilot Chat sessions new-session UI pickers so that CopilotCLISession becomes the single source of truth for isolation mode and branch state, with the pickers acting as reactive views over session observables.
Changes:
- Move git branch loading/state (
branches,branchesLoading, default branch selection) intoCopilotCLISession. - Update
CopilotCLISessionto keep_branchObservable/_isolationModeObservablein sync when setters are called. - Simplify
BranchPickerandIsolationPickerto read/write session state rather than duplicating local state.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/vs/sessions/contrib/copilotChatSessions/browser/copilotChatSessionsProvider.ts | Adds branch-loading + branch/isolation observables to CopilotCLISession and updates setters to keep observables synchronized. |
| src/vs/sessions/contrib/copilotChatSessions/browser/branchPicker.ts | Removes local loading/branch state and renders purely from session observables; disables interaction when isolation is folder mode. |
| src/vs/sessions/contrib/copilotChatSessions/browser/isolationPicker.ts | Removes local isolation state/event emission and updates the picker to use session as the source of truth. |
lszomoru
approved these changes
Mar 26, 2026
mjbvz
pushed a commit
to mjbvz/vscode
that referenced
this pull request
Mar 26, 2026
…of truth (microsoft#305128) * add isolation mode handling to branch picker and session actions * restore session's isolation mode on picker recreation * remove unused isolation context key from session actions * set default isolation mode to 'worktree' in CopilotCLISession and update isolation mode handling in IsolationPicker * refactor: streamline BranchPicker and CopilotCLISession for improved branch handling and loading logic
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.
Summary
Refactors the branch picker and isolation picker in the Copilot Chat sessions provider so that
CopilotCLISessionis the single source of truth for all branch and isolation state.What changed
CopilotCLISession— now owns branch loadingBranchPicker)branches(observable list),branchesLoading(observable), and_defaultBranchfieldssetBranch()now updates_branchObservableso the picker reactssetIsolationMode()resets branch to_defaultBranchwhen switching to folder mode_isolationModeObservableinitialized to'worktree'to match the internal defaultBranchPicker— simplified to a pure view_branches,_selectedBranch,_loading,_disabled, CTS, event emitters)branches,branchesLoading,branchObservable,isolationModeObservable)'workspace'(folder)IsolationPicker— no longer duplicates state_isolationModefield; reads from session viasession.isolationModeWhy
Previously, pickers maintained their own local state and wrote it back to the session. This caused several bugs:
'worktree', overwriting the user's selection_isolationModeObservableand_branchObservablewere never set, so reactive consumers couldn't track changes