Commit 343fbf77 authored by Juhee Lee's avatar Juhee Lee Committed by Yi-Ann Chen
Browse files

chore: extract show mcp dashboard command out of programmatic commands

parent 56c99366
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -29,11 +29,7 @@ export const USER_COMMANDS = {
  MCP_OPEN_USER_CONFIG: 'gl.mcp.openUserConfig',
};

/*
  User can't trigger these commands directly. We use them from within the code.
*/
export const PROGRAMMATIC_COMMANDS = {
  // Reveals the MCP Dashboard editor webview. Registered dynamically in setupWebviews
  // as `gl.webview.<normalized MCP_DASHBOARD_WEBVIEW_ID>.show`.
  WEBVIEW_ROOT_MCP_SHOW: 'gl.webview.root.mcp.show',
};
// Contributed in desktop.package.json and registered dynamically in setupWebviews
// from MCP_DASHBOARD_WEBVIEW_ID. Declared here so the common webview handler can
// reference it without importing desktop-specific code; mirrored in desktop USER_COMMANDS.
export const WEBVIEW_ROOT_MCP_SHOW = 'gl.webview.root.mcp.show';
+2 −2
Original line number Diff line number Diff line
import * as vscode from 'vscode';
import { DUO_CHAT_WEBVIEW_ID } from '../../constants';
import { PROGRAMMATIC_COMMANDS } from '../../command_names';
import { WEBVIEW_ROOT_MCP_SHOW } from '../../command_names';
import { WebviewMessageRegistry } from '../message_handlers/webview_message_registry';
import { createFakePartial } from '../../test_utils/create_fake_partial';
import { log } from '../../log';
@@ -179,7 +179,7 @@ describe('registerDuoChatHandlers', () => {

      await openMcpDashboard();

      expect(executeCommandSpy).toHaveBeenCalledWith(PROGRAMMATIC_COMMANDS.WEBVIEW_ROOT_MCP_SHOW);
      expect(executeCommandSpy).toHaveBeenCalledWith(WEBVIEW_ROOT_MCP_SHOW);
    });
  });

+2 −7
Original line number Diff line number Diff line
import * as vscode from 'vscode';
import { log } from '../../log';
import { DUO_CHAT_WEBVIEW_ID, AGENTIC_CHAT_WEBVIEW_ID } from '../../constants';
import { PROGRAMMATIC_COMMANDS } from '../../command_names';
import { WEBVIEW_ROOT_MCP_SHOW } from '../../command_names';
import { getActiveFileContext } from '../../chat/gitlab_chat_file_context';
import { WebviewMessageRegistry } from '../message_handlers/webview_message_registry';
import { insertCodeSnippet as insertCodeSnippetFn } from '../../chat/insert_code_snippet';
@@ -100,14 +100,9 @@ export const openLink = async (params: OpenLinkParams | unknown) => {
    log.warn(e.message);
  }
};
/**
 * Reveals the MCP Dashboard webview. Opening a panel is host-specific, so the
 * Duo Agent Platform webview sends the `openMcpDashboard` notification and the
 * extension executes the command that shows the dashboard.
 */
export const openMcpDashboard = async () => {
  try {
    await vscode.commands.executeCommand(PROGRAMMATIC_COMMANDS.WEBVIEW_ROOT_MCP_SHOW);
    await vscode.commands.executeCommand(WEBVIEW_ROOT_MCP_SHOW);
  } catch (e) {
    log.warn(`Failed to open MCP Dashboard: ${e.message}`);
  }
+2 −2
Original line number Diff line number Diff line
import {
  USER_COMMANDS as COMMON_USER_COMMANDS,
  PROGRAMMATIC_COMMANDS as COMMON_PROGRAMMATIC_COMMANDS,
  WEBVIEW_ROOT_MCP_SHOW,
} from '../common/command_names';
/*
  Commands that can be triggered from the command palette or context menus.
@@ -74,7 +74,7 @@ export const USER_COMMANDS = {
  MCP_OPEN_USER_CONFIG: COMMON_USER_COMMANDS.MCP_OPEN_USER_CONFIG,
  MCP_OPEN_WORKSPACE_CONFIG: 'gl.mcp.openWorkspaceConfig',
  SHOW_KNOWLEDGE_GRAPH: 'gl.knowledgeGraph.show',
  WEBVIEW_ROOT_MCP_SHOW: COMMON_PROGRAMMATIC_COMMANDS.WEBVIEW_ROOT_MCP_SHOW,
  WEBVIEW_ROOT_MCP_SHOW,
  OPEN_FLOW_BUILDER: 'gl.openFlowBuilder',
  DUO_AGENT_PLATFORM_ENABLE_NEW_UI: 'gl.duoAgentPlatform.enableNewUi',
  DUO_AGENT_PLATFORM_DISABLE_NEW_UI: 'gl.duoAgentPlatform.disableNewUi',