Skip to content

Commit 127d83a

Browse files
authored
Remove CopilotSessionContextMenuBridge and related logic (#318320)
remove CopilotSessionContextMenuBridge and related context menu bridging logic
1 parent 6dfc9e4 commit 127d83a

1 file changed

Lines changed: 1 addition & 74 deletions

File tree

src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsActions.ts

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,17 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { BaseActionViewItem } from '../../../../../base/browser/ui/actionbar/actionViewItems.js';
7-
import { coalesce } from '../../../../../base/common/arrays.js';
87
import { Disposable, IDisposable } from '../../../../../base/common/lifecycle.js';
9-
import { MarshalledId } from '../../../../../base/common/marshallingIds.js';
108
import { IReader, autorun, observableValue } from '../../../../../base/common/observable.js';
119
import { isWeb } from '../../../../../base/common/platform.js';
1210
import { localize2 } from '../../../../../nls.js';
1311
import { IActionViewItemService } from '../../../../../platform/actions/browser/actionViewItemService.js';
14-
import { Action2, MenuId, MenuRegistry, isIMenuItem, registerAction2 } from '../../../../../platform/actions/common/actions.js';
15-
import { CommandsRegistry, ICommandService } from '../../../../../platform/commands/common/commands.js';
12+
import { Action2, registerAction2 } from '../../../../../platform/actions/common/actions.js';
1613
import { ContextKeyExpr, IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js';
1714
import { IInstantiationService, ServicesAccessor } from '../../../../../platform/instantiation/common/instantiation.js';
1815
import { IStorageService, StorageScope, StorageTarget } from '../../../../../platform/storage/common/storage.js';
1916
import { ITelemetryService } from '../../../../../platform/telemetry/common/telemetry.js';
2017
import { IWorkbenchContribution, WorkbenchPhase, registerWorkbenchContribution2 } from '../../../../../workbench/common/contributions.js';
21-
import { IAgentSessionsService } from '../../../../../workbench/contrib/chat/browser/agentSessions/agentSessionsService.js';
2218
import { IChatInputPickerOptions } from '../../../../../workbench/contrib/chat/browser/widget/input/chatInputPickerActionItem.js';
2319
import { IModelPickerDelegate, ModelPickerActionItem } from '../../../../../workbench/contrib/chat/browser/widget/input/modelPickerActionItem.js';
2420
import { ILanguageModelChatMetadataAndIdentifier, ILanguageModelsService } from '../../../../../workbench/contrib/chat/common/languageModels.js';
@@ -516,75 +512,6 @@ class CopilotActiveSessionContribution extends Disposable implements IWorkbenchC
516512
registerWorkbenchContribution2(CopilotPickerActionViewItemContribution.ID, CopilotPickerActionViewItemContribution, WorkbenchPhase.AfterRestored);
517513
registerWorkbenchContribution2(CopilotActiveSessionContribution.ID, CopilotActiveSessionContribution, WorkbenchPhase.AfterRestored);
518514

519-
/**
520-
* Bridges extension-contributed context menu actions from {@link MenuId.AgentSessionsContext}
521-
* to {@link SessionItemContextMenuId} for the new sessions view.
522-
* Registers wrapper commands that resolve {@link ISession} → {@link IAgentSession}
523-
* and forward to the original command with marshalled context.
524-
*/
525-
class CopilotSessionContextMenuBridge extends Disposable implements IWorkbenchContribution {
526-
static readonly ID = 'copilotChatSessions.contextMenuBridge';
527-
528-
private readonly _bridgedIds = new Set<string>();
529-
530-
constructor(
531-
@IAgentSessionsService private readonly agentSessionsService: IAgentSessionsService,
532-
@ICommandService private readonly commandService: ICommandService,
533-
) {
534-
super();
535-
this._bridgeItems();
536-
this._register(MenuRegistry.onDidChangeMenu(menuIds => {
537-
if (menuIds.has(MenuId.AgentSessionsContext)) {
538-
this._bridgeItems();
539-
}
540-
}));
541-
}
542-
543-
private _bridgeItems(): void {
544-
const items = MenuRegistry.getMenuItems(MenuId.AgentSessionsContext).filter(isIMenuItem);
545-
for (const item of items) {
546-
const commandId = item.command.id;
547-
if (!commandId.startsWith('github.copilot.')) {
548-
continue;
549-
}
550-
if (commandId === 'github.copilot.cli.sessions.delete') {
551-
continue; // Delete is handled natively via sessionsManagementService
552-
}
553-
if (this._bridgedIds.has(commandId)) {
554-
continue;
555-
}
556-
this._bridgedIds.add(commandId);
557-
558-
const wrapperId = `sessionsViewPane.bridge.${commandId}`;
559-
this._register(CommandsRegistry.registerCommand(wrapperId, (accessor, context?: ISession | ISession[]) => {
560-
if (!context) {
561-
return;
562-
}
563-
const sessions = Array.isArray(context) ? context : [context];
564-
const agentSessions = coalesce(sessions.map(s => this.agentSessionsService.getSession(s.resource)));
565-
if (agentSessions.length === 0) {
566-
return;
567-
}
568-
return this.commandService.executeCommand(commandId, {
569-
session: agentSessions[0],
570-
sessions: agentSessions,
571-
$mid: MarshalledId.AgentSessionContext,
572-
});
573-
}));
574-
575-
const providerWhen = ContextKeyExpr.equals(ChatSessionProviderIdContext.key, COPILOT_PROVIDER_ID);
576-
this._register(MenuRegistry.appendMenuItem(SessionItemContextMenuId, {
577-
command: { ...item.command, id: wrapperId },
578-
group: item.group,
579-
order: item.order,
580-
when: item.when ? ContextKeyExpr.and(providerWhen, item.when) : providerWhen,
581-
}));
582-
}
583-
}
584-
}
585-
586-
registerWorkbenchContribution2(CopilotSessionContextMenuBridge.ID, CopilotSessionContextMenuBridge, WorkbenchPhase.AfterRestored);
587-
588515
registerAction2(class DeleteSessionAction extends Action2 {
589516
constructor() {
590517
super({

0 commit comments

Comments
 (0)