From 53d51477ff84b44dc5a790e20bf0adadbe49c94b Mon Sep 17 00:00:00 2001 From: Gavin Gu Date: Wed, 11 Sep 2024 16:23:08 +0800 Subject: [PATCH 1/2] refactor: redesign office chat feature flag --- packages/fx-core/src/common/featureFlags.ts | 5 +++++ packages/vscode-extension/package.json | 1 + packages/vscode-extension/src/extension.ts | 23 +++++++++++++++------ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/packages/fx-core/src/common/featureFlags.ts b/packages/fx-core/src/common/featureFlags.ts index 12b3e1f8ec..8d86494120 100644 --- a/packages/fx-core/src/common/featureFlags.ts +++ b/packages/fx-core/src/common/featureFlags.ts @@ -26,6 +26,7 @@ export class FeatureFlagName { static readonly NewProjectType = "TEAMSFX_NEW_PROJECT_TYPE"; static readonly ChatParticipant = "TEAMSFX_CHAT_PARTICIPANT"; static readonly ChatParticipantUIEntries = "TEAMSFX_CHAT_PARTICIPANT_ENTRIES"; + static readonly OfficeChatParticipant = "TEAMSFX_OFFICE_CHAT_PARTICIPANT"; static readonly SMEOAuth = "SME_OAUTH"; static readonly ShowDiagnostics = "TEAMSFX_SHOW_DIAGNOSTICS"; static readonly TelemetryTest = "TEAMSFX_TELEMETRY_TEST"; @@ -79,6 +80,10 @@ export class FeatureFlags { name: FeatureFlagName.ChatParticipantUIEntries, defaultValue: "false", }; + static readonly OfficeChatParticipant = { + name: FeatureFlagName.OfficeChatParticipant, + defaultValue: "false", + }; static readonly SMEOAuth = { name: FeatureFlagName.SMEOAuth, defaultValue: "false" }; static readonly ShowDiagnostics = { name: FeatureFlagName.ShowDiagnostics, diff --git a/packages/vscode-extension/package.json b/packages/vscode-extension/package.json index 48d2a161cf..b1425bc32c 100644 --- a/packages/vscode-extension/package.json +++ b/packages/vscode-extension/package.json @@ -1552,6 +1552,7 @@ "id": "ms-teams-vscode-extension.office", "name": "office", "description": "%teamstoolkit.chatParticipants.officeAddIn.description%", + "when": "fx-extension.isOfficeChatParticipantEnabled", "commands": [ { "name": "create", diff --git a/packages/vscode-extension/src/extension.ts b/packages/vscode-extension/src/extension.ts index c26ba0d193..ac6dab6b20 100644 --- a/packages/vscode-extension/src/extension.ts +++ b/packages/vscode-extension/src/extension.ts @@ -177,6 +177,7 @@ import { CHAT_CREATE_OFFICE_PROJECT_COMMAND_ID, officeChatParticipantId, } from "./officeChat/consts"; +import * as extensionPackage from "../package.json"; import { chatCreateOfficeProjectCommandHandler, handleOfficeFeedback, @@ -201,8 +202,11 @@ import { getSettingsVersion, projectVersionCheck } from "./utils/telemetryUtils" import { createPluginWithManifest } from "./handlers/createPluginWithManifestHandler"; export async function activate(context: vscode.ExtensionContext) { - const value = IsChatParticipantEnabled && semver.gte(vscode.version, "1.90.0"); - featureFlagManager.setBooleanValue(FeatureFlags.ChatParticipant, value); + const value = + (featureFlagManager.getBooleanValue(CoreFeatureFlags.OfficeChatParticipant) || + extensionPackage.version.includes("alpha")) && + semver.gte(vscode.version, "1.90.0"); + featureFlagManager.setBooleanValue(CoreFeatureFlags.OfficeChatParticipant, value); context.subscriptions.push(new ExtTelemetry.Reporter(context)); @@ -220,10 +224,6 @@ export async function activate(context: vscode.ExtensionContext) { registerInternalCommands(context); - if (featureFlagManager.getBooleanValue(CoreFeatureFlags.ChatParticipant)) { - registerOfficeChatParticipant(context); - } - if (isTeamsFxProject) { activateTeamsFxRegistration(context); } @@ -248,6 +248,17 @@ export async function activate(context: vscode.ExtensionContext) { featureFlagManager.getBooleanValue(CoreFeatureFlags.ChatParticipantUIEntries) ); + // control whether to show office chat participant entry in chat + await vscode.commands.executeCommand( + "setContext", + "fx-extension.isOfficeChatParticipantEnabled", + featureFlagManager.getBooleanValue(CoreFeatureFlags.OfficeChatParticipant) + ); + + if (featureFlagManager.getBooleanValue(CoreFeatureFlags.OfficeChatParticipant)) { + registerOfficeChatParticipant(context); + } + // Flags for "Build Intelligent Apps" walkthrough. // DEVEOP_COPILOT_PLUGIN: boolean in vscode settings await vscode.commands.executeCommand( From 6dcd915faf4940f99c2c968d2ee05ca7ffe32c4d Mon Sep 17 00:00:00 2001 From: Gavin Gu Date: Wed, 11 Sep 2024 17:04:34 +0800 Subject: [PATCH 2/2] fix: block stable version --- packages/vscode-extension/src/extension.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/vscode-extension/src/extension.ts b/packages/vscode-extension/src/extension.ts index ac6dab6b20..d057102025 100644 --- a/packages/vscode-extension/src/extension.ts +++ b/packages/vscode-extension/src/extension.ts @@ -198,13 +198,14 @@ import { loadLocalizedStrings } from "./utils/localizeUtils"; import { checkProjectTypeAndSendTelemetry, isM365Project } from "./utils/projectChecker"; import { ReleaseNote } from "./utils/releaseNote"; import { ExtensionSurvey } from "./utils/survey"; -import { getSettingsVersion, projectVersionCheck } from "./utils/telemetryUtils"; +import { getPackageVersion, getSettingsVersion, projectVersionCheck } from "./utils/telemetryUtils"; import { createPluginWithManifest } from "./handlers/createPluginWithManifestHandler"; export async function activate(context: vscode.ExtensionContext) { const value = - (featureFlagManager.getBooleanValue(CoreFeatureFlags.OfficeChatParticipant) || - extensionPackage.version.includes("alpha")) && + ((getPackageVersion(extensionPackage.version) === "beta" && + featureFlagManager.getBooleanValue(CoreFeatureFlags.OfficeChatParticipant)) || + getPackageVersion(extensionPackage.version) === "alpha") && semver.gte(vscode.version, "1.90.0"); featureFlagManager.setBooleanValue(CoreFeatureFlags.OfficeChatParticipant, value);