Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ import { ActionsHub } from "./power-pages/actions-hub/ActionsHub";
import { extractAuthInfo, extractOrgInfo } from "./power-pages/commonUtility";
import PacContext from "./pac/PacContext";
import ArtemisContext from "./ArtemisContext";
import { RegisterBasicPanels, RegisterCopilotPanels } from "./lib/PacActivityBarUI";
import { PacWrapper } from "./pac/PacWrapper";
import { authenticateUserInVSCode } from "../common/services/AuthenticationProvider";
import { PROVIDER_ID } from "../common/services/Constants";

let client: LanguageClient;
let _context: vscode.ExtensionContext;
let htmlServerRunning = false;
let yamlServerRunning = false;
let copilotPanelsRegistered = false;
let copilotPanelsDisposable: vscode.Disposable[] = [];


export async function activate(
Expand Down Expand Up @@ -171,6 +175,11 @@ export async function activate(
_context.subscriptions.push(cli);
_context.subscriptions.push(pacTerminal);

// Register auth and env panels
const pacWrapper = pacTerminal.getWrapper();
const basicPanels = RegisterBasicPanels(pacWrapper);
_context.subscriptions.push(...basicPanels);

let copilotNotificationShown = false;

const workspaceFolders = getWorkspaceFolders();
Expand Down Expand Up @@ -206,6 +215,7 @@ export async function activate(
}

if (EnvID && TenantID && AadObjectId) {
// Initialize ECS features client
await ECSFeaturesClient.init(
{
AppName: PowerPagesAppName,
Expand All @@ -216,6 +226,9 @@ export async function activate(
Location: getECSOrgLocationValue(clusterName, clusterNumber)
},
PowerPagesClientName, true);

// Register copilot panels only after ECS initialization is complete
registerCopilotPanels(pacWrapper);
}

oneDSLoggerWrapper.instantiate(geoName, geoLongName);
Expand Down Expand Up @@ -253,8 +266,11 @@ export async function activate(
}),

orgChangeErrorEvent(async () => {
//Even if auth change was unsuccessful, we should still initialize the actions hub
await ActionsHub.initialize(context, pacTerminal);
// Register copilot panels even if org change was unsuccessful
registerCopilotPanels(pacWrapper);

// Even if auth change was unsuccessful, we should still initialize the actions hub
await ActionsHub.initialize(_context, pacTerminal);

vscode.commands.executeCommand('setContext', 'microsoft.powerplatform.environment.initialized', true);
})
Expand Down Expand Up @@ -462,3 +478,22 @@ function showNotificationForCopilot(telemetryData: string, countOfActivePortals:
}

}

/**
* Registers copilot panels if they haven't been registered yet
* @param pacWrapper The PAC wrapper instance
*/
function registerCopilotPanels(pacWrapper: PacWrapper): void {
if (!copilotPanelsRegistered) {
// Dispose previous copilot panel registrations if they exist
for (const disposable of copilotPanelsDisposable) {
disposable.dispose();
}
copilotPanelsDisposable = [];

// Use RegisterCopilotPanels to register all copilot-related panels
copilotPanelsDisposable = RegisterCopilotPanels(pacWrapper, _context);
_context.subscriptions.push(...copilotPanelsDisposable);
copilotPanelsRegistered = true;
}
}
20 changes: 17 additions & 3 deletions src/client/lib/PacActivityBarUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,30 @@ import { EnvAndSolutionTreeView } from './EnvAndSolutionTreeView';
import { PowerPagesCopilot } from '../../common/copilot/PowerPagesCopilot';
import { PowerPagesChatParticipant } from '../../common/chat-participants/powerpages/PowerPagesChatParticipant';

export function RegisterPanels(pacWrapper: PacWrapper, context: vscode.ExtensionContext): vscode.Disposable[] {
/**
* Registers authentication and environment panels that don't require ECS initialization
* @param pacWrapper - The PAC wrapper instance
* @returns Array of disposable objects
*/
export function RegisterBasicPanels(pacWrapper: PacWrapper): vscode.Disposable[] {
const authPanel = new AuthTreeView(() => pacWrapper.authList(), pacWrapper);
const envAndSolutionPanel = new EnvAndSolutionTreeView(
() => pacWrapper.orgList(),
(environmentUrl) => pacWrapper.solutionListFromEnvironment(environmentUrl),
authPanel.onDidChangeTreeData,
pacWrapper);

const copilotPanel = new PowerPagesCopilot(context.extensionUri, context, pacWrapper);
return [authPanel, envAndSolutionPanel];
}

/**
* Registers copilot related panels that require ECS initialization
* @param pacWrapper - The PAC wrapper instance
* @param context - The VS Code extension context
* @returns Array of disposable objects
*/
export function RegisterCopilotPanels(pacWrapper: PacWrapper, context: vscode.ExtensionContext): vscode.Disposable[] {
const copilotPanel = new PowerPagesCopilot(context.extensionUri, context, pacWrapper);
const powerPagesChatParticipant = PowerPagesChatParticipant.getInstance(context, pacWrapper);

vscode.window.registerWebviewViewProvider('powerpages.copilot', copilotPanel, {
Expand All @@ -28,5 +42,5 @@ export function RegisterPanels(pacWrapper: PacWrapper, context: vscode.Extension
},
});

return [authPanel, envAndSolutionPanel, copilotPanel, powerPagesChatParticipant];
return [copilotPanel, powerPagesChatParticipant];
}
2 changes: 0 additions & 2 deletions src/client/lib/PacTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import * as path from 'path';
import * as vscode from 'vscode';
import * as os from 'os'
import { PacInterop, PacWrapper } from '../pac/PacWrapper';
import { RegisterPanels } from './PacActivityBarUI';
import { PacWrapperContext } from '../pac/PacWrapperContext';
import { RegisterUriHandler } from '../uriHandler';

Expand Down Expand Up @@ -64,7 +63,6 @@ export class PacTerminal implements vscode.Disposable {
}
}));

this._cmdDisposables.push(...RegisterPanels(this._pacWrapper, context));
this._cmdDisposables.push(RegisterUriHandler(this._pacWrapper));
}

Expand Down