Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

refactor(desktop-app): remove redundant auth owner guards (R2-L8)

Josué08086cf6255a
diff --git a/desktop-app/src/__tests__/appService.nativeLogoutRecovery.test.ts b/desktop-app/src/__tests__/appService.nativeLogoutRecovery.test.ts
index 695b24f96..a28da0cd3 100644
--- a/desktop-app/src/__tests__/appService.nativeLogoutRecovery.test.ts
+++ b/desktop-app/src/__tests__/appService.nativeLogoutRecovery.test.ts
@@ -14,16 +14,6 @@ describe('AppService logout recovery ownership', () => {
googleLogin: vi.fn().mockResolvedValue(testLoginResult()),
} as never
await service.googleLogin('initial-login')
- const assertAuthEnvironmentBinding = vi.spyOn(
- service as unknown as {
- assertAuthEnvironmentBinding: (binding: {
- environmentKey: string
- profileId: string | null
- restBaseUrl: string
- }) => void
- },
- 'assertAuthEnvironmentBinding'
- )
service.tokenStore.clearSessionToken = vi
.fn()
.mockRejectedValue(new Error('keychain unavailable'))
@@ -32,7 +22,6 @@ describe('AppService logout recovery ownership', () => {
expect(service.getCachedUserId()).toBe('user-a')
expect(service.sessionToken).toBe('synthetic-session-a')
- expect(assertAuthEnvironmentBinding).toHaveBeenCalledOnce()
await expect(service.listGfsUploadSessions()).resolves.toEqual([])
})
})
diff --git a/desktop-app/src/appService.ts b/desktop-app/src/appService.ts
index 591c29d29..a3d0478c1 100644
--- a/desktop-app/src/appService.ts
+++ b/desktop-app/src/appService.ts
@@ -1394,9 +1394,7 @@ export class AppService {
// A failed restore leaves the hop team as the actual committed
// session. Publish it as a new session before releasing the owner,
// then rebind session-scoped consumers to the token that remains.
- if (this.sessionGeneration === context.sessionGeneration) {
- this.sessionGeneration += 1
- }
+ this.sessionGeneration += 1
this.updateEntityChangeSessionToken(this.sessionToken)
this.restartEntityChangeStreamForSessionReplacement()
}
@@ -2492,7 +2490,6 @@ export class AppService {
const logoutGeneration = this.sessionGeneration
const logoutToken = this.sessionToken
const logoutMe = this.me
- const logoutEnvironment = this.captureAuthEnvironmentBinding()
const releasePrewarm = this.beginPrewarmAuthTransition()
try {
const envKey = getActiveEnvKey()
@@ -2503,21 +2500,7 @@ export class AppService {
await this.tokenStore.clearSessionToken(envKey, { legacyEnvKeys })
this.assertSessionGeneration(logoutGeneration)
} catch (error) {
- let environmentBindingMatches = false
- try {
- this.assertAuthEnvironmentBinding(logoutEnvironment)
- environmentBindingMatches = true
- } catch {
- // A selected profile change means the failed clear no longer owns this boundary.
- }
- const capturedSessionStillOwnsBoundary =
- this.sessionGeneration === logoutGeneration &&
- this.sessionToken === logoutToken &&
- this.me === logoutMe &&
- environmentBindingMatches
- if (capturedSessionStillOwnsBoundary) {
- if (logoutToken && logoutMe) this.activateGfsAuthScope()
- }
+ if (logoutToken && logoutMe) this.activateGfsAuthScope()
throw error
}
this.clearAuthenticatedSessionState()