Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop-app): reload a healthy app view in place on refresh (R1-M5)
Diego Zacarias9ecaa0087103
diff --git a/desktop-app/src/__tests__/appService.sandboxUiLifecycle.test.ts b/desktop-app/src/__tests__/appService.sandboxUiLifecycle.test.tsindex e135ec230..696cb466e 100644--- a/desktop-app/src/__tests__/appService.sandboxUiLifecycle.test.ts+++ b/desktop-app/src/__tests__/appService.sandboxUiLifecycle.test.ts@@ -1773,3 +1773,132 @@ describe('sandbox-ui IPC close ordering and payloads', () => {])})})++// Refresh of a healthy view reloads its document in place: same view, same+// session, same refresh loop. Only the launch that owns the view can reload it.+describe('sandbox-ui IPC reload of the live view', () => {+ type Sender = { id: number }++ async function setupIpc() {+ const service = makeService()+ initPluginSdkRuntime({ service, getMainWindow: () => null, userDataDir })+ electronMocks.ipcHandlers.clear()+ electronMocks.windowsBySender.clear()+ const { registerIpcHandlers } = await import('../ipc.js')+ registerIpcHandlers(service)+ const sender: Sender = { id: 1 }+ const parentWindow = new FakeParentWindow()+ electronMocks.windowsBySender.set(sender, parentWindow)+ const invokeFrom = (frameUrl: string, channel: string, payload?: unknown) => {+ const handler = electronMocks.ipcHandlers.get(channel)+ if (!handler) throw new Error(`no IPC handler registered for ${channel}`)+ return handler({ sender, senderFrame: { url: frameUrl } }, payload)+ }+ const invoke = (channel: string, payload?: unknown): Promise<unknown> =>+ invokeFrom('file:///app/index.html', channel, payload)+ const open = (launchId: string) =>+ invoke('sandboxUi:open', {+ recipeNs: 'sandbox-recipes',+ recipeName: 'first-app',+ defaultPath: '/',+ bounds: { x: 0, y: 0, width: 400, height: 300 },+ launchId,+ })+ const releasedSends = () =>+ parentWindow.webContents.send.mock.calls.filter(+ ([channel]) => channel === 'sandboxUi:released'+ )+ const reloads = () =>+ electronMocks.views.map(view => view.webContents.reloadIgnoringCache.mock.calls.length)+ return { service, parentWindow, invoke, invokeFrom, open, releasedSends, reloads }+ }++ it('reloads the view its launch owns without a new mint, a release or a new view', async () => {+ const { invoke, open, releasedSends, reloads, parentWindow } = await setupIpc()+ const launchId = crypto.randomUUID()+ await open(launchId)+ const live = getActiveSandboxUi()+ fetchMock.mockClear()++ await invoke('sandboxUi:reload', { launchId })++ expect(reloads()).toEqual([1])+ expect(getActiveSandboxUi()).toEqual(live)+ expect(parentWindow.contentView.children).toEqual([electronMocks.views[0]])+ expect(releasedSends()).toEqual([])+ expect(mintCallsFor('first-app')).toBe(0)+ // The session refresh loop of the view keeps running.+ await vi.advanceTimersByTimeAsync(SANDBOX_UI_REFRESH_INTERVAL_MS + 1_000)+ expect(mintCallsFor('first-app')).toBe(1)+ })++ it('a reload naming a launch that no longer owns the view reloads nothing', async () => {+ const { invoke, open, reloads } = await setupIpc()+ const first = crypto.randomUUID()+ const second = crypto.randomUUID()+ await open(first)+ await open(second)++ await invoke('sandboxUi:reload', { launchId: first })++ expect(getActiveSandboxUi()?.launchId).toBe(second)+ expect(reloads()).toEqual([0, 0])+ })++ it('a reload sent right after its open reloads the view that open mounts', async () => {+ const { invoke, open, reloads } = await setupIpc()+ const launchId = crypto.randomUUID()++ // Both invokes are dispatched in the same tick, in send order.+ await Promise.all([open(launchId), invoke('sandboxUi:reload', { launchId })])++ expect(getActiveSandboxUi()?.launchId).toBe(launchId)+ expect(reloads()).toEqual([1])+ })++ it('a reload that reaches main after its view crashed or its session ended does nothing', async () => {+ const { service, invoke, open, reloads } = await setupIpc()+ const crashed = crypto.randomUUID()+ await open(crashed)+ electronMocks.views[0]!.webContents.emit(+ 'render-process-gone',+ {},+ { reason: 'crashed', exitCode: 139 }+ )+ await invoke('sandboxUi:reload', { launchId: crashed })++ const loggedOut = crypto.randomUUID()+ await open(loggedOut)+ ;(service as unknown as { invalidateSandboxUiSession(): void }).invalidateSandboxUiSession()+ await invoke('sandboxUi:reload', { launchId: loggedOut })++ expect(getActiveSandboxUi()).toBeNull()+ expect(reloads()).toEqual([0, 0])+ })++ it.each([undefined, null, {}, { launchId: '../x' }, { launchId: 'launch-1' }])(+ 'rejects a reload with payload %j without reloading the live view',+ async payload => {+ const { service, invoke, open, reloads } = await setupIpc()+ await open(crypto.randomUUID())++ await expect(invoke('sandboxUi:reload', payload)).rejects.toThrow(/launchId/)+ await drainLifecycleQueue(service)++ expect(reloads()).toEqual([0])+ }+ )++ it('rejects a reload from an untrusted sender without reloading the live view', async () => {+ const { service, invokeFrom, open, reloads } = await setupIpc()+ const launchId = crypto.randomUUID()+ await open(launchId)++ await expect(+ invokeFrom('https://evil.example/', 'sandboxUi:reload', { launchId })+ ).rejects.toThrow(/Untrusted/)+ await drainLifecycleQueue(service)++ expect(reloads()).toEqual([0])+ })+})diff --git a/desktop-app/src/appService.ts b/desktop-app/src/appService.tsindex b93c16d60..8392436cd 100644--- a/desktop-app/src/appService.ts+++ b/desktop-app/src/appService.ts@@ -6083,6 +6083,20 @@ export class AppService {)}+ /**+ * Reloads the document of the view `launchId` owns, in place: same view, same+ * session cookie, same refresh loop, so nothing is minted. Enqueued+ * synchronously like `openSandboxUi`, so it acts on the view the queue holds+ * when it gets there; a launch that no longer owns the view reloads nothing.+ */+ reloadSandboxUi(options: { launchId: string }): Promise<void> {+ return this.enqueueSandboxUiLifecycle(async () => {+ const driver = await import('./sandboxUiDriver.js')+ if (driver.getActiveSandboxUi()?.launchId !== options.launchId) return+ driver.reloadActiveSandboxUiView()+ })+ }+private async teardownSandboxUiView(reason: import('./sandboxUiDriver.js').SandboxUiReleaseReason,onlyLaunchId?: stringdiff --git a/desktop-app/src/ipc.ts b/desktop-app/src/ipc.tsindex ac6b60580..497bde0b0 100644--- a/desktop-app/src/ipc.ts+++ b/desktop-app/src/ipc.ts@@ -2075,7 +2075,8 @@ export function registerIpcHandlers(service: AppService): void {// `sandboxUi:open` and `sandboxUi:close` must reach the AppService queue with// no `await` before it, in both handlers: a close the renderer sends right// after an open for the same launch would otherwise be enqueued first and- // miss the view the open then mounts.+ // miss the view the open then mounts. `sandboxUi:reload` follows the same+ // rule, so main serves it in the order the renderer sent it.ipcMain.handle('sandboxUi:open',async (@@ -2144,6 +2145,14 @@ export function registerIpcHandlers(service: AppService): void {await service.closeSandboxUi({ launchId })})+ // Same launch-id contract as close: a reload that names no launch must not+ // degrade into reloading whatever view is live.+ ipcMain.handle('sandboxUi:reload', async (event, payload?: { launchId?: unknown } | null) => {+ assertTrustedSender(event)+ const launchId = parseSandboxUiLaunchId(payload?.launchId)+ await service.reloadSandboxUi({ launchId })+ })+ipcMain.handle('sandboxUi:copyDeepLink', async (event, payload: { teamId?: unknown }) => {assertTrustedSender(event)const teamId = sanitizeString(payload?.teamId)diff --git a/desktop-app/src/preload.ts b/desktop-app/src/preload.tsindex 22ce3cfc5..7b72a4b24 100644--- a/desktop-app/src/preload.ts+++ b/desktop-app/src/preload.ts@@ -683,6 +683,8 @@ const clerum = Object.freeze({}) => ipcRenderer.invoke('sandboxUi:open', args),// Closes that launch's view only if it is still the live one.close: (args: { launchId: string }) => ipcRenderer.invoke('sandboxUi:close', args),+ // Reloads that launch's view in place only if it is still the live one.+ reload: (args: { launchId: string }) => ipcRenderer.invoke('sandboxUi:reload', args),copyDeepLink: (teamId?: string) => ipcRenderer.invoke('sandboxUi:copyDeepLink', { teamId }),listPendingDeepLinks: () => ipcRenderer.invoke('sandboxUi:listPendingDeepLinks'),clearPendingDeepLinks: () => ipcRenderer.invoke('sandboxUi:clearPendingDeepLinks'),diff --git a/desktop-app/src/renderer.d.ts b/desktop-app/src/renderer.d.tsindex 1b6e7d1fd..e5c801baf 100644--- a/desktop-app/src/renderer.d.ts+++ b/desktop-app/src/renderer.d.ts@@ -774,6 +774,8 @@ declare global {}) => Promise<void>// Closes that launch's view only if it is still the live one.close: (args: { launchId: string }) => Promise<void>+ // Reloads that launch's view in place only if it is still the live one.+ reload: (args: { launchId: string }) => Promise<void>copyDeepLink: (teamId?: string) => Promise<{ url: string }>listPendingDeepLinks: () => Promise<{ links: SandboxUiDeepLinkEnvelope[] }>clearPendingDeepLinks: () => Promise<void>diff --git a/desktop-app/src/sandboxUiDriver.ts b/desktop-app/src/sandboxUiDriver.tsindex 10d0bffb4..1f7b678d9 100644--- a/desktop-app/src/sandboxUiDriver.ts+++ b/desktop-app/src/sandboxUiDriver.ts@@ -1101,10 +1101,10 @@ export function reloadSandboxUiWebContents(}/**- * Reload the active embed in place once its session refresh has re-minted the- * cookie after the document came back 401. No-op when nothing is mounted or the- * view was already torn down. The user-facing Refresh relaunches the view- * instead, so it never comes through here.+ * Reload the active embed in place, keeping its view, session and refresh loop.+ * Used by the user-facing Refresh of a healthy view and by the session refresh+ * once it has re-minted the cookie after the document came back 401. No-op when+ * nothing is mounted or the view was already torn down.*/export function reloadActiveSandboxUiView(): void {reloadSandboxUiWebContents(active?.view.webContents)diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex c1fec507d..a56d70244 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -598,14 +598,31 @@ export function App() {[embed, launchForActiveAppTab, setWorkspaceTabs, vm.clearAppsPicker])- // Refresh, Reopen after a crash and Retry after a session failure: tear the- // active tab's view down, healthy or not, and open a fresh one (new view, new+ // Reopen after a crash and Retry after a session failure: tear the active+ // tab's view down, healthy or not, and open a fresh one (new view, new// session) where the old one stood. It never comes from a re-click, which// leaves a live view alone.const relaunchActiveApp = React.useCallback(() => {activateAndLaunch(state => state, undefined, { kind: 'activeTab', replace: true })}, [activateAndLaunch])+ // Refresh reloads a mounted view in place, so the app keeps its session+ // storage, history and full URL and nothing is minted. Read from the machine,+ // not the last render: the view may have ended, or a relaunch may have taken+ // the tab, since Refresh was offered. Without a mounted view there is nothing+ // to reload, so the tab is relaunched instead.+ const refreshActiveApp = React.useCallback(() => {+ const state = embed.getSnapshot()+ const owner = state.owner === null ? undefined : state.views.get(state.owner)+ if (owner?.phase !== 'mounted') {+ relaunchActiveApp()+ return+ }+ void window.clerum.sandboxUi.reload({ launchId: owner.launchId }).catch(error => {+ console.warn('[SandboxUI] Could not reload the app:', error)+ })+ }, [embed, relaunchActiveApp])+// Load the CONTENT of a workspace tab once it is (about to be) active — the// universal reveal seam. It never selects the tab itself (the store already// owns identity/active). Chat tabs delegate to `handleSelectChatAgent` (the@@ -2197,7 +2214,7 @@ export function App() {return}if (commandId === 'app.refresh') {- relaunchActiveApp()+ refreshActiveApp()return}if (commandId === 'app.backToApps') {@@ -2291,7 +2308,7 @@ export function App() {handleNewWorkspaceChatTab,handleSidebarNavSelect,openChatDrawer,- relaunchActiveApp,+ refreshActiveApp,revealWorkspaceTab,sandboxUiMounted,vm.activeChatId,@@ -3025,6 +3042,7 @@ export function App() {localSearchRequestId={sandboxLocalSearchRequestId}titlebarLeadingContainer={titlebarLeadingRoot}onLaunchApp={handleOpenSandboxUiApp}+ onRefresh={refreshActiveApp}onRelaunch={relaunchActiveApp}onEmbedBoundsApplied={handleSandboxUiBoundsApplied}onEmbedSlotTopChange={setChatDrawerEmbedTop}diff --git a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsxindex f9369f2fa..350074394 100644--- a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx+++ b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx@@ -801,17 +801,19 @@ describe('App deep-link orchestration', () => {await waitForMounted()expect(commandPaletteHarness.props?.isEligible('app.refresh')).toBe(true)- // Refresh relaunches the app: the live view closes and a new one opens.+ // Refresh reloads the live view in place: no close, no new view.const first = main.openCall(0).launchIdawait act(async () => commandPaletteHarness.props?.onExecute('app.refresh'))- await waitFor(() => expect(openSandboxUi()).toHaveBeenCalledTimes(2))- expect(closeSandboxUi()).toHaveBeenCalledWith({ launchId: first })- await waitForMounted()+ await act(() => main.settle())+ expect(main.liveReloads()).toBe(1)+ expect(main.live()?.launchId).toBe(first)+ expect(openSandboxUi()).toHaveBeenCalledTimes(1)+ expect(closeSandboxUi()).not.toHaveBeenCalled()act(() => emitCommand?.('commands.open'))await act(async () => commandPaletteHarness.props?.onExecute('app.backToApps'))await waitFor(() => expect(embedState().owner).toBeNull())- expect(closeSandboxUi()).toHaveBeenLastCalledWith({ launchId: main.openCall(1).launchId })+ expect(closeSandboxUi()).toHaveBeenLastCalledWith({ launchId: first })})it('resets controlled command requests with the authenticated shell lifetime', async () => {diff --git a/desktop-app/ui/src/__tests__/App.sandboxUiOwnership.test.tsx b/desktop-app/ui/src/__tests__/App.sandboxUiOwnership.test.tsxindex 44c48e225..0290e4239 100644--- a/desktop-app/ui/src/__tests__/App.sandboxUiOwnership.test.tsx+++ b/desktop-app/ui/src/__tests__/App.sandboxUiOwnership.test.tsx@@ -616,34 +616,82 @@ describe('App wires gestures and main events to the embed ownership machine', ()expect(lastLaunch().type).toBe('intent')})- it('relaunches from Refresh: the live view closes first and the new one opens where it stood', async () => {+ it('reloads a healthy view in place from Refresh: same view, same route, no relaunch', async () => {await renderApp()await openFromSidebar(ALPHA, 1)const first = main.openCall(0).launchIdmain.navigate('/tickets/7')fireEvent.click(screen.getByRole('button', { name: 'Refresh app content' }))- await waitFor(() => expect(sandboxUi.open).toHaveBeenCalledTimes(2))+ await act(() => main.settle())- expect(lastLaunch()).toMatchObject({- type: 'relaunch',- launch: { tabId: tabOf(ALPHA!.appRef)!.id },- })- expect(sandboxUi.close).toHaveBeenCalledWith({ launchId: first })- expect(sandboxUi.close.mock.invocationCallOrder[0]!).toBeLessThan(- sandboxUi.open.mock.invocationCallOrder[1]!- )- expect(main.openCall(1).routePath).toBe('/tickets/7')- expect(await screen.findByRole('button', { name: 'Refresh app content' })).toBeTruthy()+ expect(main.liveReloads()).toBe(1)+ expect(main.live()).toEqual({ launchId: first, appRef: ALPHA!.appRef, routePath: '/tickets/7' })+ expect(sandboxUi.open).toHaveBeenCalledTimes(1)+ expect(sandboxUi.close).not.toHaveBeenCalled()+ expect(main.reported('sandboxUi:released')).toEqual([])+ expect(owner()?.launchId).toBe(first)+ expect(screen.getByRole('button', { name: 'Refresh app content' })).toBeTruthy()})- it('relaunches from the app.refresh command without flushing inside an effect', async () => {+ it('reloads a healthy view in place from the app.refresh command', async () => {await renderApp()await openFromSidebar(ALPHA, 1)+ const first = main.openCall(0).launchIdawait shortcut('app.refresh')- await waitFor(() => expect(sandboxUi.open).toHaveBeenCalledTimes(2))+ await act(() => main.settle())++ expect(main.liveReloads()).toBe(1)+ expect(main.live()?.launchId).toBe(first)+ expect(sandboxUi.open).toHaveBeenCalledTimes(1)+ expect(sandboxUi.close).not.toHaveBeenCalled()+ expect(flushSyncErrors).toEqual([])+ })++ // Refresh is offered while the last render showed a mounted view, but the+ // machine can move on before React renders again. Refresh then reopens the+ // tab: it never reloads a view that is not mounted, gone or still opening.+ it('relaunches from app.refresh when the view ended before React rendered it', async () => {+ await renderApp()+ await openFromSidebar(ALPHA, 1)+ const first = main.openCall(0).launchId++ await act(async () => {+ void main.crash()+ const release = main.reported('sandboxUi:released').at(-1) as Parameters<+ EmbedOwnershipMachine['onReleased']+ >[0]+ expect(release).toMatchObject({ launchId: first, reason: 'crashed' })+ machineHarness.machine!.onReleased(release)+ shortcutCommandCb?.('app.refresh', 'host')+ })+ await act(() => main.settle())++ expect(sandboxUi.reload).not.toHaveBeenCalled()expect(lastLaunch().type).toBe('relaunch')+ expect(main.live()?.launchId).toBe(main.openCall(1).launchId)+ })++ it('relaunches from app.refresh while the relaunch before it is still opening', async () => {+ await renderApp()+ await openFromSidebar(ALPHA, 1)+ await act(() => main.refreshFailed(new Error('mint failed')))+ const retry = await screen.findByRole('button', { name: 'Retry' })++ act(() => {+ fireEvent.click(retry)+ shortcutCommandCb?.('app.refresh', 'host')+ })+ await act(() => main.settle())++ expect(sandboxUi.reload).not.toHaveBeenCalled()+ expect(machineHarness.launches.slice(-2).map(entry => entry.type)).toEqual([+ 'relaunch',+ 'relaunch',+ ])+ expect(main.live()?.launchId).toBe(machineHarness.launches.at(-1)!.launch.launchId)+ expect(main.liveReloads()).toBe(0)})it("shows the live view's session failure with Retry, which relaunches it", async () => {@@ -667,8 +715,8 @@ describe('App wires gestures and main events to the embed ownership machine', ()await openFromSidebar(ALPHA, 1)const first = main.openCall(0).launchId- // The replaced view's loop gives up before the close for it reaches main.- fireEvent.click(screen.getByRole('button', { name: 'Refresh app content' }))+ // The replaced view's loop gives up before the open replacing it reaches main.+ act(() => sidebarHarness.props?.onOpenSandboxUiApp?.(BETA!))await act(() => main.refreshFailed(new Error('stale failure')))await act(() => main.settle())@@ -699,16 +747,17 @@ describe('App wires gestures and main events to the embed ownership machine', ()await act(() => main.retitle('Alpha Inbox'))expect(screen.getByRole('button', { name: 'Alpha Inbox', pressed: true })).toBeTruthy()- // The view a relaunch replaces retitles itself before its close reaches main.+ // The view an open replaces retitles itself before that open reaches main.const first = main.openCall(0).launchId- fireEvent.click(screen.getByRole('button', { name: 'Refresh app content' }))+ act(() => sidebarHarness.props?.onOpenSandboxUiApp?.(BETA!))await act(() => main.retitle('Stale'))await act(() => main.settle())expect(main.reported('sandboxUi:titleChanged')).toContainEqual(expect.objectContaining({ launchId: first, title: 'Stale' }))- expect(screen.getByRole('button', { name: 'Alpha Inbox', pressed: true })).toBeTruthy()+ expect(main.live()?.launchId).toBe(main.openCall(1).launchId)+ expect(screen.getByRole('button', { name: 'Alpha Inbox', pressed: false })).toBeTruthy()expect(screen.queryByRole('button', { name: 'Stale' })).toBeNull()})diff --git a/desktop-app/ui/src/__tests__/__fixtures__/sandboxUiMainFake.ts b/desktop-app/ui/src/__tests__/__fixtures__/sandboxUiMainFake.tsindex 8ef14810c..2d4b3ae6c 100644--- a/desktop-app/ui/src/__tests__/__fixtures__/sandboxUiMainFake.ts+++ b/desktop-app/ui/src/__tests__/__fixtures__/sandboxUiMainFake.ts@@ -24,10 +24,10 @@ import type { SandboxUiReleasedEvent } from '../../../../src/types'/*** The trusted renderer's `window.clerum.sandboxUi` lifecycle bridge, backed by* the REAL main process: AppService's lifecycle queue, the sandbox-ui driver,- * the session refresh loop and the `sandboxUi:open` / `sandboxUi:close`- * handlers of ipc.ts, on the Electron fakes. Nothing here decides what main- * reports: every `released`, every open outcome and every location comes from- * that code. The helpers only act on the world (rpc-proxy's answer to a mint,+ * the session refresh loop and the `sandboxUi:open` / `sandboxUi:close` /+ * `sandboxUi:reload` handlers of ipc.ts, on the Electron fakes. Nothing here+ * decides what main reports: every `released`, every open outcome and every+ * location comes from that code. The helpers only act on the world (rpc-proxy's answer to a mint,* the embed's renderer crashing, the user navigating the app, time passing).** The wire is two FIFO lanes, as IPC is: a call reaches main one macrotask@@ -153,6 +153,19 @@ export function createSandboxUiMainFake() {// The document a view asked for commits and loads a task later, as a real// page does; until then the view stands for the route it was asked to show.function onLoad(webContents: FakeWebContents): void {+ // A reload commits the document the view is showing again, a task later.+ webContents.reloadIgnoringCache.mockImplementation(() => {+ inFlight += 1+ void macrotask()+ .then(() => {+ if (webContents.destroyed || main.dead || !webContents.currentUrl) return+ webContents.emit('did-navigate', {}, webContents.currentUrl, 200, '')+ webContents.emit('did-finish-load')+ })+ .finally(() => {+ inFlight -= 1+ })+ })if (crashNextMount) {crashNextMount = falsewebContents.emit('render-process-gone', {}, { reason: 'crashed', exitCode: 139 })@@ -203,6 +216,7 @@ export function createSandboxUiMainFake() {const open = vi.fn((request: SandboxUiOpenCall) => send('sandboxUi:open', request))const close = vi.fn((request: { launchId: string }) => send('sandboxUi:close', request))+ const reload = vi.fn((request: { launchId: string }) => send('sandboxUi:reload', request))function liveView() {const active = getActiveSandboxUi()@@ -217,6 +231,7 @@ export function createSandboxUiMainFake() {bridge: {open,close,+ reload,onReleased: vi.fn((listener: (event: SandboxUiReleasedEvent) => void) => {releasedListeners.add(listener)return () => releasedListeners.delete(listener)@@ -240,6 +255,10 @@ export function createSandboxUiMainFake() {if (!call) throw new Error(`no open call #${index}`)return call[0]},+ /** How many times main reloaded the document of the view it has mounted right now. */+ liveReloads(): number {+ return liveView()?.view.webContents.reloadIgnoringCache.mock.calls.length ?? 0+ },/** The view main has mounted right now, and the route it stands for. */live(): { launchId: string; appRef: string; routePath?: string } | null {const active = getActiveSandboxUi()diff --git a/desktop-app/ui/src/pages/SandboxUiPage.tsx b/desktop-app/ui/src/pages/SandboxUiPage.tsxindex be253901e..aebd4ef76 100644--- a/desktop-app/ui/src/pages/SandboxUiPage.tsx+++ b/desktop-app/ui/src/pages/SandboxUiPage.tsx@@ -218,6 +218,7 @@ export function SandboxUiPage({localSearchRequestId = 0,titlebarLeadingContainer = null,onLaunchApp,+ onRefresh,onRelaunch,onEmbedBoundsApplied,onEmbedSlotTopChange,@@ -479,7 +480,7 @@ export function SandboxUiPage({<TitlebarLeadingActionclassName="sandbox-ui-refresh-btn"label="Refresh app content"- onClick={() => onRelaunch?.()}+ onClick={() => onRefresh?.()}><IconRefresh /></TitlebarLeadingAction>diff --git a/desktop-app/ui/src/pages/SandboxUiPage.types.ts b/desktop-app/ui/src/pages/SandboxUiPage.types.tsindex f03562599..cf1be23df 100644--- a/desktop-app/ui/src/pages/SandboxUiPage.types.ts+++ b/desktop-app/ui/src/pages/SandboxUiPage.types.ts@@ -28,7 +28,9 @@ export type SandboxUiPageProps = {// 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.onLaunchApp: (app: ActiveSandboxUiApp) => void- /** Tears the active tab's view down and opens a fresh one (Refresh, Reopen, Retry). */+ /** Refreshes the content of the active tab's app (Refresh). */+ onRefresh?: () => void+ /** Tears the active tab's view down and opens a fresh one (Reopen, Retry). */onRelaunch?: () => voidonEmbedBoundsApplied?: () => voidonEmbedSlotTopChange?: (topPx: number) => voiddiff --git a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsxindex 4bea03413..6b2141b54 100644--- a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx@@ -348,7 +348,7 @@ describe('SandboxUiPage', () => {expect(screen.getByRole('button', { name: 'Copy current app link' })).toBeTruthy()})- it('asks its owner to relaunch on Refresh, only once the app is mounted', async () => {+ it('asks its owner to refresh on Refresh, only once the app is mounted', async () => {sandboxUi.listApps.mockResolvedValue({apps: [{@@ -368,8 +368,9 @@ describe('SandboxUiPage', () => {finishOpen = resolve}))+ const onRefresh = vi.fn()const onRelaunch = vi.fn()- render(<SandboxUiPage onRelaunch={onRelaunch} />)+ render(<SandboxUiPage onRefresh={onRefresh} onRelaunch={onRelaunch} />)fireEvent.click(await screen.findByRole('button', { name: 'Open Sales CRM' }))await waitFor(() => expect(sandboxUi.open).toHaveBeenCalledOnce())// While the view is still opening there is nothing to refresh.@@ -378,8 +379,9 @@ describe('SandboxUiPage', () => {await act(async () => finishOpen())fireEvent.click(await screen.findByRole('button', { name: 'Refresh app content' }))- expect(onRelaunch).toHaveBeenCalledOnce()- // The relaunch is the owner's: the page itself neither reloads nor closes.+ expect(onRefresh).toHaveBeenCalledOnce()+ expect(onRelaunch).not.toHaveBeenCalled()+ // The refresh is the owner's: the page itself neither reloads nor closes.expect(sandboxUi.close).not.toHaveBeenCalled()})