Commit 57c4e411 authored by Denys Mishunov's avatar Denys Mishunov 🔴
Browse files

fix: re-register handlers for the agentic chat

parent adedfb41
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -3,13 +3,13 @@ import { WebviewMessageRegistry } from '../message_handlers';
import { AGENTIC_CHAT_WEBVIEW_ID } from '../../constants';
import { createFakePartial } from '../../test_utils/create_fake_partial';
import { USER_COMMANDS } from '../../command_names';
import { LsWebviewController } from '../ls_webview_controller';
import { LSDuoChatWebviewController } from '../duo_chat/duo_chat_controller';
import { registerDuoAgenticChatCommands } from './duo_agentic_chat_commands';

describe('registerDuoAgenticChatCommands', () => {
  let webviewMessageRegistry: WebviewMessageRegistry;
  let sendNotificationMock: jest.Mock;
  let chatController: LsWebviewController;
  let chatController: LSDuoChatWebviewController;

  const testCases = [
    {
@@ -31,7 +31,7 @@ describe('registerDuoAgenticChatCommands', () => {
      sendNotification: sendNotificationMock,
    });

    chatController = createFakePartial<LsWebviewController>({
    chatController = createFakePartial<LSDuoChatWebviewController>({
      show: jest.fn(),
    });

+2 −2
Original line number Diff line number Diff line
@@ -2,11 +2,11 @@ import vscode from 'vscode';
import { WebviewMessageRegistry } from '../message_handlers';
import { AGENTIC_CHAT_WEBVIEW_ID } from '../../constants';
import { USER_COMMANDS } from '../../command_names';
import { LsWebviewController } from '../ls_webview_controller';
import { LSDuoChatWebviewController } from '../duo_chat/duo_chat_controller';

export const registerDuoAgenticChatCommands = async (
  webviewMessageRegistry: WebviewMessageRegistry,
  chatController: LsWebviewController,
  chatController: LSDuoChatWebviewController,
) => {
  const sendNewViewPrompt = async (view: string) => {
    await chatController.show();
+10 −18
Original line number Diff line number Diff line
@@ -416,16 +416,20 @@ describe('setupWebviews', () => {
          title: 'Duo Chat',
          uris: ['https://example.com/duo-chat'],
        },
        {
          id: AGENTIC_CHAT_WEBVIEW_ID,
          title: 'GitLab Duo Agentic Chat',
          uris: ['https://example.com/agentic-duo-chat'],
        },
      ]);
    });

    it('should register Duo chat messages in the registry', async () => {
      await setupWebviews(webviewManager, webviewMessageRegistry, aiContextManager);
      expect(registerDuoChatHandlers).toHaveBeenCalledWith(
        webviewMessageRegistry,
        expect.any(LSDuoChatWebviewController),
        DUO_CHAT_WEBVIEW_ID,
      );
      expect(jest.mocked(registerDuoChatHandlers).mock.calls).toEqual([
        [webviewMessageRegistry, expect.any(LSDuoChatWebviewController), DUO_CHAT_WEBVIEW_ID],
        [webviewMessageRegistry, expect.any(LSDuoChatWebviewController), AGENTIC_CHAT_WEBVIEW_ID],
      ]);
    });

    it('should register Duo chat commands', async () => {
@@ -437,25 +441,13 @@ describe('setupWebviews', () => {
        aiContextManager,
      );
    });
  });

  describe('Duo Agentic Chat commands', () => {
    beforeEach(() => {
      jest.mocked(webviewManager.getWebviewInfos).mockResolvedValue([
        {
          id: AGENTIC_CHAT_WEBVIEW_ID,
          title: 'Duo Agentic Chat',
          uris: ['https://example.com/duo-chat'],
        },
      ]);
    });

    it('should register Duo Agentic Chat commands', async () => {
      await setupWebviews(webviewManager, webviewMessageRegistry, aiContextManager);

      expect(registerDuoAgenticChatCommands).toHaveBeenCalledWith(
        webviewMessageRegistry,
        expect.any(LsWebviewController),
        expect.any(LSDuoChatWebviewController),
      );
    });
  });
+2 −3
Original line number Diff line number Diff line
@@ -23,13 +23,12 @@ import { registerDuoChatCommands } from './duo_chat/duo_chat_commands';
import { registerDuoAgenticChatCommands } from './duo_agentic_chat/duo_agentic_chat_commands';
import { LSDuoChatWebviewController } from './duo_chat/duo_chat_controller';

const CHAT_WEBVIEW_IDS = [DUO_CHAT_WEBVIEW_ID];
const CHAT_WEBVIEW_IDS = [DUO_CHAT_WEBVIEW_ID, AGENTIC_CHAT_WEBVIEW_ID];

// webviews that show in the VS Code panels, sidebar or other custom views (like activity bar)
const PANEL_WEBVIEW_IDS = [
  ...CHAT_WEBVIEW_IDS,
  DUO_WORKFLOW_PANEL_WEBVIEW_ID,
  AGENTIC_CHAT_WEBVIEW_ID,
  AGENTIC_TABS_WEBVIEW_ID,
];

@@ -171,7 +170,7 @@ const setupPanelWebview = async (
    disposables.push(
      await registerDuoAgenticChatCommands(
        webviewMessageRegistry,
        controller as LsWebviewController,
        controller as LSDuoChatWebviewController,
      ),
    );
  }