Skip to content

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

TypeScript

feat(desktop-app): move mounted-app actions into the native title bar (F5)

Diego Zacariasa67f7c6e75e3
diff --git a/desktop-app/test/browser/responsiveUtilityGutter.browser.test.ts b/desktop-app/test/browser/responsiveUtilityGutter.browser.test.ts
index 9daaf914e..d592b901c 100644
--- a/desktop-app/test/browser/responsiveUtilityGutter.browser.test.ts
+++ b/desktop-app/test/browser/responsiveUtilityGutter.browser.test.ts
@@ -8,7 +8,7 @@ const SYSTEM_CHROME = '/Applications/Google Chrome.app/Contents/MacOS/Google Chr
type HeaderGeometry = {
appsPaddingRight: number
- mountedPaddingRight: number
+ embedPaddingRight: number
pagePaddingRight: number
}
@@ -23,9 +23,11 @@ function launchOptions() {
// The command-center (global-search) now lives in the window title bar on every
// route, so the content panel and its headers reserve NO base gutter for it —
-// that fixture is deliberately absent here. The only horizontal reservation left
-// in the panel is the apps notification drawer's rail, applied to the page while
-// the drawer is open, which is what this geometry measures.
+// that fixture is deliberately absent here. The mounted-app actions also moved to
+// the title bar, so the mounted view's layout now anchors on the embed slot
+// (`.sandbox-ui-embed-slot`) rather than a header row. The only horizontal
+// reservation left in the panel is the apps notification drawer's rail, applied
+// to the page while the drawer is open, which is what this geometry measures.
async function headerGeometry(width: number, drawerOpen = false): Promise<HeaderGeometry> {
if (!browser) throw new Error('Browser must launch before measuring responsive utility geometry')
const page = await browser.newPage({ viewport: { width, height: 800 } })
@@ -33,7 +35,7 @@ async function headerGeometry(width: number, drawerOpen = false): Promise<Header
<div class="content-panel${drawerOpen ? ' content-panel--app-notification-drawer-open' : ''}">
<section class="page">
<header class="apps-page-header">Apps</header>
- <header class="sandbox-ui-mounted-header"><button>Back</button></header>
+ <div class="sandbox-ui-embed-slot"></div>
</section>
</div>
`)
@@ -44,7 +46,7 @@ async function headerGeometry(width: number, drawerOpen = false): Promise<Header
Number.parseFloat(getComputedStyle(document.querySelector(selector)!).paddingRight)
return {
appsPaddingRight: number('.apps-page-header'),
- mountedPaddingRight: number('.sandbox-ui-mounted-header'),
+ embedPaddingRight: number('.sandbox-ui-embed-slot'),
pagePaddingRight: number('.page'),
}
})
@@ -65,11 +67,11 @@ describe('responsive utility gutter', () => {
const closed = await headerGeometry(1100)
const open = await headerGeometry(1100, true)
- // Closed: no base gutter on the mounted-app header (search is in the title
- // bar). Open: the page reserves the drawer rail and the mounted-app header
- // sits flush against it (its own padding stays 0).
- expect(closed.mountedPaddingRight).toBe(0)
- expect(open.mountedPaddingRight).toBe(0)
+ // Closed: no base gutter on the mounted embed (search is in the title bar).
+ // Open: the page reserves the drawer rail and the embed sits flush against it
+ // (the embed slot's own padding stays 0 — the page pads, not the slot).
+ expect(closed.embedPaddingRight).toBe(0)
+ expect(open.embedPaddingRight).toBe(0)
expect(open.pagePaddingRight).toBe(466)
})
@@ -78,13 +80,13 @@ describe('responsive utility gutter', () => {
const desktop = await headerGeometry(1221)
// With search in the title bar, neither the apps picker header nor the
- // mounted-app header pads a base gutter at any width — the responsive
- // "utility budget" that reserved space for the floating in-panel search is
- // retired. Regression guard: re-introducing a floating in-panel search would
- // make one of these non-zero again.
+ // mounted embed pads a base gutter at any width — the responsive "utility
+ // budget" that reserved space for the floating in-panel search is retired.
+ // Regression guard: re-introducing a floating in-panel search would make one
+ // of these non-zero again.
expect(mobile.appsPaddingRight).toBe(0)
- expect(mobile.mountedPaddingRight).toBe(0)
+ expect(mobile.embedPaddingRight).toBe(0)
expect(desktop.appsPaddingRight).toBe(0)
- expect(desktop.mountedPaddingRight).toBe(0)
+ expect(desktop.embedPaddingRight).toBe(0)
})
})
diff --git a/desktop-app/test/e2e-playwright/plugin-workload-sdk-codex-fallback.spec.ts b/desktop-app/test/e2e-playwright/plugin-workload-sdk-codex-fallback.spec.ts
index 2d7e9e237..fd5eb9e38 100644
--- a/desktop-app/test/e2e-playwright/plugin-workload-sdk-codex-fallback.spec.ts
+++ b/desktop-app/test/e2e-playwright/plugin-workload-sdk-codex-fallback.spec.ts
@@ -165,7 +165,7 @@ test('Desktop Apps falls back to the authorized non-Codex target when Codex is u
await expect(appCard).toHaveCount(1)
await expect(appCard).toBeVisible({ timeout: 30_000 })
await appCard.click()
- await expect(page.getByRole('button', { name: 'Back to apps' })).toBeVisible({
+ await expect(page.getByTestId('sandbox-ui-mounted')).toBeVisible({
timeout: 30_000,
})
let embedded: EmbeddedContents | null = null
@@ -231,7 +231,9 @@ test('Desktop Apps falls back to the authorized non-Codex target when Codex is u
expect(fallbackAttempt!.status).toBe('complete')
expect(fallbackAttempt!.codexAttemptId).toBe('')
- await page.getByRole('button', { name: 'Back to apps' }).click()
+ // "Back to apps" was removed; the sidebar Apps nav owns the return to the
+ // picker now (same channel as app.backToApps).
+ await page.getByTestId('nav-sandbox-ui').click()
await expect(page.getByRole('heading', { name: 'Apps', exact: true })).toBeVisible()
} finally {
if (proxyStopped) {
diff --git a/desktop-app/test/e2e-playwright/plugin-workload-sdk-no-grant-guard.spec.ts b/desktop-app/test/e2e-playwright/plugin-workload-sdk-no-grant-guard.spec.ts
index 27f4f6bf0..e61558b6c 100644
--- a/desktop-app/test/e2e-playwright/plugin-workload-sdk-no-grant-guard.spec.ts
+++ b/desktop-app/test/e2e-playwright/plugin-workload-sdk-no-grant-guard.spec.ts
@@ -139,7 +139,7 @@ test('Desktop Apps refuses a Codex prompt when the execution binding is missing'
await expect(appCard).toHaveCount(1)
await expect(appCard).toBeVisible({ timeout: 30_000 })
await appCard.click()
- await expect(page.getByRole('button', { name: 'Back to apps' })).toBeVisible({
+ await expect(page.getByTestId('sandbox-ui-mounted')).toBeVisible({
timeout: 30_000,
})
let embedded: EmbeddedContents | null = null
@@ -170,7 +170,9 @@ test('Desktop Apps refuses a Codex prompt when the execution binding is missing'
if (after > before) {
expect(latestSdkInvocationStatus(fixture, 'promptBridge')).not.toBe('complete')
}
- await page.getByRole('button', { name: 'Back to apps' }).click()
+ // "Back to apps" was removed; the sidebar Apps nav owns the return to the
+ // picker now (same channel as app.backToApps).
+ await page.getByTestId('nav-sandbox-ui').click()
await expect(page.getByRole('heading', { name: 'Apps', exact: true })).toBeVisible()
} finally {
await finalizeRecording(app, page)
diff --git a/desktop-app/test/e2e-playwright/plugin-workload-sdk-sandbox-ui.spec.ts b/desktop-app/test/e2e-playwright/plugin-workload-sdk-sandbox-ui.spec.ts
index aa1dc4acb..f722d0a3e 100644
--- a/desktop-app/test/e2e-playwright/plugin-workload-sdk-sandbox-ui.spec.ts
+++ b/desktop-app/test/e2e-playwright/plugin-workload-sdk-sandbox-ui.spec.ts
@@ -137,7 +137,7 @@ test('Desktop Apps executes promptBridge and clientNotifications inside the real
await expect(appCard).toHaveCount(1)
await expect(appCard).toBeVisible({ timeout: 30_000 })
await appCard.click()
- await expect(page.getByRole('button', { name: 'Back to apps' })).toBeVisible({
+ await expect(page.getByTestId('sandbox-ui-mounted')).toBeVisible({
timeout: 30_000,
})
@@ -310,9 +310,11 @@ test('Desktop Apps executes promptBridge and clientNotifications inside the real
// Renderer chrome + native view both remain alive after the two backend
// operations, proving the Desktop Apps path rather than a direct proxy call.
- await expect(page.getByRole('button', { name: 'Back to apps' })).toBeVisible()
+ await expect(page.getByTestId('sandbox-ui-mounted')).toBeVisible()
expect(await findSandboxUiContents(app, fixture)).toMatchObject({ id: webContentsId })
- await page.getByRole('button', { name: 'Back to apps' }).click()
+ // "Back to apps" was removed; the sidebar Apps nav owns the return to the
+ // picker now (same channel as app.backToApps).
+ await page.getByTestId('nav-sandbox-ui').click()
await expect(page.getByRole('heading', { name: 'Apps', exact: true })).toBeVisible()
} finally {
await finalizeRecording(app, page)
diff --git a/desktop-app/test/e2e-playwright/qa-recorder-apps.spec.ts b/desktop-app/test/e2e-playwright/qa-recorder-apps.spec.ts
index af88a607a..ae26ce47e 100644
--- a/desktop-app/test/e2e-playwright/qa-recorder-apps.spec.ts
+++ b/desktop-app/test/e2e-playwright/qa-recorder-apps.spec.ts
@@ -69,23 +69,25 @@ test('optional QA recorder: Desktop apps journey', async ({}, testInfo) => {
// The embedded app is a native WebContentsView floated above the DOM, so
// assert the mounted chrome OR the minting loader OR the parked preview
- // image. The "Back to apps" button is rendered for both the `minting`
- // and `mounted` launch states, so it is the most reliable signal that the
- // open flow actually ran.
- const backButton = page.getByRole('button', { name: 'Back to apps' })
+ // image. The `sandbox-ui-mounted` section is rendered for both the
+ // `minting` and `mounted` launch states, so it is the most reliable signal
+ // that the open flow actually ran (it replaced the old "Back to apps"
+ // button, which was removed).
+ const mountedSignal = page.getByTestId('sandbox-ui-mounted')
const loadingApp = page.getByText('Loading app')
const embedPreview = page.getByTestId('sandbox-ui-embed-preview')
- const mounted = backButton.or(loadingApp).or(embedPreview).first()
+ const mounted = mountedSignal.or(loadingApp).or(embedPreview).first()
await expect(mounted).toBeVisible({ timeout: 20_000 })
await screenshotAndLog(page, testInfo, 'desktop-apps-embedded')
- // (3) Back action returns to the catalog. The Back button is part of the
- // mounted union above, so only click it when it is the visible signal —
- // if the open surfaced an error banner instead, the catalog is already
- // showing and there is nothing to return from.
- if (await backButton.isVisible().catch(() => false)) {
- await backButton.click()
+ // (3) Return to the catalog via the sidebar Apps nav ("Back to apps" was
+ // removed; the sidebar owns the return now, same channel as
+ // app.backToApps). Only when the app actually mounted — if the open
+ // surfaced an error banner instead, the catalog is already showing and
+ // there is nothing to return from.
+ if (await mountedSignal.isVisible().catch(() => false)) {
+ await page.getByTestId('nav-sandbox-ui').click()
await expect(appsHeading).toBeVisible({ timeout: 20_000 })
await expect(catalogBody).toBeVisible({ timeout: 20_000 })
await screenshotAndLog(page, testInfo, 'desktop-apps-back')
diff --git a/desktop-app/test/e2e-playwright/responsive-layout-producer-backed.spec.ts b/desktop-app/test/e2e-playwright/responsive-layout-producer-backed.spec.ts
index 00d8e7660..fac5a2bec 100644
--- a/desktop-app/test/e2e-playwright/responsive-layout-producer-backed.spec.ts
+++ b/desktop-app/test/e2e-playwright/responsive-layout-producer-backed.spec.ts
@@ -179,25 +179,33 @@ test('Desktop app tray layout is exercised with producer-backed notification and
expect(Math.round(mobileSearch.width)).toBe(Math.round(mobileHeader.width))
})
- await test.step('long return label truncates while its full name and controls remain accessible', async () => {
+ await test.step('long return label stays accessible via tooltip while title-bar actions never overlap', async () => {
await resizeDesktop(app!, 1100)
const returnButton = page.getByRole('button', { name: `Back to ${LONG_CONVERSATION}` })
await expect(returnButton).toHaveAttribute('title', `Back to ${LONG_CONVERSATION}`)
- const visibleLabel = returnButton.locator('span')
- const labelGeometry = await visibleLabel.evaluate(element => ({
- clientWidth: element.clientWidth,
- scrollWidth: element.scrollWidth,
- }))
- expect(labelGeometry.scrollWidth).toBeGreaterThan(labelGeometry.clientWidth)
-
- const controls = page.locator('.sandbox-ui-mounted-header button')
+ // Icon-only now: the full conversation name is no longer a visible text
+ // span (the truncation/ellipsis invariant was retired with the max-width),
+ // it lives in the hover-tooltip flyout, which still carries the complete
+ // label for sighted users. Same intent: the full name stays accessible.
+ const returnTooltip = page
+ .locator('.titlebar-leading-action', {
+ has: page.getByRole('button', { name: `Back to ${LONG_CONVERSATION}` }),
+ })
+ .getByRole('tooltip')
+ await expect(returnTooltip).toHaveText(`Back to ${LONG_CONVERSATION}`)
+
+ // The app actions moved into the title bar's leading slot — a single row
+ // now, not a wrapped header, so the old multi-row "uniqueness" check is
+ // retired. What still matters: the leading actions never overlap each
+ // other or the header search that shares their row (D-A3 coexistence).
+ const controls = page.locator('.window-titlebar__leading button')
const controlBoxes = await controls.evaluateAll(elements =>
elements.map(element => {
const rect = element.getBoundingClientRect()
return { x: rect.x, y: rect.y, width: rect.width, height: rect.height }
})
)
- expect(new Set(controlBoxes.map(box => Math.round(box.y))).size).toBeGreaterThan(1)
+ expect(controlBoxes.length, 'title-bar leading actions must be present').toBeGreaterThan(0)
const searchBox = await bounds(page.getByRole('textbox', { name: 'Search' }))
for (let index = 0; index < controlBoxes.length; index += 1) {
assertNoIntersection(controlBoxes[index]!, searchBox)
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsx
index 661e93ed0..638a6da5c 100644
--- a/desktop-app/ui/src/App.tsx
+++ b/desktop-app/ui/src/App.tsx
@@ -309,6 +309,7 @@ export function App() {
const [notificationOpenRequestId, setNotificationOpenRequestId] = React.useState(0)
const [sidebarToggleRequestId, setSidebarToggleRequestId] = React.useState(0)
const [titlebarActionsRoot, setTitlebarActionsRoot] = React.useState<HTMLDivElement | null>(null)
+ const [titlebarLeadingRoot, setTitlebarLeadingRoot] = React.useState<HTMLDivElement | null>(null)
const [chatLocalSearchOpen, setChatLocalSearchOpen] = React.useState(false)
const [chatLocalSearchState, setChatLocalSearchState] = React.useState<{
query: string
@@ -2012,7 +2013,7 @@ export function App() {
return (
<AuthContext.Provider value={authValue}>
<div className="app-frame">
- <WindowTitleBar actionsRef={setTitlebarActionsRoot} />
+ <WindowTitleBar actionsRef={setTitlebarActionsRoot} leadingRef={setTitlebarLeadingRoot} />
<div className="app-root" inert={bootSplashLoading || undefined}>
{vm.isAuthenticated ? (
<NavigationContext.Provider value={navValue}>
@@ -2132,6 +2133,7 @@ export function App() {
shortcutOpenRequestId={sandboxUiShortcutOpenRequestId}
localSearchRequestId={sandboxLocalSearchRequestId}
chatDrawerOpen={chatDrawerVisible}
+ titlebarLeadingContainer={titlebarLeadingRoot}
onToggleChatDrawer={toggleChatDrawer}
onBackToConversation={handleSandboxUiBackToConversation}
onEmbeddedAppOpening={handleSandboxUiOpening}
diff --git a/desktop-app/ui/src/components/SidebarNav/icons.tsx b/desktop-app/ui/src/components/SidebarNav/icons.tsx
index 2a50332ec..0f3c73f04 100644
--- a/desktop-app/ui/src/components/SidebarNav/icons.tsx
+++ b/desktop-app/ui/src/components/SidebarNav/icons.tsx
@@ -277,6 +277,14 @@ export function IconChevronRight(props: IconProps) {
)
}
+export function IconChevronLeft(props: IconProps) {
+ return (
+ <svg viewBox="0 0 24 24" aria-hidden="true" {...BASE_STROKE_PROPS} {...props}>
+ <path d="m15 18-6-6 6-6" />
+ </svg>
+ )
+}
+
export function IconClose(props: IconProps) {
return (
<svg viewBox="0 0 24 24" aria-hidden="true" {...BASE_STROKE_PROPS} {...props}>
diff --git a/desktop-app/ui/src/components/WindowTitleBar/index.tsx b/desktop-app/ui/src/components/WindowTitleBar/index.tsx
index 050b84dc0..984e18961 100644
--- a/desktop-app/ui/src/components/WindowTitleBar/index.tsx
+++ b/desktop-app/ui/src/components/WindowTitleBar/index.tsx
@@ -44,6 +44,7 @@ function targetOwnsPointerGesture(target: EventTarget | null): boolean {
target.closest(
[
'.window-titlebar__controls',
+ '.window-titlebar__leading',
'.global-search',
'.notification-bell-wrapper',
'button',
@@ -62,7 +63,7 @@ export function TitlebarActionsPortal({ children, container }: TitlebarActionsPo
return container ? createPortal(children, container) : null
}
-export function WindowTitleBar({ actions, actionsRef }: WindowTitleBarProps) {
+export function WindowTitleBar({ actions, actionsRef, leadingRef }: WindowTitleBarProps) {
const [controlsState, setControlsState] = React.useState<WindowControlsState>(
DEFAULT_WINDOW_CONTROLS_STATE
)
@@ -138,6 +139,7 @@ export function WindowTitleBar({ actions, actionsRef }: WindowTitleBarProps) {
</button>
))}
</div>
+ <div className="window-titlebar__leading" ref={leadingRef} />
<div className="window-titlebar__actions" ref={actionsRef}>
{actions}
</div>
diff --git a/desktop-app/ui/src/components/WindowTitleBar/types.ts b/desktop-app/ui/src/components/WindowTitleBar/types.ts
index 529ef58cd..02d47db5e 100644
--- a/desktop-app/ui/src/components/WindowTitleBar/types.ts
+++ b/desktop-app/ui/src/components/WindowTitleBar/types.ts
@@ -12,6 +12,7 @@ export type WindowControlsState = {
export type WindowTitleBarProps = {
actions?: React.ReactNode
actionsRef?: React.Ref<HTMLDivElement>
+ leadingRef?: React.Ref<HTMLDivElement>
}
export type TitlebarActionsPortalProps = {
diff --git a/desktop-app/ui/src/pages/SandboxUiPage.tsx b/desktop-app/ui/src/pages/SandboxUiPage.tsx
index 0b4e0634c..ca83a3f48 100644
--- a/desktop-app/ui/src/pages/SandboxUiPage.tsx
+++ b/desktop-app/ui/src/pages/SandboxUiPage.tsx
@@ -1,10 +1,12 @@
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
-import { Button, StatusBanner } from '@components/Common'
+import { createPortal } from 'react-dom'
+import { IconButton, StatusBanner } from '@components/Common'
+import { joinClasses } from '@lib/classNames'
import SandboxCurrentContentSearch from '../components/SandboxCurrentContentSearch'
import type { AppFindState } from '../components/SandboxCurrentContentSearch/types'
import {
IconChat,
- IconClose,
+ IconChevronLeft,
IconCopy,
IconRefresh,
IconSandboxUi,
@@ -160,6 +162,42 @@ const APP_PAGE_SIZE = 6
let pendingSandboxUiUnmountCleanup: number | null = null
let nextSandboxFindClientRequestId = 0
+// Icon-only app action rendered into the native title bar's leading slot. The
+// visible label lives in an instant hover flyout (reusing the sidebar
+// `.nav-tooltip` treatment) so the collapsed control still announces itself;
+// `IconButton` keeps the accessible name and native title from `label`.
+function TitlebarLeadingAction({
+ className,
+ label,
+ pressed,
+ onClick,
+ children,
+}: {
+ className: string
+ label: string
+ pressed?: boolean
+ onClick: () => void
+ children: React.ReactNode
+}) {
+ return (
+ <span className="titlebar-leading-action">
+ <IconButton
+ variant="ghost"
+ size="sm"
+ className={joinClasses('titlebar-leading-action__btn', className)}
+ label={label}
+ aria-pressed={pressed}
+ onClick={onClick}
+ >
+ {children}
+ </IconButton>
+ <span className="nav-tooltip titlebar-leading-action__tooltip" role="tooltip">
+ {label}
+ </span>
+ </span>
+ )
+}
+
export function SandboxUiPage({
actionRequest = null,
boundsRefreshKey = 0,
@@ -173,6 +211,7 @@ export function SandboxUiPage({
shortcutOpenRequestId = 0,
localSearchRequestId = 0,
chatDrawerOpen = false,
+ titlebarLeadingContainer = null,
onToggleChatDrawer,
onBackToConversation,
onEmbeddedAppOpening,
@@ -569,88 +608,65 @@ export function SandboxUiPage({
const showRefreshBanner =
refreshError && launch.kind === 'mounted' && refreshError.appRef === launch.appRef
return (
- <section className="page">
- <div className="sandbox-ui-mounted-header">
- {conversationOrigin && (onToggleChatDrawer || onBackToConversation) ? (
- // The originating conversation lives in the drawer beside the live
- // embed now, so "Back to {title}" toggles the drawer instead of
- // destroying the embed and reconstructing the chat full-screen. When
- // no drawer toggle is wired it falls back to the destroy-and-
- // reconstitute path (also reachable via the app.backToConversation
- // command).
- <Button
- color="neutral"
- variant={onToggleChatDrawer && chatDrawerOpen ? 'solid' : 'soft'}
- size="sm"
- className="sandbox-ui-conversation-btn"
- aria-label={`Back to ${conversationOrigin.title}`}
- aria-pressed={onToggleChatDrawer ? chatDrawerOpen : undefined}
- title={`Back to ${conversationOrigin.title}`}
- onClick={
- onToggleChatDrawer ? onToggleChatDrawer : () => void handleBackToConversation()
- }
- >
- <IconChat />
- <span>Back to {conversationOrigin.title}</span>
- </Button>
- ) : null}
- <Button
- color="neutral"
- variant="soft"
- size="sm"
- className="sandbox-ui-close-btn"
- aria-label="Back to apps"
- title="Back to apps"
- onClick={() => void onBackToApps()}
- >
- <IconClose />
- <span>Back to apps</span>
- </Button>
- {launch.kind === 'mounted' && onToggleChatDrawer && !conversationOrigin && (
- // No originating conversation to return to — a plain drawer toggle.
- <Button
- color="neutral"
- variant={chatDrawerOpen ? 'solid' : 'soft'}
- size="sm"
- className="sandbox-ui-chat-drawer-btn"
- aria-label="Toggle chat drawer"
- aria-pressed={chatDrawerOpen}
- title="Toggle chat drawer"
- onClick={onToggleChatDrawer}
- >
- <IconChat />
- <span>Chat</span>
- </Button>
+ <section className="page" data-testid="sandbox-ui-mounted">
+ {/* App actions live in the native title bar's leading slot (icon-only,
+ label in a hover flyout). They render through a portal only once the
+ title bar has published its container; there is no inline fallback,
+ mirroring how the header search/bell portal works. "Back to apps" is
+ intentionally gone — the sidebar owns the return to the app picker. */}
+ {titlebarLeadingContainer &&
+ createPortal(
+ <div className="window-titlebar__leading-actions">
+ {conversationOrigin && (onToggleChatDrawer || onBackToConversation) ? (
+ // The originating conversation lives in the drawer beside the
+ // live embed now, so this toggles the drawer instead of
+ // destroying the embed and reconstructing the chat full-screen.
+ // When no drawer toggle is wired it falls back to the destroy-
+ // and-reconstitute path (also reachable via the
+ // app.backToConversation command).
+ <TitlebarLeadingAction
+ className="sandbox-ui-conversation-btn"
+ label={`Back to ${conversationOrigin.title}`}
+ pressed={onToggleChatDrawer ? chatDrawerOpen : undefined}
+ onClick={
+ onToggleChatDrawer ? onToggleChatDrawer : () => void handleBackToConversation()
+ }
+ >
+ <IconChevronLeft />
+ </TitlebarLeadingAction>
+ ) : null}
+ {launch.kind === 'mounted' && onToggleChatDrawer && !conversationOrigin && (
+ // No originating conversation to return to — a plain drawer toggle.
+ <TitlebarLeadingAction
+ className="sandbox-ui-chat-drawer-btn"
+ label="Toggle chat drawer"
+ pressed={chatDrawerOpen}
+ onClick={onToggleChatDrawer}
+ >
+ <IconChat />
+ </TitlebarLeadingAction>
+ )}
+ {launch.kind === 'mounted' && (
+ <>
+ <TitlebarLeadingAction
+ className="sandbox-ui-refresh-btn"
+ label="Refresh app content"
+ onClick={onRefresh}
+ >
+ <IconRefresh />
+ </TitlebarLeadingAction>
+ <TitlebarLeadingAction
+ className="sandbox-ui-copy-link-btn"
+ label="Copy current app link"
+ onClick={() => void onCopyDeepLink()}
+ >
+ <IconCopy />
+ </TitlebarLeadingAction>
+ </>
+ )}
+ </div>,
+ titlebarLeadingContainer
)}
- {launch.kind === 'mounted' && (
- <>
- <Button
- color="neutral"
- variant="soft"
- size="sm"
- className="sandbox-ui-refresh-btn"
- aria-label="Refresh"
- title="Refresh app content"
- onClick={onRefresh}
- >
- <IconRefresh />
- <span>Refresh</span>
- </Button>
- <Button
- color="neutral"
- variant="soft"
- size="sm"
- className="sandbox-ui-copy-link-btn"
- aria-label="Copy current app link"
- title="Copy current app link"
- onClick={() => void onCopyDeepLink()}
- >
- <IconCopy />
- <span>Copy URL</span>
- </Button>
- </>
- )}
- </div>
{showRefreshBanner && (
<StatusBanner
tone="error"
diff --git a/desktop-app/ui/src/pages/SandboxUiPage.types.ts b/desktop-app/ui/src/pages/SandboxUiPage.types.ts
index d801b44a9..3dc356dd5 100644
--- a/desktop-app/ui/src/pages/SandboxUiPage.types.ts
+++ b/desktop-app/ui/src/pages/SandboxUiPage.types.ts
@@ -31,6 +31,7 @@ export type SandboxUiPageProps = {
shortcutOpenRequestId?: number
localSearchRequestId?: number
chatDrawerOpen?: boolean
+ titlebarLeadingContainer?: HTMLElement | null
onToggleChatDrawer?: () => void
onBackToConversation?: () => void | Promise<void>
onEmbeddedAppOpening?: (app: ActiveSandboxUiApp) => 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 42d09a511..f772995b9 100644
--- a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.focus.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.focus.test.tsx
@@ -2,7 +2,14 @@
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 } from '../SandboxUiPage'
+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} />
+}
const sandboxUi = {
listApps: vi.fn(),
@@ -38,7 +45,7 @@ function installSandboxBridge(): void {
async function openApp(): Promise<void> {
fireEvent.click(await screen.findByRole('button', { name: 'Open Sales CRM' }))
- await screen.findByRole('button', { name: 'Back to apps' })
+ await screen.findByTestId('sandbox-ui-mounted')
}
describe('SandboxUiPage contextual-search focus ownership', () => {
@@ -96,7 +103,7 @@ describe('SandboxUiPage contextual-search focus ownership', () => {
expect(document.activeElement).toBe(input)
fireEvent.change(input, { target: { value: 'invoice' } })
- screen.getByRole('button', { name: 'Refresh' }).focus()
+ screen.getByRole('button', { name: 'Refresh app content' }).focus()
rendered.rerender(<SandboxUiPage localSearchRequestId={2} />)
expect(document.activeElement).toBe(input)
@@ -131,7 +138,7 @@ describe('SandboxUiPage contextual-search focus ownership', () => {
shortcutOpenRequestId={1}
/>
)
- await screen.findByRole('button', { name: 'Back to apps' })
+ await screen.findByTestId('sandbox-ui-mounted')
await new Promise(resolve => window.setTimeout(resolve, 0))
expect(screen.queryByRole('textbox', { name: 'Find in current app' })).toBeNull()
diff --git a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
index 1abfd50ae..2717ee5b9 100644
--- a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
@@ -2,7 +2,14 @@
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 } from '../SandboxUiPage'
+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} />
+}
const sandboxUi = {
listApps: vi.fn(),
@@ -181,8 +188,11 @@ describe('SandboxUiPage', () => {
},
})
})
- expect(await screen.findByRole('button', { name: 'Back to apps' })).toBeTruthy()
- expect(screen.getAllByRole('button', { name: /^Back to / })).toHaveLength(1)
+ expect(await screen.findByTestId('sandbox-ui-mounted')).toBeTruthy()
+ // "Back to apps" was removed by design — the sidebar owns the return to the
+ // app picker now. The mounted app-actions moved to the title-bar leading slot.
+ expect(screen.queryByRole('button', { name: 'Back to apps' })).toBeNull()
+ expect(screen.getByRole('button', { name: 'Refresh app content' })).toBeTruthy()
})
it('exposes a chat-drawer toggle in the mounted header that reflects and drives drawer state', async () => {
@@ -235,7 +245,7 @@ describe('SandboxUiPage', () => {
render(<SandboxUiPage />)
fireEvent.click(await screen.findByRole('button', { name: "Open Andy's Sales CRM" }))
- await screen.findByRole('button', { name: 'Back to apps' })
+ await screen.findByTestId('sandbox-ui-mounted')
expect(screen.queryByRole('button', { name: 'Toggle chat drawer' })).toBeNull()
})
@@ -260,7 +270,7 @@ describe('SandboxUiPage', () => {
<SandboxUiPage actionRequest={null} onEmbeddedAppBack={onEmbeddedAppBack} />
)
fireEvent.click(await screen.findByRole('button', { name: 'Open Sales CRM' }))
- await screen.findByRole('button', { name: 'Refresh' })
+ await screen.findByRole('button', { name: 'Refresh app content' })
rerender(
<SandboxUiPage
@@ -345,7 +355,7 @@ describe('SandboxUiPage', () => {
}
const { rerender } = render(<SandboxUiPage {...props} actionRequest={null} />)
fireEvent.click(await screen.findByRole('button', { name: 'Open Sales CRM' }))
- await screen.findByRole('button', { name: 'Refresh' })
+ await screen.findByRole('button', { name: 'Refresh app content' })
rerender(<SandboxUiPage {...props} actionRequest={{ id: 1, action: 'back-to-conversation' }} />)
@@ -636,10 +646,14 @@ describe('SandboxUiPage', () => {
)
fireEvent.click(await screen.findByRole('button', { name: "Open Andy's Sales CRM" }))
+ // The control is icon-only now: the full label stays the accessible name and
+ // native title, and its visible copy lives in the hover-tooltip flyout
+ // (role="tooltip") rather than an inline text span.
const button = await screen.findByRole('button', { name: `Back to ${title}` })
expect(button.getAttribute('title')).toBe(`Back to ${title}`)
- expect(button.querySelector('span')?.textContent).toBe(`Back to ${title}`)
+ const tooltip = button.closest('.titlebar-leading-action')?.querySelector('[role="tooltip"]')
+ expect(tooltip?.textContent).toBe(`Back to ${title}`)
})
it('keeps the app mounted when returning to the conversation fails', async () => {
@@ -675,7 +689,8 @@ describe('SandboxUiPage', () => {
await waitFor(() => expect(onBackToConversation).toHaveBeenCalledOnce())
expect(sandboxUi.close).not.toHaveBeenCalled()
- expect(screen.getByRole('button', { name: 'Back to apps' })).toBeTruthy()
+ // Still mounted (not returned to the picker) — the embed chrome is present.
+ expect(screen.getByTestId('sandbox-ui-mounted')).toBeTruthy()
})
it('keeps the conversation origin during Strict Mode effect replay', async () => {
@@ -767,7 +782,7 @@ describe('SandboxUiPage', () => {
)
fireEvent.click(await screen.findByRole('button', { name: "Open Andy's Sales CRM" }))
- await screen.findByRole('button', { name: 'Back to apps' })
+ await screen.findByTestId('sandbox-ui-mounted')
onEmbedBoundsApplied.mockClear()
rerender(
@@ -798,7 +813,7 @@ describe('SandboxUiPage', () => {
render(<SandboxUiPage onEmbedSlotTopChange={onEmbedSlotTopChange} />)
fireEvent.click(await screen.findByRole('button', { name: "Open Andy's Sales CRM" }))
- await screen.findByRole('button', { name: 'Back to apps' })
+ await screen.findByTestId('sandbox-ui-mounted')
// The slot rect (getBoundingClientRect mock -> top: 12) flows through the real
// useEmbedBounds push, so the callback fires with Math.round(rect.top) = 12.
@@ -832,9 +847,9 @@ describe('SandboxUiPage', () => {
render(<SandboxUiPage />)
fireEvent.click(await screen.findByRole('button', { name: "Open Andy's Sales CRM" }))
- await screen.findByRole('button', { name: 'Back to apps' })
+ await screen.findByTestId('sandbox-ui-mounted')
- fireEvent.click(screen.getByRole('button', { name: 'Refresh' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Refresh app content' }))
await waitFor(() => {
expect(sandboxUi.reload).toHaveBeenCalledTimes(1)
@@ -862,7 +877,7 @@ describe('SandboxUiPage', () => {
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 screen.findByTestId('sandbox-ui-mounted')
rerender(<SandboxUiPage headerShellOverlayOpen />)
@@ -922,7 +937,7 @@ describe('SandboxUiPage', () => {
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 screen.findByTestId('sandbox-ui-mounted')
await waitFor(() => expect(sandboxUi.setVisible).toHaveBeenLastCalledWith(true))
sandboxUi.setVisible.mockClear()
@@ -958,7 +973,7 @@ describe('SandboxUiPage', () => {
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 screen.findByTestId('sandbox-ui-mounted')
await waitFor(() => expect(sandboxUi.setVisible).toHaveBeenLastCalledWith(true))
sandboxUi.setVisible.mockClear()
@@ -1010,7 +1025,7 @@ describe('SandboxUiPage', () => {
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 screen.findByTestId('sandbox-ui-mounted')
await waitFor(() => expect(sandboxUi.setVisible).toHaveBeenLastCalledWith(true))
sandboxUi.setVisible.mockClear()
diff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.css
index cf34dc29e..a452442dd 100644
--- a/desktop-app/ui/src/styles.css
+++ b/desktop-app/ui/src/styles.css
@@ -81,7 +81,13 @@ h3 {
.window-titlebar {
position: relative;
- z-index: var(--layer-header);
+ /* Sit above the sidebar's own stacking layer (.left-nav uses
+ --sidebar-flyout-layer = --layer-dropdown + 1000) so the leading slot's
+ downward hover flyout paints over the sidebar column instead of behind it.
+ Still below dialogs/toasts (2300+), which correctly cover the whole chrome.
+ The title bar never vertically overlaps lower chrome, so this only affects
+ that flyout. */
+ z-index: calc(var(--layer-dropdown) + 1010);
isolation: isolate;
height: var(--window-titlebar-height);
display: flex;
@@ -359,6 +365,76 @@ h3 {
opacity: 1;
}
+/* Leading slot: mounted-app actions live here (icon-only), packed just after
+ the window controls in the same title-bar row so they sit at the top-left,
+ over the sidebar's content column and clear of the macOS traffic lights. The
+ header search + bell keep the right edge via .window-titlebar__actions. */
+.window-titlebar__leading {
+ /* .window-titlebar__actions is fixed and paints its (draggable, full-width)
+ .top-bar above this row; without a higher stacking order that band would
+ intercept pointer events over these actions and steal their clicks. */
+ position: relative;
+ z-index: calc(var(--layer-header) + 2);
+ display: flex;
+ align-items: center;
+ gap: var(--space-1);
+ margin-left: var(--space-4);
+ min-width: 0;
+ height: var(--window-titlebar-height);
+ pointer-events: none;
+ -webkit-app-region: no-drag;
+}
+
+.window-titlebar__leading-actions {
+ display: flex;
+ align-items: center;
+ gap: var(--space-1);
+ pointer-events: auto;
+}
+
+.window-titlebar__leading .titlebar-leading-action {
+ position: relative;
+ display: inline-flex;
+}
+
+/* Ghost affordance matching the title-bar bell / chat-drawer IconButtons:
+ no border or fill at rest, accent border + neutral fill on hover or when
+ the toggle is pressed. */
+.window-titlebar__leading .titlebar-leading-action__btn.ui-icon-button {
+ width: 30px;
+ height: 30px;
+ min-height: 30px;
+ border-color: transparent;
+ background: transparent;
+ box-shadow: none;
+ color: var(--titlebar-control-ink);
+}
+
+.window-titlebar__leading .titlebar-leading-action__btn.ui-icon-button svg {
+ width: 16px;
+ height: 16px;
+}
+
+.window-titlebar__leading .titlebar-leading-action__btn.ui-icon-button:hover:enabled,
+.window-titlebar__leading .titlebar-leading-action__btn.ui-icon-button[aria-pressed='true'] {
+ border-color: rgba(var(--accent-rgb), 0.42);
+ background: var(--surface-hover);
+ color: var(--text);
+}
+
+/* Reuse the sidebar .nav-tooltip flyout for an instant hover label, reoriented
+ to drop below the action (this is a horizontal top bar, not a vertical rail). */
+.window-titlebar__leading .titlebar-leading-action__tooltip {
+ left: 50%;
+ top: calc(100% + var(--space-1));
+ transform: translateX(-50%);
+}
+
+.window-titlebar__leading .titlebar-leading-action:hover .titlebar-leading-action__tooltip,
+.window-titlebar__leading .titlebar-leading-action:focus-within .titlebar-leading-action__tooltip {
+ opacity: 1;
+}
+
.top-bar {
position: absolute;
top: var(--space-4);
@@ -12804,87 +12880,32 @@ pre {
}
}
-/* Tight single-row header for the mounted sandbox-ui app view. The command
- center now lives in the window title bar (not floating over the panel), so
- this row spans the full width; the notification-drawer-open state reserves
- the right rail on the page instead (see below). */
-.sandbox-ui-mounted-header {
- display: flex;
- align-items: center;
- justify-content: flex-start;
- flex-wrap: wrap;
- align-content: flex-start;
- gap: var(--space-2);
- min-width: 0;
- padding-top: var(--space-4);
-}
-
-.sandbox-ui-conversation-btn,
-.sandbox-ui-close-btn,
-.sandbox-ui-copy-link-btn,
-.sandbox-ui-refresh-btn {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- gap: var(--space-1);
- padding: var(--space-1) var(--space-2);
- border-color: rgba(var(--accent-rgb), 0.45);
- background: rgba(var(--panel-rgb), 0.95);
-}
-
-.sandbox-ui-conversation-btn {
- min-width: 0;
- max-width: min(280px, 40vw);
-}
-
-.sandbox-ui-conversation-btn span {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.sandbox-ui-conversation-btn svg,
-.sandbox-ui-close-btn svg,
-.sandbox-ui-copy-link-btn svg,
-.sandbox-ui-refresh-btn svg {
- width: 16px;
- height: 16px;
-}
-
/* Pull the embed up and let it fill the column: tighten the page-shell gap,
trim the content-panel top padding, and switch the page to a flex column
so the embed slot's flex: 1 stretches to the available height instead of
- relying on a hardcoded min-height. The :has() selectors only fire when
- the mounted-header is in the tree — the picker view (no header) keeps the
- standard page chrome. */
-.page:has(.sandbox-ui-mounted-header) {
+ relying on a hardcoded min-height. The app actions moved to the title bar's
+ leading slot, so these :has() selectors now anchor on the embed slot itself
+ — present only in the mounted/minting view, never in the picker. */
+.page:has(.sandbox-ui-embed-slot) {
display: flex;
flex-direction: column;
gap: var(--space-1);
min-height: 0;
}
-.content-panel:has(.sandbox-ui-mounted-header) {
+.content-panel:has(.sandbox-ui-embed-slot) {
padding: var(--space-2) 0 0;
align-content: stretch;
}
-.content-panel:has(.sandbox-ui-mounted-header) > .top-bar {
+.content-panel:has(.sandbox-ui-embed-slot) > .top-bar {
right: var(--space-4);
}
-.content-panel.content-panel--app-notification-drawer-open > .page:has(.sandbox-ui-mounted-header) {
+.content-panel.content-panel--app-notification-drawer-open > .page:has(.sandbox-ui-embed-slot) {
padding-right: var(--app-header-utilities-width);
}
-.content-panel.content-panel--app-notification-drawer-open .sandbox-ui-mounted-header {
- padding-right: 0;
-}
-
-.sandbox-ui-mounted-header {
- padding-left: var(--space-4);
-}
-
/* Chat drawer — Cursor-style chat column beside the live app embed. It shrinks
the embed with the same `--app-header-utilities-width` gutter the notification
drawer uses, but derives that gutter from its OWN width (`--chat-drawer-width`)
@@ -12900,14 +12921,10 @@ pre {
--app-header-utilities-width: var(--chat-drawer-width);
}
-.content-panel.content-panel--chat-drawer-open > .page:has(.sandbox-ui-mounted-header) {
+.content-panel.content-panel--chat-drawer-open > .page:has(.sandbox-ui-embed-slot) {
padding-right: var(--app-header-utilities-width);
}
-.content-panel.content-panel--chat-drawer-open .sandbox-ui-mounted-header {
- padding-right: 0;
-}
-
/* The chat drawer occupies the right rail at --layer-chat-overlay, above the
header (`.top-bar` at --layer-header) within the shared content-panel stacking
context — so the header's transient dropdowns (the notification Inbox popover,