From 2c51cfd4ddd8fa5ea1d793142958eabf492fb977 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Sun, 8 Mar 2026 17:10:05 +1100 Subject: [PATCH] Avoid continuing in Copilot CLI when already in Copilot CLI (#300025) * refactor: enhance actionProvider to utilize contextKeyService for session type checks * refactor: add contextKeyService to ChatSuggestNextWidget for session type handling * refactor: simplify actionProvider by removing contextKeyService dependency --- .../widget/chatContentParts/chatSuggestNextWidget.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatSuggestNextWidget.ts b/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatSuggestNextWidget.ts index c9e3d0c4a96..8952b2339b1 100644 --- a/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatSuggestNextWidget.ts +++ b/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatSuggestNextWidget.ts @@ -9,7 +9,9 @@ import { Emitter, Event } from '../../../../../../base/common/event.js'; import { Disposable, DisposableStore } from '../../../../../../base/common/lifecycle.js'; import { ThemeIcon } from '../../../../../../base/common/themables.js'; import { localize } from '../../../../../../nls.js'; +import { IContextKeyService } from '../../../../../../platform/contextkey/common/contextkey.js'; import { IContextMenuService } from '../../../../../../platform/contextview/browser/contextView.js'; +import { ChatContextKeys } from '../../../common/actions/chatContextKeys.js'; import { IChatMode } from '../../../common/chatModes.js'; import { IChatSessionsService } from '../../../common/chatSessionsService.js'; import { IHandOff } from '../../../common/promptSyntax/promptFileParser.js'; @@ -36,7 +38,8 @@ export class ChatSuggestNextWidget extends Disposable { constructor( @IContextMenuService private readonly contextMenuService: IContextMenuService, - @IChatSessionsService private readonly chatSessionsService: IChatSessionsService + @IChatSessionsService private readonly chatSessionsService: IChatSessionsService, + @IContextKeyService private readonly contextKeyService: IContextKeyService ) { super(); this.domNode = this.createSuggestNextWidget(); @@ -126,11 +129,15 @@ export class ChatSuggestNextWidget extends Disposable { // Get chat session contributions to show in chevron dropdown // Filter to only first-party providers that support "continue in". // TODO: Expand later to any agent with `canDelegate` === true. + const currentSessionType = this.contextKeyService.getContextKeyValue(ChatContextKeys.chatSessionType.key); const contributions = this.chatSessionsService.getAllChatSessionContributions(); const availableContributions = contributions.filter(c => { if (!c.canDelegate) { return false; } + if (c.type === currentSessionType) { + return false; + } const provider = getAgentSessionProvider(c.type); return provider !== undefined && getAgentCanContinueIn(provider); });