From 3039592d245670f6f2faa409dfdee040da87d6ec Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Sun, 6 Apr 2025 15:31:05 -0700 Subject: [PATCH] fix deeplink handling --- core/config/ConfigHandler.ts | 11 ++++++++--- core/core.ts | 5 ++++- core/protocol/coreWebview.ts | 2 +- .../vscode/src/extension/VsCodeExtension.ts | 15 +++------------ 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index e43664098..8a50ff1a1 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -328,7 +328,7 @@ export class ConfigHandler { } // Org id: check id validity, save selection, switch and reload - async setSelectedOrgId(orgId: string) { + async setSelectedOrgId(orgId: string, profileId?: string) { if (orgId === this.currentOrg.id) { return; } @@ -346,8 +346,13 @@ export class ConfigHandler { }); this.currentOrg = org; - this.currentProfile = org.currentProfile; - await this.reloadConfig(); + + if (profileId) { + this.setSelectedProfileId(profileId); + } else { + this.currentProfile = org.currentProfile; + await this.reloadConfig(); + } } // Profile id: check id validity, save selection, switch and reload diff --git a/core/core.ts b/core/core.ts index 16edc0cee..f948491fc 100644 --- a/core/core.ts +++ b/core/core.ts @@ -819,7 +819,10 @@ export class Core { }); on("didChangeSelectedOrg", async (msg) => { - await this.configHandler.setSelectedOrgId(msg.data.id); + await this.configHandler.setSelectedOrgId( + msg.data.id, + msg.data.profileId, + ); }); on("didChangeControlPlaneSessionInfo", async (msg) => { diff --git a/core/protocol/coreWebview.ts b/core/protocol/coreWebview.ts index c3c5b7fc3..2e1bd3ff1 100644 --- a/core/protocol/coreWebview.ts +++ b/core/protocol/coreWebview.ts @@ -3,6 +3,6 @@ import { ToWebviewFromIdeOrCoreProtocol } from "./webview.js"; export type ToCoreFromWebviewProtocol = ToCoreFromIdeOrWebviewProtocol & { didChangeSelectedProfile: [{ id: string }, void]; - didChangeSelectedOrg: [{ id: string }, void]; + didChangeSelectedOrg: [{ id: string; profileId?: string }, void]; }; export type ToWebviewFromCoreProtocol = ToWebviewFromIdeOrCoreProtocol; diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts index 6852fd4f4..ee28c6c79 100644 --- a/extensions/vscode/src/extension/VsCodeExtension.ts +++ b/extensions/vscode/src/extension/VsCodeExtension.ts @@ -202,16 +202,10 @@ export class VsCodeExtension { let profileId = queryParams.get("profile_id"); let orgId = queryParams.get("org_id"); - if (orgId) { - if (orgId === "null") { - orgId = null; - } + if (orgId && orgId !== "null") { // In case org id is passed with profile id // Make sure org is updated before profile is set - if (profileId) { - if (profileId === "null") { - profileId = null; - } + if (profileId && profileId !== "null") { this.core.invoke("didChangeSelectedOrg", { id: orgId, profileId, @@ -221,10 +215,7 @@ export class VsCodeExtension { id: orgId, }); } - } else if (profileId) { - if (profileId === "null") { - profileId = null; - } + } else if (profileId && profileId !== "null") { this.core.invoke("didChangeSelectedProfile", { id: profileId, });