Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): r2-m1 retain target team for mount retries
Josué5b7f86c207ec
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex 6d73f5a03..dbe0b82e8 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -532,6 +532,20 @@ export function App() {[vm.getCurrentTeamId, vm.handleEnsureTeamContext, vm.handleSelectChatAgent, vm.pushToast])+ const deferSandboxUiDeepLinkUntilTerminal = React.useCallback(+ async (+ pending: PendingSandboxUiDeepLink,+ message: string,+ launchContext: PendingSandboxUiDeepLinkLaunch,+ tone: 'info' | 'error' = 'error'+ ) => {+ if (deferSandboxUiDeepLink(pending, message, tone)) {+ await restoreSandboxUiDeepLinkTeam(launchContext)+ }+ },+ [deferSandboxUiDeepLink, restoreSandboxUiDeepLinkTeam]+ )+const closeActiveSandboxUiEmbedForHandoff = React.useCallback(async () => {if (!activeSandboxUiApp) returnawait window.clerum.sandboxUi.close()@@ -650,16 +664,14 @@ export function App() {switchedTeam,conversationOrigin: pending.conversationOrigin,}- const exhaustedRetryBudget = deferSandboxUiDeepLink(+ await deferSandboxUiDeepLinkUntilTerminal(pending,`Could not switch to the linked team yet: ${errorMessage(error)}. This link will retry shortly.`,+ launchContext,'info')- if (exhaustedRetryBudget) {- await restoreSandboxUiDeepLinkTeam(launchContext)- }return}throw error@@ -684,14 +696,12 @@ export function App() {switchedTeam,conversationOrigin: pending.conversationOrigin,}- const exhaustedRetryBudget = deferSandboxUiDeepLink(+ await deferSandboxUiDeepLinkUntilTerminal(pending,`${resolution.label} is still starting up. This link will retry shortly.`,+ launchContext,'info')- if (exhaustedRetryBudget) {- await restoreSandboxUiDeepLinkTeam(launchContext)- }return}const requestId = launchSandboxUiApp(@@ -737,7 +747,7 @@ export function App() {bootSplashLoading,closeActiveSandboxUiEmbedForHandoff,clearSandboxUiDeepLinkProcessing,- deferSandboxUiDeepLink,+ deferSandboxUiDeepLinkUntilTerminal,launchSandboxUiApp,pendingSandboxUiDeepLinks,restoreSandboxUiDeepLinkTeam,@@ -783,14 +793,16 @@ export function App() {await acknowledgeSandboxUiDeepLink(launch.linkId)return}- await restoreSandboxUiDeepLinkTeam(launch)- deferSandboxUiDeepLink(pending, result.message || 'The native app view did not mount')+ await deferSandboxUiDeepLinkUntilTerminal(+ pending,+ result.message || 'The native app view did not mount',+ launch+ )},[acknowledgeSandboxUiDeepLink,clearSandboxUiDeepLinkProcessing,- deferSandboxUiDeepLink,- restoreSandboxUiDeepLinkTeam,+ deferSandboxUiDeepLinkUntilTerminal,])diff --git a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsxindex 3fdd6da14..69a971841 100644--- a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx+++ b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx@@ -712,7 +712,7 @@ describe('App deep-link orchestration', () => {expect(ensureTeamContext).toHaveBeenCalledTimes(1)})- it('does not override a manual team switch while a cross-team app link is retrying', async () => {+ it('retries a failed cross-team native mount without treating its own restore as a user switch', async () => {vi.useFakeTimers({ shouldAdvanceTime: true })let liveTeamId = 'team-a'const ensureTeamContext = vi.fn(async ({ teamId }: { teamId?: string }) => {@@ -731,8 +731,8 @@ describe('App deep-link orchestration', () => {appRef: 'ns/app',title: 'Linked App',defaultPath: '/',- ready: false,- phase: 'deploying',+ ready: true,+ phase: 'active',},],})@@ -743,12 +743,65 @@ describe('App deep-link orchestration', () => {emitDeepLink?.({ id: 1, appRef: 'ns/app', teamId: 'team-b' })})await confirmPendingAppLink()+ await reportShortcutOpenResult({ status: 'failed', message: 'native mount failed' })await waitFor(() => {- expect(currentController.pushToast).toHaveBeenCalledWith(- 'Linked App is still starting up. This link will retry shortly.',- 'info'- )+ expect(currentController.pushToast).toHaveBeenCalledWith('native mount failed', 'error')+ })+ expect(liveTeamId).toBe('team-b')+ expect(acknowledgeDeepLink).not.toHaveBeenCalled()++ await act(async () => {+ vi.advanceTimersByTime(1_000)+ await Promise.resolve()+ })+ await reportShortcutOpenResult()++ await waitFor(() => expect(acknowledgeDeepLink).toHaveBeenCalledWith(1))+ expect(acknowledgeDeepLink).toHaveBeenCalledTimes(1)+ expect(liveTeamId).toBe('team-b')+ expect(ensureTeamContext).toHaveBeenCalledTimes(1)+ expect(currentController.pushToast).not.toHaveBeenCalledWith(+ expect.stringContaining('you switched teams'),+ 'error'+ )+ })++ it('does not override a manual team switch during a failed cross-team native-mount retry', async () => {+ vi.useFakeTimers({ shouldAdvanceTime: true })+ let liveTeamId = 'team-a'+ const ensureTeamContext = vi.fn(async ({ teamId }: { teamId?: string }) => {+ if (!teamId || teamId === liveTeamId) return false+ liveTeamId = teamId+ return true+ })+ currentController = makeController({+ initialExperienceLoading: false,+ handleEnsureTeamContext: ensureTeamContext,+ getCurrentTeamId: () => liveTeamId,+ })+ listApps.mockResolvedValue({+ apps: [+ {+ appRef: 'ns/app',+ title: 'Linked App',+ defaultPath: '/',+ ready: true,+ phase: 'active',+ },+ ],+ })+ render(<App />)+ await waitFor(() => expect(emitDeepLink).not.toBeNull())++ act(() => {+ emitDeepLink?.({ id: 1, appRef: 'ns/app', teamId: 'team-b' })+ })+ await confirmPendingAppLink()+ await reportShortcutOpenResult({ status: 'failed', message: 'native mount failed' })++ await waitFor(() => {+ expect(currentController.pushToast).toHaveBeenCalledWith('native mount failed', 'error')})expect(liveTeamId).toBe('team-b')expect(ensureTeamContext).toHaveBeenCalledTimes(1)@@ -760,12 +813,10 @@ describe('App deep-link orchestration', () => {})await waitFor(() => expect(currentController.pushToast).toHaveBeenCalledTimes(2))- const retryNoise = currentController.pushToast.mock.calls.filter(- ([message, tone]) =>- message === 'Linked App is still starting up. This link will retry shortly.' &&- tone === 'info'+ const nativeMountFailures = currentController.pushToast.mock.calls.filter(+ ([message, tone]) => message === 'native mount failed' && tone === 'error')- expect(retryNoise).toHaveLength(1)+ expect(nativeMountFailures).toHaveLength(1)expect(currentController.pushToast).toHaveBeenCalledWith(expect.stringContaining('you switched teams'),'error'@@ -773,8 +824,8 @@ describe('App deep-link orchestration', () => {expect(confirmDialogHarness.props?.title).toBe('App link could not be opened')expect(liveTeamId).toBe('team-c')expect(ensureTeamContext).toHaveBeenCalledTimes(1)- expect(currentController.handleNavSelect).not.toHaveBeenCalledWith(DESKTOP_ROUTES.apps)- expect(sandboxUiPageHarness.props?.shortcutOpenRequestId).toBeUndefined()+ expect(currentController.handleNavSelect).toHaveBeenCalledTimes(1)+ expect(sandboxUiPageHarness.props?.shortcutOpenRequestId).toBe(1)expect(acknowledgeDeepLink).not.toHaveBeenCalled()await act(async () => {