From 5186c242a1c7d6a621f77ed9a818bc6b2a1623cd Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Thu, 1 Aug 2024 17:11:15 +0530 Subject: [PATCH 01/10] chore:ECS config for @powerpages --- package.json | 4 ++-- .../powerpages/PowerPagesChatParticipant.ts | 11 +++++++++ src/common/copilot/utils/copilotUtil.ts | 23 ++++++++++++++++++- src/common/ecs-features/ecsFeatureGates.ts | 11 +++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 751f3d518..50bb54b8e 100644 --- a/package.json +++ b/package.json @@ -116,8 +116,8 @@ { "id": "powerpages", "name": "powerpages", - "fullName": "Power Pages Copilot", - "description": "Power Pages Copilot", + "fullName": "Copilot for Power Pages", + "description": "Copilot for Power Pages", "isSticky": true, "when": "config.powerPlatform.experimental.powerPagesInGitHubCopilotChat" } diff --git a/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts b/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts index 880b35253..652697a93 100644 --- a/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts +++ b/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts @@ -19,6 +19,7 @@ import { IIntelligenceAPIEndpointInformation } from '../../services/Interfaces'; import { v4 as uuidv4 } from 'uuid'; import { ITelemetry } from '../../OneDSLoggerTelemetry/telemetry/ITelemetry'; import { orgChangeErrorEvent, orgChangeEvent } from '../../../client/OrgChangeNotifier'; +import { getEnabledOrgList } from '../../copilot/utils/copilotUtil'; export class PowerPagesChatParticipant { private static instance: PowerPagesChatParticipant | null = null; @@ -96,6 +97,16 @@ export class PowerPagesChatParticipant { }; } + if (!getEnabledOrgList().includes(this.orgID)) { + stream.markdown(COPILOT_NOT_AVAILABLE_MSG); + return { + metadata: { + command: '' + } + }; + } + + 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); diff --git a/src/common/copilot/utils/copilotUtil.ts b/src/common/copilot/utils/copilotUtil.ts index d25d6f564..cdc48ccc9 100644 --- a/src/common/copilot/utils/copilotUtil.ts +++ b/src/common/copilot/utils/copilotUtil.ts @@ -6,7 +6,7 @@ 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 { CopilotDisableList, EnablePowerPagesGitHubCopilot, EnableProDevCopilot } from "../../ecs-features/ecsFeatureGates"; import { AUTH_CREATE_FAILED, AUTH_CREATE_MESSAGE } from "../constants"; import { showInputBoxAndGetOrgUrl, showProgressWithNotification } from "../../utilities/Utils"; import { SUCCESS } from "../../constants"; @@ -79,3 +79,24 @@ export function enableCrossGeoDataFlowInGeo() { return enableCrossGeoDataFlowInGeo.split(',').map(org => org.trim()); } + +export function getEnabledOrgList() { + const allowedProDevCopilotOrgs = ECSFeaturesClient.getConfig(EnablePowerPagesGitHubCopilot).allowedProDevCopilotOrgs; + + if (allowedProDevCopilotOrgs === undefined || allowedProDevCopilotOrgs === "") { + return []; + } + + return allowedProDevCopilotOrgs.split(',').map(org => org.trim()); +} + +export function getEnabledTenantList() { + + const allowedProDevCopilotTenants = ECSFeaturesClient.getConfig(EnablePowerPagesGitHubCopilot).allowedProDevCopilotTenants; + + if (allowedProDevCopilotTenants === undefined || allowedProDevCopilotTenants === "") { + return []; + } + + return allowedProDevCopilotTenants.split(',').map(org => org.trim()); +} diff --git a/src/common/ecs-features/ecsFeatureGates.ts b/src/common/ecs-features/ecsFeatureGates.ts index 6a66a98ff..214a15459 100644 --- a/src/common/ecs-features/ecsFeatureGates.ts +++ b/src/common/ecs-features/ecsFeatureGates.ts @@ -38,3 +38,14 @@ export const { "capiSupportedProDevCopilotGeoWithCrossGeoDataFlow": "eu,se,ch,fr,de,no" }, }); + +export const { + feature: EnablePowerPagesGitHubCopilot +} = getFeatureConfigs({ + teamName: PowerPagesClientName, + description: 'Enable Power Pages GitHub Copilot', + fallback: { + allowedProDevCopilotTenants: "", + allowedProDevCopilotOrgs: "abcc137d-7ae6-ee11-9048-000d3a106507", + }, +}); From 522989d55ae40399d8f6f2334ed0f14023f29802 Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Sun, 25 Aug 2024 20:32:31 +0530 Subject: [PATCH 02/10] feat: Add ECSFeaturesClient initialization in extension.ts --- src/client/extension.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/client/extension.ts b/src/client/extension.ts index df44d5996..5da5a8939 100644 --- a/src/client/extension.ts +++ b/src/client/extension.ts @@ -43,6 +43,8 @@ import { workspaceContainsPortalConfigFolder } from "../common/utilities/PathFin import { getPortalsOrgURLs } from "../common/utilities/WorkspaceInfoFinderUtil"; import { SUCCESS } from "../common/constants"; import { AadIdKey } from "../common/OneDSLoggerTelemetry/telemetryConstants"; +import { PowerPagesAppName, PowerPagesClientName } from "../common/ecs-features/constants"; +import { ECSFeaturesClient } from "../common/ecs-features/ecsFeatureClient"; let client: LanguageClient; let _context: vscode.ExtensionContext; @@ -198,7 +200,20 @@ export async function activate( if ((pacActiveAuth && pacActiveAuth.Status === SUCCESS)) { AadIdObject = pacActiveAuth.Results?.filter(obj => obj.Key === AadIdKey); } + const { geoName, geoLongName } = artemisResponse.response; + + // Initialize ECS config in webExtensionContext + await ECSFeaturesClient.init(_telemetry, + { + AppName: PowerPagesAppName, + EnvID: queryParamsMap.get(queryParameters.ENV_ID) as string, + UserID: WebExtensionContext.userId, + TenantID: queryParamsMap.get(queryParameters.TENANT_ID) as string, + Region: queryParamsMap.get(queryParameters.REGION) as string + }, + PowerPagesClientName); + oneDSLoggerWrapper.instantiate(geoName, geoLongName); let initContext: object = { ...orgDetails, orgGeo: geoName }; if (AadIdObject?.[0]?.Value) { From e366534c425ab3f7e575e0d91f65354014a13c99 Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Mon, 26 Aug 2024 14:57:35 +0530 Subject: [PATCH 03/10] feat: Initialize ECSFeaturesClient with environment ID, tenant ID, and Aad ID This commit initializes the ECSFeaturesClient in the extension.ts file with the environment ID, tenant ID, and Aad ID. It retrieves these values from the pacActiveAuth object and uses them to configure the ECSFeaturesClient. This change ensures that the ECSFeaturesClient is properly initialized with the necessary information for its functionality. Co-authored-by: amitjoshi --- src/client/extension.ts | 31 ++++++++++--------- .../telemetryConstants.ts | 4 ++- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/client/extension.ts b/src/client/extension.ts index 5da5a8939..7776dae6c 100644 --- a/src/client/extension.ts +++ b/src/client/extension.ts @@ -42,7 +42,7 @@ import { ArtemisService } from "../common/services/ArtemisService"; import { workspaceContainsPortalConfigFolder } from "../common/utilities/PathFinderUtil"; import { getPortalsOrgURLs } from "../common/utilities/WorkspaceInfoFinderUtil"; import { SUCCESS } from "../common/constants"; -import { AadIdKey } from "../common/OneDSLoggerTelemetry/telemetryConstants"; +import { AadIdKey, EnvIdKey, TenantIdKey } from "../common/OneDSLoggerTelemetry/telemetryConstants"; import { PowerPagesAppName, PowerPagesClientName } from "../common/ecs-features/constants"; import { ECSFeaturesClient } from "../common/ecs-features/ecsFeatureClient"; @@ -195,25 +195,28 @@ export async function activate( const orgID = orgDetails.OrgId; const artemisResponse = await ArtemisService.getArtemisResponse(orgID, _telemetry, ""); if (artemisResponse !== null && artemisResponse.response !== null) { + const { geoName, geoLongName } = artemisResponse.response; const pacActiveAuth = await pacTerminal.getWrapper()?.activeAuth(); - let AadIdObject; + let AadIdObject, EnvID, TenantID; if ((pacActiveAuth && pacActiveAuth.Status === SUCCESS)) { AadIdObject = pacActiveAuth.Results?.filter(obj => obj.Key === AadIdKey); + EnvID = pacActiveAuth.Results?.filter(obj => obj.Key === EnvIdKey); + TenantID = pacActiveAuth.Results?.filter(obj => obj.Key === TenantIdKey); } - const { geoName, geoLongName } = artemisResponse.response; - // Initialize ECS config in webExtensionContext - await ECSFeaturesClient.init(_telemetry, - { - AppName: PowerPagesAppName, - EnvID: queryParamsMap.get(queryParameters.ENV_ID) as string, - UserID: WebExtensionContext.userId, - TenantID: queryParamsMap.get(queryParameters.TENANT_ID) as string, - Region: queryParamsMap.get(queryParameters.REGION) as string - }, - PowerPagesClientName); - + if (EnvID?.[0]?.Value && TenantID?.[0]?.Value && AadIdObject?.[0]?.Value) { + await ECSFeaturesClient.init(_telemetry, + { + AppName: PowerPagesAppName, + EnvID: EnvID[0].Value, + UserID: AadIdObject[0].Value, + TenantID: TenantID[0].Value, + Region: geoName + }, + PowerPagesClientName); + } + oneDSLoggerWrapper.instantiate(geoName, geoLongName); let initContext: object = { ...orgDetails, orgGeo: geoName }; if (AadIdObject?.[0]?.Value) { diff --git a/src/common/OneDSLoggerTelemetry/telemetryConstants.ts b/src/common/OneDSLoggerTelemetry/telemetryConstants.ts index eab9ad972..331f9034f 100644 --- a/src/common/OneDSLoggerTelemetry/telemetryConstants.ts +++ b/src/common/OneDSLoggerTelemetry/telemetryConstants.ts @@ -39,4 +39,6 @@ export enum GeoNames { // Custom telemetry feature flag export const CUSTOM_TELEMETRY_FOR_POWER_PAGES_SETTING_NAME = 'enableTelemetry'; -export const AadIdKey= 'Entra ID Object Id:'; \ No newline at end of file +export const AadIdKey= 'Entra ID Object Id:'; +export const EnvIdKey = "Environment Id"; +export const TenantIdKey = "Tenant Id"; From ecd5daa8a2600113293204d5e2a97a448bd79f22 Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Wed, 4 Sep 2024 11:58:46 +0530 Subject: [PATCH 04/10] chore: Update PowerPagesChatParticipant with ecs --- .../powerpages/PowerPagesChatParticipant.ts | 11 ++++++----- .../powerpages/PowerPagesChatParticipantConstants.ts | 1 + src/common/copilot/utils/copilotUtil.ts | 4 ++++ src/common/ecs-features/ecsFeatureGates.ts | 3 ++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts b/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts index 56b939639..852efc495 100644 --- a/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts +++ b/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts @@ -12,14 +12,14 @@ import { sendApiRequest } from '../../copilot/IntelligenceApiService'; import { PacWrapper } from '../../../client/pac/PacWrapper'; import { intelligenceAPIAuthentication } from '../../services/AuthenticationProvider'; import { ActiveOrgOutput } from '../../../client/pac/PacTypes'; -import { AUTHENTICATION_FAILED_MSG, COPILOT_NOT_AVAILABLE_MSG, DISCLAIMER_MESSAGE, INVALID_RESPONSE, NO_PROMPT_MESSAGE, PAC_AUTH_NOT_FOUND, POWERPAGES_CHAT_PARTICIPANT_ID, RESPONSE_AWAITED_MSG, RESPONSE_SCENARIOS, SKIP_CODES, STATER_PROMPTS, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ERROR, 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, WELCOME_MESSAGE, WELCOME_PROMPT } from './PowerPagesChatParticipantConstants'; +import { AUTHENTICATION_FAILED_MSG, COPILOT_NOT_AVAILABLE_MSG, DISCLAIMER_MESSAGE, INVALID_RESPONSE, NO_PROMPT_MESSAGE, PAC_AUTH_NOT_FOUND, POWERPAGES_CHAT_PARTICIPANT_ID, RESPONSE_AWAITED_MSG, RESPONSE_SCENARIOS, SKIP_CODES, STATER_PROMPTS, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ERROR, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_INVOKED, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NOT_AVAILABLE_ECS, 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, WELCOME_MESSAGE, WELCOME_PROMPT } from './PowerPagesChatParticipantConstants'; import { ORG_DETAILS_KEY, handleOrgChangeSuccess, initializeOrgDetails } from '../../utilities/OrgHandlerUtils'; import { createAndReferenceLocation, getComponentInfo, getEndpoint, provideChatParticipantFollowups, handleChatParticipantFeedback, createErrorResult, createSuccessResult } from './PowerPagesChatParticipantUtils'; import { checkCopilotAvailability, fetchRelatedFiles, getActiveEditorContent } from '../../utilities/Utils'; import { IIntelligenceAPIEndpointInformation } from '../../services/Interfaces'; import { v4 as uuidv4 } from 'uuid'; import { orgChangeErrorEvent, orgChangeEvent } from '../../../client/OrgChangeNotifier'; -import { getEnabledOrgList } from '../../copilot/utils/copilotUtil'; +import { isPowerPagesGitHubCopilotEnabled } from '../../copilot/utils/copilotUtil'; import { ADX_WEBPAGE, IApiRequestParams, IRelatedFiles } from '../../constants'; export class PowerPagesChatParticipant { @@ -101,15 +101,16 @@ export class PowerPagesChatParticipant { this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS, { orgID: this.orgID, environmentID: this.environmentID, sessionId: this.powerPagesAgentSessionId }); - if (!getEnabledOrgList().includes(this.orgID)) { + if (!isPowerPagesGitHubCopilotEnabled()) { stream.markdown(COPILOT_NOT_AVAILABLE_MSG); - createSuccessResult('', RESPONSE_SCENARIOS.COPILOT_NOT_AVAILABLE, this.orgID); + this.telemetry.sendTelemetryErrorEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NOT_AVAILABLE_ECS, { sessionId: this.powerPagesAgentSessionId, orgID: this.orgID }); + return createSuccessResult('', RESPONSE_SCENARIOS.COPILOT_NOT_AVAILABLE, this.orgID); } const intelligenceApiAuthResponse = await intelligenceAPIAuthentication(this.telemetry, this.powerPagesAgentSessionId, this.orgID, true); if (!intelligenceApiAuthResponse) { - createErrorResult(AUTHENTICATION_FAILED_MSG, RESPONSE_SCENARIOS.AUTHENTICATION_FAILED, this.orgID); + return createErrorResult(AUTHENTICATION_FAILED_MSG, RESPONSE_SCENARIOS.AUTHENTICATION_FAILED, this.orgID); } const intelligenceApiToken = intelligenceApiAuthResponse.accessToken; diff --git a/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts b/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts index 5a035b8ac..6178fe374 100644 --- a/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts +++ b/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts @@ -48,5 +48,6 @@ export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO = 'GitHubPowerPa export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO_FEEDBACK_THUMBSUP = 'GitHubPowerPagesAgentScenarioFeedbackThumbsUp'; export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO_FEEDBACK_THUMBSDOWN = 'GitHubPowerPagesAgentScenarioFeedbackThumbsDown'; export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ERROR = 'GitHubPowerPagesAgentError'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NOT_AVAILABLE_ECS = 'GitHubPowerPagesAgentNotAvailableECS'; diff --git a/src/common/copilot/utils/copilotUtil.ts b/src/common/copilot/utils/copilotUtil.ts index cdc48ccc9..faa7ffc33 100644 --- a/src/common/copilot/utils/copilotUtil.ts +++ b/src/common/copilot/utils/copilotUtil.ts @@ -100,3 +100,7 @@ export function getEnabledTenantList() { return allowedProDevCopilotTenants.split(',').map(org => org.trim()); } + +export function isPowerPagesGitHubCopilotEnabled() { + return ECSFeaturesClient.getConfig(EnablePowerPagesGitHubCopilot).enablePowerpagesInGithubChat +} diff --git a/src/common/ecs-features/ecsFeatureGates.ts b/src/common/ecs-features/ecsFeatureGates.ts index 214a15459..760fa5bd7 100644 --- a/src/common/ecs-features/ecsFeatureGates.ts +++ b/src/common/ecs-features/ecsFeatureGates.ts @@ -46,6 +46,7 @@ export const { description: 'Enable Power Pages GitHub Copilot', fallback: { allowedProDevCopilotTenants: "", - allowedProDevCopilotOrgs: "abcc137d-7ae6-ee11-9048-000d3a106507", + allowedProDevCopilotOrgs: "", + enablePowerpagesInGithubChat: false, }, }); From 349a9dfa4de3f0aa5da10f80292c89074349388e Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Fri, 6 Sep 2024 15:14:05 +0530 Subject: [PATCH 05/10] chore: Update telemetry constants for environment and tenant IDs --- src/common/OneDSLoggerTelemetry/telemetryConstants.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/OneDSLoggerTelemetry/telemetryConstants.ts b/src/common/OneDSLoggerTelemetry/telemetryConstants.ts index 331f9034f..fc98d1280 100644 --- a/src/common/OneDSLoggerTelemetry/telemetryConstants.ts +++ b/src/common/OneDSLoggerTelemetry/telemetryConstants.ts @@ -40,5 +40,5 @@ export enum GeoNames { export const CUSTOM_TELEMETRY_FOR_POWER_PAGES_SETTING_NAME = 'enableTelemetry'; export const AadIdKey= 'Entra ID Object Id:'; -export const EnvIdKey = "Environment Id"; -export const TenantIdKey = "Tenant Id"; +export const EnvIdKey = "Environment Id:"; +export const TenantIdKey = "Tenant Id:"; From b1f796da44f97fbb91b23154a965c36bd4b48ee6 Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Tue, 10 Sep 2024 17:12:59 +0530 Subject: [PATCH 06/10] chore: ecs update for region.stamp --- package.json | 3 +-- src/client/extension.ts | 3 +-- .../powerpages/PowerPagesChatParticipant.ts | 7 +++--- .../PowerPagesChatParticipantConstants.ts | 5 +++- src/common/copilot/utils/copilotUtil.ts | 25 ++++--------------- src/common/ecs-features/ecsFeatureGates.ts | 4 +-- 6 files changed, 15 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 2804b6c24..23720a2a6 100644 --- a/package.json +++ b/package.json @@ -118,8 +118,7 @@ "name": "powerpages", "fullName": "Copilot for Power Pages", "description": "Copilot for Power Pages", - "isSticky": true, - "when": "never" + "isSticky": true } ], "problemMatchers": [ diff --git a/src/client/extension.ts b/src/client/extension.ts index c37375763..cd2e5ebd8 100644 --- a/src/client/extension.ts +++ b/src/client/extension.ts @@ -204,7 +204,6 @@ export async function activate( TenantID = pacActiveAuth.Results?.filter(obj => obj.Key === TenantIdKey); } - // Initialize ECS config in webExtensionContext if (EnvID?.[0]?.Value && TenantID?.[0]?.Value && AadIdObject?.[0]?.Value) { await ECSFeaturesClient.init(_telemetry, { @@ -212,7 +211,7 @@ export async function activate( EnvID: EnvID[0].Value, UserID: AadIdObject[0].Value, TenantID: TenantID[0].Value, - Region: geoName + Region: artemisResponse.stamp }, PowerPagesClientName); } diff --git a/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts b/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts index ef316c2b7..8bb2b50b8 100644 --- a/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts +++ b/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts @@ -12,7 +12,7 @@ import { sendApiRequest } from '../../copilot/IntelligenceApiService'; import { PacWrapper } from '../../../client/pac/PacWrapper'; import { intelligenceAPIAuthentication } from '../../services/AuthenticationProvider'; import { ActiveOrgOutput } from '../../../client/pac/PacTypes'; -import { AUTHENTICATION_FAILED_MSG, COPILOT_NOT_AVAILABLE_MSG, DISCLAIMER_MESSAGE, INVALID_RESPONSE, NO_PROMPT_MESSAGE, PAC_AUTH_INPUT, PAC_AUTH_NOT_FOUND, POWERPAGES_CHAT_PARTICIPANT_ID, RESPONSE_AWAITED_MSG, RESPONSE_SCENARIOS, SKIP_CODES, STATER_PROMPTS, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ERROR, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_INVOKED, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_LOCATION_REFERENCED, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NO_PROMPT, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NOT_AVAILABLE_ECS, 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, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SUCCESSFUL_PROMPT, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WEBPAGE_RELATED_FILES, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WELCOME_PROMPT, WELCOME_MESSAGE, WELCOME_PROMPT } from './PowerPagesChatParticipantConstants'; +import { AUTHENTICATION_FAILED_MSG, COPILOT_NOT_AVAILABLE_MSG, COPILOT_NOT_RELEASED_MSG, DISCLAIMER_MESSAGE, INVALID_RESPONSE, NO_PROMPT_MESSAGE, PAC_AUTH_INPUT, PAC_AUTH_NOT_FOUND, POWERPAGES_CHAT_PARTICIPANT_ID, RESPONSE_AWAITED_MSG, RESPONSE_SCENARIOS, SKIP_CODES, STATER_PROMPTS, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ERROR, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_INVOKED, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_LOCATION_REFERENCED, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NO_PROMPT, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NOT_AVAILABLE_ECS, 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, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SUCCESSFUL_PROMPT, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WEBPAGE_RELATED_FILES, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WELCOME_PROMPT, WELCOME_MESSAGE, WELCOME_PROMPT } from './PowerPagesChatParticipantConstants'; import { ORG_DETAILS_KEY, handleOrgChangeSuccess, initializeOrgDetails } from '../../utilities/OrgHandlerUtils'; import { createAndReferenceLocation, getComponentInfo, getEndpoint, provideChatParticipantFollowups, handleChatParticipantFeedback, createErrorResult, createSuccessResult, removeChatVariables } from './PowerPagesChatParticipantUtils'; import { checkCopilotAvailability, fetchRelatedFiles, getActiveEditorContent } from '../../utilities/Utils'; @@ -108,11 +108,10 @@ export class PowerPagesChatParticipant { this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS, { orgID: this.orgID, environmentID: this.environmentID, sessionId: this.powerPagesAgentSessionId }); oneDSLoggerWrapper.getLogger().traceInfo(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS, { orgID: this.orgID, environmentID: this.environmentID, sessionId: this.powerPagesAgentSessionId }); - if (!isPowerPagesGitHubCopilotEnabled()) { - stream.markdown(COPILOT_NOT_AVAILABLE_MSG); + stream.markdown(COPILOT_NOT_RELEASED_MSG); this.telemetry.sendTelemetryErrorEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NOT_AVAILABLE_ECS, { sessionId: this.powerPagesAgentSessionId, orgID: this.orgID }); - return createSuccessResult('', RESPONSE_SCENARIOS.COPILOT_NOT_AVAILABLE, this.orgID); + return createSuccessResult('', RESPONSE_SCENARIOS.COPILOT_NOT_RELEASED, this.orgID); } const intelligenceApiAuthResponse = await intelligenceAPIAuthentication(this.telemetry, this.powerPagesAgentSessionId, this.orgID, true); diff --git a/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts b/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts index 6d4e9e318..969f5bc52 100644 --- a/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts +++ b/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts @@ -23,7 +23,8 @@ export const RESPONSE_SCENARIOS = { FORM_PROMPT: 'FORM_PROMPT', LIST_PROMPT: 'LIST_PROMPT', WEB_API_PROMPT: 'WEB_API_PROMPT', - WELCOME_PROMPT: 'WELCOME_PROMPT' + WELCOME_PROMPT: 'WELCOME_PROMPT', + COPILOT_NOT_RELEASED: 'COPILOT_NOT_RELEASED' }; // Localized strings @@ -40,6 +41,7 @@ export const INVALID_RESPONSE = vscode.l10n.t('Something went wrong. Don’t wor export const DISCLAIMER_MESSAGE = vscode.l10n.t('Make sure AI-generated content is accurate and appropriate before using. [Learn more](https://go.microsoft.com/fwlink/?linkid=2240145) | [View terms](https://go.microsoft.com/fwlink/?linkid=2189520)'); export const NO_PROMPT_MESSAGE = vscode.l10n.t('Hi! Power Pages lets you build secure, professional websites that you can quickly configure and publish across web browsers and devices.\n\nTo create your website, visit the [Power Pages](https://powerpages.microsoft.com/).\nReturn to this chat and @powerpages can help you write and edit your website code.'); export const PAC_AUTH_INPUT = vscode.l10n.t("Checking for active auth profile..."); +export const COPILOT_NOT_RELEASED_MSG = vscode.l10n.t("@PowerPages is not yet available in your region.") // Telemetry Event Names export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_INVOKED = 'VSCodeExtensionGitHubPowerPagesAgentInvoked'; @@ -54,5 +56,6 @@ export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_LOCATION_REFERENCED = 'VS export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NO_PROMPT = 'VSCodeExtensionGitHubPowerPagesAgentNoPrompt'; export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WELCOME_PROMPT = 'VSCodeExtensionGitHubPowerPagesAgentWelcomePrompt'; export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SUCCESSFUL_PROMPT = 'VSCodeExtensionGitHubPowerPagesAgentSuccessfulPrompt'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NOT_AVAILABLE_ECS = 'VSCodeExtensionGitHubPowerPagesAgentNotAvailableECS'; diff --git a/src/common/copilot/utils/copilotUtil.ts b/src/common/copilot/utils/copilotUtil.ts index 8ad92ebf6..6825aae3e 100644 --- a/src/common/copilot/utils/copilotUtil.ts +++ b/src/common/copilot/utils/copilotUtil.ts @@ -80,27 +80,12 @@ export function enableCrossGeoDataFlowInGeo() { return enableCrossGeoDataFlowInGeo.split(',').map(org => org.trim()); } -export function getEnabledOrgList() { - const allowedProDevCopilotOrgs = ECSFeaturesClient.getConfig(EnablePowerPagesGitHubCopilot).allowedProDevCopilotOrgs; - - if (allowedProDevCopilotOrgs === undefined || allowedProDevCopilotOrgs === "") { - return []; - } - - return allowedProDevCopilotOrgs.split(',').map(org => org.trim()); -} - -export function getEnabledTenantList() { - - const allowedProDevCopilotTenants = ECSFeaturesClient.getConfig(EnablePowerPagesGitHubCopilot).allowedProDevCopilotTenants; +export function isPowerPagesGitHubCopilotEnabled() { + const enablePowerpagesInGithubCopilot = ECSFeaturesClient.getConfig(EnablePowerPagesGitHubCopilot).enablePowerpagesInGithubCopilot - if (allowedProDevCopilotTenants === undefined || allowedProDevCopilotTenants === "") { - return []; + if(enablePowerpagesInGithubCopilot === undefined) { + return false; } - return allowedProDevCopilotTenants.split(',').map(org => org.trim()); -} - -export function isPowerPagesGitHubCopilotEnabled() { - return ECSFeaturesClient.getConfig(EnablePowerPagesGitHubCopilot).enablePowerpagesInGithubChat + return enablePowerpagesInGithubCopilot; } diff --git a/src/common/ecs-features/ecsFeatureGates.ts b/src/common/ecs-features/ecsFeatureGates.ts index 760fa5bd7..b49fe6453 100644 --- a/src/common/ecs-features/ecsFeatureGates.ts +++ b/src/common/ecs-features/ecsFeatureGates.ts @@ -45,8 +45,6 @@ export const { teamName: PowerPagesClientName, description: 'Enable Power Pages GitHub Copilot', fallback: { - allowedProDevCopilotTenants: "", - allowedProDevCopilotOrgs: "", - enablePowerpagesInGithubChat: false, + enablePowerpagesInGithubCopilot: false, }, }); From 9252eeae382479d7a34b9d7a762bc8e263f486be Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Tue, 10 Sep 2024 17:19:03 +0530 Subject: [PATCH 07/10] icon update --- .../powerpages/PowerPagesChatParticipant.ts | 2 +- .../powerpages/assets/copilot.svg | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/common/chat-participants/powerpages/assets/copilot.svg diff --git a/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts b/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts index 8bb2b50b8..f038cdeef 100644 --- a/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts +++ b/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts @@ -43,7 +43,7 @@ export class PowerPagesChatParticipant { this.chatParticipant = createChatParticipant(POWERPAGES_CHAT_PARTICIPANT_ID, this.handler); //TODO: Check the icon image - this.chatParticipant.iconPath = vscode.Uri.joinPath(context.extensionUri, 'src', 'common', 'chat-participants', 'powerpages', 'assets', 'copilot.png'); + this.chatParticipant.iconPath = vscode.Uri.joinPath(context.extensionUri, 'src', 'common', 'chat-participants', 'powerpages', 'assets', 'copilot.svg'); this.chatParticipant.onDidReceiveFeedback((feedback: vscode.ChatResultFeedback) => { handleChatParticipantFeedback(feedback, this.powerPagesAgentSessionId, this.telemetry); diff --git a/src/common/chat-participants/powerpages/assets/copilot.svg b/src/common/chat-participants/powerpages/assets/copilot.svg new file mode 100644 index 000000000..1f752210c --- /dev/null +++ b/src/common/chat-participants/powerpages/assets/copilot.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 4fba3b39729b327f3b6c73403f28240f2a09db35 Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Tue, 10 Sep 2024 17:33:24 +0530 Subject: [PATCH 08/10] refactor: Update telemetry events for @powerpages ecs --- .../chat-participants/powerpages/PowerPagesChatParticipant.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts b/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts index f038cdeef..7947c7ebb 100644 --- a/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts +++ b/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts @@ -110,7 +110,8 @@ export class PowerPagesChatParticipant { if (!isPowerPagesGitHubCopilotEnabled()) { stream.markdown(COPILOT_NOT_RELEASED_MSG); - this.telemetry.sendTelemetryErrorEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NOT_AVAILABLE_ECS, { sessionId: this.powerPagesAgentSessionId, orgID: this.orgID }); + this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NOT_AVAILABLE_ECS, { sessionId: this.powerPagesAgentSessionId, orgID: this.orgID }); + oneDSLoggerWrapper.getLogger().traceInfo(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NOT_AVAILABLE_ECS, { sessionId: this.powerPagesAgentSessionId, orgID: this.orgID }); return createSuccessResult('', RESPONSE_SCENARIOS.COPILOT_NOT_RELEASED, this.orgID); } From 79366adfa44842bc50d9ac1316178004797b10c1 Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Tue, 10 Sep 2024 17:55:49 +0530 Subject: [PATCH 09/10] refactor: localization strings --- l10n/bundle.l10n.json | 7 ++++--- loc/translations-export/vscode-powerplatform.xlf | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/l10n/bundle.l10n.json b/l10n/bundle.l10n.json index 127de4559..35cb416d0 100644 --- a/l10n/bundle.l10n.json +++ b/l10n/bundle.l10n.json @@ -76,12 +76,13 @@ "Explain the following code {% include 'Page Copy'%}": "Explain the following code {% include 'Page Copy'%}", "Hi! @powerpages can help you write, edit, and even summarize your website code.": "Hi! @powerpages can help you write, edit, and even summarize your website code.", "Authentication failed. Please try again.": "Authentication failed. Please try again.", - "Copilot is not available. Please contact your administrator.": "Copilot is not available. Please contact your administrator.", + "AI features have been disabled by your organization. Contact your admin for details. [Learn more](https://go.microsoft.com/fwlink/?linkid=2285848)": "AI features have been disabled by your organization. Contact your admin for details. [Learn more](https://go.microsoft.com/fwlink/?linkid=2285848)", "Active auth profile is not found or has expired. Please try again.": "Active auth profile is not found or has expired. Please try again.", "Something went wrong. Don’t worry, you can try again.": "Something went wrong. Don’t worry, you can try again.", "Make sure AI-generated content is accurate and appropriate before using. [Learn more](https://go.microsoft.com/fwlink/?linkid=2240145) | [View terms](https://go.microsoft.com/fwlink/?linkid=2189520)": "Make sure AI-generated content is accurate and appropriate before using. [Learn more](https://go.microsoft.com/fwlink/?linkid=2240145) | [View terms](https://go.microsoft.com/fwlink/?linkid=2189520)", - "Checking for active auth profile...": "Checking for active auth profile...", "Hi! Power Pages lets you build secure, professional websites that you can quickly configure and publish across web browsers and devices.\n\nTo create your website, visit the [Power Pages](https://powerpages.microsoft.com/).\nReturn to this chat and @powerpages can help you write and edit your website code.": "Hi! Power Pages lets you build secure, professional websites that you can quickly configure and publish across web browsers and devices.\n\nTo create your website, visit the [Power Pages](https://powerpages.microsoft.com/).\nReturn to this chat and @powerpages can help you write and edit your website code.", + "Checking for active auth profile...": "Checking for active auth profile...", + "@PowerPages is not yet available in your region.": "@PowerPages is not yet available in your region.", "Select Folder for new PCF Control/Do not translate 'PCF' as it is a product name.": { "message": "Select Folder for new PCF Control", "comment": [ @@ -255,4 +256,4 @@ "The {0} represents profile's Azure Cloud Instances" ] } -} +} \ No newline at end of file diff --git a/loc/translations-export/vscode-powerplatform.xlf b/loc/translations-export/vscode-powerplatform.xlf index 4b26baf59..e324304d3 100644 --- a/loc/translations-export/vscode-powerplatform.xlf +++ b/loc/translations-export/vscode-powerplatform.xlf @@ -1,6 +1,9 @@ + + @PowerPages is not yet available in your region. + A content snippet with the same name already exists. Please enter a different name. @@ -13,6 +16,9 @@ A webtemplate with the same name already exists. Please enter a different name. + + AI features have been disabled by your organization. Contact your admin for details. [Learn more](https://go.microsoft.com/fwlink/?linkid=2285848) + AI-generated content can contain mistakes @@ -88,9 +94,6 @@ Copied to clipboard! - - Copilot is not available. Please contact your administrator. - Copy to clipboard From 332f12cbb14c20b59d3244ea0e1214ead46a108b Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Tue, 10 Sep 2024 18:21:23 +0530 Subject: [PATCH 10/10] refactor: Remove unused parameter in initializeOrgDetails function --- .../powerpages/PowerPagesChatParticipant.ts | 4 ++-- src/common/utilities/OrgHandlerUtils.ts | 19 ++++--------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts b/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts index 7947c7ebb..85de5fbcd 100644 --- a/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts +++ b/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts @@ -227,7 +227,7 @@ export class PowerPagesChatParticipant { private async initializeOrgDetails(): Promise { try { - const { orgID, orgUrl, environmentID } = await initializeOrgDetails(this.isOrgDetailsInitialized, this.extensionContext, this._pacWrapper); + const { orgID, orgUrl, environmentID } = await initializeOrgDetails(this.isOrgDetailsInitialized, this._pacWrapper); if (!orgID) { return; @@ -242,7 +242,7 @@ export class PowerPagesChatParticipant { } private async handleOrgChangeSuccess(orgDetails: ActiveOrgOutput): Promise { - const { orgID, orgUrl, environmentID } = handleOrgChangeSuccess(orgDetails, this.extensionContext); + const { orgID, orgUrl, environmentID } = handleOrgChangeSuccess(orgDetails); this.orgID = orgID; this.orgUrl = orgUrl; this.environmentID = environmentID; diff --git a/src/common/utilities/OrgHandlerUtils.ts b/src/common/utilities/OrgHandlerUtils.ts index 11df49592..f6f492416 100644 --- a/src/common/utilities/OrgHandlerUtils.ts +++ b/src/common/utilities/OrgHandlerUtils.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. */ -import { ExtensionContext } from 'vscode'; import { ActiveOrgOutput } from '../../client/pac/PacTypes'; import { PacWrapper } from '../../client/pac/PacWrapper'; import { IOrgDetails } from '../chat-participants/powerpages/PowerPagesChatParticipantTypes'; @@ -15,26 +14,22 @@ export const ORG_DETAILS_KEY = 'orgDetails'; export function handleOrgChangeSuccess( orgDetails: ActiveOrgOutput, - extensionContext: ExtensionContext ): IOrgDetails { const { OrgId: orgID, OrgUrl: orgUrl, EnvironmentId: environmentID } = orgDetails; - extensionContext.globalState.update(ORG_DETAILS_KEY, { orgID, orgUrl, environmentID }); - return { orgID, orgUrl, environmentID }; } -async function fetchOrgDetailsFromPac(pacWrapper: PacWrapper, extensionContext: ExtensionContext): Promise { +async function fetchOrgDetailsFromPac(pacWrapper: PacWrapper): Promise { const pacActiveOrg = await pacWrapper.activeOrg(); if (pacActiveOrg && pacActiveOrg.Status === SUCCESS) { - return handleOrgChangeSuccess(pacActiveOrg.Results, extensionContext); + return handleOrgChangeSuccess(pacActiveOrg.Results); } throw new Error(ERROR_CONSTANTS.PAC_AUTH_FAILED); } export async function initializeOrgDetails( isOrgDetailsInitialized: boolean, - extensionContext: ExtensionContext, pacWrapper?: PacWrapper ): Promise { const orgDetails: IOrgDetails = { orgID: '', orgUrl: '', environmentID: '' }; @@ -43,21 +38,15 @@ export async function initializeOrgDetails( return orgDetails; } - // Get stored organization details from global state - const storedOrgDetails: IOrgDetails | undefined = extensionContext.globalState.get(ORG_DETAILS_KEY); - if (storedOrgDetails && storedOrgDetails.orgID && storedOrgDetails.orgUrl && storedOrgDetails.environmentID) { - return storedOrgDetails; - } - if (pacWrapper) { try { - const fetchedOrgDetails = await fetchOrgDetailsFromPac(pacWrapper, extensionContext); + const fetchedOrgDetails = await fetchOrgDetailsFromPac(pacWrapper); orgDetails.orgID = fetchedOrgDetails.orgID; orgDetails.orgUrl = fetchedOrgDetails.orgUrl; orgDetails.environmentID = fetchedOrgDetails.environmentID; } catch (error) { await createAuthProfileExp(pacWrapper); - const fetchedOrgDetails = await fetchOrgDetailsFromPac(pacWrapper, extensionContext); + const fetchedOrgDetails = await fetchOrgDetailsFromPac(pacWrapper); orgDetails.orgID = fetchedOrgDetails.orgID; orgDetails.orgUrl = fetchedOrgDetails.orgUrl; orgDetails.environmentID = fetchedOrgDetails.environmentID;