Skip to content

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

TypeScript

fix(desktop-app): leave the user where they navigated when a linked app is abandoned (R1-M2)

Diego Zacariase726a598736a
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsx
index 9c4f63633..c1fec507d 100644
--- a/desktop-app/ui/src/App.tsx
+++ b/desktop-app/ui/src/App.tsx
@@ -1696,9 +1696,10 @@ export function App() {
// What a deep link does once its launch settled. Mounted: done. Failed: retried
// with the failure's message until the retry budget runs out. Abandoned (the
- // user left its tab before it mounted): dropped without a retry, which would
- // reopen an app the user walked away from, and the team it switched to is
- // given back.
+ // user moved off its tab before it mounted, or the session or window holding
+ // it went away): dropped as is. A retry would reopen an app the user walked
+ // away from, and giving back the team or the originating chat would pull the
+ // user out of wherever they just went; their navigation wins.
const finishSandboxUiDeepLinkLaunch = React.useCallback(
async (context: PendingSandboxUiDeepLinkLaunch, launchId: LaunchId, outcome: LaunchOutcome) => {
if (context.generation !== sandboxUiDeepLinkGenerationRef.current) {
@@ -1717,7 +1718,6 @@ export function App() {
return
}
if (outcome === 'abandoned') {
- await restoreSandboxUiDeepLinkTeam(context)
await acknowledgeSandboxUiDeepLink(context.linkId)
return
}
@@ -1735,7 +1735,6 @@ export function App() {
clearSandboxUiDeepLinkProcessing,
deferSandboxUiDeepLinkUntilTerminal,
embed,
- restoreSandboxUiDeepLinkTeam,
]
)
diff --git a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
index 8e2d42ffd..f9369f2fa 100644
--- a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
+++ b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
@@ -157,7 +157,11 @@ vi.mock('@components/CommandPalette', () => ({
},
}))
vi.mock('@components/BootSplash', () => ({ BootSplash: () => null }))
-vi.mock('@components/Common', () => ({ Button: () => null, ToastStack: () => null }))
+vi.mock('@components/Common', () => ({
+ Button: () => null,
+ IconButton: () => null,
+ ToastStack: () => null,
+}))
vi.mock('@components/ConfirmDialog', () => ({
ConfirmDialog: (props: {
title: string
@@ -2004,7 +2008,7 @@ describe('App deep-link orchestration', () => {
expect(closeSandboxUi()).toHaveBeenCalledWith({ launchId: main.openCall(0).launchId })
})
- it('acks a cross-team link left before it mounted without retrying it, and gives the team back', async () => {
+ it('acks a cross-team link left before it mounted without retrying it or switching teams back', async () => {
let liveTeamId = 'team-a'
const ensureTeamContext = vi.fn(async ({ teamId }: { teamId?: string }) => {
if (!teamId || teamId === liveTeamId) return false
@@ -2032,8 +2036,8 @@ describe('App deep-link orchestration', () => {
await selectTab(0)
await waitFor(() => expect(acknowledgeDeepLink).toHaveBeenCalledWith(1))
- expect(ensureTeamContext).toHaveBeenLastCalledWith({ teamId: 'team-a', announce: true })
- expect(liveTeamId).toBe('team-a')
+ expect(ensureTeamContext).toHaveBeenCalledTimes(1)
+ expect(liveTeamId).toBe('team-b')
expect(confirmDialogHarness.props?.title).not.toBe('App link could not be opened')
expect(currentController.pushToast).not.toHaveBeenCalledWith(
expect.stringContaining('Could not open app link'),
@@ -2046,6 +2050,47 @@ describe('App deep-link orchestration', () => {
expect(openSandboxUi()).toHaveBeenCalledTimes(1)
})
+ it('keeps the user where they navigated when a cross-team link is abandoned', async () => {
+ 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,
+ navItem: DESKTOP_ROUTES.chat,
+ selectedAgent: 'alpha',
+ activeChatId: 'chat-1',
+ handleEnsureTeamContext: ensureTeamContext,
+ getCurrentTeamId: () => liveTeamId,
+ } as Partial<AppController>)
+ listApps.mockResolvedValue({ apps: [READY_APP] })
+ render(<App />)
+ await waitFor(() => expect(emitDeepLink).not.toBeNull())
+
+ main.holdNextOpen()
+ act(() => {
+ emitDeepLink?.({ id: 1, appRef: 'ns/app', teamId: 'team-b' })
+ })
+ await confirmPendingAppLink()
+ await waitForAppOpen()
+ expect(liveTeamId).toBe('team-b')
+
+ // The user goes to Files while the linked app is still opening.
+ act(() => {
+ currentController.handleNavSelect(DESKTOP_ROUTES.files)
+ })
+
+ await waitFor(() => expect(acknowledgeDeepLink).toHaveBeenCalledWith(1))
+ await act(async () => {
+ await new Promise(resolve => window.setTimeout(resolve, 50))
+ })
+ expect(liveTeamId).toBe('team-b')
+ expect(activeWorkspaceTab(currentController.workspaceTabs)?.kind).toBe('files')
+ expect(openSandboxUi()).toHaveBeenCalledTimes(1)
+ })
+
it('stops a deep link waiting on its launch when App unmounts, without acting on it', async () => {
currentController = makeController({ initialExperienceLoading: false })
listApps.mockResolvedValue({ apps: [READY_APP] })