diff --git a/extension/src/server/interactionService.ts b/extension/src/server/interactionService.ts index 924292420cd..8d0d5accec5 100644 --- a/extension/src/server/interactionService.ts +++ b/extension/src/server/interactionService.ts @@ -211,6 +211,7 @@ export class InteractionService implements IInteractionService { extensionLogOutputChannel.info(`Displaying message: ${emoji} ${message}`); vscode.window.showInformationMessage(formatText(message)); + this.clearProgressNotification(); } // There is no need for a different success message handler, as a general informative message ~= success @@ -223,6 +224,7 @@ export class InteractionService implements IInteractionService { extensionLogOutputChannel.info(`Displaying success message: ${message}`); vscode.window.showInformationMessage(formatText(message)); + this.clearProgressNotification(); } displaySubtleMessage(message: string) { @@ -238,6 +240,7 @@ export class InteractionService implements IInteractionService { displayPlainText(message: string) { extensionLogOutputChannel.info(`Displaying plain text: ${message}`); vscode.window.showInformationMessage(formatText(message)); + this.clearProgressNotification(); } // No direct equivalent in VS Code, so don't display anything visually, just log to output channel. diff --git a/extension/src/test/rpc/interactionServiceTests.test.ts b/extension/src/test/rpc/interactionServiceTests.test.ts index f05e49f326b..8ccb00955bc 100644 --- a/extension/src/test/rpc/interactionServiceTests.test.ts +++ b/extension/src/test/rpc/interactionServiceTests.test.ts @@ -94,6 +94,19 @@ suite('InteractionService endpoints', () => { showInformationMessageSpy.restore(); }); + test('displayMessage clears progress notification', async () => { + const testInfo = await createTestRpcServer(); + const showInformationMessageSpy = sinon.spy(vscode.window, 'showInformationMessage'); + // Access the private _progressNotifier via casting to any + const progressNotifier = (testInfo.interactionService as any)._progressNotifier; + const clearProgressSpy = sinon.spy(progressNotifier, 'clear'); + testInfo.interactionService.displayMessage(":test_emoji:", 'Test info message'); + assert.ok(showInformationMessageSpy.calledWith('Test info message')); + assert.ok(clearProgressSpy.calledOnce, 'ProgressNotifier.clear should be called once'); + showInformationMessageSpy.restore(); + clearProgressSpy.restore(); + }); + test("displaySuccess endpoint", async () => { const testInfo = await createTestRpcServer(); const showInformationMessageSpy = sinon.spy(vscode.window, 'showInformationMessage'); @@ -102,6 +115,19 @@ suite('InteractionService endpoints', () => { showInformationMessageSpy.restore(); }); + test("displaySuccess clears progress notification", async () => { + const testInfo = await createTestRpcServer(); + const showInformationMessageSpy = sinon.spy(vscode.window, 'showInformationMessage'); + // Access the private _progressNotifier via casting to any + const progressNotifier = (testInfo.interactionService as any)._progressNotifier; + const clearProgressSpy = sinon.spy(progressNotifier, 'clear'); + testInfo.interactionService.displaySuccess('Test success message'); + assert.ok(showInformationMessageSpy.calledWith('Test success message')); + assert.ok(clearProgressSpy.calledOnce, 'ProgressNotifier.clear should be called once'); + showInformationMessageSpy.restore(); + clearProgressSpy.restore(); + }); + test("displaySubtleMessage endpoint", async () => { const testInfo = await createTestRpcServer(); const setStatusBarMessageSpy = sinon.spy(vscode.window, 'setStatusBarMessage'); @@ -156,6 +182,19 @@ suite('InteractionService endpoints', () => { assert.ok(openTextDocumentStub.calledOnce, 'openTextDocument should be called once'); openTextDocumentStub.restore(); }); + + test("displayPlainText clears progress notification", async () => { + const testInfo = await createTestRpcServer(); + const showInformationMessageSpy = sinon.spy(vscode.window, 'showInformationMessage'); + // Access the private _progressNotifier via casting to any + const progressNotifier = (testInfo.interactionService as any)._progressNotifier; + const clearProgressSpy = sinon.spy(progressNotifier, 'clear'); + testInfo.interactionService.displayPlainText('Test plain text'); + assert.ok(showInformationMessageSpy.calledWith('Test plain text')); + assert.ok(clearProgressSpy.calledOnce, 'ProgressNotifier.clear should be called once'); + showInformationMessageSpy.restore(); + clearProgressSpy.restore(); + }); }); type RpcServerTestInfo = {