Skip to content

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

TypeScript

fix(desktop-app): open apps from the picker grid through a workspace tab

Diego Zacarias72dbdeb39841
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsx
index fa43a017e..7244f90b2 100644
--- a/desktop-app/ui/src/App.tsx
+++ b/desktop-app/ui/src/App.tsx
@@ -407,7 +407,7 @@ export function App() {
// state after an UNsolicited close — crash/quit/GC — so a later tab switch
// does not persist or re-close a dead embed). A FAILED open does not reset it:
// the tab keeps owning whatever main may still hold (see
- // `handleSandboxUiRemoved`).
+ // `handleSandboxUiOpenFailed`).
const liveSandboxUiTabIdRef = React.useRef<string | null>(null)
// Monotonic generation bumped on EVERY transition of the active embed (the
// deactivation effect and the deep-link handoff are the only emitters). Each
@@ -1297,14 +1297,14 @@ export function App() {
setSandboxUiMounted(false)
setActiveSandboxUiApp(app)
// Arm the store's embed-liveness ref on EVERY open, however it was launched
- // (store launch, deep link, relaunch, or the in-page picker grid opening the
- // embed directly without changing the active tab). The deactivation effect
- // otherwise only arms it on an active-tab CHANGE, so an embed re-mounted
- // WITHIN the still-active app tab — after a back-to-apps / unsolicited
- // onClosed cleared the ref — would never be tracked and would leak (the
- // native view paints over the next tab). Guard on `null` so this never
- // clobbers the OUTGOING id the effect still needs on an app→app switch
- // (ref stays the old tab; the effect reads it, then re-points to the new one).
+ // (store launch from the sidebar or the picker grid, deep link, or relaunch).
+ // The deactivation effect otherwise only arms it on an active-tab CHANGE, so
+ // an embed re-mounted WITHIN the still-active app tab — a strip relaunch
+ // after a back-to-apps / unsolicited onClosed cleared the ref — would never
+ // be tracked and would leak (the native view paints over the next tab).
+ // Guard on `null` so this never clobbers the OUTGOING id the effect still
+ // needs on an app→app switch (ref stays the old tab; the effect reads it,
+ // then re-points to the new one).
if (liveSandboxUiTabIdRef.current === null) {
const active = activeWorkspaceTab(workspaceTabsRef.current)
if (active?.kind === 'app') liveSandboxUiTabIdRef.current = active.id
@@ -1334,7 +1334,7 @@ export function App() {
// the open IPC leaves the previous view live in main, and only an owner makes
// the deactivation effect `close()` it when the user leaves the tab. When main
// already tore the view down, that `close()` is a harmless no-op.
- const handleSandboxUiRemoved = React.useCallback(() => {
+ const handleSandboxUiOpenFailed = React.useCallback(() => {
setActiveSandboxUiApp(null)
setSandboxUiMounted(false)
setSandboxUiConversationOrigin(null)
@@ -2939,10 +2939,11 @@ export function App() {
shortcutOpenRequestId={sandboxUiShortcutOpenRequestId}
localSearchRequestId={sandboxLocalSearchRequestId}
titlebarLeadingContainer={titlebarLeadingRoot}
+ onLaunchApp={handleOpenSandboxUiApp}
onEmbeddedAppOpening={handleSandboxUiOpening}
onEmbeddedAppMounted={handleSandboxUiMounted}
onEmbeddedAppBack={handleSandboxUiClosed}
- onEmbeddedAppRemoved={handleSandboxUiRemoved}
+ onEmbeddedAppOpenFailed={handleSandboxUiOpenFailed}
onEmbedBoundsApplied={handleSandboxUiBoundsApplied}
onEmbedSlotTopChange={setChatDrawerEmbedTop}
onEmbedSlotRightChange={setNotificationTrayLeft}
diff --git a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
index 8d96d1424..ca15a4c46 100644
--- a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
+++ b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
@@ -107,7 +107,7 @@ const sandboxUiPageHarness = vi.hoisted(() => ({
}) => void
onEmbeddedAppMounted?: () => void
onEmbeddedAppBack?: () => void
- onEmbeddedAppRemoved?: () => void
+ onEmbeddedAppOpenFailed?: () => void
onShortcutOpenResult?: (
requestId: number,
result: { status: 'mounted' } | { status: 'failed'; message: string }
@@ -535,7 +535,7 @@ describe('App deep-link orchestration', () => {
expect(sandboxUiPageHarness.props?.shortcutApp?.appRef).toBe('ns/app')
expect(sidebarHarness.props?.collapsed).toBe(true)
- act(() => sandboxUiPageHarness.props?.onEmbeddedAppRemoved?.())
+ act(() => sandboxUiPageHarness.props?.onEmbeddedAppOpenFailed?.())
expect(sidebarHarness.props?.collapsed).toBe(true)
})
diff --git a/desktop-app/ui/src/__tests__/App.sandboxUiOwnership.test.tsx b/desktop-app/ui/src/__tests__/App.sandboxUiOwnership.test.tsx
index 4c0a269a8..75b73f66e 100644
--- a/desktop-app/ui/src/__tests__/App.sandboxUiOwnership.test.tsx
+++ b/desktop-app/ui/src/__tests__/App.sandboxUiOwnership.test.tsx
@@ -17,11 +17,12 @@ import { mapKindToRoute } from '@lib/workspaceTabsRoute'
import { App } from '@/App'
import { openGfsResourcePayload, resolvedFile } from '@/gfs/__fixtures__/gfsProducerFixtures'
-// Ownership of the native sandbox-ui embed across a FAILED relaunch. The
-// WebContentsView paints above the renderer DOM, so whichever app tab owns it
-// must emit `sandboxUi.close()` when the user leaves it — even after an open on
-// that tab failed, because main may still hold a view (a failure before the
-// open IPC never reaches main at all). These cases drive the REAL SandboxUiPage
+// Ownership of the native sandbox-ui embed. The WebContentsView paints above the
+// renderer DOM, so whichever app tab owns it must emit `sandboxUi.close()` when
+// the user leaves it — even after an open on that tab failed, because main may
+// still hold a view (a failure before the open IPC never reaches main at all),
+// and also when the app was opened from the in-page picker grid, which must
+// create that owning tab. These cases drive the REAL SandboxUiPage
// (its open/catch path is the producer under test) and the REAL tab strip; the
// App harness in App.chatDrawer.test.tsx stubs SandboxUiPage and so cannot.
@@ -42,6 +43,7 @@ type WorkspaceState = ReturnType<typeof useAppController>['workspaceTabs']
const sidebarHarness = vi.hoisted(() => ({
props: null as null | {
+ onSelect?: (item: string) => void
onOpenSandboxUiApp?: (app: {
appRef: string
label: string
@@ -188,7 +190,11 @@ function makeController(): AppController {
isHostAccessBlocked: vi.fn(() => false),
handleSelectChatAgent,
handleOpenNotification: vi.fn(async () => undefined),
- handleNavSelect: vi.fn(),
+ // Only the Apps entry matters here: like the real navigation controller it
+ // shows the instance-less picker instead of opening a tab.
+ handleNavSelect: vi.fn((item: string) => {
+ if (item === DESKTOP_ROUTES.apps) showAppsPicker()
+ }),
handleLogout: vi.fn(),
pushToast: vi.fn(),
setStatus: noop,
@@ -268,9 +274,10 @@ function makeSandboxUiBridge() {
type OpenGfsPayload = Awaited<ReturnType<typeof openGfsResourcePayload>>
-describe('App sandbox-ui ownership survives a failed relaunch', () => {
+describe('App sandbox-ui embed always has an owning app tab', () => {
let currentController: AppController
let openGfsResourceCb: ((resource: OpenGfsPayload) => void) | null
+ let shortcutCommandCb: ((commandId: string, source: string) => void) | null
let sandboxUi: ReturnType<typeof makeSandboxUiBridge>
let slotRect: ReturnType<typeof vi.spyOn>
@@ -278,6 +285,7 @@ describe('App sandbox-ui ownership survives a failed relaunch', () => {
vi.clearAllMocks()
sidebarHarness.props = null
openGfsResourceCb = null
+ shortcutCommandCb = null
currentController = makeController()
vi.mocked(useAppController).mockImplementation(() => useReactiveController(currentController))
vi.stubGlobal('requestAnimationFrame', (cb: FrameRequestCallback) => {
@@ -299,7 +307,12 @@ describe('App sandbox-ui ownership survives a failed relaunch', () => {
Object.defineProperty(window, 'clerum', {
configurable: true,
value: {
- shortcuts: { onCommand: vi.fn(() => vi.fn()) },
+ shortcuts: {
+ onCommand: vi.fn((cb: (commandId: string, source: string) => void) => {
+ shortcutCommandCb = cb
+ return vi.fn()
+ }),
+ },
app: { rendererReady: vi.fn().mockResolvedValue(undefined) },
sandboxUi,
pluginSdk: {
@@ -392,4 +405,57 @@ describe('App sandbox-ui ownership survives a failed relaunch', () => {
await waitFor(() => expect(sandboxUi.close).toHaveBeenCalledTimes(1))
})
+
+ it('opens an app from the in-page picker grid as its own active tab that closes the embed on leave', async () => {
+ // Reach the picker from a conversation through the sidebar, as a user does.
+ currentController.selectedAgent = 'agent-a'
+ currentController.activeChatId = 'chat-1'
+ ;(currentController as { chatList: unknown }).chatList = [{ id: 'chat-1', title: 'Planning' }]
+ render(<App />)
+ await waitFor(() => expect(sandboxUi.listApps).toHaveBeenCalled())
+ act(() => sidebarHarness.props?.onSelect?.(DESKTOP_ROUTES.apps))
+ expect(currentController.appsPickerActive).toBe(true)
+
+ fireEvent.click(await screen.findByRole('button', { name: 'Open Alpha' }))
+
+ await waitFor(() => expect(sandboxUi.open).toHaveBeenCalledTimes(1))
+ const activeTab = activeWorkspaceTab(currentController.workspaceTabs)
+ expect(activeTab?.kind).toBe('app')
+ expect(activeTab?.app?.appRef).toBe(ALPHA!.appRef)
+ expect(currentController.appsPickerActive).toBe(false)
+ // The drawer comes up with the conversation the picker was reached from.
+ expect(currentController.handleSelectChatAgent).toHaveBeenCalledWith(
+ 'agent-a',
+ expect.objectContaining({ chatId: 'chat-1', keepNavItem: true })
+ )
+ expect(sandboxUi.close).not.toHaveBeenCalled()
+
+ await handOffMarkdownFromPlugin()
+
+ await waitFor(() => expect(sandboxUi.close).toHaveBeenCalledTimes(1))
+ })
+
+ it('opens a grid pick shown inside an app tab after back-to-apps as its own tab, leaving that tab intact', async () => {
+ await renderWithLiveApp(ALPHA)
+ const alphaTab = activeWorkspaceTab(currentController.workspaceTabs)
+ expect(alphaTab?.kind).toBe('app')
+
+ // The in-view "Back to apps" button is gone by design; the host shortcut
+ // command is the remaining real entry point.
+ act(() => shortcutCommandCb?.('app.backToApps', 'host'))
+ await waitFor(() => expect(sandboxUi.close).toHaveBeenCalledTimes(1))
+ // Still inside the Alpha tab, now showing the picker grid.
+ expect(currentController.workspaceTabs.activeTabId).toBe(alphaTab!.id)
+
+ fireEvent.click(await screen.findByRole('button', { name: 'Open Beta' }))
+
+ await waitFor(() => expect(sandboxUi.open).toHaveBeenCalledTimes(2))
+ const activeTab = activeWorkspaceTab(currentController.workspaceTabs)
+ expect(activeTab?.id).not.toBe(alphaTab!.id)
+ expect(activeTab?.kind).toBe('app')
+ expect(activeTab?.app?.appRef).toBe(BETA!.appRef)
+ const alphaAfter = currentController.workspaceTabs.tabs.find(tab => tab.id === alphaTab!.id)
+ expect(alphaAfter?.app?.appRef).toBe(ALPHA!.appRef)
+ expect(alphaAfter?.title).toBe(alphaTab!.title)
+ })
})
diff --git a/desktop-app/ui/src/lib/sandboxUiAppSelection.ts b/desktop-app/ui/src/lib/sandboxUiAppSelection.ts
index bf35e8ee8..f36e3de0b 100644
--- a/desktop-app/ui/src/lib/sandboxUiAppSelection.ts
+++ b/desktop-app/ui/src/lib/sandboxUiAppSelection.ts
@@ -4,7 +4,7 @@ import type {
} from '@lib/sandboxUiAppSelection.types'
import type { ActiveSandboxUiApp } from '@/uiTypes'
-function toActiveSandboxUiApp(app: SandboxUiAppListing): ActiveSandboxUiApp {
+export function toActiveSandboxUiApp(app: SandboxUiAppListing): ActiveSandboxUiApp {
return {
appRef: app.appRef,
label: app.title?.trim() || app.appRef,
diff --git a/desktop-app/ui/src/pages/SandboxUiPage.tsx b/desktop-app/ui/src/pages/SandboxUiPage.tsx
index 68015e5ce..19fe81fe0 100644
--- a/desktop-app/ui/src/pages/SandboxUiPage.tsx
+++ b/desktop-app/ui/src/pages/SandboxUiPage.tsx
@@ -2,16 +2,14 @@ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react
import { createPortal } from 'react-dom'
import { IconButton, StatusBanner } from '@components/Common'
import { joinClasses } from '@lib/classNames'
+import type { ActiveSandboxUiApp } from '@/uiTypes'
import SandboxCurrentContentSearch from '../components/SandboxCurrentContentSearch'
import type { AppFindState } from '../components/SandboxCurrentContentSearch/types'
import { IconCopy, IconRefresh, IconSandboxUi } from '../components/SidebarNav/icons'
import { clickableRowProps } from '../lib/clickableRowProps'
+import { toActiveSandboxUiApp } from '../lib/sandboxUiAppSelection'
import type { SandboxUiAppListing } from '../lib/sandboxUiAppSelection.types'
-import type {
- SandboxUiLaunchApp,
- SandboxUiPageProps,
- SandboxUiShortcutOpenResult,
-} from './SandboxUiPage.types'
+import type { SandboxUiPageProps, SandboxUiShortcutOpenResult } from './SandboxUiPage.types'
type PhasePillTone = 'allowed' | 'warning' | 'denied' | 'info' | 'muted'
@@ -212,16 +210,17 @@ export function SandboxUiPage({
shortcutOpenRequestId = 0,
localSearchRequestId = 0,
titlebarLeadingContainer = null,
+ onLaunchApp,
onEmbeddedAppOpening,
onEmbeddedAppMounted,
onEmbeddedAppBack,
- onEmbeddedAppRemoved,
+ onEmbeddedAppOpenFailed,
onEmbedBoundsApplied,
onEmbedSlotTopChange,
onEmbedSlotRightChange,
onNotify,
onShortcutOpenResult,
-}: SandboxUiPageProps = {}) {
+}: SandboxUiPageProps) {
const [apps, setApps] = useState<SandboxUiAppListing[] | null>(null)
const [error, setError] = useState<string | null>(null)
const [launch, setLaunch] = useState<LaunchState>({ kind: 'idle' })
@@ -392,10 +391,7 @@ export function SandboxUiPage({
// quit / partition GC) and the explicit back-to-apps `closeEmbed`.
const openApp = useCallback(
- async (app: SandboxUiLaunchApp): Promise<SandboxUiShortcutOpenResult> => {
- if (app.ready === false) {
- return { status: 'failed', message: 'This app is starting up. Try again in a moment.' }
- }
+ async (app: ActiveSandboxUiApp): Promise<SandboxUiShortcutOpenResult> => {
const [recipeNs, recipeName] = app.appRef.split('/', 2)
if (!recipeNs || !recipeName) {
return { status: 'failed', message: 'Invalid app reference' }
@@ -443,24 +439,11 @@ export function SandboxUiPage({
? 'This app is starting up — try again in a moment.'
: message
setLaunch({ kind: 'error', appRef: app.appRef, message: userFacing })
- onEmbeddedAppRemoved?.()
+ onEmbeddedAppOpenFailed?.()
return { status: 'failed', message: userFacing }
}
},
- [onEmbeddedAppMounted, onEmbeddedAppOpening, onEmbeddedAppRemoved]
- )
-
- const onOpen = useCallback(
- async (app: SandboxUiAppListing) => {
- await openApp({
- appRef: app.appRef,
- label: appLabel(app),
- icon: app.icon,
- defaultPath: app.defaultPath,
- ready: app.ready,
- })
- },
- [openApp]
+ [onEmbeddedAppMounted, onEmbeddedAppOpening, onEmbeddedAppOpenFailed]
)
const closeEmbed = useCallback(async () => {
@@ -516,7 +499,7 @@ export function SandboxUiPage({
})
}, [onShortcutOpenResult, openApp, shortcutApp, shortcutOpenRequestId])
- // Track bounds while mounted; also during 'minting' so onOpen can read
+ // Track bounds while mounted; also during 'minting' so openApp can read
// the slot's rect AFTER the layout pass that renders the slot div.
useEmbedBounds(
embedSlotRef,
@@ -773,7 +756,7 @@ export function SandboxUiPage({
const activatable = app.ready
const activate = (): void => {
if (!activatable) return
- void onOpen(app)
+ onLaunchApp(toActiveSandboxUiApp(app))
}
return (
<div
diff --git a/desktop-app/ui/src/pages/SandboxUiPage.types.ts b/desktop-app/ui/src/pages/SandboxUiPage.types.ts
index 787b35330..ca8754ea4 100644
--- a/desktop-app/ui/src/pages/SandboxUiPage.types.ts
+++ b/desktop-app/ui/src/pages/SandboxUiPage.types.ts
@@ -7,10 +7,6 @@ export type SandboxUiConversationOrigin = {
teamId?: string
}
-export type SandboxUiLaunchApp = ActiveSandboxUiApp & {
- ready?: boolean
-}
-
export type SandboxUiShortcutOpenResult =
| { status: 'mounted' }
| { status: 'failed'; message: string }
@@ -30,10 +26,14 @@ export type SandboxUiPageProps = {
shortcutOpenRequestId?: number
localSearchRequestId?: number
titlebarLeadingContainer?: HTMLElement | null
+ // The picker grid hands the chosen app to the owner instead of opening it
+ // itself, so every embed is opened against a workspace tab that owns it. The
+ // app comes back through `shortcutApp` / `shortcutOpenRequestId`.
+ onLaunchApp: (app: ActiveSandboxUiApp) => void
onEmbeddedAppOpening?: (app: ActiveSandboxUiApp) => void
onEmbeddedAppMounted?: () => void
onEmbeddedAppBack?: () => void
- onEmbeddedAppRemoved?: () => void
+ onEmbeddedAppOpenFailed?: () => void
onEmbedBoundsApplied?: () => void
onEmbedSlotTopChange?: (topPx: number) => void
onEmbedSlotRightChange?: (rightPx: number) => void
diff --git a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.focus.test.tsx b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.focus.test.tsx
index 500f509df..deb1d9096 100644
--- a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.focus.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.focus.test.tsx
@@ -1,15 +1,7 @@
// @vitest-environment jsdom
-import React from 'react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
-import { SandboxUiPage as SandboxUiPageBase } from '../SandboxUiPage'
-
-// The page portals its mounted-app actions into the title bar's leading slot.
-// In isolation there is no WindowTitleBar, so supply a container (document.body)
-// to exercise the real portal path and keep the actions queryable via `screen`.
-function SandboxUiPage(props: React.ComponentProps<typeof SandboxUiPageBase>) {
- return <SandboxUiPageBase titlebarLeadingContainer={document.body} {...props} />
-}
+import { LaunchingSandboxUiPage as SandboxUiPage } from './__fixtures__/launchingSandboxUiPage'
const sandboxUi = {
listApps: vi.fn(),
diff --git a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
index 27928ea1e..5e1b0d304 100644
--- a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
@@ -3,13 +3,7 @@ import React from 'react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
import { SandboxUiPage as SandboxUiPageBase } from '../SandboxUiPage'
-
-// The page portals its mounted-app actions into the title bar's leading slot.
-// In isolation there is no WindowTitleBar, so supply a container (document.body)
-// to exercise the real portal path and keep the actions queryable via `screen`.
-function SandboxUiPage(props: React.ComponentProps<typeof SandboxUiPageBase>) {
- return <SandboxUiPageBase titlebarLeadingContainer={document.body} {...props} />
-}
+import { LaunchingSandboxUiPage as SandboxUiPage } from './__fixtures__/launchingSandboxUiPage'
const sandboxUi = {
listApps: vi.fn(),
@@ -116,6 +110,63 @@ describe('SandboxUiPage', () => {
expect(screen.getAllByRole('button', { name: /^Open / })).toHaveLength(2)
})
+ it('hands a grid pick to the owner instead of opening the embed itself', async () => {
+ sandboxUi.listApps.mockResolvedValueOnce({
+ apps: [
+ {
+ appRef: 'sandbox-recipes/sales-crm',
+ title: " Andy's Sales CRM ",
+ icon: 'data:image/png;base64,icon',
+ defaultPath: '/accounts',
+ ready: true,
+ phase: 'active',
+ updatedAt: null,
+ },
+ ],
+ })
+ const onLaunchApp = vi.fn()
+ const onEmbeddedAppOpening = vi.fn()
+
+ render(
+ <SandboxUiPageBase onLaunchApp={onLaunchApp} onEmbeddedAppOpening={onEmbeddedAppOpening} />
+ )
+ fireEvent.click(await screen.findByRole('button', { name: "Open Andy's Sales CRM" }))
+
+ expect(onLaunchApp).toHaveBeenCalledExactlyOnceWith({
+ appRef: 'sandbox-recipes/sales-crm',
+ label: "Andy's Sales CRM",
+ icon: 'data:image/png;base64,icon',
+ defaultPath: '/accounts',
+ })
+ await new Promise(resolve => window.setTimeout(resolve, 0))
+ // Without an owner feeding the app back, the page stays on the picker.
+ expect(sandboxUi.open).not.toHaveBeenCalled()
+ expect(onEmbeddedAppOpening).not.toHaveBeenCalled()
+ expect(screen.queryByTestId('sandbox-ui-mounted')).toBeNull()
+ })
+
+ it('does not launch an app that is still starting up', async () => {
+ sandboxUi.listApps.mockResolvedValueOnce({
+ apps: [
+ {
+ appRef: 'sandbox-recipes/sales-crm',
+ title: "Andy's Sales CRM",
+ defaultPath: '/',
+ ready: false,
+ phase: 'deploying',
+ updatedAt: null,
+ },
+ ],
+ })
+ const onLaunchApp = vi.fn()
+
+ render(<SandboxUiPageBase onLaunchApp={onLaunchApp} />)
+ fireEvent.click(await screen.findByText("Andy's Sales CRM"))
+
+ expect(screen.queryByRole('button', { name: "Open Andy's Sales CRM" })).toBeNull()
+ expect(onLaunchApp).not.toHaveBeenCalled()
+ })
+
it('does not let an old unmount timer close an immediate replacement page', async () => {
sandboxUi.listApps.mockResolvedValue({ apps: [] })
sandboxUi.close.mockResolvedValue(undefined)
diff --git a/desktop-app/ui/src/pages/__tests__/__fixtures__/launchingSandboxUiPage.tsx b/desktop-app/ui/src/pages/__tests__/__fixtures__/launchingSandboxUiPage.tsx
new file mode 100644
index 000000000..06819a78e
--- /dev/null
+++ b/desktop-app/ui/src/pages/__tests__/__fixtures__/launchingSandboxUiPage.tsx
@@ -0,0 +1,36 @@
+import { type ComponentProps, useCallback, useState } from 'react'
+import type { ActiveSandboxUiApp } from '@/uiTypes'
+import { SandboxUiPage } from '../../SandboxUiPage'
+
+type LaunchingSandboxUiPageProps = Omit<ComponentProps<typeof SandboxUiPage>, 'onLaunchApp'> & {
+ onLaunchApp?: (app: ActiveSandboxUiApp) => void
+}
+
+// The picker grid never opens an app itself: it hands it to the owner, and App
+// (`launchSandboxUiApp`) feeds it back as `shortcutApp` with a fresh
+// `shortcutOpenRequestId`. Page-level tests that need a mounted app reproduce
+// exactly that round-trip here; the App-level ownership suite covers the real
+// owner end to end. The title-bar container is document.body so the portaled
+// mounted-app actions stay queryable via `screen`.
+export function LaunchingSandboxUiPage({ onLaunchApp, ...props }: LaunchingSandboxUiPageProps) {
+ const [launched, setLaunched] = useState<{ app: ActiveSandboxUiApp; requestId: number } | null>(
+ null
+ )
+ const handleLaunchApp = useCallback(
+ (app: ActiveSandboxUiApp) => {
+ onLaunchApp?.(app)
+ setLaunched(current => ({ app, requestId: (current?.requestId ?? 0) + 1 }))
+ },
+ [onLaunchApp]
+ )
+ return (
+ <SandboxUiPage
+ titlebarLeadingContainer={document.body}
+ {...props}
+ {...(launched
+ ? { shortcutApp: launched.app, shortcutOpenRequestId: launched.requestId }
+ : {})}
+ onLaunchApp={handleLaunchApp}
+ />
+ )
+}