Skip to content

Commit

Permalink
Fix build error after merge from master
Browse files Browse the repository at this point in the history
  • Loading branch information
tyaginidhi committed Jul 10, 2024
1 parent bc29cca commit d8b65e7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export async function activate(
oneDSLoggerWrapper.getLogger().traceError(exceptionError.name, exceptionError.message, exceptionError, { eventName: 'VscodeDesktopUsage' });
}
// Init OrgChangeNotifier instance
OrgChangeNotifier.createOrgChangeNotifierInstance(pacTerminal.getWrapper(), _context);
OrgChangeNotifier.createOrgChangeNotifierInstance(pacTerminal.getWrapper());

vscode.workspace.onDidOpenTextDocument(didOpenTextDocument);
vscode.workspace.textDocuments.forEach(didOpenTextDocument);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
import * as vscode from 'vscode';
import { createChatParticipant } from '../ChatParticipantUtils';
import { IComponentInfo, IPowerPagesChatResult } from './PowerPagesChatParticipantTypes';
import { ITelemetry } from '../../../client/telemetry/ITelemetry';
import TelemetryReporter from '@vscode/extension-telemetry';
import { sendApiRequest } from '../../copilot/IntelligenceApiService';
import { PacWrapper } from '../../../client/pac/PacWrapper';
import { intelligenceAPIAuthentication } from '../../services/AuthenticationProvider';
import { ActiveOrgOutput } from '../../../client/pac/PacTypes';
import { orgChangeErrorEvent, orgChangeEvent } from '../../OrgChangeNotifier';
import { AUTHENTICATION_FAILED_MSG, COPILOT_NOT_AVAILABLE_MSG,NO_PROMPT_MESSAGE, PAC_AUTH_NOT_FOUND, POWERPAGES_CHAT_PARTICIPANT_ID, RESPONSE_AWAITED_MSG, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_INVOKED, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS_NOT_FOUND, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO } from './PowerPagesChatParticipantConstants';
import { AUTHENTICATION_FAILED_MSG, COPILOT_NOT_AVAILABLE_MSG, NO_PROMPT_MESSAGE, PAC_AUTH_NOT_FOUND, POWERPAGES_CHAT_PARTICIPANT_ID, RESPONSE_AWAITED_MSG, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_INVOKED, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS_NOT_FOUND, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO } from './PowerPagesChatParticipantConstants';
import { ORG_DETAILS_KEY, handleOrgChangeSuccess, initializeOrgDetails } from '../../utilities/OrgHandlerUtils';
import { getComponentInfo, getEndpoint } from './PowerPagesChatParticipantUtils';
import { checkCopilotAvailability, getActiveEditorContent } from '../../utilities/Utils';
import { IIntelligenceAPIEndpointInformation } from '../../services/Interfaces';
import { v4 as uuidv4 } from 'uuid';
import { ITelemetry } from '../../OneDSLoggerTelemetry/telemetry/ITelemetry';
import { orgChangeErrorEvent, orgChangeEvent } from '../../../client/OrgChangeNotifier';

export class PowerPagesChatParticipant {
private static instance: PowerPagesChatParticipant | null = null;
Expand All @@ -28,7 +28,7 @@ export class PowerPagesChatParticipant {
private readonly _pacWrapper?: PacWrapper;
private isOrgDetailsInitialized = false;
private readonly _disposables: vscode.Disposable[] = [];
private cachedEndpoint: IIntelligenceAPIEndpointInformation| null = null;
private cachedEndpoint: IIntelligenceAPIEndpointInformation | null = null;
private powerPagesAgentSessionId: string;

private orgID: string | undefined;
Expand Down Expand Up @@ -82,21 +82,21 @@ export class PowerPagesChatParticipant {

stream.progress(RESPONSE_AWAITED_MSG)

this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_INVOKED, {sessionId: this.powerPagesAgentSessionId});
this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_INVOKED, { sessionId: this.powerPagesAgentSessionId });

await this.initializeOrgDetails();

if (!this.orgID || !this.environmentID) {
stream.markdown(PAC_AUTH_NOT_FOUND);
this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS_NOT_FOUND, {sessionId: this.powerPagesAgentSessionId});
this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS_NOT_FOUND, { sessionId: this.powerPagesAgentSessionId });
return {
metadata: {
command: ''
}
};
}

