Skip to content

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

TypeScript

fix: preserve producer status during environment handoff

Josué24052da689d9
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/desktopEnvironmentHandoff.test.ts b/desktop-app/ui/src/hooks/domain/__tests__/desktopEnvironmentHandoff.test.ts
index 00a4a7acc..c8059ecfe 100644
--- a/desktop-app/ui/src/hooks/domain/__tests__/desktopEnvironmentHandoff.test.ts
+++ b/desktop-app/ui/src/hooks/domain/__tests__/desktopEnvironmentHandoff.test.ts
@@ -454,6 +454,56 @@ describe('Desktop environment handoff concurrency', () => {
)
})
+ it('preserves a producer status when handoff logout returns no generation', async () => {
+ let publishProducerStatus:
+ | ((message: string, tone: 'info' | 'success' | 'error') => void)
+ | null = null
+ const logout = vi.fn(async () => {
+ publishProducerStatus?.('Logout failed: secure storage is unavailable.', 'error')
+ return null
+ })
+ const { handler, setStatus } = createHandler(
+ () => ({ booting: false, busy: false, authTransitioning: false, isAuthenticated: true }),
+ undefined,
+ logout
+ )
+ publishProducerStatus = setStatus
+
+ await handler({
+ ...targetEnvironment,
+ externalRestApiBaseUrl: `${targetEnvironment.externalRestApiBaseUrl}/api/v1`,
+ })
+
+ expect(logout).toHaveBeenCalledOnce()
+ expect(setStatus).toHaveBeenLastCalledWith(
+ 'Logout failed: secure storage is unavailable.',
+ 'error'
+ )
+ })
+
+ it('preserves a producer status when environment selection returns null', async () => {
+ const { handler, selectRuntimeConfig, setStatus } = createHandler(() => ({
+ booting: false,
+ busy: false,
+ authTransitioning: false,
+ isAuthenticated: false,
+ }))
+ selectRuntimeConfig.mockImplementationOnce(async () => {
+ setStatus('Failed to switch environment: stale session.', 'info')
+ return null
+ })
+
+ await handler({
+ ...targetEnvironment,
+ externalRestApiBaseUrl: `${targetEnvironment.externalRestApiBaseUrl}/api/v1`,
+ })
+
+ expect(setStatus).toHaveBeenLastCalledWith(
+ 'Failed to switch environment: stale session.',
+ 'info'
+ )
+ })
+
it.each([
{
targetKind: 'saved target',
diff --git a/desktop-app/ui/src/hooks/domain/desktopEnvironmentHandoff.ts b/desktop-app/ui/src/hooks/domain/desktopEnvironmentHandoff.ts
index c37c6d26f..268ccdcfa 100644
--- a/desktop-app/ui/src/hooks/domain/desktopEnvironmentHandoff.ts
+++ b/desktop-app/ui/src/hooks/domain/desktopEnvironmentHandoff.ts
@@ -279,14 +279,6 @@ export function createDesktopEnvironmentSetupHandler({
)
return
}
- authState = getAuthState()
- }
- if (isAuthenticationOperationInProgress(authState)) {
- reportAuthenticationStateChanged(authState, setStatus)
- } else if (authState.isAuthenticated) {
- setStatus('Could not sign out before switching desktop environments.', 'error')
- } else {
- setStatus('Could not confirm sign out before switching desktop environments.', 'error')
}
return
}
@@ -381,13 +373,7 @@ export function createDesktopEnvironmentSetupHandler({
}
setPendingDesktopEnvironmentSetup(null)
const selection = await handleSelectRuntimeConfig(savedOption.id, sessionGeneration)
- if (!selection) {
- setStatus(
- 'Could not select the linked desktop environment. Try opening the link again.',
- 'error'
- )
- return
- }
+ if (!selection) return
if (!(await ownsSessionGeneration(selection.sessionGeneration))) return
authState = getAuthState()
if (isAuthenticationOperationInProgress(authState) || authState.isAuthenticated) {