From bd9136ec4afded5f06414ed83eaf0ed7d1365003 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 4 Oct 2024 11:31:15 -0700 Subject: [PATCH] don't force window reload when checking beta checkbox --- core/protocol/ide.ts | 1 + extensions/vscode/package.json | 2 +- .../vscode/src/extension/VsCodeExtension.ts | 10 ++++++++++ gui/src/components/ProfileSwitcher.tsx | 19 +++++++++++++++---- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index 393797f5d..43cacb733 100644 --- a/core/protocol/ide.ts +++ b/core/protocol/ide.ts @@ -97,4 +97,5 @@ export type ToWebviewOrCoreFromIdeProtocol = { { sessionInfo: ControlPlaneSessionInfo | undefined }, void, ]; + didChangeIdeSettings: [{ settings: IdeSettings }, void]; }; diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 2269b08dc..193546288 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -77,7 +77,7 @@ "continue.enableContinueForTeams": { "type": "boolean", "default": false, - "markdownDescription": "_(Requires window reload)_ Enable Continue for teams beta features. To sign in, click the person icon in the bottom right of the sidebar." + "markdownDescription": "Enable Continue for teams beta features. To sign in, click the person icon in the bottom right of the sidebar." }, "continue.showInlineTip": { "type": "boolean", diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts index f2a6b8b70..674a80d1f 100644 --- a/extensions/vscode/src/extension/VsCodeExtension.ts +++ b/extensions/vscode/src/extension/VsCodeExtension.ts @@ -331,6 +331,16 @@ export class VsCodeExtension { this.ide.onDidChangeActiveTextEditor((filepath) => { this.core.invoke("didChangeActiveTextEditor", { filepath }); }); + + vscode.workspace.onDidChangeConfiguration(async (event) => { + if (event.affectsConfiguration(EXTENSION_NAME)) { + const settings = this.ide.getIdeSettingsSync(); + const webviewProtocol = await this.webviewProtocolPromise; + webviewProtocol.request("didChangeIdeSettings", { + settings, + }); + } + }); } static continueVirtualDocumentScheme = EXTENSION_NAME; diff --git a/gui/src/components/ProfileSwitcher.tsx b/gui/src/components/ProfileSwitcher.tsx index a7e7cb362..89034faa2 100644 --- a/gui/src/components/ProfileSwitcher.tsx +++ b/gui/src/components/ProfileSwitcher.tsx @@ -142,18 +142,29 @@ function ProfileSwitcher() { useEffect(() => { ideMessenger.ide.getIdeSettings().then(({ enableControlServerBeta }) => { + setControlServerBetaEnabled(enableControlServerBeta); + dispatch(setLastControlServerBetaEnabledStatus(enableControlServerBeta)); + const shouldShowPopup = !lastControlServerBetaEnabledStatus && enableControlServerBeta; - if (shouldShowPopup) { ideMessenger.ide.showToast("info", "Continue for Teams enabled"); } - - setControlServerBetaEnabled(enableControlServerBeta); - dispatch(setLastControlServerBetaEnabledStatus(enableControlServerBeta)); }); }, []); + useWebviewListener( + "didChangeIdeSettings", + async (msg) => { + const { settings } = msg; + setControlServerBetaEnabled(settings.enableControlServerBeta); + dispatch( + setLastControlServerBetaEnabledStatus(settings.enableControlServerBeta), + ); + }, + [], + ); + useEffect(() => { ideMessenger .request("config/listProfiles", undefined)