|
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
6 | 6 | import { BaseActionViewItem } from '../../../../../base/browser/ui/actionbar/actionViewItems.js'; |
7 | | -import { coalesce } from '../../../../../base/common/arrays.js'; |
8 | 7 | import { Disposable, IDisposable } from '../../../../../base/common/lifecycle.js'; |
9 | | -import { MarshalledId } from '../../../../../base/common/marshallingIds.js'; |
10 | 8 | import { IReader, autorun, observableValue } from '../../../../../base/common/observable.js'; |
11 | 9 | import { isWeb } from '../../../../../base/common/platform.js'; |
12 | 10 | import { localize2 } from '../../../../../nls.js'; |
13 | 11 | 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'; |
16 | 13 | import { ContextKeyExpr, IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js'; |
17 | 14 | import { IInstantiationService, ServicesAccessor } from '../../../../../platform/instantiation/common/instantiation.js'; |
18 | 15 | import { IStorageService, StorageScope, StorageTarget } from '../../../../../platform/storage/common/storage.js'; |
19 | 16 | import { ITelemetryService } from '../../../../../platform/telemetry/common/telemetry.js'; |
20 | 17 | import { IWorkbenchContribution, WorkbenchPhase, registerWorkbenchContribution2 } from '../../../../../workbench/common/contributions.js'; |
21 | | -import { IAgentSessionsService } from '../../../../../workbench/contrib/chat/browser/agentSessions/agentSessionsService.js'; |
22 | 18 | import { IChatInputPickerOptions } from '../../../../../workbench/contrib/chat/browser/widget/input/chatInputPickerActionItem.js'; |
23 | 19 | import { IModelPickerDelegate, ModelPickerActionItem } from '../../../../../workbench/contrib/chat/browser/widget/input/modelPickerActionItem.js'; |
24 | 20 | import { ILanguageModelChatMetadataAndIdentifier, ILanguageModelsService } from '../../../../../workbench/contrib/chat/common/languageModels.js'; |
@@ -516,75 +512,6 @@ class CopilotActiveSessionContribution extends Disposable implements IWorkbenchC |
516 | 512 | registerWorkbenchContribution2(CopilotPickerActionViewItemContribution.ID, CopilotPickerActionViewItemContribution, WorkbenchPhase.AfterRestored); |
517 | 513 | registerWorkbenchContribution2(CopilotActiveSessionContribution.ID, CopilotActiveSessionContribution, WorkbenchPhase.AfterRestored); |
518 | 514 |
|
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 | | - |
588 | 515 | registerAction2(class DeleteSessionAction extends Action2 { |
589 | 516 | constructor() { |
590 | 517 | super({ |
|
0 commit comments