Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop-app): r19-l4 clear linked setup on auth transitions
Josué28a726460d20
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.tsxindex 776a7f23f..fb7d4f714 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@@ -739,6 +739,50 @@ describe('Desktop environment handoff', () => {)})+ it('clears linked setup confirmation when saving hits an auth transition', async () => {+ mocks.saveRuntimeConfig.mockRejectedValueOnce(+ wrapLikeElectronIpc('auth:saveRuntimeConfig', new Error('auth_transition_in_progress'))+ )+ render(<Probe />)+ await waitFor(() => expect(screen.getByTestId('configuration-loaded')).toHaveTextContent('yes'))+ await dispatchDesktopEnvironmentLink({+ appName: 'Linked tenant',+ externalRestApiBaseUrl: 'https://new-api.example.test',+ })+ expect(screen.getByTestId('pending-environment')).toHaveTextContent(+ 'https://new-api.example.test'+ )++ await act(async () => confirmDesktopEnvironmentSetupForTest?.())++ expect(screen.getByTestId('pending-environment')).toHaveTextContent('none')+ expect(mocks.setStatus).toHaveBeenCalledWith(+ 'Finish the current authentication action, then reopen this desktop link.',+ 'info'+ )+ })++ it('clears linked setup confirmation when confirmation meets an auth operation', async () => {+ render(<Probe />)+ await waitFor(() => expect(screen.getByTestId('configuration-loaded')).toHaveTextContent('yes'))+ await dispatchDesktopEnvironmentLink({+ appName: 'Linked tenant',+ externalRestApiBaseUrl: 'https://new-api.example.test',+ })+ expect(screen.getByTestId('pending-environment')).toHaveTextContent(+ 'https://new-api.example.test'+ )+ await act(async () => setBootingForTest?.(true))++ await act(async () => confirmDesktopEnvironmentSetupForTest?.())++ expect(screen.getByTestId('pending-environment')).toHaveTextContent('none')+ expect(mocks.setStatus).toHaveBeenCalledWith(+ 'Finish the current authentication action, then reopen this desktop link.',+ 'info'+ )+ })+it('leaves RPC discovery to the backend for a REST-only environment link', async () => {const linkedEnvironment = {appName: 'New tenant',diff --git a/desktop-app/ui/src/hooks/domain/desktopEnvironmentHandoff.ts b/desktop-app/ui/src/hooks/domain/desktopEnvironmentHandoff.tsindex 28bb58739..b288f8f72 100644--- a/desktop-app/ui/src/hooks/domain/desktopEnvironmentHandoff.ts+++ b/desktop-app/ui/src/hooks/domain/desktopEnvironmentHandoff.ts@@ -125,8 +125,10 @@ function isAuthenticationOperationInProgress(state: DesktopEnvironmentHandoffStafunction reportAuthenticationStateChanged(state: DesktopEnvironmentHandoffState,- setStatus: SetStatusFn+ setStatus: SetStatusFn,+ setPendingDesktopEnvironmentSetup: (config: DesktopRuntimeConfig | null) => void): void {+ setPendingDesktopEnvironmentSetup(null)if (isAuthenticationOperationInProgress(state)) {setStatus('Finish the current authentication action, then reopen this desktop link.', 'info')return@@ -170,9 +172,11 @@ export function createDesktopEnvironmentSetupHandler({const ownsSessionGeneration = async (expectedSessionGeneration: number): Promise<boolean> => {try {if ((await getSessionGeneration()) === expectedSessionGeneration) return true+ setPendingDesktopEnvironmentSetup(null)setStatus('The desktop session changed while processing this link. Open it again.', 'info')return false} catch {+ setPendingDesktopEnvironmentSetup(null)setStatus('Could not verify the desktop session. Try opening the link again.', 'error')return false}@@ -225,7 +229,7 @@ export function createDesktopEnvironmentSetupHandler({if (!(await ownsSessionGeneration(sessionGeneration))) returnlet authState = getAuthState()if (isAuthenticationOperationInProgress(authState)) {- reportAuthenticationStateChanged(authState, setStatus)+ reportAuthenticationStateChanged(authState, setStatus, setPendingDesktopEnvironmentSetup)return}@@ -270,7 +274,7 @@ export function createDesktopEnvironmentSetupHandler({authState = getAuthState()if (isAuthenticationOperationInProgress(authState) || !authState.isAuthenticated) {- reportAuthenticationStateChanged(authState, setStatus)+ reportAuthenticationStateChanged(authState, setStatus, setPendingDesktopEnvironmentSetup)return}@@ -305,7 +309,7 @@ export function createDesktopEnvironmentSetupHandler({authState = getAuthState()if (isAuthenticationOperationInProgress(authState)) {- reportAuthenticationStateChanged(authState, setStatus)+ reportAuthenticationStateChanged(authState, setStatus, setPendingDesktopEnvironmentSetup)return}if (authState.isAuthenticated) {@@ -322,7 +326,7 @@ export function createDesktopEnvironmentSetupHandler({if (!(await ownsSessionGeneration(sessionGeneration))) returnauthState = getAuthState()if (authState.isAuthenticated) {- reportAuthenticationStateChanged(authState, setStatus)+ reportAuthenticationStateChanged(authState, setStatus, setPendingDesktopEnvironmentSetup)return}}@@ -335,7 +339,7 @@ export function createDesktopEnvironmentSetupHandler({if (!(await ownsSessionGeneration(sessionGeneration))) returnauthState = getAuthState()if (isAuthenticationOperationInProgress(authState) || authState.isAuthenticated) {- reportAuthenticationStateChanged(authState, setStatus)+ reportAuthenticationStateChanged(authState, setStatus, setPendingDesktopEnvironmentSetup)return}restMatch = resolveDesktopEnvironmentRestMatch(@@ -386,7 +390,7 @@ export function createDesktopEnvironmentSetupHandler({if (!(await ownsSessionGeneration(selection.sessionGeneration))) returnauthState = getAuthState()if (isAuthenticationOperationInProgress(authState) || authState.isAuthenticated) {- reportAuthenticationStateChanged(authState, setStatus)+ reportAuthenticationStateChanged(authState, setStatus, setPendingDesktopEnvironmentSetup)return}try {@@ -404,7 +408,7 @@ export function createDesktopEnvironmentSetupHandler({if (!(await ownsSessionGeneration(sessionGeneration))) returnauthState = getAuthState()if (isAuthenticationOperationInProgress(authState) || authState.isAuthenticated) {- reportAuthenticationStateChanged(authState, setStatus)+ reportAuthenticationStateChanged(authState, setStatus, setPendingDesktopEnvironmentSetup)return}setPendingDesktopEnvironmentSetup({ ...linkedConfig, rpcProxyBaseUrl: '' })@@ -416,6 +420,7 @@ export function createDesktopEnvironmentSetupHandler({return}if (isAuthenticationOperationInProgress(getAuthState())) {+ setPendingDesktopEnvironmentSetup(null)setStatus('Finish the current authentication action, then reopen this desktop link.', 'info')return}diff --git a/desktop-app/ui/src/hooks/domain/useAuthController.ts b/desktop-app/ui/src/hooks/domain/useAuthController.tsindex 859b83412..7cc4c631e 100644--- a/desktop-app/ui/src/hooks/domain/useAuthController.ts+++ b/desktop-app/ui/src/hooks/domain/useAuthController.ts@@ -354,6 +354,7 @@ export function useAuthController({expectedSessionGeneration !== undefined &&message.includes('auth_transition_in_progress')) {+ setPendingDesktopEnvironmentSetup(null)setStatus('Finish the current authentication action, then reopen this desktop link.','info'@@ -569,6 +570,7 @@ export function useAuthController({setStatus('The desktop session changed while processing this link. Open it again.', 'info')}const reportAuthenticationInProgress = () => {+ setPendingDesktopEnvironmentSetup(null)setStatus('Finish the current authentication action, then reopen this desktop link.', 'info')}