1
>
/*---------------------------------------------------------------------------------------------
isolationGroupModel.ts
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));
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) {
41
_state.folderUri = undefined;