Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop-ui): reset invalid environment handoffs
Josuéa2b690162c5e
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/desktopEnvironmentHandoff.test.ts b/desktop-app/ui/src/hooks/domain/__tests__/desktopEnvironmentHandoff.test.tsindex f66522556..d0fd402e0 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/desktopEnvironmentHandoff.test.ts+++ b/desktop-app/ui/src/hooks/domain/__tests__/desktopEnvironmentHandoff.test.ts@@ -253,6 +253,24 @@ describe('Desktop environment handoff concurrency', () => {)})+ it('clears a prior setup confirmation when environment verification fails', async () => {+ const refreshRuntimeConfigState = vi.fn(async () => {+ throw new Error('runtime config unavailable')+ })+ const { handler, setPendingDesktopEnvironmentSetup, setStatus } = createHandler(+ () => ({ booting: false, busy: false, authTransitioning: false, isAuthenticated: false }),+ refreshRuntimeConfigState+ )++ await handler(targetEnvironment)++ expect(setPendingDesktopEnvironmentSetup).toHaveBeenCalledWith(null)+ expect(setStatus).toHaveBeenCalledWith(+ 'Could not verify the desktop environment. Try opening it again.',+ 'error'+ )+ })+it('discards a link when the native session generation changes during config refresh', async () => {let finishRefresh!: (state: DesktopRuntimeConfigState) => voidlet reportRefreshStarted!: () => void@@ -362,6 +380,49 @@ describe('Desktop environment handoff concurrency', () => {)})+ it('does not load a selected environment when login completes after selection returns', async () => {+ const savedTarget = (await runtimeConfigModule!.getDesktopRuntimeConfigState()).options.find(+ option =>+ option.externalRestApiBaseUrl === `${targetEnvironment.externalRestApiBaseUrl}/api/v1`+ )+ if (!savedTarget) throw new Error('The config producer did not return the saved target')+ let generationReads = 0+ const getSessionGeneration = vi.fn(async () => {+ generationReads += 1+ if (generationReads === 3) {+ await nativeProducer.googleLogin('synthetic-login-after-selection-return')+ }+ return nativeProducer.getSessionGeneration()+ })+ const {+ handler,+ selectRuntimeConfig,+ setPendingDesktopEnvironmentSetup,+ onSessionNeedsLoad,+ setStatus,+ } = createHandler(+ () => ({ booting: false, busy: false, authTransitioning: false, isAuthenticated: false }),+ undefined,+ undefined,+ undefined,+ undefined,+ getSessionGeneration+ )++ await handler({+ ...targetEnvironment,+ externalRestApiBaseUrl: `${targetEnvironment.externalRestApiBaseUrl}/api/v1`,+ })++ expect(selectRuntimeConfig).toHaveBeenCalledWith(savedTarget.id, expect.any(Number))+ expect(onSessionNeedsLoad).not.toHaveBeenCalled()+ expect(setPendingDesktopEnvironmentSetup).toHaveBeenCalledWith(null)+ expect(setStatus).toHaveBeenCalledWith(+ 'The desktop session changed while processing this link. Open it again.',+ 'info'+ )+ })+it('stops after logout when a newer native login wins before the handoff continues', async () => {let isAuthenticated = trueconst logout = vi.fn(async () => {diff --git a/desktop-app/ui/src/hooks/domain/desktopEnvironmentHandoff.ts b/desktop-app/ui/src/hooks/domain/desktopEnvironmentHandoff.tsindex b288f8f72..6e55d1835 100644--- a/desktop-app/ui/src/hooks/domain/desktopEnvironmentHandoff.ts+++ b/desktop-app/ui/src/hooks/domain/desktopEnvironmentHandoff.ts@@ -222,6 +222,7 @@ export function createDesktopEnvironmentSetupHandler({try {configState = await refreshRuntimeConfigState()} catch {+ setPendingDesktopEnvironmentSetup(null)setStatus('Could not verify the desktop environment. Try opening it again.', 'error')return}@@ -333,6 +334,7 @@ export function createDesktopEnvironmentSetupHandler({try {configState = await refreshRuntimeConfigState()} catch {+ setPendingDesktopEnvironmentSetup(null)setStatus('Could not verify the desktop environment. Try opening it again.', 'error')return}