Merge pull request #6910 from continuedev/dallin/handle-session-changes

fix: only update on session change when needed
This commit is contained in:
Nate Sesti 2025-07-31 18:11:53 -07:00 • committed by GitHub
commit e93842d7a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 10 deletions

View file

@ -363,13 +363,42 @@ export class ConfigHandler {
async updateControlPlaneSessionInfo(
sessionInfo: ControlPlaneSessionInfo | undefined,
) {
this.controlPlaneClient = new ControlPlaneClient(
Promise.resolve(sessionInfo),
this.ideSettingsPromise,
this.ide.getIdeInfo(),
);
this.abortCascade();
await this.cascadeInit("Control plane session info update");
const currentSession = await this.controlPlaneClient.sessionInfoPromise;
const newSession = sessionInfo;
let reload = false;
if (newSession) {
if (currentSession) {
if (
newSession.AUTH_TYPE !== AuthType.OnPrem &&
currentSession.AUTH_TYPE !== AuthType.OnPrem
) {
if (newSession.account.id !== currentSession.account.id) {
// session id change (non-on-prem)
reload = true;
}
}
} else {
// log in
reload = true;
}
} else {
if (currentSession) {
// log out
reload = true;
}
}
if (reload) {
this.controlPlaneClient = new ControlPlaneClient(
Promise.resolve(sessionInfo),
this.ideSettingsPromise,
this.ide.getIdeInfo(),
);
this.abortCascade();
await this.cascadeInit("Control plane session info update");
}
return reload;
}
// Org id: check id validity, save selection, switch and reload

View file

@ -36,9 +36,7 @@ export const TRIAL_PROXY_URL =
export class ControlPlaneClient {
constructor(
private readonly sessionInfoPromise: Promise<
ControlPlaneSessionInfo | undefined
>,
readonly sessionInfoPromise: Promise<ControlPlaneSessionInfo | undefined>,
private readonly ideSettingsPromise: Promise<IdeSettings>,
private readonly ideInfoPromise: Promise<IdeInfo>,
) {}