this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS, {orgID: this.orgID, environmentID: this.environmentID, sessionId: this.powerPagesAgentSessionId});
this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS, { orgID: this.orgID, environmentID: this.environmentID, sessionId: this.powerPagesAgentSessionId });

const intelligenceApiAuthResponse = await intelligenceAPIAuthentication(this.telemetry, this.powerPagesAgentSessionId, this.orgID, true);

Expand All @@ -113,7 +113,7 @@ export class PowerPagesChatParticipant {

const intelligenceAPIEndpointInfo = await getEndpoint(this.orgID, this.environmentID, this.telemetry, this.cachedEndpoint, this.powerPagesAgentSessionId);

const copilotAvailabilityStatus = checkCopilotAvailability(intelligenceAPIEndpointInfo.intelligenceEndpoint, this.orgID, this.telemetry,this.powerPagesAgentSessionId);
const copilotAvailabilityStatus = checkCopilotAvailability(intelligenceAPIEndpointInfo.intelligenceEndpoint, this.orgID, this.telemetry, this.powerPagesAgentSessionId);

if (!copilotAvailabilityStatus) {
stream.markdown(COPILOT_NOT_AVAILABLE_MSG)
Expand Down Expand Up @@ -143,15 +143,15 @@ export class PowerPagesChatParticipant {
};
}

const {activeFileParams} = getActiveEditorContent();
const { activeFileParams } = getActiveEditorContent();

const {componentInfo, entityName}: IComponentInfo = await getComponentInfo(this.telemetry, this.orgUrl, activeFileParams, this.powerPagesAgentSessionId);
const { componentInfo, entityName }: IComponentInfo = await getComponentInfo(this.telemetry, this.orgUrl, activeFileParams, this.powerPagesAgentSessionId);

const llmResponse = await sendApiRequest([{ displayText: userPrompt, code: '' }], activeFileParams, this.orgID, intelligenceApiToken, this.powerPagesAgentSessionId, entityName, componentInfo, this.telemetry, intelligenceAPIEndpointInfo.intelligenceEndpoint, intelligenceAPIEndpointInfo.geoName, intelligenceAPIEndpointInfo.crossGeoDataMovementEnabledPPACFlag);

const scenario = llmResponse.length > 1 ? llmResponse[llmResponse.length - 1] : llmResponse[0].displayText;

this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO, {scenario: scenario, sessionId: this.powerPagesAgentSessionId, orgId: this.orgID, environmentId: this.environmentID})
this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO, { scenario: scenario, sessionId: this.powerPagesAgentSessionId, orgId: this.orgID, environmentId: this.environmentID })

