diff --git a/src/client/extension.ts b/src/client/extension.ts index 5a1c6fe39..e9707cb8e 100644 --- a/src/client/extension.ts +++ b/src/client/extension.ts @@ -183,6 +183,10 @@ export async function activate( const basicPanels = RegisterBasicPanels(pacWrapper); _context.subscriptions.push(...basicPanels); + // Register copilot panels immediately during activation to ensure chat participant is always available + // This ensures @powerpages works even when user is not authenticated + registerCopilotPanels(pacWrapper); + let copilotNotificationShown = false; const workspaceFolders = getWorkspaceFolders(); @@ -513,5 +517,7 @@ function registerCopilotPanels(pacWrapper: PacWrapper): void { copilotPanelsDisposable = RegisterCopilotPanels(pacWrapper, _context); _context.subscriptions.push(...copilotPanelsDisposable); copilotPanelsRegistered = true; + + oneDSLoggerWrapper.getLogger().traceInfo("CopilotPanelsRegistered"); } } diff --git a/src/client/test/Integration/copilotRegistration.test.ts b/src/client/test/Integration/copilotRegistration.test.ts new file mode 100644 index 000000000..66308757e --- /dev/null +++ b/src/client/test/Integration/copilotRegistration.test.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + */ + +import * as vscode from 'vscode'; +import { expect } from 'chai'; + +describe('Copilot Registration Tests', () => { + before(async () => { + // Ensure the extension is activated + const extension = vscode.extensions.getExtension("microsoft-IsvExpTools.powerplatform-vscode"); + if (extension && !extension.isActive) { + await extension.activate(); + } + }); + + it('should register @powerpages chat participant during extension activation', async () => { + // Give the extension some time to complete its activation + await new Promise(resolve => setTimeout(resolve, 2000)); + + // Try to get the chat participants to verify powerpages is registered + // Note: This is a basic test that verifies the participant is available + // The actual VS Code chat API doesn't expose a direct way to enumerate participants + // but we can verify no immediate errors occur when trying to access copilot functionality + + // Check if the chat is available and no obvious errors + const chatExtension = vscode.extensions.getExtension('GitHub.copilot-chat'); + if (chatExtension && chatExtension.isActive) { + // If GitHub Copilot Chat is available, our participant should be registered + // This is an indirect test - the main validation is that our registration code runs + expect(true).to.be.true; // Registration completed without throwing errors + } else { + // If GitHub Copilot Chat is not available, we can't fully test the chat participant + // but we can at least verify our extension activated without errors + const powerPlatformExtension = vscode.extensions.getExtension("microsoft-IsvExpTools.powerplatform-vscode"); + expect(powerPlatformExtension?.isActive).to.be.true; + } + }); + + it('should handle extension activation without authentication gracefully', async () => { + // This test verifies that even without authentication, the extension activates + // and the chat participant is registered (though it will prompt for auth when used) + + const extension = vscode.extensions.getExtension("microsoft-IsvExpTools.powerplatform-vscode"); + expect(extension?.isActive).to.be.true; + + // No errors should have been thrown during activation + // The chat participant should be registered even if auth is not complete + expect(true).to.be.true; + }); +}); \ No newline at end of file