fix(platform): await session startup before register IPC returns

Register was racing pushState ahead of sessionReady, leaving the UI on the session-restore shell instead of onboarding.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-06-01 22:35:43 -04:00
co-authored by Cursor
parent 9561e68ac3
commit 405786b8d8
+6 -3
View File
@@ -1113,7 +1113,7 @@ class PearcordPlatform extends EventEmitter {
}
}
async _bootstrapAfterUser (user) {
async _bootstrapAfterUser (user, { waitSessionStartup = false } = {}) {
this.onboarded = true
writeOnboardedMarker(this.storagePath)
this.presence = new PearcordPresence({ userId: user.id })
@@ -1200,7 +1200,9 @@ class PearcordPlatform extends EventEmitter {
this._lastVoiceSpeakingGossipKey = ''
this._lastVoiceSpeakingGossipAt = 0
this.guilds = await this.listGuilds()
void this._finishSessionStartup()
const startup = this._finishSessionStartup()
if (waitSessionStartup) await startup
else void startup
this.emit('user', user)
return user
}
@@ -1917,11 +1919,12 @@ class PearcordPlatform extends EventEmitter {
const user = await this.identity.register({ username, displayName })
this.guilds = []
this.mode = 'home'
const boot = await this._bootstrapAfterUser(user)
const boot = await this._bootstrapAfterUser(user, { waitSessionStartup: true })
span.end({
userId: user?.id || null,
guildCount: this.guilds?.length ?? 0,
activeChannelId: this.activeChannelId || null,
sessionReady: this._sessionReady,
spanKind: 'identity.register'
})
return boot