Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(desktop): add contextual command palette actions
Josué1c137072bbbf
diff --git a/desktop-app/src/__tests__/desktopCommands.test.ts b/desktop-app/src/__tests__/desktopCommands.test.tsindex d0341c75a..1df3baca4 100644--- a/desktop-app/src/__tests__/desktopCommands.test.ts+++ b/desktop-app/src/__tests__/desktopCommands.test.ts@@ -124,12 +124,48 @@ describe('Desktop command registry', () => {})it('enables commands from the same registry context used by keyboard and palette actions', () => {- const context = { tabCount: 1, searchableContent: false, composerAvailable: false }+ const context = {+ tabCount: 1,+ searchableContent: false,+ composerAvailable: false,+ appMounted: false,+ conversationOriginAvailable: false,+ }expect(isDesktopCommandEligible(getDesktopCommand('tabs.select1'), context)).toBe(true)expect(isDesktopCommandEligible(getDesktopCommand('tabs.select2'), context)).toBe(false)expect(isDesktopCommandEligible(getDesktopCommand('tabs.next'), context)).toBe(false)expect(isDesktopCommandEligible(getDesktopCommand('search.current'), context)).toBe(false)expect(isDesktopCommandEligible(getDesktopCommand('composer.focus'), context)).toBe(false)expect(isDesktopCommandEligible(getDesktopCommand('search.open'), context)).toBe(true)+ expect(isDesktopCommandEligible(getDesktopCommand('app.refresh'), context)).toBe(false)+ expect(+ isDesktopCommandEligible(getDesktopCommand('app.refresh'), { ...context, appMounted: true })+ ).toBe(true)+ expect(+ isDesktopCommandEligible(getDesktopCommand('app.backToConversation'), {+ ...context,+ appMounted: true,+ conversationOriginAvailable: true,+ })+ ).toBe(true)+ })++ it('keeps every approved contextual palette action unbound', () => {+ for (const id of [+ 'navigate.plugins',+ 'navigate.contexts',+ 'navigate.teams',+ 'navigate.connectors',+ 'navigate.files',+ 'sidebar.toggle',+ 'app.refresh',+ 'app.backToApps',+ 'app.backToConversation',+ ] as const) {+ const command = getDesktopCommand(id)+ expect(command.defaultBinding).toBeNull()+ expect(command.visibleInPalette).toBe(true)+ expect(command.visibleInSettings).toBe(false)+ }})})diff --git a/desktop-app/src/desktopCommands.ts b/desktop-app/src/desktopCommands.tsindex 72cbbfed7..fd87d4e11 100644--- a/desktop-app/src/desktopCommands.ts+++ b/desktop-app/src/desktopCommands.ts@@ -14,6 +14,8 @@ export type DesktopCommandEligibility =| 'tab-index'| 'searchable-content'| 'composer-available'+ | 'app-mounted'+ | 'conversation-origin'export type SemanticShortcutBinding = {key: string@@ -42,6 +44,8 @@ export type DesktopCommandRuntimeContext = {tabCount: numbersearchableContent: booleancomposerAvailable: boolean+ appMounted: boolean+ conversationOriginAvailable: boolean}function tabSelectCommand<const Id extends `tabs.select${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}`>(@@ -320,6 +324,141 @@ const definitions = [visibleInPalette: true,visibleInSettings: false,},+ {+ id: 'navigate.plugins',+ label: 'Go to Plugins',+ description: 'Open the Plugins workspace.',+ group: 'Navigation',+ order: 180,+ defaultBinding: null,+ sources: ['host', 'sandbox'],+ eligibility: 'always',+ editingPolicy: 'suppress',+ modalPolicy: 'block',+ actionOwner: 'renderer',+ visibleInPalette: true,+ visibleInSettings: false,+ },+ {+ id: 'navigate.contexts',+ label: 'Go to Contexts',+ description: 'Open the Contexts workspace.',+ group: 'Navigation',+ order: 190,+ defaultBinding: null,+ sources: ['host', 'sandbox'],+ eligibility: 'always',+ editingPolicy: 'suppress',+ modalPolicy: 'block',+ actionOwner: 'renderer',+ visibleInPalette: true,+ visibleInSettings: false,+ },+ {+ id: 'navigate.teams',+ label: 'Go to Teams',+ description: 'Open the Teams workspace.',+ group: 'Navigation',+ order: 200,+ defaultBinding: null,+ sources: ['host', 'sandbox'],+ eligibility: 'always',+ editingPolicy: 'suppress',+ modalPolicy: 'block',+ actionOwner: 'renderer',+ visibleInPalette: true,+ visibleInSettings: false,+ },+ {+ id: 'navigate.connectors',+ label: 'Go to Connectors',+ description: 'Open the Connectors workspace.',+ group: 'Navigation',+ order: 210,+ defaultBinding: null,+ sources: ['host', 'sandbox'],+ eligibility: 'always',+ editingPolicy: 'suppress',+ modalPolicy: 'block',+ actionOwner: 'renderer',+ visibleInPalette: true,+ visibleInSettings: false,+ },+ {+ id: 'navigate.files',+ label: 'Go to Global File System',+ description: 'Open the Global File System browser.',+ group: 'Navigation',+ order: 220,+ defaultBinding: null,+ sources: ['host', 'sandbox'],+ eligibility: 'always',+ editingPolicy: 'suppress',+ modalPolicy: 'block',+ actionOwner: 'renderer',+ visibleInPalette: true,+ visibleInSettings: false,+ },+ {+ id: 'sidebar.toggle',+ label: 'Toggle sidebar',+ description: 'Collapse, expand, or open the responsive sidebar.',+ group: 'Workspace',+ order: 230,+ defaultBinding: null,+ sources: ['host', 'sandbox'],+ eligibility: 'always',+ editingPolicy: 'suppress',+ modalPolicy: 'block',+ actionOwner: 'renderer',+ visibleInPalette: true,+ visibleInSettings: false,+ },+ {+ id: 'app.refresh',+ label: 'Refresh current app',+ description: 'Refresh the currently mounted app.',+ group: 'Workspace',+ order: 240,+ defaultBinding: null,+ sources: ['host', 'sandbox'],+ eligibility: 'app-mounted',+ editingPolicy: 'suppress',+ modalPolicy: 'block',+ actionOwner: 'renderer',+ visibleInPalette: true,+ visibleInSettings: false,+ },+ {+ id: 'app.backToApps',+ label: 'Back to Apps',+ description: 'Close the current app and return to Apps.',+ group: 'Workspace',+ order: 250,+ defaultBinding: null,+ sources: ['host', 'sandbox'],+ eligibility: 'app-mounted',+ editingPolicy: 'suppress',+ modalPolicy: 'block',+ actionOwner: 'renderer',+ visibleInPalette: true,+ visibleInSettings: false,+ },+ {+ id: 'app.backToConversation',+ label: 'Back to conversation',+ description: 'Return to the conversation that opened the current app.',+ group: 'Workspace',+ order: 260,+ defaultBinding: null,+ sources: ['host', 'sandbox'],+ eligibility: 'conversation-origin',+ editingPolicy: 'suppress',+ modalPolicy: 'block',+ actionOwner: 'renderer',+ visibleInPalette: true,+ visibleInSettings: false,+ },] as const satisfies readonly DesktopCommandDefinition[]export type DesktopCommandId = (typeof definitions)[number]['id']@@ -358,6 +497,8 @@ export function isDesktopCommandEligible(return command.tabIndex !== undefined && command.tabIndex < context.tabCount}if (command.eligibility === 'searchable-content') return context.searchableContent+ if (command.eligibility === 'app-mounted') return context.appMounted+ if (command.eligibility === 'conversation-origin') return context.conversationOriginAvailablereturn context.composerAvailable}diff --git a/desktop-app/src/preload.ts b/desktop-app/src/preload.tsindex b7d45e549..1c3b13a4b 100644--- a/desktop-app/src/preload.ts+++ b/desktop-app/src/preload.ts@@ -35,6 +35,15 @@ const DESKTOP_COMMAND_IDS = new Set<DesktopCommandId>(['navigate.apps','navigate.agents','notifications.open',+ 'navigate.plugins',+ 'navigate.contexts',+ 'navigate.teams',+ 'navigate.connectors',+ 'navigate.files',+ 'sidebar.toggle',+ 'app.refresh',+ 'app.backToApps',+ 'app.backToConversation',])function isDesktopCommandId(value: unknown): value is DesktopCommandId {diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex 8ebcd5c92..f14886afe 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -270,12 +270,17 @@ export function App() {const [composerFocusRequestId, setComposerFocusRequestId] = React.useState(0)const [globalSearchFocusRequestId, setGlobalSearchFocusRequestId] = React.useState(0)const [notificationOpenRequestId, setNotificationOpenRequestId] = React.useState(0)+ const [sidebarToggleRequestId, setSidebarToggleRequestId] = React.useState(0)const [chatLocalSearchOpen, setChatLocalSearchOpen] = React.useState(false)const [chatLocalSearchState, setChatLocalSearchState] = React.useState<{query: stringcurrentMatch: ChatLocalMatch | null}>({ query: '', currentMatch: null })const [sandboxLocalSearchRequestId, setSandboxLocalSearchRequestId] = React.useState(0)+ const [sandboxActionRequest, setSandboxActionRequest] = React.useState<{+ id: number+ action: 'refresh' | 'back-to-apps' | 'back-to-conversation'+ } | null>(null)const [commandPaletteOpen, setCommandPaletteOpen] = React.useState(false)const [commandPaletteReturnToSandbox, setCommandPaletteReturnToSandbox] = React.useState(false)const [settingsShortcutsRequestId, setSettingsShortcutsRequestId] = React.useState(0)@@ -1086,8 +1091,20 @@ export function App() {vm.navItem === DESKTOP_ROUTES.chat &&Boolean(activeChatViewTab(chatViewTabs).agentRef) &&vm.hostRuntimeStatus?.degraded?.reason !== 'llm_key_missing',+ appMounted: vm.navItem === DESKTOP_ROUTES.apps && Boolean(activeSandboxUiApp),+ conversationOriginAvailable:+ vm.navItem === DESKTOP_ROUTES.apps &&+ Boolean(activeSandboxUiApp) &&+ Boolean(sandboxUiConversationOrigin),}),- [activeSandboxUiApp, chatViewTabs, vm.activeChatId, vm.hostRuntimeStatus, vm.navItem]+ [+ activeSandboxUiApp,+ chatViewTabs,+ sandboxUiConversationOrigin,+ vm.activeChatId,+ vm.hostRuntimeStatus,+ vm.navItem,+ ])const isCommandEligible = React.useCallback(@@ -1170,6 +1187,41 @@ export function App() {setNotificationOpenRequestId(value => value + 1)return}+ if (+ commandId === 'navigate.plugins' ||+ commandId === 'navigate.contexts' ||+ commandId === 'navigate.teams' ||+ commandId === 'navigate.connectors' ||+ commandId === 'navigate.files'+ ) {+ const routes = {+ 'navigate.plugins': DESKTOP_ROUTES.plugins,+ 'navigate.contexts': DESKTOP_ROUTES.contexts,+ 'navigate.teams': DESKTOP_ROUTES.teams,+ 'navigate.connectors': DESKTOP_ROUTES.connectors,+ 'navigate.files': DESKTOP_ROUTES.files,+ } as const+ handleSidebarNavSelect(routes[commandId])+ return+ }+ if (commandId === 'sidebar.toggle') {+ setSidebarToggleRequestId(value => value + 1)+ return+ }+ if (+ commandId === 'app.refresh' ||+ commandId === 'app.backToApps' ||+ commandId === 'app.backToConversation'+ ) {+ const action =+ commandId === 'app.refresh'+ ? 'refresh'+ : commandId === 'app.backToApps'+ ? 'back-to-apps'+ : 'back-to-conversation'+ setSandboxActionRequest(previous => ({ id: (previous?.id ?? 0) + 1, action }))+ return+ }if (commandId === 'chat.newTab') {closeChatLocalSearch(false)handleNewChatViewTab()@@ -1729,6 +1781,7 @@ export function App() {onOpenSandboxUiApp={handleOpenSandboxUiApp}onSettingsMenuOpenChange={setSidebarSettingsMenuOpen}onSelect={handleSidebarNavSelect}+ toggleRequestId={sidebarToggleRequestId}/><section className="workspace-layout"><section@@ -1789,6 +1842,7 @@ export function App() {{vm.navItem === DESKTOP_ROUTES.apps && (<SandboxUiPageboundsRefreshKey={sandboxUiBoundsRefreshKey}+ actionRequest={sandboxActionRequest}conversationOrigin={sandboxUiConversationOrigin}currentTeamId={vm.currentTeamId}headerShellOverlayOpen={diff --git a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsxindex bacaef7ea..e3a1007b4 100644--- a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx+++ b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx@@ -30,11 +30,19 @@ const commandPaletteHarness = vi.hoisted(() => ({},}))+const sidebarHarness = vi.hoisted(() => ({+ props: null as null | { toggleRequestId?: number },+}))+const sandboxUiPageHarness = vi.hoisted(() => ({props: null as null | {headerShellOverlayOpen?: booleanshortcutOpenRequestId?: numberlocalSearchRequestId?: number+ actionRequest?: {+ id: number+ action: 'refresh' | 'back-to-apps' | 'back-to-conversation'+ } | nullonEmbeddedAppOpening?: (app: {appRef: stringlabel: string@@ -84,7 +92,12 @@ vi.mock('@components/ConfirmDialog', () => ({return null},}))-vi.mock('@components/SidebarNav', () => ({ SidebarNav: () => null }))+vi.mock('@components/SidebarNav', () => ({+ SidebarNav: (props: NonNullable<typeof sidebarHarness.props>) => {+ sidebarHarness.props = props+ return null+ },+}))vi.mock('@pages/AgentsPage', () => ({ AgentsPage: () => null }))vi.mock('@pages/AuthPage', () => ({ AuthPage: () => null }))vi.mock('@pages/ChatPage', () => ({ ChatPage: () => null }))@@ -215,6 +228,7 @@ describe('App deep-link orchestration', () => {commandPaletteHarness.props = nullsettingsPageHarness.props = nullsandboxUiPageHarness.props = null+ sidebarHarness.props = nullacknowledgeDeepLink.mockResolvedValue(undefined)listApps.mockResolvedValue({ apps: [] })listPendingDeepLinks.mockResolvedValue({ links: [] })@@ -391,6 +405,42 @@ describe('App deep-link orchestration', () => {expect(currentController.handleLogout).toHaveBeenCalledOnce()})+ it('routes approved contextual palette actions through shell and app owners', () => {+ currentController = makeController({ initialExperienceLoading: false })+ render(<App />)+ act(() => emitCommand?.('commands.open'))++ for (const [commandId, route] of [+ ['navigate.plugins', DESKTOP_ROUTES.plugins],+ ['navigate.contexts', DESKTOP_ROUTES.contexts],+ ['navigate.teams', DESKTOP_ROUTES.teams],+ ['navigate.connectors', DESKTOP_ROUTES.connectors],+ ['navigate.files', DESKTOP_ROUTES.files],+ ] as const) {+ act(() => commandPaletteHarness.props?.onExecute(commandId))+ expect(currentController.handleNavSelect).toHaveBeenLastCalledWith(route)+ }++ act(() => commandPaletteHarness.props?.onExecute('sidebar.toggle'))+ expect(sidebarHarness.props?.toggleRequestId).toBe(1)++ currentController.navItem = DESKTOP_ROUTES.apps+ act(() => emitCommand?.('commands.open'))+ act(() => {+ sandboxUiPageHarness.props?.onEmbeddedAppOpening?.({+ appRef: 'ns/app',+ label: 'App',+ defaultPath: '/',+ })+ })+ expect(commandPaletteHarness.props?.isEligible('app.refresh')).toBe(true)+ act(() => commandPaletteHarness.props?.onExecute('app.refresh'))+ expect(sandboxUiPageHarness.props?.actionRequest).toEqual({ id: 1, action: 'refresh' })+ act(() => commandPaletteHarness.props?.onExecute('app.backToApps'))+ expect(sandboxUiPageHarness.props?.actionRequest).toEqual({ id: 2, action: 'back-to-apps' })+ expect(commandPaletteHarness.props?.isEligible('app.backToConversation')).toBe(false)+ })+afterEach(() => {vi.useRealTimers()})diff --git a/desktop-app/ui/src/components/SidebarNav/index.tsx b/desktop-app/ui/src/components/SidebarNav/index.tsxindex 87a547924..bf4f454af 100644--- a/desktop-app/ui/src/components/SidebarNav/index.tsx+++ b/desktop-app/ui/src/components/SidebarNav/index.tsx@@ -45,6 +45,7 @@ export function SidebarNav({onOpenSandboxUiApp,onSettingsMenuOpenChange,onSelect,+ toggleRequestId = 0,}: SidebarNavProps) {const { busy, me, handleLogout: onLogout } = useAuthContext()const { activeChatId, latestChatSessions, latestChatSessionsLoading, sessionStateByChatKey } =@@ -67,6 +68,7 @@ export function SidebarNav({chatId: stringtitle: string} | null>(null)+ const lastToggleRequestIdRef = useRef(0)const desktopAppInfo = useDesktopAppInfo()const desktopVersionTooltip = formatDesktopAppVersionTooltip(desktopAppInfo)const sidebarRef = useRef<HTMLElement | null>(null)@@ -89,6 +91,16 @@ export function SidebarNav({useClickOutside(sidebarRef, mobileMenuOpen, () => setMobileMenuOpen(false))useClickOutside(sessionsRef, Boolean(sessionMenuId), () => setSessionMenuId(null))+ useEffect(() => {+ if (toggleRequestId <= lastToggleRequestIdRef.current) return+ lastToggleRequestIdRef.current = toggleRequestId+ if (isMobileSidebarViewport()) {+ setMobileMenuOpen(open => !open)+ } else {+ onCollapsedChange(!collapsed)+ }+ }, [collapsed, onCollapsedChange, toggleRequestId])+const email = me?.emailconst displayName = me?.name || email?.split('@')[0] || 'Unknown'const initials = useMemo(() => {diff --git a/desktop-app/ui/src/components/SidebarNav/types.ts b/desktop-app/ui/src/components/SidebarNav/types.tsindex fe5e5d832..03b12d210 100644--- a/desktop-app/ui/src/components/SidebarNav/types.ts+++ b/desktop-app/ui/src/components/SidebarNav/types.ts@@ -9,4 +9,5 @@ export type SidebarNavProps = {onOpenSandboxUiApp: (app: ActiveSandboxUiApp) => voidonSettingsMenuOpenChange?: (open: boolean) => voidonSelect: (item: NavItem) => void+ toggleRequestId?: number}diff --git a/desktop-app/ui/src/components/__tests__/SidebarNav.test.tsx b/desktop-app/ui/src/components/__tests__/SidebarNav.test.tsxindex b424bfeb5..cb57d5108 100644--- a/desktop-app/ui/src/components/__tests__/SidebarNav.test.tsx+++ b/desktop-app/ui/src/components/__tests__/SidebarNav.test.tsx@@ -113,6 +113,42 @@ describe('SidebarNav logo', () => {expect(screen.getByTestId('nav-files').textContent).toContain('Global File System')expect(screen.queryByRole('menuitem', { name: 'Files' })).toBeNull()})++ it('routes a controlled palette request through desktop collapse behavior', () => {+ const onCollapsedChange = vi.fn()+ const { rerender } = render(+ <SidebarNav {...baseProps({ onCollapsedChange, toggleRequestId: 0 })} />+ )++ rerender(<SidebarNav {...baseProps({ onCollapsedChange, toggleRequestId: 1 })} />)++ expect(onCollapsedChange).toHaveBeenCalledWith(true)+ })++ it('routes a controlled palette request through the mobile drawer behavior', () => {+ vi.spyOn(window, 'matchMedia').mockImplementation(+ query =>+ ({+ matches: true,+ media: query,+ onchange: null,+ addListener: vi.fn(),+ removeListener: vi.fn(),+ addEventListener: vi.fn(),+ removeEventListener: vi.fn(),+ dispatchEvent: vi.fn(),+ }) as MediaQueryList+ )+ const onCollapsedChange = vi.fn()+ const { container, rerender } = render(+ <SidebarNav {...baseProps({ onCollapsedChange, toggleRequestId: 0 })} />+ )++ rerender(<SidebarNav {...baseProps({ onCollapsedChange, toggleRequestId: 1 })} />)++ expect(container.querySelector('.left-nav')?.classList.contains('mobile-open')).toBe(true)+ expect(onCollapsedChange).not.toHaveBeenCalled()+ })})describe('SidebarNav new-chat affordance', () => {diff --git a/desktop-app/ui/src/pages/SandboxUiPage.tsx b/desktop-app/ui/src/pages/SandboxUiPage.tsxindex 52f7e912c..ae7e88f43 100644--- a/desktop-app/ui/src/pages/SandboxUiPage.tsx+++ b/desktop-app/ui/src/pages/SandboxUiPage.tsx@@ -155,6 +155,7 @@ type AppFindState =| { status: 'error'; message: string }export function SandboxUiPage({+ actionRequest = null,boundsRefreshKey = 0,conversationOrigin = null,currentTeamId = '',@@ -188,6 +189,7 @@ export function SandboxUiPage({const lastLocalSearchRequestIdRef = useRef(0)const localSearchPreviousFocusRef = useRef<HTMLElement | null>(null)const lastShortcutOpenRequestIdRef = useRef(0)+ const lastActionRequestIdRef = useRef(0)const shellOverlayOpen =headerShellOverlayOpen || sidebarShellOverlayOpen || toastShellOverlayOpen@@ -447,6 +449,18 @@ export function SandboxUiPage({void window.clerum.sandboxUi.reload()}, [])+ useEffect(() => {+ if (!actionRequest || actionRequest.id <= lastActionRequestIdRef.current) return+ lastActionRequestIdRef.current = actionRequest.id+ if (actionRequest.action === 'refresh') {+ onRefresh()+ } else if (actionRequest.action === 'back-to-apps') {+ void onBackToApps()+ } else {+ void handleBackToConversation()+ }+ }, [actionRequest, handleBackToConversation, onBackToApps, onRefresh])+const onCopyDeepLink = useCallback(async () => {try {await window.clerum.sandboxUi.copyDeepLink(currentTeamId || undefined)diff --git a/desktop-app/ui/src/pages/SandboxUiPage.types.ts b/desktop-app/ui/src/pages/SandboxUiPage.types.tsindex d863df1a6..f6b5f3c45 100644--- a/desktop-app/ui/src/pages/SandboxUiPage.types.ts+++ b/desktop-app/ui/src/pages/SandboxUiPage.types.ts@@ -16,6 +16,10 @@ export type SandboxUiShortcutOpenResult =| { status: 'failed'; message: string }export type SandboxUiPageProps = {+ actionRequest?: {+ id: number+ action: 'refresh' | 'back-to-apps' | 'back-to-conversation'+ } | nullboundsRefreshKey?: string | numberconversationOrigin?: SandboxUiConversationOrigin | nullcurrentTeamId?: stringdiff --git a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsxindex e35e5955e..fc43ea418 100644--- a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx@@ -185,6 +185,79 @@ describe('SandboxUiPage', () => {expect(screen.getAllByRole('button', { name: /^Back to / })).toHaveLength(1)})+ it('routes controlled refresh and back requests through mounted-app owners', async () => {+ sandboxUi.listApps.mockResolvedValue({+ apps: [+ {+ appRef: 'sandbox-recipes/sales-crm',+ title: 'Sales CRM',+ defaultPath: '/',+ ready: true,+ phase: 'active',+ updatedAt: null,+ },+ ],+ })+ sandboxUi.open.mockResolvedValue(undefined)+ sandboxUi.close.mockResolvedValue(undefined)+ sandboxUi.reload.mockResolvedValue(undefined)+ const onEmbeddedAppBack = vi.fn()+ const { rerender } = render(+ <SandboxUiPage actionRequest={null} onEmbeddedAppBack={onEmbeddedAppBack} />+ )+ fireEvent.click(await screen.findByRole('button', { name: 'Open Sales CRM' }))++ rerender(+ <SandboxUiPage+ actionRequest={{ id: 1, action: 'refresh' }}+ onEmbeddedAppBack={onEmbeddedAppBack}+ />+ )+ expect(sandboxUi.reload).toHaveBeenCalledOnce()++ rerender(+ <SandboxUiPage+ actionRequest={{ id: 2, action: 'back-to-apps' }}+ onEmbeddedAppBack={onEmbeddedAppBack}+ />+ )+ await waitFor(() => {+ expect(sandboxUi.close).toHaveBeenCalledOnce()+ expect(onEmbeddedAppBack).toHaveBeenCalledOnce()+ })+ })++ it('routes controlled conversation return through the existing transition owner', async () => {+ sandboxUi.listApps.mockResolvedValue({+ apps: [+ {+ appRef: 'sandbox-recipes/sales-crm',+ title: 'Sales CRM',+ defaultPath: '/',+ ready: true,+ phase: 'active',+ updatedAt: null,+ },+ ],+ })+ sandboxUi.open.mockResolvedValue(undefined)+ sandboxUi.close.mockResolvedValue(undefined)+ const onBackToConversation = vi.fn().mockResolvedValue(undefined)+ const props = {+ conversationOrigin: { agentName: 'agent', chatId: 'chat', title: 'Conversation' },+ onBackToConversation,+ }+ const { rerender } = render(<SandboxUiPage {...props} actionRequest={null} />)+ fireEvent.click(await screen.findByRole('button', { name: 'Open Sales CRM' }))++ rerender(<SandboxUiPage {...props} actionRequest={{ id: 1, action: 'back-to-conversation' }} />)++ await waitFor(() => {+ expect(onBackToConversation).toHaveBeenCalledOnce()+ expect(sandboxUi.close).toHaveBeenCalledOnce()+ })+ })+it('runs contextual find only against the mounted active WebContents contract', async () => {sandboxUi.listApps.mockResolvedValueOnce({apps: [