From ce24a200f56c2153ed327398b03aa51f288f8f2b Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 11 Mar 2025 17:14:10 -0700 Subject: [PATCH] correctly persist selected profile --- core/core.ts | 7 +++++-- core/protocol/core.ts | 5 ++++- gui/src/context/Auth.tsx | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/core.ts b/core/core.ts index 8e14aa668..fd4c6eb62 100644 --- a/core/core.ts +++ b/core/core.ts @@ -295,8 +295,11 @@ export class Core { this.configHandler.updateIdeSettings(msg.data); }); - on("config/listProfiles", (msg) => { - return this.configHandler.listProfiles(); + on("config/listProfiles", async (msg) => { + const profiles = this.configHandler.listProfiles(); + const selectedProfileId = + this.configHandler.currentProfile?.profileDescription.id ?? null; + return { profiles, selectedProfileId }; }); on("config/refreshProfiles", async (msg) => { diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 1b19a46cb..138c7e9d3 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -68,7 +68,10 @@ export type ToCoreFromIdeOrWebviewProtocol = { "config/deleteModel": [{ title: string }, void]; "config/addContextProvider": [ContextProviderWithParams, void]; "config/reload": [undefined, ConfigResult]; - "config/listProfiles": [undefined, ProfileDescription[] | null]; + "config/listProfiles": [ + undefined, + { profiles: ProfileDescription[] | null; selectedProfileId: string | null }, + ]; "config/refreshProfiles": [undefined, void]; "config/openProfile": [{ profileId: string | undefined }, void]; "config/updateSharedConfig": [SharedConfigSchema, SharedConfigSchema]; diff --git a/gui/src/context/Auth.tsx b/gui/src/context/Auth.tsx index 807065019..d4e6f7925 100644 --- a/gui/src/context/Auth.tsx +++ b/gui/src/context/Auth.tsx @@ -168,8 +168,8 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ if (result.status === "success") { dispatch( updateProfilesThunk({ - profiles: result.content, - selectedProfileId: null, + profiles: result.content.profiles, + selectedProfileId: result.content.selectedProfileId, }), ); }