Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): r1-m1 provide query context in App test harnesses
M2ae564e07f6a
diff --git a/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx b/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsxindex 2a9fad2a8..2ed050667 100644--- a/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx+++ b/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx@@ -1,14 +1,20 @@// @vitest-environment jsdom-import { useReducer } from 'react'+import { type ReactElement, type ReactNode, useReducer } from 'react'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { useNotificationsContext } from '@contexts/NotificationsContext'-import { QueryClientProvider, useInfiniteQuery, useQueries, useQuery } from '@tanstack/react-query'+import {+ QueryClient,+ QueryClientProvider,+ useInfiniteQuery,+ useQueries,+ useQuery,+} from '@tanstack/react-query'import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'import { DESKTOP_ROUTES } from '@constants/navigation'import { desktopQueryKeys } from '@hooks/domain/queryKeys'import { useAppController } from '@hooks/useAppController'import type { GfsPreviewResource } from '@lib/gfsPreview'-import { desktopQueryClient } from '@lib/queryClient'+import { desktopQueryClient, desktopQueryDefaults } from '@lib/queryClient'import {activeWorkspaceTab,createWorkspaceTabsState,@@ -411,6 +417,15 @@ const CHAT_LIST = [},]+function renderApp(ui: ReactElement) {+ const queryClient = new QueryClient({ defaultOptions: desktopQueryDefaults })+ return render(ui, {+ wrapper: ({ children }: { children: ReactNode }) => (+ <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>+ ),+ })+}+describe('App chat drawer — reopen preserves the last-viewed chat', () => {let currentController: AppController@@ -455,7 +470,7 @@ describe('App chat drawer — reopen preserves the last-viewed chat', () => {navItem: DESKTOP_ROUTES.chat,chatList: CHAT_LIST,} as Partial<AppController>)- const { rerender } = render(<App />)+ const { rerender } = renderApp(<App />)// Open a second real tab (chat-2), then return to chat-1 — mirrors a user// who has both conversations open and is viewing chat-1 when they launch.@@ -512,7 +527,7 @@ describe('App chat drawer — reopen preserves the last-viewed chat', () => {hostAuthorityRevision,} as Partial<AppController>)- const { rerender } = render(<App />)+ const { rerender } = renderApp(<App />)expect(appHeaderHarness.notifications).toEqual([notification])expect(appHeaderHarness.unreadNotificationCount).toBe(1)@@ -543,7 +558,7 @@ describe('App chat drawer — reopen preserves the last-viewed chat', () => {navItem: DESKTOP_ROUTES.chat,chatList: CHAT_LIST,} as Partial<AppController>)- const { rerender } = render(<App />)+ const { rerender } = renderApp(<App />)// Open both conversations as real tabs (chat-2, then back to chat-1) so the// drawer switcher lists both — the user has chat-2 open and is viewing chat-1@@ -645,7 +660,7 @@ describe('App chat drawer — reopen preserves the last-viewed chat', () => {} as unknown as Window['clerum'],})- render(<App />)+ renderApp(<App />)// Launch the app and mark the embed mounted so `chat.switcher` (eligibility// `app-mounted`) is dispatchable, then manually close the drawer so the@@ -710,7 +725,7 @@ describe('App chat drawer — reopen preserves the last-viewed chat', () => {} as unknown as Window['clerum'],})- render(<App />)+ renderApp(<App />)// Launch from chat-1: drawer opens over the live embed with chat-1 active.act(() => {@@ -744,7 +759,7 @@ describe('App chat drawer — reopen preserves the last-viewed chat', () => {navItem: DESKTOP_ROUTES.chat,chatList: CHAT_LIST,} as Partial<AppController>)- render(<App />)+ renderApp(<App />)// Launch from chat-1: the chat drawer becomes visible over the live embed.act(() => {@@ -768,7 +783,7 @@ describe('App chat drawer — reopen preserves the last-viewed chat', () => {it('passes the measured embed edge to the notification drawer while chat is closed', () => {currentController = makeController({ navItem: DESKTOP_ROUTES.apps } as Partial<AppController>)- render(<App />)+ renderApp(<App />)act(() => {sidebarHarness.props?.onOpenSandboxUiApp?.({@@ -785,7 +800,7 @@ describe('App chat drawer — reopen preserves the last-viewed chat', () => {it('keeps the notification rail boundary through a same-edge app reopen', () => {currentController = makeController({ navItem: DESKTOP_ROUTES.apps } as Partial<AppController>)- render(<App />)+ renderApp(<App />)act(() => {sidebarHarness.props?.onOpenSandboxUiApp?.({@@ -830,7 +845,7 @@ describe('App chat drawer — reopen preserves the last-viewed chat', () => {navItem: DESKTOP_ROUTES.chat,chatList: CHAT_LIST,} as Partial<AppController>)- const { rerender } = render(<App />)+ const { rerender } = renderApp(<App />)// Launch from chat-1 → drawer opens on chat-1.act(() => {@@ -864,7 +879,7 @@ describe('App chat drawer — reopen preserves the last-viewed chat', () => {navItem: DESKTOP_ROUTES.chat,chatList: CHAT_LIST,} as Partial<AppController>)- const { rerender } = render(<App />)+ const { rerender } = renderApp(<App />)// Launch from chat-1 → drawer open, app live, navItem apps.act(() => {@@ -914,7 +929,7 @@ describe('App chat drawer — reopen preserves the last-viewed chat', () => {navItem: DESKTOP_ROUTES.chat,chatList: CHAT_LIST,} as Partial<AppController>)- const { rerender } = render(<App />)+ const { rerender } = renderApp(<App />)// Launch from the picker (no origin) → app live, apps route, drawer CLOSED.act(() => {@@ -960,7 +975,7 @@ describe('App chat drawer — reopen preserves the last-viewed chat', () => {navItem: DESKTOP_ROUTES.chat,chatList: CHAT_LIST,} as Partial<AppController>)- const { rerender } = render(<App />)+ const { rerender } = renderApp(<App />)// Launch from the picker (no origin) → app live, apps route, drawer CLOSED.act(() => {@@ -1009,7 +1024,7 @@ describe('App chat drawer — reopen preserves the last-viewed chat', () => {navItem: DESKTOP_ROUTES.chat,chatList: CHAT_LIST,} as Partial<AppController>)- const { rerender } = render(<App />)+ const { rerender } = renderApp(<App />)// Launch from the picker (no origin) → app live, apps route, drawer CLOSED.act(() => {@@ -1098,7 +1113,7 @@ describe('App files multi-instance — deep-link opens by path (mini-spec 06 §3})it('opens two files tabs for two distinct gfsUris and focuses the existing one on re-open', () => {- render(<App />)+ renderApp(<App />)const filesTabs = () => currentController.workspaceTabs.tabs.filter(t => t.kind === 'files')// Two distinct deep-links -> two separate files tabs, in open order.@@ -1183,7 +1198,7 @@ describe('App plugin previewable handoff — routes through resolveGfsPreview (Rconst videoPayload = await openGfsResourcePayload(resolvedFile('vid1', 'demo.mp4', { gfsUri: 'gfs://main/vid1' }))- render(<App />)+ renderApp(<App />)const previewTabs = () => currentController.workspaceTabs.tabs.filter(t => t.kind === 'preview')const filesTabs = () => currentController.workspaceTabs.tabs.filter(t => t.kind === 'files')@@ -1214,7 +1229,7 @@ describe('App plugin previewable handoff — routes through resolveGfsPreview (Rconst pdfPayload = await openGfsResourcePayload(resolvedFile('doc1', 'report.pdf', { gfsUri: 'gfs://main/doc1' }))- render(<App />)+ renderApp(<App />)const previewTabs = () => currentController.workspaceTabs.tabs.filter(t => t.kind === 'preview')const filesTabs = () => currentController.workspaceTabs.tabs.filter(t => t.kind === 'files')@@ -1490,7 +1505,7 @@ describe('App live GFS preview revalidation', () => {finishResolve = resolvePromise}) as never)- render(<App />)+ renderApp(<App />)await waitFor(() => expect(dispatchEntityChange).toBeTypeOf('function'))const initial = () => currentController.workspaceTabs.tabs.find(tab => tab.id === 'preview-md')@@ -1565,7 +1580,7 @@ describe('App live GFS preview revalidation', () => {}return new Promise(() => {}) as never})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(dispatchEntityChange).toBeTypeOf('function'))act(() =>@@ -1600,7 +1615,7 @@ describe('App live GFS preview revalidation', () => {return Promise.reject(new Error('Not authenticated')) as neverreturn new Promise(() => {}) as never})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(dispatchEntityChange).toBeTypeOf('function'))act(() => dispatchEntityChange?.({ ...USER_SCOPE_INVALIDATED }))@@ -1621,7 +1636,7 @@ describe('App live GFS preview revalidation', () => {vi.useFakeTimers()const resolve = vi.mocked(window.clerum.gfs.resolve)resolve.mockRejectedValue(new Error(unavailableMessage))- render(<App />)+ renderApp(<App />)await act(async () => {await Promise.resolve()await Promise.resolve()@@ -1728,7 +1743,7 @@ describe('App chat drawer — narrow-width suppression (mini-spec 05)', () => {}it('suppresses the drawer below the threshold and restores it on re-widen, but a manual close stays closed', () => {- render(<App />)+ renderApp(<App />)// Launch from chat-1: the drawer opens over the live embed. The first sync// reads a 0 panel (jsdom), which is not "too narrow", so it starts visible.@@ -1795,7 +1810,7 @@ describe('App chat drawer — narrow-width suppression (mini-spec 05)', () => {} as unknown as Window['clerum'],})- render(<App />)+ renderApp(<App />)// Launch the app (drawer available), then narrow the panel below 846 so the// drawer is suppressed: app is live, but the drawer is not a divertable surface.@@ -1818,7 +1833,7 @@ describe('App chat drawer — narrow-width suppression (mini-spec 05)', () => {})it('publishes the rail top from the measured embed slot on app tabs, falling back until measured', () => {- render(<App />)+ renderApp(<App />)act(() => {sidebarHarness.props?.onOpenSandboxUiApp?.({@@ -1898,7 +1913,7 @@ describe('App chat drawer — universal availability (mini-spec 04a)', () => {// R2: available on app/files/settings, never on chat.it('makes the drawer available on non-chat tabs and hides it on chat tabs (R2)', () => {- render(<App />)+ renderApp(<App />)expect(appHeaderHarness.props?.drawerAvailable).toBe(false) // chat tabact(() => currentController.handleNavSelect(DESKTOP_ROUTES.files))@@ -1930,7 +1945,7 @@ describe('App chat drawer — universal availability (mini-spec 04a)', () => {navItem: DESKTOP_ROUTES.files,chatList: CHAT_LIST,} as Partial<AppController>)- const { container } = render(<App />)+ const { container } = renderApp(<App />)expect(appHeaderHarness.props?.drawerAvailable).toBe(true)act(() => appHeaderHarness.props?.onToggleChatDrawer?.())@@ -1954,7 +1969,7 @@ describe('App chat drawer — universal availability (mini-spec 04a)', () => {navItem: DESKTOP_ROUTES.files,chatList: CHAT_LIST,} as Partial<AppController>)- const { container } = render(<App />)+ const { container } = renderApp(<App />)expect(appHeaderHarness.props?.drawerAvailable).toBe(true)// jsdom lays nothing out (getBoundingClientRect is all-zero), so give the@@ -1997,7 +2012,7 @@ describe('App chat drawer — universal availability (mini-spec 04a)', () => {navItem: DESKTOP_ROUTES.files,chatList: CHAT_LIST,} as Partial<AppController>)- render(<App />)+ renderApp(<App />)const blankChatCount = () =>currentController.workspaceTabs.tabs.filter(@@ -2022,7 +2037,7 @@ describe('App chat drawer — universal availability (mini-spec 04a)', () => {// R5 + DEC-2: the drawer is global; switching between non-chat kinds keeps it// open and never lets the chat reconcile steal focus onto a chat tab.it('keeps the drawer intact across non-chat tab switches without stealing focus (R5/DEC-2)', () => {- render(<App />)+ renderApp(<App />)act(() => currentController.handleNavSelect(DESKTOP_ROUTES.files))act(() => appHeaderHarness.props?.onToggleChatDrawer?.())expect(appHeaderHarness.props?.chatDrawerOpen).toBe(true)@@ -2046,7 +2061,7 @@ describe('App chat drawer — universal availability (mini-spec 04a)', () => {// chat shows, and clears the open intent so returning to a non-chat tab does not// silently re-open it.it('collapses the drawer before the chat and clears the intent when a chat tab is selected (R4)', () => {- render(<App />)+ renderApp(<App />)act(() =>sidebarHarness.props?.onOpenSandboxUiApp?.({appRef: 'ns/app',@@ -2078,7 +2093,7 @@ describe('App chat drawer — universal availability (mini-spec 04a)', () => {// form), so opening the tray can't close the drawer. Collapsing the drawer frees// the rail and the tray reclaims its drawer form — the tray behavior is intact.it('keeps the notification tray out of the rail while the chat drawer occupies it', () => {- render(<App />)+ renderApp(<App />)act(() =>sidebarHarness.props?.onOpenSandboxUiApp?.({appRef: 'ns/app',diff --git a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsxindex cb678abcc..81fc9c7f4 100644--- a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx+++ b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx@@ -1,10 +1,12 @@// @vitest-environment jsdom-import { type ReactNode, useEffect, useReducer } from 'react'+import { type ReactElement, type ReactNode, useEffect, useReducer } from 'react'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { QueryClient, QueryClientProvider } from '@tanstack/react-query'import { act, render, waitFor } from '@testing-library/react'import { renderToStaticMarkup } from 'react-dom/server'import { DESKTOP_ROUTES, SIDEBAR_COLLAPSED_KEY } from '@constants/navigation'import { useAppController } from '@hooks/useAppController'+import { desktopQueryDefaults } from '@lib/queryClient'import {activeWorkspaceTab,createWorkspaceTabsState,@@ -367,6 +369,15 @@ function makeController(overrides: Partial<AppController> = {}): AppController {return controller}+function renderApp(ui: ReactElement) {+ const queryClient = new QueryClient({ defaultOptions: desktopQueryDefaults })+ return render(ui, {+ wrapper: ({ children }: { children: ReactNode }) => (+ <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>+ ),+ })+}+describe('App deep-link orchestration', () => {let currentController: AppControllerlet emitDeepLink: ((link: SandboxUiDeepLinkEnvelope) => void) | null@@ -392,7 +403,7 @@ describe('App deep-link orchestration', () => {},} as Partial<AppController>)- render(<App />)+ renderApp(<App />)expect(confirmDialogHarness.props?.title).toBe('Add desktop environment?')const dialogBody = renderToStaticMarkup(<>{confirmDialogHarness.props?.body}</>)@@ -423,7 +434,7 @@ describe('App deep-link orchestration', () => {handleConfirmDesktopEnvironmentSwitchConfirmation: confirmSwitch,} as Partial<AppController>)- render(<App />)+ renderApp(<App />)expect(confirmDialogHarness.props?.title).toBe('Switch desktop environment?')expect(confirmDialogHarness.props?.confirmLabel).toBe('Sign out and switch')@@ -499,7 +510,7 @@ describe('App deep-link orchestration', () => {initialExperienceLoading: false,navItem: DESKTOP_ROUTES.apps,} as Partial<AppController>)- render(<App />)+ renderApp(<App />)expect(sidebarHarness.props?.collapsed).toBe(false)act(() => {@@ -527,7 +538,7 @@ describe('App deep-link orchestration', () => {initialExperienceLoading: false,navItem: DESKTOP_ROUTES.apps,} as Partial<AppController>)- render(<App />)+ renderApp(<App />)act(() => {sandboxUiPageHarness.props?.onEmbeddedAppOpening?.({@@ -561,7 +572,7 @@ describe('App deep-link orchestration', () => {initialExperienceLoading: false,navItem: DESKTOP_ROUTES.apps,} as Partial<AppController>)- render(<App />)+ renderApp(<App />)expect(sidebarHarness.props?.collapsed).toBe(true)act(() => {@@ -587,7 +598,7 @@ describe('App deep-link orchestration', () => {initialExperienceLoading: false,navItem,} as Partial<AppController>)- const view = render(<App />)+ const view = renderApp(<App />)expect(appHeaderHarness.props?.placement).toBe('titlebar')@@ -600,7 +611,7 @@ describe('App deep-link orchestration', () => {initialExperienceLoading: false,selectedAgent: 'alpha',} as Partial<AppController>)- render(<App />)+ renderApp(<App />)act(() => emitCommand?.('chat.newTab'))expect(currentController.handleSelectChatAgent).toHaveBeenCalledWith('alpha', {@@ -619,7 +630,7 @@ describe('App deep-link orchestration', () => {selectedAgent: 'alpha',activeChatId: 'chat-1',} as Partial<AppController>)- render(<App />)+ renderApp(<App />)act(() => emitCommand?.('search.open'))expect(appHeaderHarness.props?.searchFocusRequestId).toBe(1)@@ -632,7 +643,7 @@ describe('App deep-link orchestration', () => {it('suppresses application commands while plugin consent owns the app surface', () => {currentController = makeController({ initialExperienceLoading: false })- render(<App />)+ renderApp(<App />)const consent = document.createElement('div')consent.className = 'da-plugin-consent'consent.setAttribute('role', 'dialog')@@ -650,7 +661,7 @@ describe('App deep-link orchestration', () => {navItem: DESKTOP_ROUTES.apps,selectedAgent: 'alpha',} as Partial<AppController>)- render(<App />)+ renderApp(<App />)act(() => {sandboxUiPageHarness.props?.onEmbeddedAppOpening?.({appRef: 'ns/app',@@ -684,7 +695,7 @@ describe('App deep-link orchestration', () => {navItem: DESKTOP_ROUTES.apps,selectedAgent: 'alpha',} as Partial<AppController>)- render(<App />)+ renderApp(<App />)act(() => {sandboxUiPageHarness.props?.onEmbeddedAppOpening?.({appRef: 'ns/app',@@ -708,7 +719,7 @@ describe('App deep-link orchestration', () => {initialExperienceLoading: false,navItem: DESKTOP_ROUTES.apps,} as Partial<AppController>)- render(<App />)+ renderApp(<App />)act(() => emitCommand?.('commands.open', 'sandbox'))act(() => commandPaletteHarness.props?.onClose())@@ -717,7 +728,7 @@ describe('App deep-link orchestration', () => {it('opens Settings Shortcuts through the registered palette action', () => {currentController = makeController({ initialExperienceLoading: false })- render(<App />)+ renderApp(<App />)act(() => emitCommand?.('commands.open'))act(() => commandPaletteHarness.props?.onExecute('settings.shortcuts'))@@ -727,7 +738,7 @@ describe('App deep-link orchestration', () => {it('routes approved core palette actions through their existing owners', () => {currentController = makeController({ initialExperienceLoading: false })- render(<App />)+ renderApp(<App />)act(() => emitCommand?.('commands.open'))act(() => commandPaletteHarness.props?.onExecute('settings.open'))@@ -748,7 +759,7 @@ describe('App deep-link orchestration', () => {it('routes approved contextual palette actions through shell and app owners', () => {currentController = makeController({ initialExperienceLoading: false })- render(<App />)+ renderApp(<App />)act(() => emitCommand?.('commands.open'))for (const [commandId, route] of [@@ -788,7 +799,7 @@ describe('App deep-link orchestration', () => {it('resets controlled command requests with the authenticated shell lifetime', async () => {currentController = makeController({ initialExperienceLoading: false })- const { rerender } = render(<App />)+ const { rerender } = renderApp(<App />)act(() => emitCommand?.('commands.open'))act(() => commandPaletteHarness.props?.onExecute('notifications.open'))@@ -862,7 +873,7 @@ describe('App deep-link orchestration', () => {},],})- const { rerender } = render(<App />)+ const { rerender } = renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -905,7 +916,7 @@ describe('App deep-link orchestration', () => {},],})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -927,7 +938,7 @@ describe('App deep-link orchestration', () => {it('acknowledges an authenticated app link when confirmation is cancelled', async () => {currentController = makeController({ initialExperienceLoading: false })- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -961,7 +972,7 @@ describe('App deep-link orchestration', () => {},],})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(sandboxUiPageHarness.props).not.toBeNull())// The native WebContentsView paints above renderer DOM, so the overlay// signal must stay off until a deep-link dialog actually needs to show.@@ -991,7 +1002,7 @@ describe('App deep-link orchestration', () => {navItem: DESKTOP_ROUTES.apps,handleEnsureTeamContext: ensureTeamContext,})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1038,7 +1049,7 @@ describe('App deep-link orchestration', () => {navItem: DESKTOP_ROUTES.apps,handleEnsureTeamContext: ensureTeamContext,})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1096,7 +1107,7 @@ describe('App deep-link orchestration', () => {},],})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1115,7 +1126,7 @@ describe('App deep-link orchestration', () => {})it('never presents a user A link after user B becomes authenticated', async () => {- const { rerender } = render(<App />)+ const { rerender } = renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1162,7 +1173,7 @@ describe('App deep-link orchestration', () => {resolveColdList = resolve}))- const { rerender } = render(<App />)+ const { rerender } = renderApp(<App />)currentController = makeController({initialExperienceLoading: false,@@ -1192,7 +1203,7 @@ describe('App deep-link orchestration', () => {it('restores the previous team when the linked app is unavailable', async () => {currentController = makeController({ initialExperienceLoading: false })- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1226,7 +1237,7 @@ describe('App deep-link orchestration', () => {selectedAgent: 'alpha',activeChatId: 'chat-1',} as Partial<AppController>)- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1254,7 +1265,7 @@ describe('App deep-link orchestration', () => {navItem: DESKTOP_ROUTES.apps,handleEnsureTeamContext: ensureTeamContext,})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(sandboxUiPageHarness.props).not.toBeNull())act(() => {@@ -1296,7 +1307,7 @@ describe('App deep-link orchestration', () => {},],})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1335,7 +1346,7 @@ describe('App deep-link orchestration', () => {handleEnsureTeamContext: ensureTeamContext,getCurrentTeamId: () => liveTeamId,})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1370,7 +1381,7 @@ describe('App deep-link orchestration', () => {acknowledgeDeepLink.mockImplementationOnce(() => {throw new Error('bridge unavailable')})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1404,7 +1415,7 @@ describe('App deep-link orchestration', () => {},],})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1437,7 +1448,7 @@ describe('App deep-link orchestration', () => {},],}))- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1488,7 +1499,7 @@ describe('App deep-link orchestration', () => {},],}))- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1553,7 +1564,7 @@ describe('App deep-link orchestration', () => {},],})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1608,7 +1619,7 @@ describe('App deep-link orchestration', () => {},],})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1684,7 +1695,7 @@ describe('App deep-link orchestration', () => {},],})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1723,7 +1734,7 @@ describe('App deep-link orchestration', () => {initialExperienceLoading: false,handleEnsureTeamContext: ensureTeamContext,})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1762,7 +1773,7 @@ describe('App deep-link orchestration', () => {initialExperienceLoading: false,handleEnsureTeamContext: ensureTeamContext,})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1795,7 +1806,7 @@ describe('App deep-link orchestration', () => {},],})- render(<App />)+ renderApp(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())act(() => {@@ -1870,7 +1881,7 @@ describe('App deep-link orchestration', () => {it('restores the saved route when an app tab is reactivated (mini-spec 05 §3, T3)', async () => {currentController = makeController({ initialExperienceLoading: false })listApps.mockResolvedValue({ apps: [READY_APP] })- render(<App />)+ renderApp(<App />)await launchAppFromSidebar()// Launched at the default route — nothing persisted yet.expect(sandboxUiPageHarness.props?.shortcutApp?.routePath).toBeUndefined()@@ -1894,7 +1905,7 @@ describe('App deep-link orchestration', () => {it('keeps two tabs of the same app on their own routes when alternating (§5)', async () => {currentController = makeController({ initialExperienceLoading: false })listApps.mockResolvedValue({ apps: [READY_APP] })- render(<App />)+ renderApp(<App />)// Two tabs of the same app: [chat, A, B].await launchAppFromSidebar()@@ -1921,7 +1932,7 @@ describe('App deep-link orchestration', () => {it('closes the embed exactly once on deactivation — the store is the single emitter (§3)', async () => {currentController = makeController({ initialExperienceLoading: false })listApps.mockResolvedValue({ apps: [READY_APP] })- render(<App />)+ renderApp(<App />)await launchAppFromSidebar()closeSandboxUi.mockClear()@@ -1935,7 +1946,7 @@ describe('App deep-link orchestration', () => {it('does not re-close after an UNsolicited close reconciles the tab as not mounted (§3)', async () => {currentController = makeController({ initialExperienceLoading: false })listApps.mockResolvedValue({ apps: [READY_APP] })- render(<App />)+ renderApp(<App />)await launchAppFromSidebar()// Unsolicited teardown (crash / quit / partition GC) arrives while the app@@ -1960,7 +1971,7 @@ describe('App deep-link orchestration', () => {it('closes an embed re-mounted within the still-active app tab (Blocker — arm-on-open)', async () => {currentController = makeController({ initialExperienceLoading: false })listApps.mockResolvedValue({ apps: [READY_APP] })- render(<App />)+ renderApp(<App />)await launchAppFromSidebar()// Back-to-apps / unsolicited onClosed clears the liveness ref but leaves the@@ -1998,7 +2009,7 @@ describe('App deep-link orchestration', () => {handleEnsureTeamContext: ensureTeamContext,})listApps.mockResolvedValue({ apps: [READY_APP] })- render(<App />)+ renderApp(<App />)await launchAppFromSidebar()const outgoingId = appTabs()[0]?.id@@ -2041,7 +2052,7 @@ describe('App deep-link orchestration', () => {it('does not close or overwrite an app tab reactivated before the stale getLocation resolves (R1-H1, T3)', async () => {currentController = makeController({ initialExperienceLoading: false })listApps.mockResolvedValue({ apps: [READY_APP] })- render(<App />)+ renderApp(<App />)await launchAppFromSidebar() // tabs: [chat, A]; A is livecloseSandboxUi.mockClear()@@ -2083,7 +2094,7 @@ describe('App deep-link orchestration', () => {currentController = makeController({ initialExperienceLoading: false })// Two genuinely distinct apps: A's stale continuation must not tear down B.listApps.mockResolvedValue({ apps: [READY_APP, READY_APP_B] })- render(<App />)+ renderApp(<App />)await launchAppFromSidebar('ns/app') // tabs: [chat, A]; A is livecloseSandboxUi.mockClear()@@ -2142,7 +2153,7 @@ describe('App deep-link orchestration', () => {// The deep link targets an UNAVAILABLE app (ns/missing) so the post-handoff// open fails cleanly instead of relaunching an app and muddying the assertions.listApps.mockResolvedValue({ apps: [READY_APP] })- render(<App />)+ renderApp(<App />)await launchAppFromSidebar('ns/app') // tabs: [chat, A]; A live, liveRef = Aconst outgoingId = appTabs()[0]?.id@@ -2195,7 +2206,7 @@ describe('App deep-link orchestration', () => {currentController = makeController({ initialExperienceLoading: false })// Two genuinely distinct apps so the read can carry the WRONG app's location.listApps.mockResolvedValue({ apps: [READY_APP, READY_APP_B] })- render(<App />)+ renderApp(<App />)await launchAppFromSidebar('ns/app') // tabs: [chat, A]; A liveconst outgoingId = appTabs()[0]?.id@@ -2227,7 +2238,7 @@ describe('App deep-link orchestration', () => {it('preserves the outgoing tab route when the deactivation read surfaces a foreign app (R4-M1, §3, T3)', async () => {currentController = makeController({ initialExperienceLoading: false })listApps.mockResolvedValue({ apps: [READY_APP, READY_APP_B] })- render(<App />)+ renderApp(<App />)await launchAppFromSidebar('ns/app') // tabs: [chat, A]; A live & activeconst outgoingId = appTabs()[0]!.id@@ -2268,7 +2279,7 @@ describe('App deep-link orchestration', () => {handleEnsureTeamContext: ensureTeamContext,})listApps.mockResolvedValue({ apps: [READY_APP] })- render(<App />)+ renderApp(<App />)await launchAppFromSidebar('ns/app') // A live & activeconst outgoingId = appTabs()[0]!.iddiff --git a/desktop-app/ui/src/__tests__/App.sandboxUiOwnership.test.tsx b/desktop-app/ui/src/__tests__/App.sandboxUiOwnership.test.tsxindex 4525d0f4c..b3da5fc99 100644--- a/desktop-app/ui/src/__tests__/App.sandboxUiOwnership.test.tsx+++ b/desktop-app/ui/src/__tests__/App.sandboxUiOwnership.test.tsx@@ -1,10 +1,12 @@// @vitest-environment jsdom-import { useReducer } from 'react'+import { type ReactElement, type ReactNode, useReducer } from 'react'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { QueryClient, QueryClientProvider } from '@tanstack/react-query'import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'import { DESKTOP_ROUTES } from '@constants/navigation'import { useAppController } from '@hooks/useAppController'import type { GfsPreviewResource } from '@lib/gfsPreview'+import { desktopQueryDefaults } from '@lib/queryClient'import { toActiveSandboxUiApps } from '@lib/sandboxUiAppSelection'import type { SandboxUiAppListing } from '@lib/sandboxUiAppSelection.types'import {@@ -274,6 +276,15 @@ function makeSandboxUiBridge() {type OpenGfsPayload = Awaited<ReturnType<typeof openGfsResourcePayload>>+function renderApp(ui: ReactElement) {+ const queryClient = new QueryClient({ defaultOptions: desktopQueryDefaults })+ return render(ui, {+ wrapper: ({ children }: { children: ReactNode }) => (+ <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>+ ),+ })+}+describe('App sandbox-ui embed always has an owning app tab', () => {let currentController: AppControllerlet openGfsResourceCb: ((resource: OpenGfsPayload) => void) | null@@ -334,7 +345,7 @@ describe('App sandbox-ui embed always has an owning app tab', () => {})async function renderWithLiveApp(app: typeof ALPHA) {- render(<App />)+ renderApp(<App />)// The strip relaunch resolves the tab's app against the loaded listing.await waitFor(() => expect(sandboxUi.listApps).toHaveBeenCalled())await act(async () => {@@ -411,7 +422,7 @@ describe('App sandbox-ui embed always has an owning app tab', () => {currentController.selectedAgent = 'agent-a'currentController.activeChatId = 'chat-1';(currentController as { chatList: unknown }).chatList = [{ id: 'chat-1', title: 'Planning' }]- render(<App />)+ renderApp(<App />)await waitFor(() => expect(sandboxUi.listApps).toHaveBeenCalled())act(() => sidebarHarness.props?.onSelect?.(DESKTOP_ROUTES.apps))expect(currentController.appsPickerActive).toBe(true)@@ -538,7 +549,7 @@ describe('App sandbox-ui embed always has an owning app tab', () => {})it('keeps the newer launch owned when a superseded open resolves late and its view then dies', async () => {- render(<App />)+ renderApp(<App />)await waitFor(() => expect(sandboxUi.listApps).toHaveBeenCalled())await act(async () => {await Promise.resolve()