Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop-app): preserve signed-out restore generation (R17-L4)
Josué68368416d7e5
diff --git a/desktop-app/src/__tests__/appService.setupRestoreRace.test.ts b/desktop-app/src/__tests__/appService.setupRestoreRace.test.tsindex 48f1f96b9..78e0a3988 100644--- a/desktop-app/src/__tests__/appService.setupRestoreRace.test.ts+++ b/desktop-app/src/__tests__/appService.setupRestoreRace.test.ts@@ -17,6 +17,22 @@ type SetupActivation = {}describe('AppService setup and saved-session ownership', () => {+ it('does not advance the session generation when saved-session restore fails while signed out', async () => {+ const { service } = await createNativeCommitTestHarness()+ const app = service as unknown as {+ authClient: { getMe: ReturnType<typeof vi.fn> }+ tokenStore: { getSessionToken: ReturnType<typeof vi.fn> }+ getSessionGeneration: () => number+ }+ app.tokenStore.getSessionToken.mockResolvedValue('synthetic-saved-session-a')+ app.authClient = {+ getMe: vi.fn().mockRejectedValue(new Error('synthetic network failure')),+ }++ await expect(service.getSessionState()).resolves.toEqual({ authenticated: false, me: null })+ expect(app.getSessionGeneration()).toBe(0)+ })+it.each(['Google', 'password'] as const)('lets a pending %s login win over a background saved-session restore',async provider => {diff --git a/desktop-app/src/appService.ts b/desktop-app/src/appService.tsindex 42de93d2c..591c29d29 100644--- a/desktop-app/src/appService.ts+++ b/desktop-app/src/appService.ts@@ -1744,7 +1744,7 @@ export class AppService {} catch (error) {return this.withNativeAuthEnvironmentCommit(async () => {if (!ownsRestore()) return currentSession()- this.clearAuthenticatedSessionState()+ if (this.sessionToken !== null || this.me !== null) this.clearAuthenticatedSessionState()if (AppService.isRejectedStoredSessionError(error)) {await this.tokenStore.clearSessionToken(getActiveEnvKey(), {legacyEnvKeys: getActiveLegacyEnvKeys(),