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
This commit is contained in:
Don Jayamanne
2026-03-08 17:10:05 +11:00
committed by GitHub
parent 1eb2581989
commit 2c51cfd4dd

View File

@@ -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<string>(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);
});