Loading package.json +16 −2 Original line number Diff line number Diff line Loading @@ -68,6 +68,11 @@ "command": "gl.explainSelectedCode", "title": "Explain Selected Code", "category": "GitLab Duo" }, { "command": "gl.newChatConversation", "title": "Start new chat conversation", "category": "GitLab Duo" } ], "submenus": [ Loading @@ -85,6 +90,10 @@ { "command": "gl.explainSelectedCode", "when": "config.gitlab.featureFlags.chat && editorHasSelection && gitlab:validState" }, { "command": "gl.newChatConversation", "when": "config.gitlab.featureFlags.chat && gitlab:validState" } ], "editor/context": [ Loading @@ -105,12 +114,17 @@ { "command": "gl.openChat", "when": "config.gitlab.featureFlags.chat && gitlab:validState", "key": "alt+c alt+c" "key": "alt+o" }, { "command": "gl.explainSelectedCode", "when": "config.gitlab.featureFlags.chat && editorHasSelection && gitlab:validState", "key": "alt+c alt+e" "key": "alt+e" }, { "command": "gl.newChatConversation", "when": "config.gitlab.featureFlags.chat && gitlab:validState", "key": "alt+n" } ], "configuration": { Loading src/common/chat/commands/new_chat_conversation.test.ts 0 → 100644 +23 −0 Original line number Diff line number Diff line import { GitLabChatController } from '../gitlab_chat_controller'; import { newChatConversation } from './new_chat_conversation'; describe('newChatConversation', () => { let controller: GitLabChatController; beforeEach(() => { controller = { processNewUserRecord: jest.fn(), } as unknown as Partial<GitLabChatController> as GitLabChatController; }); it('triggers new "/reset" record', async () => { await newChatConversation(controller); expect(controller.processNewUserRecord).toHaveBeenCalledWith( expect.objectContaining({ content: '/reset', role: 'user', type: 'newConversation', }), ); }); }); src/common/chat/commands/new_chat_conversation.ts 0 → 100644 +17 −0 Original line number Diff line number Diff line import { GitLabChatController } from '../gitlab_chat_controller'; import { GitLabChatRecord } from '../gitlab_chat_record'; export const COMMAND_NEW_CHAT_CONVERSATION = 'gl.newChatConversation'; /** * Command will start new chat conversation */ export const newChatConversation = async (controller: GitLabChatController) => { const record = new GitLabChatRecord({ role: 'user', type: 'newConversation', content: `/reset`, }); await controller.processNewUserRecord(record); }; src/common/chat/gitlab_chat.test.ts +8 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,8 @@ describe('activateChat', () => { vscode.commands.registerCommand = jest .fn() .mockReturnValueOnce('command1') .mockReturnValueOnce('command2'); .mockReturnValueOnce('command2') .mockReturnValueOnce('command3'); }); it('registers view provider', () => { Loading @@ -45,8 +46,14 @@ describe('activateChat', () => { 'gl.explainSelectedCode', expect.any(Function), ); expect(vscode.commands.registerCommand).toHaveBeenNthCalledWith( 3, 'gl.newChatConversation', expect.any(Function), ); expect(context.subscriptions[1]).toEqual('command1'); expect(context.subscriptions[2]).toEqual('command2'); expect(context.subscriptions[3]).toEqual('command3'); }); }); src/common/chat/gitlab_chat.ts +7 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,10 @@ import { COMMAND_EXPLAIN_SELECTED_CODE, explainSelectedCode, } from './commands/explain_selected_code'; import { COMMAND_NEW_CHAT_CONVERSATION, newChatConversation, } from './commands/new_chat_conversation'; import { GitLabPlatformManager } from '../platform/gitlab_platform'; import { CHAT_SIDEBAR_VIEW_ID } from './gitlab_chat_view'; Loading @@ -24,6 +28,9 @@ export const activateChat = (context: vscode.ExtensionContext, manager: GitLabPl vscode.commands.registerCommand(COMMAND_EXPLAIN_SELECTED_CODE, async () => { await explainSelectedCode(controller); }), vscode.commands.registerCommand(COMMAND_NEW_CHAT_CONVERSATION, async () => { await newChatConversation(controller); }), ); }; Loading Loading
package.json +16 −2 Original line number Diff line number Diff line Loading @@ -68,6 +68,11 @@ "command": "gl.explainSelectedCode", "title": "Explain Selected Code", "category": "GitLab Duo" }, { "command": "gl.newChatConversation", "title": "Start new chat conversation", "category": "GitLab Duo" } ], "submenus": [ Loading @@ -85,6 +90,10 @@ { "command": "gl.explainSelectedCode", "when": "config.gitlab.featureFlags.chat && editorHasSelection && gitlab:validState" }, { "command": "gl.newChatConversation", "when": "config.gitlab.featureFlags.chat && gitlab:validState" } ], "editor/context": [ Loading @@ -105,12 +114,17 @@ { "command": "gl.openChat", "when": "config.gitlab.featureFlags.chat && gitlab:validState", "key": "alt+c alt+c" "key": "alt+o" }, { "command": "gl.explainSelectedCode", "when": "config.gitlab.featureFlags.chat && editorHasSelection && gitlab:validState", "key": "alt+c alt+e" "key": "alt+e" }, { "command": "gl.newChatConversation", "when": "config.gitlab.featureFlags.chat && gitlab:validState", "key": "alt+n" } ], "configuration": { Loading
src/common/chat/commands/new_chat_conversation.test.ts 0 → 100644 +23 −0 Original line number Diff line number Diff line import { GitLabChatController } from '../gitlab_chat_controller'; import { newChatConversation } from './new_chat_conversation'; describe('newChatConversation', () => { let controller: GitLabChatController; beforeEach(() => { controller = { processNewUserRecord: jest.fn(), } as unknown as Partial<GitLabChatController> as GitLabChatController; }); it('triggers new "/reset" record', async () => { await newChatConversation(controller); expect(controller.processNewUserRecord).toHaveBeenCalledWith( expect.objectContaining({ content: '/reset', role: 'user', type: 'newConversation', }), ); }); });
src/common/chat/commands/new_chat_conversation.ts 0 → 100644 +17 −0 Original line number Diff line number Diff line import { GitLabChatController } from '../gitlab_chat_controller'; import { GitLabChatRecord } from '../gitlab_chat_record'; export const COMMAND_NEW_CHAT_CONVERSATION = 'gl.newChatConversation'; /** * Command will start new chat conversation */ export const newChatConversation = async (controller: GitLabChatController) => { const record = new GitLabChatRecord({ role: 'user', type: 'newConversation', content: `/reset`, }); await controller.processNewUserRecord(record); };
src/common/chat/gitlab_chat.test.ts +8 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,8 @@ describe('activateChat', () => { vscode.commands.registerCommand = jest .fn() .mockReturnValueOnce('command1') .mockReturnValueOnce('command2'); .mockReturnValueOnce('command2') .mockReturnValueOnce('command3'); }); it('registers view provider', () => { Loading @@ -45,8 +46,14 @@ describe('activateChat', () => { 'gl.explainSelectedCode', expect.any(Function), ); expect(vscode.commands.registerCommand).toHaveBeenNthCalledWith( 3, 'gl.newChatConversation', expect.any(Function), ); expect(context.subscriptions[1]).toEqual('command1'); expect(context.subscriptions[2]).toEqual('command2'); expect(context.subscriptions[3]).toEqual('command3'); }); });
src/common/chat/gitlab_chat.ts +7 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,10 @@ import { COMMAND_EXPLAIN_SELECTED_CODE, explainSelectedCode, } from './commands/explain_selected_code'; import { COMMAND_NEW_CHAT_CONVERSATION, newChatConversation, } from './commands/new_chat_conversation'; import { GitLabPlatformManager } from '../platform/gitlab_platform'; import { CHAT_SIDEBAR_VIEW_ID } from './gitlab_chat_view'; Loading @@ -24,6 +28,9 @@ export const activateChat = (context: vscode.ExtensionContext, manager: GitLabPl vscode.commands.registerCommand(COMMAND_EXPLAIN_SELECTED_CODE, async () => { await explainSelectedCode(controller); }), vscode.commands.registerCommand(COMMAND_NEW_CHAT_CONVERSATION, async () => { await newChatConversation(controller); }), ); }; Loading