llmResponse.forEach((response: { displayText: string | vscode.MarkdownString; code: string; }) => {
if (response.displayText) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { ITelemetry } from "../../../client/telemetry/ITelemetry";
import { ADX_ENTITYFORM} from "../../copilot/constants";
import { ADX_ENTITYFORM } from "../../copilot/constants";
import { getEntityColumns, getEntityName, getFormXml } from "../../copilot/dataverseMetadata";
import { IActiveFileParams } from "../../copilot/model";
import { ITelemetry } from "../../OneDSLoggerTelemetry/telemetry/ITelemetry";
import { ArtemisService } from "../../services/ArtemisService";
import { dataverseAuthentication } from "../../services/AuthenticationProvider";
import { IIntelligenceAPIEndpointInformation } from "../../services/Interfaces";
import { SUPPORTED_ENTITIES } from "./PowerPagesChatParticipantConstants";
import { IComponentInfo } from "./PowerPagesChatParticipantTypes";



export async function getEndpoint(
orgID: string,
environmentID: string,
Expand Down Expand Up @@ -51,7 +49,7 @@ export async function getComponentInfo(telemetry: ITelemetry, orgUrl: string | u
}
}

return {componentInfo, entityName: metadataInfo.entityName};
return { componentInfo, entityName: metadataInfo.entityName };
}

export function isEntityInSupportedList(entity: string): boolean {
Expand Down
5 changes: 3 additions & 2 deletions src/common/copilot/utils/copilotUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import * as vscode from "vscode";
import { PacWrapper } from "../../../client/pac/PacWrapper";
import { ECSFeaturesClient } from "../../ecs-features/ecsFeatureClient";
import { CopilotDisableList, EnableProDevCopilot } from "../../ecs-features/ecsFeatureGates";
import { AUTH_CREATE_FAILED, AUTH_CREATE_MESSAGE, PAC_SUCCESS } from "../constants";
import { AUTH_CREATE_FAILED, AUTH_CREATE_MESSAGE } from "../constants";
import { showInputBoxAndGetOrgUrl, showProgressWithNotification } from "../../utilities/Utils";
import { SUCCESS } from "../../constants";

export async function createAuthProfileExp(pacWrapper: PacWrapper | undefined) {
const userOrgUrl = await showInputBoxAndGetOrgUrl();
Expand All @@ -22,7 +23,7 @@ export async function createAuthProfileExp(pacWrapper: PacWrapper | undefined) {
}

const pacAuthCreateOutput = await showProgressWithNotification(vscode.l10n.t(AUTH_CREATE_MESSAGE), async () => { return await pacWrapper?.authCreateNewAuthProfileForOrg(userOrgUrl) });
if (pacAuthCreateOutput && pacAuthCreateOutput.Status !== PAC_SUCCESS) {
if (pacAuthCreateOutput && pacAuthCreateOutput.Status !== SUCCESS) {
vscode.window.showErrorMessage(AUTH_CREATE_FAILED);
return;
}
Expand Down
8 changes: 4 additions & 4 deletions src/common/utilities/OrgHandlerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { ExtensionContext } from 'vscode';
import { ActiveOrgOutput } from '../../client/pac/PacTypes';
import { PacWrapper } from '../../client/pac/PacWrapper';
import { IOrgDetails } from '../chat-participants/powerpages/PowerPagesChatParticipantTypes';
import { PAC_SUCCESS } from '../copilot/constants';
import { createAuthProfileExp } from './Utils';
import { SUCCESS } from '../constants';
import { createAuthProfileExp } from '../copilot/utils/copilotUtil';

export const ORG_DETAILS_KEY = 'orgDetails';

Expand All @@ -31,7 +31,7 @@ export async function initializeOrgDetails(
pacWrapper?: PacWrapper
): Promise<{ orgID: string, orgUrl: string, environmentID: string }> {
if (isOrgDetailsInitialized) {
return {orgID:'', orgUrl: '', environmentID: ''};
return { orgID: '', orgUrl: '', environmentID: '' };
}

const orgDetails: IOrgDetails | undefined = extensionContext.globalState.get(ORG_DETAILS_KEY);
Expand All @@ -46,7 +46,7 @@ export async function initializeOrgDetails(
} else {
if (pacWrapper) {
const pacActiveOrg = await pacWrapper.activeOrg();
if (pacActiveOrg && pacActiveOrg.Status === PAC_SUCCESS) {
if (pacActiveOrg && pacActiveOrg.Status === SUCCESS) {
const orgDetails = handleOrgChangeSuccess(pacActiveOrg.Results, extensionContext);
orgID = orgDetails.orgID;
orgUrl = orgDetails.orgUrl;
Expand Down

0 comments on commit d8b65e7

Please sign in to comment.