From 42b5b2147f53cfda43a2d09cc4ea39e5ec669904 Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Wed, 14 Jan 2026 22:10:19 +0100 Subject: [PATCH] Background - remove isolation picker (#2858) --- .../copilotCLIChatSessionsContribution.ts | 79 +------------------ 1 file changed, 4 insertions(+), 75 deletions(-) diff --git a/extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts b/extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts index cb377f938ae..44e044bddd2 100644 --- a/extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts +++ b/extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts @@ -8,7 +8,6 @@ import * as l10n from '@vscode/l10n'; import * as vscode from 'vscode'; import { ChatExtendedRequestHandler, Uri } from 'vscode'; import { IRunCommandExecutionService } from '../../../platform/commands/common/runCommandExecutionService'; -import { IVSCodeExtensionContext } from '../../../platform/extContext/common/extensionContext'; import { IGitService } from '../../../platform/git/common/gitService'; import { toGitUri } from '../../../platform/git/common/utils'; import { ILogService } from '../../../platform/log/common/logService'; @@ -39,24 +38,6 @@ import { CopilotCloudSessionsProvider } from './copilotCloudSessionsProvider'; const AGENTS_OPTION_ID = 'agent'; const MODELS_OPTION_ID = 'model'; -const ISOLATION_OPTION_ID = 'isolation'; - -const disabledIsolation: Readonly = { - id: 'disabled', - name: 'Workspace', - description: l10n.t('Use the current workspace for this session') -}; -const disabledIsolationLocked: Readonly = { ...disabledIsolation, locked: true }; - -function getLockedIsolationOption(name: string): vscode.ChatSessionProviderOptionItem { - return { - id: 'enabled', - name, - description: l10n.t('Using worktree for this session'), - locked: true, - icon: new vscode.ThemeIcon('worktree') - }; -} const UncommittedChangesStep = 'uncommitted-changes'; type ConfirmationResult = { step: string; accepted: boolean; metadata?: CLIConfirmationMetadata }; @@ -86,19 +67,12 @@ function isUntitledSessionId(sessionId: string): boolean { } export class CopilotCLISessionIsolationManager { - static COPILOT_CLI_DEFAULT_ISOLATION_MEMENTO_KEY = 'github.copilot.cli.sessionIsolation'; private _sessionIsolation: Map = new Map(); - constructor( - @IVSCodeExtensionContext private readonly extensionContext: IVSCodeExtensionContext, - @IChatSessionWorktreeService private readonly worktreeManagerService: IChatSessionWorktreeService - ) { } + constructor(@IChatSessionWorktreeService private readonly worktreeManagerService: IChatSessionWorktreeService) { } private getDefaultIsolationPreference(): boolean { - if (!this.worktreeManagerService.isWorktreeSupportedObs.get()) { - return false; - } - return this.extensionContext.globalState.get(CopilotCLISessionIsolationManager.COPILOT_CLI_DEFAULT_ISOLATION_MEMENTO_KEY, true); + return this.worktreeManagerService.isWorktreeSupportedObs.get(); } getIsolationPreference(sessionId: string): boolean { @@ -106,12 +80,11 @@ export class CopilotCLISessionIsolationManager { const defaultIsolation = this.getDefaultIsolationPreference(); this._sessionIsolation.set(sessionId, defaultIsolation); } - return this._sessionIsolation.get(sessionId) ?? false; + return this._sessionIsolation.get(sessionId) ?? true; } async setIsolationPreference(sessionId: string, enabled: boolean): Promise { this._sessionIsolation.set(sessionId, enabled); - await this.extensionContext.globalState.update(CopilotCLISessionIsolationManager.COPILOT_CLI_DEFAULT_ISOLATION_MEMENTO_KEY, enabled); } } @@ -277,20 +250,6 @@ export class CopilotCLIChatSessionContentProvider extends Disposable implements options[MODELS_OPTION_ID] = model; } - if (!existingSession || !this.copilotCLIWorktreeManagerService.isWorktreeSupportedObs.get()) { - options[ISOLATION_OPTION_ID] = this.copilotCLIWorktreeManagerService.isWorktreeSupportedObs.get() && isolationEnabled ? 'enabled' : 'disabled'; - } else if (existingSession && workingDirectory) { - // For existing sessions with a worktree, show the worktree branch name as a locked option - const worktreeProperties = this.copilotCLIWorktreeManagerService.getWorktreeProperties(copilotcliSessionId); - if (worktreeProperties?.branchName) { - options[ISOLATION_OPTION_ID] = getLockedIsolationOption(worktreeProperties.branchName); - } else { - options[ISOLATION_OPTION_ID] = disabledIsolationLocked; - } - } else if (existingSession) { - options[ISOLATION_OPTION_ID] = disabledIsolationLocked; - } - const history = existingSession?.object?.getChatHistory() || []; existingSession?.dispose(); // Always keep track of this in memory. @@ -306,11 +265,6 @@ export class CopilotCLIChatSessionContentProvider extends Disposable implements } async provideChatSessionProviderOptions(): Promise { - const isolationItems = [ - { id: 'enabled', name: 'Worktree', description: l10n.t('Use a git worktree for this session') }, - disabledIsolation - ]; - const [models, agents] = await Promise.all([ this.copilotCLIModels.getModels(), this.copilotCLIAgents.getAgents() @@ -334,15 +288,6 @@ export class CopilotCLIChatSessionContentProvider extends Disposable implements } ] }; - if (this.copilotCLIWorktreeManagerService.isWorktreeSupportedObs.get()) { - this.worktreeOptionShown = true; - options.optionGroups.push({ - id: ISOLATION_OPTION_ID, - name: l10n.t('Isolation'), - description: l10n.t('Choose Worktree or Workspace for this session'), - items: isolationItems - }); - } if (hasAgents) { options.optionGroups.unshift({ id: AGENTS_OPTION_ID, @@ -364,9 +309,6 @@ export class CopilotCLIChatSessionContentProvider extends Disposable implements } else if (update.optionId === AGENTS_OPTION_ID) { void this.copilotCLIAgents.setDefaultAgent(update.value); void this.copilotCLIAgents.trackSessionAgent(sessionId, update.value); - } else if (update.optionId === ISOLATION_OPTION_ID) { - // Handle isolation option changes - await this.isolationManager.setIsolationPreference(sessionId, update.value === 'enabled'); } } } @@ -469,19 +411,6 @@ export class CopilotCLIChatSessionParticipant extends Disposable { if (!session || token.isCancellationRequested) { return {}; } - if (isUntitled && session.object.options.isolationEnabled && session.object.options.workingDirectory && this.copilotCLIWorktreeManagerService.isWorktreeSupportedObs.get()) { - const changes: { optionId: string; value: vscode.ChatSessionProviderOptionItem }[] = []; - // For existing sessions with a worktree, show the worktree branch name as a locked option - const worktreeProperties = this.copilotCLIWorktreeManagerService.getWorktreeProperties(session.object.sessionId); - if (worktreeProperties?.branchName) { - changes.push({ optionId: ISOLATION_OPTION_ID, value: getLockedIsolationOption(worktreeProperties.branchName) }); - this.contentProvider.notifySessionOptionsChange(resource, changes); - } - } else if (isUntitled && (!session.object.options.isolationEnabled || !this.copilotCLIWorktreeManagerService.isWorktreeSupportedObs.get())) { - const changes: { optionId: string; value: vscode.ChatSessionProviderOptionItem }[] = []; - changes.push({ optionId: ISOLATION_OPTION_ID, value: disabledIsolationLocked }); - this.contentProvider.notifySessionOptionsChange(resource, changes); - } this.copilotCLIAgents.trackSessionAgent(session.object.sessionId, agent?.name); if (isUntitled) { @@ -815,7 +744,7 @@ export class CopilotCLIChatSessionParticipant extends Disposable { let workingDirectory: Uri | undefined; let worktreeProperties: Awaited> | undefined; - let isolationEnabled = false; + let isolationEnabled = true; if (chatSessionContext) { const existingSessionId = this.untitledSessionIdMapping.get(SessionIdForCLI.parse(chatSessionContext.chatSessionItem.resource));