Loading src/common/chat/gitlab_chat_controller.test.ts +14 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ describe('GitLabChatController', () => { beforeEach(() => { controller = new GitLabChatController(platformManager, {} as vscode.ExtensionContext); apiMock.processNewUserPrompt = jest.fn().mockReturnValue({ apiMock.processNewUserPrompt = jest.fn().mockResolvedValue({ aiAction: { errors: [], requestId: 'uniqueId', Loading Loading @@ -131,6 +131,19 @@ describe('GitLabChatController', () => { ); }); describe('with API error on sending the message', () => { it('updates message with API error and sends VSCode error notification', async () => { apiMock.processNewUserPrompt = jest .fn() .mockRejectedValue({ response: { errors: [{ message: 'testError' }] } }); await controller.processNewUserRecord(record); expect(record.errors).toStrictEqual(['API error: testError']); expect(vscode.window.showErrorMessage).toHaveBeenCalledWith('API error: testError'); }); }); it('fills updated history', async () => { expect(controller.chatHistory).toEqual([]); Loading src/common/chat/gitlab_chat_controller.ts +14 −6 Original line number Diff line number Diff line Loading @@ -56,8 +56,13 @@ export class GitLabChatController implements vscode.WebviewViewProvider { if (!record.content) return; await this.#view.show(); await this.sendNewPrompt(record); if (record.errors.length > 0) { await vscode.window.showErrorMessage(record.errors[0]); return; } await this.addToChat(record); switch (record.type) { Loading Loading @@ -92,12 +97,14 @@ export class GitLabChatController implements vscode.WebviewViewProvider { private async sendNewPrompt(record: GitLabChatRecord) { if (!record.content) throw new Error('Trying to send prompt without content.'); const actionResponse = await this.#api.processNewUserPrompt( record.content, GitLabChatFileContext.forActiveFile(), ); await this.#api .processNewUserPrompt(record.content, GitLabChatFileContext.forActiveFile()) .then(actionResponse => { record.update(actionResponse.aiAction); }) .catch(err => { record.update({ errors: [`API error: ${err.response.errors[0].message}`] }); }); } private async refreshRecord(record: GitLabChatRecord) { Loading @@ -113,6 +120,7 @@ export class GitLabChatController implements vscode.WebviewViewProvider { contentHtml: apiResponse.contentHtml, extras: apiResponse.extras, timestamp: apiResponse.timestamp, errors: apiResponse.errors, }); } Loading webviews/vue2/gitlab_duo_chat/src/App.vue +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ export default { }, provide() { return { renderMarkdown: () => {}, renderMarkdown: content => content, renderGFM: element => { element.classList.add('gl-markdown', 'gl-compact-markdown'); }, Loading Loading
src/common/chat/gitlab_chat_controller.test.ts +14 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ describe('GitLabChatController', () => { beforeEach(() => { controller = new GitLabChatController(platformManager, {} as vscode.ExtensionContext); apiMock.processNewUserPrompt = jest.fn().mockReturnValue({ apiMock.processNewUserPrompt = jest.fn().mockResolvedValue({ aiAction: { errors: [], requestId: 'uniqueId', Loading Loading @@ -131,6 +131,19 @@ describe('GitLabChatController', () => { ); }); describe('with API error on sending the message', () => { it('updates message with API error and sends VSCode error notification', async () => { apiMock.processNewUserPrompt = jest .fn() .mockRejectedValue({ response: { errors: [{ message: 'testError' }] } }); await controller.processNewUserRecord(record); expect(record.errors).toStrictEqual(['API error: testError']); expect(vscode.window.showErrorMessage).toHaveBeenCalledWith('API error: testError'); }); }); it('fills updated history', async () => { expect(controller.chatHistory).toEqual([]); Loading
src/common/chat/gitlab_chat_controller.ts +14 −6 Original line number Diff line number Diff line Loading @@ -56,8 +56,13 @@ export class GitLabChatController implements vscode.WebviewViewProvider { if (!record.content) return; await this.#view.show(); await this.sendNewPrompt(record); if (record.errors.length > 0) { await vscode.window.showErrorMessage(record.errors[0]); return; } await this.addToChat(record); switch (record.type) { Loading Loading @@ -92,12 +97,14 @@ export class GitLabChatController implements vscode.WebviewViewProvider { private async sendNewPrompt(record: GitLabChatRecord) { if (!record.content) throw new Error('Trying to send prompt without content.'); const actionResponse = await this.#api.processNewUserPrompt( record.content, GitLabChatFileContext.forActiveFile(), ); await this.#api .processNewUserPrompt(record.content, GitLabChatFileContext.forActiveFile()) .then(actionResponse => { record.update(actionResponse.aiAction); }) .catch(err => { record.update({ errors: [`API error: ${err.response.errors[0].message}`] }); }); } private async refreshRecord(record: GitLabChatRecord) { Loading @@ -113,6 +120,7 @@ export class GitLabChatController implements vscode.WebviewViewProvider { contentHtml: apiResponse.contentHtml, extras: apiResponse.extras, timestamp: apiResponse.timestamp, errors: apiResponse.errors, }); } Loading
webviews/vue2/gitlab_duo_chat/src/App.vue +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ export default { }, provide() { return { renderMarkdown: () => {}, renderMarkdown: content => content, renderGFM: element => { element.classList.add('gl-markdown', 'gl-compact-markdown'); }, Loading