src/vs/sessions/contrib/automations/common/isolationGroupModel.ts

160 LOC · 149 covered · 11 uncovered · 51 ranges · 23 concepts · 22 introducers · 11 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the fileisolationGroupModel.ts ×3 · 8 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×3 · 19 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×1 · 2 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×1 · 2 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.test|title=AutomationIsolationModel preserves an edited Worktree branch when HEAD changes or disappears|occurrence=1 · 0 introduced LOCisolationGroupModel.test…isolationGroupModel.ts ×1 · 2 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×1 · 1 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×1 · 1 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×1 · 6 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×1 · 2 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×1 · 1 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×2 · 2 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×1 · 2 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×1 · 2 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×2 · 6 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×2 · 4 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×3 · 4 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×2 · 2 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×2 · 2 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×1 · 2 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×2 · 9 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×1 · 2 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.ts ×18 · 68 introduced LOCisolationGroupModel.ts ×…isolationGroupModel.test|title=AutomationIsolationModel Folder mode treats a saved branch as legacy derived state|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/sessions/contrib/automations/test/common/isolationGroupModel.test|title=AutomationIsolationModel Folder mode treats a saved branch as legacy derived state|occurrence=1isolationGroupModel.test…isolationGroupModel.test|title=AutomationIsolationModel blocks unsupported Worktree selection without changing the mode|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/sessions/contrib/automations/test/common/isolationGroupModel.test|title=AutomationIsolationModel blocks unsupported Worktree selection without changing the mode|occurrence=1isolationGroupModel.test…isolationGroupModel.test|title=AutomationIsolationModel clears explicit branch intent when the folder changes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/sessions/contrib/automations/test/common/isolationGroupModel.test|title=AutomationIsolationModel clears explicit branch intent when the folder changes|occurrence=1isolationGroupModel.test…isolationGroupModel.test|title=AutomationIsolationModel does not use generated worktree HEAD as an implicit branch|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/sessions/contrib/automations/test/common/isolationGroupModel.test|title=AutomationIsolationModel does not use generated worktree HEAD as an implicit branch|occurrence=1isolationGroupModel.test…isolationGroupModel.test|title=AutomationIsolationModel ignores hidden workspace updates while workspace-less mode is active|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/sessions/contrib/automations/test/common/isolationGroupModel.test|title=AutomationIsolationModel ignores hidden workspace updates while workspace-less mode is active|occurrence=1isolationGroupModel.test…isolationGroupModel.test|title=AutomationIsolationModel keeps explicit branch intent across temporary isolation-mode toggles|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/sessions/contrib/automations/test/common/isolationGroupModel.test|title=AutomationIsolationModel keeps explicit branch intent across temporary isolation-mode toggles|occurrence=1isolationGroupModel.test…isolationGroupModel.test|title=AutomationIsolationModel normalizes local branch names|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/sessions/contrib/automations/test/common/isolationGroupModel.test|title=AutomationIsolationModel normalizes local branch names|occurrence=1isolationGroupModel.test…isolationGroupModel.test|title=AutomationIsolationModel preserves an edited Worktree branch when HEAD changes or disappears|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/sessions/contrib/automations/test/common/isolationGroupModel.test|title=AutomationIsolationModel preserves an edited Worktree branch when HEAD changes or disappears|occurrence=1isolationGroupModel.test…isolationGroupModel.test|title=AutomationIsolationModel provider-default isolation displays Folder without selecting it explicitly|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/sessions/contrib/automations/test/common/isolationGroupModel.test|title=AutomationIsolationModel provider-default isolation displays Folder without selecting it explicitly|occurrence=1isolationGroupModel.test…isolationGroupModel.test|title=AutomationIsolationModel rejects generated worktree branches from persisted and explicit selection state|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/sessions/contrib/automations/test/common/isolationGroupModel.test|title=AutomationIsolationModel rejects generated worktree branches from persisted and explicit selection state|occurrence=1isolationGroupModel.test…isolationGroupModel.test|title=AutomationIsolationModel workspace-less mode clears repository state and returns to Folder mode explicitly|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/sessions/contrib/automations/test/common/isolationGroupModel.test|title=AutomationIsolationModel workspace-less mode clears repository state and returns to Folder mode explicitly|occurrence=1isolationGroupModel.test…Focused file · src/vs/sessions/contrib/automations/common/isolationGroupModel.ts · 160 LOCcommon/isolationGroupMod…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- isolationGroupModel.ts ×18
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { isEqual } from '../../../../base/common/resources.js';
7 > import { IObservable, ISettableObservable, observableValue, transaction } from '../../../../base/common/observable.js';
8 > import { URI } from '../../../../base/common/uri.js';
9 >
10 > const GENERATED_WORKTREE_BRANCH_MARKER = 'copilot-worktree-';
11 >
12 > function isSelectableAutomationBranch(name: string | undefined): name is string {
13 > return !!name && !name.includes(GENERATED_WORKTREE_BRANCH_MARKER);
14 > }
15 >
16 > export function normalizeAutomationBranchNames(names: Iterable<string | undefined>): readonly string[] {
17 > return [...new Set([...names].filter(isSelectableAutomationBranch))].sort((a, b) => a.localeCompare(b)); isolationGroupModel.ts ×1
18 > }
20 > export interface IAutomationIsolationFormState {
21 > isQuickChat: boolean;
22 > folderUri: URI | undefined;
23 > isolationMode: string | undefined;
24 > branch: string | undefined;
25 > }
26 >
27 > /**
28 > * Keeps explicit Worktree branch intent separate from the repository's live HEAD.
29 > */
30 > export class AutomationIsolationModel {
31 > private _headBranch: string | undefined;
32 > private _selectedBranch: string | undefined;
33 > private _supportsWorktreeConfiguration = false;
34 > private readonly _isQuickChat: ISettableObservable<boolean>;
35 > readonly isQuickChatObs: IObservable<boolean>;
36 > private readonly _folderUri: ISettableObservable<URI | undefined>;
37 > readonly folderUriObs: IObservable<URI | undefined>;
38 >
39 > constructor(private readonly _state: IAutomationIsolationFormState) {
40 > if (_state.isQuickChat) { isolationGroupModel.ts ×2
41 > _state.folderUri = undefined; isolationGroupModel.ts ×2
42 > _state.isolationMode = undefined;
43 > _state.branch = undefined;
44 > }
45 > const branch = _state.isolationMode === 'worktree' ? _state.branch : undefined; isolationGroupModel.ts ×2
46 > this._selectedBranch = isSelectableAutomationBranch(branch) ? branch : undefined;
47 > this._state.branch = this._selectedBranch;
48 > this._isQuickChat = observableValue(this, _state.isQuickChat);
49 > this.isQuickChatObs = this._isQuickChat;
50 > this._folderUri = observableValue(this, _state.folderUri);
51 > this.folderUriObs = this._folderUri;
52 > }
54 > get isQuickChat(): boolean {
55 > return this._state.isQuickChat; isolationGroupModel.ts ×3
56 > }
58 > get folderUri(): URI | undefined {
59 > return this._state.folderUri; isolationGroupModel.ts ×1
60 > }
62 > get isolationMode(): string {
63 > return this._state.isolationMode ?? 'workspace'; isolationGroupModel.ts ×1
64 > }
66 > get selectedBranch(): string | undefined {
67 > return this._selectedBranch; isolationGroupModel.ts ×1
68 > }
70 > get headBranch(): string | undefined {
71 > return this._headBranch; isolationGroupModel.ts ×1
72 > }
74 > get displayBranch(): string | undefined {
75 > return this.isolationMode === 'worktree' isolationGroupModel.ts ×2
76 > ? this._selectedBranch ?? this._headBranch isolationGroupModel.ts ×1
77 > : this._headBranch; isolationGroupModel.ts ×1
80 > get persistedBranch(): string | undefined {
81 > if (!this._state.folderUri || this.isolationMode !== 'worktree' || !this._supportsWorktreeConfiguration) { isolationGroupModel.ts ×3
82 > return undefined; isolationGroupModel.ts ×1
83 > }
84 > return this._selectedBranch ?? this._headBranch; isolationGroupModel.ts ×1
87 > get supportsWorktreeConfiguration(): boolean {
88 return this._supportsWorktreeConfiguration;
89 }
91 > get branchPickerAvailable(): boolean {
92 > return !!this._state.folderUri && this.isolationMode === 'worktree' && this._supportsWorktreeConfiguration; isolationGroupModel.ts ×2
93 > }
95 > setSupportsWorktreeConfiguration(supported: boolean): void {
96 > this._supportsWorktreeConfiguration = supported; isolationGroupModel.ts ×1
97 > }
99 > selectIsolationMode(mode: 'workspace' | 'worktree'): boolean {
100 > if (this._state.isQuickChat || (mode === 'worktree' && (!this._state.folderUri || !this._supportsWorktreeConfiguration))) { isolationGroupModel.ts ×2
101 > return false; isolationGroupModel.ts ×2
102 > }
103 > this._state.isolationMode = mode; isolationGroupModel.ts ×1
104 > return true;
107 > setQuickChat(isQuickChat: boolean, workspaceFolderUri?: URI): void {
108 > if (this._state.isQuickChat === isQuickChat) { isolationGroupModel.ts ×3
109 if (!isQuickChat) {
110 this.setWorkspace(workspaceFolderUri);
111 }
112 return;
113 }
114 > this._state.isQuickChat = isQuickChat; isolationGroupModel.ts ×3
115 > if (isQuickChat) {
116 > this._state.folderUri = undefined;
117 > this._state.isolationMode = undefined;
118 > this._headBranch = undefined;
119 > this._selectedBranch = undefined;
120 > this._state.branch = undefined;
121 > } else {
122 > this._state.isolationMode = 'workspace';
123 > this._state.folderUri = workspaceFolderUri;
124 > }
125 > transaction(tx => {
126 > this._isQuickChat.set(isQuickChat, tx);
127 > this._folderUri.set(this._state.folderUri, tx);
128 > });
129 > }
131 > setWorkspace(folderUri: URI | undefined): boolean {
132 > if (this._state.isQuickChat) { isolationGroupModel.ts ×2
133 > return false; isolationGroupModel.ts ×2
134 > }
135 > if (isEqual(this._state.folderUri, folderUri)) { isolationGroupModel.ts ×3
136 return true;
137 }
138 > this._state.folderUri = folderUri; isolationGroupModel.ts ×3
139 > this._headBranch = undefined;
140 > this._selectedBranch = undefined;
141 > this._state.branch = undefined;
142 > if (!folderUri) {
143 this._state.isolationMode = 'workspace';
144 }
145 > this._folderUri.set(folderUri, undefined); isolationGroupModel.ts ×3
146 > return true;
149 > setHeadBranch(branch: string | undefined): void {
150 > this._headBranch = isSelectableAutomationBranch(branch) ? branch : undefined; isolationGroupModel.ts ×3
151 > }
153 > selectBranch(branch: string): void {
154 > if (!isSelectableAutomationBranch(branch)) { isolationGroupModel.ts ×1
155 > return;
156 > }
157 > this._selectedBranch = branch;
158 > this._state.branch = branch;
159 > }