296
*/
297
async resolveIsolationConfig(request: IResolveIsolationConfigRequest): Promise<IIsolationConfigContribution> {
298
>
const gitInfo = request.workingDirectory ? await this._getGitInfo(request.workingDirectory) : undefined;
worktreeIsolation.ts
299
>
300
>
const isolationProperty = schemaProperty<'folder' | 'worktree'>({
301
>
type: 'string',
302
>
title: localize('agentHost.sessionConfig.isolation', "Isolation"),
303
>
description: localize('agentHost.sessionConfig.isolationDescription', "Where the agent should make changes"),
304
>
enum: gitInfo ? ['folder', 'worktree'] : ['folder'],
305
>
enumLabels: gitInfo ? [localize('agentHost.sessionConfig.isolation.folder', "Folder"), localize('agentHost.sessionConfig.isolation.worktree', "Worktree")] : [localize('agentHost.sessionConfig.isolation.folder', "Folder")],
306
>
enumDescriptions: gitInfo ? [localize('agentHost.sessionConfig.isolation.folderDescription', "Work directly in the folder"), localize('agentHost.sessionConfig.isolation.worktreeDescription', "Create a Git worktree for isolation")] : [localize('agentHost.sessionConfig.isolation.folderDescription', "Work directly in the folder")],
307
>
default: gitInfo ? 'worktree' : 'folder',
308
>
readOnly: !gitInfo,
309
>
sessionMutable: false,
310
>
});
311
>
312
>
// Resolve isolation first — downstream schema shapes (branch's
313
>
// read-only mode + enum restriction) depend on the effective value.
314
>
const isolationDefault: 'folder' | 'worktree' = gitInfo ? 'worktree' : 'folder';
315
>
const isolationValue = isolationProperty.validate(request.config?.[SessionConfigKey.Isolation])
316
? request.config![SessionConfigKey.Isolation] as 'folder' | 'worktree'
317
: isolationDefault;
319
>
let branchProperty: ISchemaProperty<string> | undefined;
320
>
let branchDefault: string | undefined;
321
>
let branchValue: string | undefined;
322
>
let worktreeBranchPrefixProperty: ISchemaProperty<string> | undefined;
323
>
let worktreeIncludeFilesProperty: ISchemaProperty<readonly string[]> | undefined;
324
>
if (gitInfo) {
325
const branchReadOnly = isolationValue === 'folder';
326
branchDefault = isolationValue === 'worktree' ? gitInfo.defaultBranch.name : gitInfo.currentBranch;