Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop-app): hide sandbox embed while the deeplink confirm dialog is open
Diego Zacarias3e4f28216eb0
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex df521d4b0..0b8a3f2bf 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -1878,6 +1878,9 @@ export function App() {}sidebarShellOverlayOpen={sidebarSettingsMenuOpen}toastShellOverlayOpen={vm.toasts.length > 0}+ deepLinkOverlayOpen={Boolean(+ pendingSandboxUiConfirmation || failedSandboxUiDeepLink+ )}shortcutApp={activeSandboxUiApp}shortcutOpenRequestId={sandboxUiShortcutOpenRequestId}localSearchRequestId={sandboxLocalSearchRequestId}diff --git a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsxindex 107bc742d..bb8c2309b 100644--- a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx+++ b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx@@ -37,6 +37,7 @@ const sidebarHarness = vi.hoisted(() => ({const sandboxUiPageHarness = vi.hoisted(() => ({props: null as null | {headerShellOverlayOpen?: boolean+ deepLinkOverlayOpen?: booleanshortcutOpenRequestId?: numberlocalSearchRequestId?: numberactionRequest?: {@@ -612,6 +613,73 @@ describe('App deep-link orchestration', () => {expect(sandboxUiPageHarness.props?.shortcutOpenRequestId).toBeUndefined()})+ it('signals a deep-link overlay to the sandbox page while the confirm dialog is open', async () => {+ currentController = makeController({+ initialExperienceLoading: false,+ navItem: DESKTOP_ROUTES.apps,+ })+ listApps.mockResolvedValue({+ apps: [+ {+ appRef: 'ns/app',+ title: 'Linked App',+ defaultPath: '/',+ ready: true,+ phase: 'active',+ },+ ],+ })+ render(<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.+ expect(sandboxUiPageHarness.props?.deepLinkOverlayOpen).toBeFalsy()+ await waitFor(() => expect(emitDeepLink).not.toBeNull())++ act(() => {+ emitDeepLink?.({ id: 1, appRef: 'ns/app' })+ })++ await waitFor(() => expect(confirmDialogHarness.props?.title).toBe('Open app link?'))+ expect(sandboxUiPageHarness.props?.deepLinkOverlayOpen).toBe(true)++ await confirmPendingAppLink()+ await reportShortcutOpenResult()+ await waitFor(() => expect(acknowledgeDeepLink).toHaveBeenCalledWith(1))+ await waitFor(() => expect(sandboxUiPageHarness.props?.deepLinkOverlayOpen).toBe(false))+ })++ it('keeps the deep-link overlay signal raised while the failure dialog is open', async () => {+ vi.useFakeTimers({ shouldAdvanceTime: true })+ const ensureTeamContext = vi.fn(async () => {+ throw Object.assign(new Error('fetch failed'), { code: 'ECONNRESET' })+ })+ currentController = makeController({+ initialExperienceLoading: false,+ navItem: DESKTOP_ROUTES.apps,+ handleEnsureTeamContext: ensureTeamContext,+ })+ render(<App />)+ await waitFor(() => expect(emitDeepLink).not.toBeNull())++ act(() => {+ emitDeepLink?.({ id: 1, appRef: 'ns/app', teamId: 'team-b' })+ })+ await confirmPendingAppLink()++ for (const delay of [1_000, 2_000, 4_000, 8_000, 15_000]) {+ await act(async () => {+ vi.advanceTimersByTime(delay)+ await Promise.resolve()+ })+ }++ await waitFor(() =>+ expect(confirmDialogHarness.props?.title).toBe('App link could not be opened')+ )+ expect(sandboxUiPageHarness.props?.deepLinkOverlayOpen).toBe(true)+ })+it('does not duplicate an authenticated confirmation for the same link id', async () => {currentController = makeController({ initialExperienceLoading: false })listApps.mockResolvedValue({diff --git a/desktop-app/ui/src/pages/SandboxUiPage.tsx b/desktop-app/ui/src/pages/SandboxUiPage.tsxindex 349caa429..8264906ed 100644--- a/desktop-app/ui/src/pages/SandboxUiPage.tsx+++ b/desktop-app/ui/src/pages/SandboxUiPage.tsx@@ -156,6 +156,7 @@ export function SandboxUiPage({headerShellOverlayOpen = false,sidebarShellOverlayOpen = false,toastShellOverlayOpen = false,+ deepLinkOverlayOpen = false,shortcutApp = null,shortcutOpenRequestId = 0,localSearchRequestId = 0,@@ -184,8 +185,14 @@ export function SandboxUiPage({const localSearchPreviousFocusRef = useRef<HTMLElement | null>(null)const lastShortcutOpenRequestIdRef = useRef(0)const lastActionRequestIdRef = useRef(0)+ // The deep-link confirm/error dialogs render as renderer DOM at the App+ // shell level; like the other shell overlays they must hide the native+ // WebContentsView, which always paints above the DOM, to be visible at all.const shellOverlayOpen =- headerShellOverlayOpen || sidebarShellOverlayOpen || toastShellOverlayOpen+ headerShellOverlayOpen ||+ sidebarShellOverlayOpen ||+ toastShellOverlayOpen ||+ deepLinkOverlayOpenconst reload = useCallback(async () => {setError(null)diff --git a/desktop-app/ui/src/pages/SandboxUiPage.types.ts b/desktop-app/ui/src/pages/SandboxUiPage.types.tsindex 15958eee5..69c420c13 100644--- a/desktop-app/ui/src/pages/SandboxUiPage.types.ts+++ b/desktop-app/ui/src/pages/SandboxUiPage.types.ts@@ -26,6 +26,7 @@ export type SandboxUiPageProps = {headerShellOverlayOpen?: booleansidebarShellOverlayOpen?: booleantoastShellOverlayOpen?: boolean+ deepLinkOverlayOpen?: booleanshortcutApp?: ActiveSandboxUiApp | nullshortcutOpenRequestId?: numberlocalSearchRequestId?: numberdiff --git a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsxindex 2fcd97dec..a029c9051 100644--- a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx@@ -851,6 +851,45 @@ describe('SandboxUiPage', () => {})})+ it('hides the native view while a deep-link dialog overlay is open and restores it on close', async () => {+ sandboxUi.listApps.mockResolvedValueOnce({+ apps: [+ {+ appRef: 'sandbox-recipes/sales-crm',+ title: "Andy's Sales CRM",+ defaultPath: '/',+ ready: true,+ phase: 'active',+ updatedAt: null,+ },+ ],+ })+ sandboxUi.open.mockResolvedValueOnce(undefined)+ sandboxUi.capturePreview.mockResolvedValueOnce('data:image/png;base64,deeplink')++ const { rerender } = render(<SandboxUiPage />)++ fireEvent.click(await screen.findByRole('button', { name: "Open Andy's Sales CRM" }))+ await screen.findByRole('button', { name: 'Back to apps' })+ await waitFor(() => expect(sandboxUi.setVisible).toHaveBeenLastCalledWith(true))+ sandboxUi.setVisible.mockClear()++ // The "Open app link?" / "App link could not be opened" dialogs live in the+ // renderer DOM; without hiding the WebContentsView they render behind the+ // embedded app and the user can never reach the confirm/dismiss buttons.+ rerender(<SandboxUiPage deepLinkOverlayOpen />)++ await waitFor(() => {+ expect(screen.getByTestId('sandbox-ui-embed-preview')).toBeTruthy()+ expect(sandboxUi.setVisible).toHaveBeenLastCalledWith(false)+ })++ sandboxUi.setVisible.mockClear()+ rerender(<SandboxUiPage />)++ await waitFor(() => expect(sandboxUi.setVisible).toHaveBeenLastCalledWith(true))+ })+it('hides an active native view even before local launch state is available', async () => {sandboxUi.listApps.mockResolvedValueOnce({ apps: [] })sandboxUi.capturePreview.mockResolvedValueOnce(null)