Skip to content

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

TypeScript

fix(desktop-app): r19-l5 explain setup auth transitions

Josué5f99f59447e8
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useAuthController.desktopEnvironment.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useAuthController.desktopEnvironment.test.tsx
index fb7d4f714..044e671dc 100644
--- a/desktop-app/ui/src/hooks/domain/__tests__/useAuthController.desktopEnvironment.test.tsx
+++ b/desktop-app/ui/src/hooks/domain/__tests__/useAuthController.desktopEnvironment.test.tsx
@@ -399,6 +399,50 @@ describe('Desktop environment handoff', () => {
)
})
+ it('explains an authentication transition when desktop setup is temporarily blocked', async () => {
+ mocks.completeDesktopSetup.mockRejectedValue(
+ wrapLikeElectronIpc('auth:completeDesktopSetup', new Error('auth_transition_in_progress'))
+ )
+ render(<Probe />)
+
+ await waitFor(() => expect(desktopSetupTokenListener).toBeTypeOf('function'))
+ await act(async () => {
+ desktopSetupTokenListener?.({
+ email: '[email protected]',
+ authorizationToken: 'synthetic-setup-token',
+ })
+ })
+
+ await waitFor(() =>
+ expect(mocks.setStatus).toHaveBeenCalledWith(
+ 'Finish the current authentication action, then try desktop setup again.',
+ 'error'
+ )
+ )
+ })
+
+ it('explains when the desktop session changes during setup', async () => {
+ mocks.completeDesktopSetup.mockRejectedValue(
+ wrapLikeElectronIpc('auth:completeDesktopSetup', new Error('stale_session_generation'))
+ )
+ render(<Probe />)
+
+ await waitFor(() => expect(desktopSetupTokenListener).toBeTypeOf('function'))
+ await act(async () => {
+ desktopSetupTokenListener?.({
+ email: '[email protected]',
+ authorizationToken: 'synthetic-setup-token',
+ })
+ })
+
+ await waitFor(() =>
+ expect(mocks.setStatus).toHaveBeenCalledWith(
+ 'The desktop session changed while setup was in progress. Try desktop setup again.',
+ 'error'
+ )
+ )
+ })
+
it('switches to a saved environment matching its REST endpoint', async () => {
render(<Probe />)
await waitFor(() => expect(screen.getByTestId('configuration-loaded')).toHaveTextContent('yes'))
diff --git a/desktop-app/ui/src/hooks/domain/useAuthController.ts b/desktop-app/ui/src/hooks/domain/useAuthController.ts
index 7cc4c631e..d790ace1c 100644
--- a/desktop-app/ui/src/hooks/domain/useAuthController.ts
+++ b/desktop-app/ui/src/hooks/domain/useAuthController.ts
@@ -45,6 +45,12 @@ function isUnauthorizedError(error: unknown) {
function getDesktopSetupErrorMessage(error: unknown) {
const message = error instanceof Error ? error.message : String(error)
+ if (message.includes('auth_transition_in_progress')) {
+ return 'Finish the current authentication action, then try desktop setup again.'
+ }
+ if (message.includes('stale_session_generation')) {
+ return 'The desktop session changed while setup was in progress. Try desktop setup again.'
+ }
if (message.includes('desktop_setup_requires_signout')) {
return 'Sign out before setting up another desktop environment.'
}