Skip to content

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

TypeScript

fix(desktop): align embedded notification drawer to app rail

Josué6f628f891f03
diff --git a/desktop-app/src/__tests__/preload.windowControls.test.ts b/desktop-app/src/__tests__/preload.windowControls.test.ts
index a967360a3..7fa31140a 100644
--- a/desktop-app/src/__tests__/preload.windowControls.test.ts
+++ b/desktop-app/src/__tests__/preload.windowControls.test.ts
@@ -27,7 +27,7 @@ afterEach(() => {
describe('preload window controls contract', () => {
it('exposes the titlebar controls through clerum with matching IPC channels and cleanup', async () => {
- await import('../preload')
+ await import('../preload.js')
const exposed = electron.exposeInMainWorld.mock.calls.find(
([name]) => name === 'clerum'
diff --git a/desktop-app/test/browser/responsiveUtilityGutter.browser.test.ts b/desktop-app/test/browser/responsiveUtilityGutter.browser.test.ts
index 5e1ffc4fc..4c9eafdcb 100644
--- a/desktop-app/test/browser/responsiveUtilityGutter.browser.test.ts
+++ b/desktop-app/test/browser/responsiveUtilityGutter.browser.test.ts
@@ -60,6 +60,32 @@ async function headerGeometry(width: number, drawerOpen = false): Promise<Header
return geometry
}
+async function notificationDrawerGeometry() {
+ if (!browser) throw new Error('Browser must launch before measuring notification drawer geometry')
+ const page = await browser.newPage({ viewport: { width: 1200, height: 800 } })
+ await page.setContent(`
+ <div class="app-frame">
+ <div class="content-panel">
+ <div class="sandbox-ui-embed-slot" style="position: fixed; left: 16px; top: 80px; width: 650px; height: 600px"></div>
+ </div>
+ <div
+ class="notification-menu notification-menu--app-drawer notification-menu--embed-aligned"
+ style="--notification-drawer-left: 666px"
+ ></div>
+ </div>
+ `)
+ await page.addStyleTag({ path: path.join(UI_ROOT, 'styles/tokens.css') })
+ await page.addStyleTag({ path: path.join(UI_ROOT, 'styles.css') })
+ const geometry = await page.evaluate(() => {
+ const rect = (selector: string) => document.querySelector(selector)!.getBoundingClientRect()
+ const embed = rect('.sandbox-ui-embed-slot')
+ const drawer = rect('.notification-menu--app-drawer')
+ return { drawerLeft: drawer.left, drawerRight: drawer.right, embedRight: embed.right }
+ })
+ await page.close()
+ return geometry
+}
+
describe('responsive utility gutter', () => {
beforeAll(async () => {
browser = await chromium.launch(launchOptions())
@@ -92,4 +118,11 @@ describe('responsive utility gutter', () => {
expect(desktop.appsPaddingRight).toBe(438)
expect(desktop.mountedPaddingRight).toBe(438)
})
+
+ it('fills the measured embedded-app rail when the chat drawer is closed', async () => {
+ const geometry = await notificationDrawerGeometry()
+
+ expect(geometry.drawerLeft).toBe(geometry.embedRight)
+ expect(geometry.drawerRight).toBe(1182)
+ })
})
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsx
index 249eea5a9..80856d1f1 100644
--- a/desktop-app/ui/src/App.tsx
+++ b/desktop-app/ui/src/App.tsx
@@ -264,6 +264,7 @@ export function App() {
const [headerShellOverlayOpen, setHeaderShellOverlayOpen] = React.useState(false)
const [headerNotificationTrayOpen, setHeaderNotificationTrayOpen] = React.useState(false)
const [notificationDrawerReady, setNotificationDrawerReady] = React.useState(false)
+ const [notificationTrayLeft, setNotificationTrayLeft] = React.useState<number | null>(null)
const [chatDrawerOpen, setChatDrawerOpen] = React.useState(false)
const [chatDrawerReady, setChatDrawerReady] = React.useState(false)
// Measured top of the embed slot, published as `--chat-drawer-top` so the fixed
@@ -771,6 +772,7 @@ export function App() {
const handleSandboxUiOpening = React.useCallback((app: ActiveSandboxUiApp) => {
setSandboxUiMounted(false)
+ setNotificationTrayLeft(null)
setActiveSandboxUiApp(app)
}, [])
@@ -781,6 +783,7 @@ export function App() {
const handleSandboxUiClosed = React.useCallback(() => {
setActiveSandboxUiApp(null)
setSandboxUiMounted(false)
+ setNotificationTrayLeft(null)
setSandboxUiConversationOrigin(null)
setHeaderShellOverlayOpen(false)
setSidebarSettingsMenuOpen(false)
@@ -789,6 +792,7 @@ export function App() {
const handleSandboxUiRemoved = React.useCallback(() => {
setActiveSandboxUiApp(null)
setSandboxUiMounted(false)
+ setNotificationTrayLeft(null)
setSandboxUiConversationOrigin(null)
setHeaderShellOverlayOpen(false)
setSidebarSettingsMenuOpen(false)
@@ -2078,6 +2082,9 @@ export function App() {
notificationTrayUsesDrawer ? 'drawer' : 'overlay'
}
notificationTrayReady={notificationDrawerReady}
+ notificationTrayLeft={
+ notificationTrayUsesDrawer ? notificationTrayLeft : null
+ }
onNotificationTrayOpenChange={setHeaderNotificationTrayOpen}
onShellOverlayOpenChange={setHeaderShellOverlayOpen}
/>
@@ -2140,6 +2147,7 @@ export function App() {
onEmbeddedAppRemoved={handleSandboxUiRemoved}
onEmbedBoundsApplied={handleSandboxUiBoundsApplied}
onEmbedSlotTopChange={setChatDrawerEmbedTop}
+ onEmbedSlotRightChange={setNotificationTrayLeft}
onNotify={vm.pushToast}
onShortcutOpenResult={handleSandboxUiShortcutOpenResult}
/>
diff --git a/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx b/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx
index 4dc0ef75d..319b2cc6d 100644
--- a/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx
+++ b/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx
@@ -22,10 +22,14 @@ const sandboxUiPageHarness = vi.hoisted(() => ({
onEmbeddedAppMounted?: () => void
onEmbedBoundsApplied?: () => void
onEmbedSlotTopChange?: (topPx: number) => void
+ onEmbedSlotRightChange?: (rightPx: number) => void
},
}))
const appHeaderHarness = vi.hoisted(() => ({
- props: null as null | { notificationTrayMode?: 'drawer' | 'overlay' },
+ props: null as null | {
+ notificationTrayMode?: 'drawer' | 'overlay'
+ notificationTrayLeft?: number | null
+ },
// Captured from context so tests can drive the "open conversation" gesture the
// notification tray fires.
openNotification: null as null | ((notification: AppNotification) => Promise<void>),
@@ -425,6 +429,23 @@ describe('App chat drawer — reopen preserves the last-viewed chat', () => {
expect(appHeaderHarness.props?.notificationTrayMode).toBe('drawer')
})
+ it('passes the measured embed edge to the notification drawer while chat is closed', () => {
+ currentController = makeController({ navItem: DESKTOP_ROUTES.apps } as Partial<AppController>)
+ render(<App />)
+
+ act(() => {
+ sidebarHarness.props?.onOpenSandboxUiApp?.({
+ appRef: 'ns/app',
+ label: 'App',
+ defaultPath: '/',
+ })
+ sandboxUiPageHarness.props?.onEmbedSlotRightChange?.(716)
+ })
+
+ expect(appHeaderHarness.props?.notificationTrayMode).toBe('drawer')
+ expect(appHeaderHarness.props?.notificationTrayLeft).toBe(716)
+ })
+
// #2 — reconciler covers the drawer (minispec 04 approach A). The ChatThread
// session list moves `vm.activeChatId` via switchToChat WITHOUT touching
// chatViewTabs. Simulate that (mutate activeChatId as the vm would) and assert
diff --git a/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx b/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx
index a7b4cc8eb..0212ebfa3 100644
--- a/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx
+++ b/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx
@@ -239,6 +239,18 @@ describe('AppHeader notification tray presentation', () => {
).toBe(true)
})
+ it('aligns the embedded-app drawer to the measured embed slot edge', () => {
+ render(
+ <AppHeader notificationTrayMode="drawer" notificationTrayReady notificationTrayLeft={416} />
+ )
+
+ fireEvent.click(screen.getByRole('button', { name: 'Notifications and approvals' }))
+
+ const tray = screen.getByRole('dialog', { name: 'Notifications and approvals' })
+ expect(tray.classList.contains('notification-menu--embed-aligned')).toBe(true)
+ expect(tray.style.getPropertyValue('--notification-drawer-left')).toBe('416px')
+ })
+
it('keeps the existing floating overlay outside embedded apps', async () => {
const onShellOverlayOpenChange = vi.fn()
render(<AppHeader onShellOverlayOpenChange={onShellOverlayOpenChange} />)
diff --git a/desktop-app/ui/src/components/HeaderActions/index.tsx b/desktop-app/ui/src/components/HeaderActions/index.tsx
index 1868d20d0..d35ffcf33 100644
--- a/desktop-app/ui/src/components/HeaderActions/index.tsx
+++ b/desktop-app/ui/src/components/HeaderActions/index.tsx
@@ -87,6 +87,7 @@ export const HeaderActions = React.memo(function HeaderActions({
notificationOpenRequestId = 0,
notificationTrayMode = 'overlay',
notificationTrayReady = true,
+ notificationTrayLeft = null,
onNotificationTrayOpenChange,
onShellOverlayOpenChange,
}: HeaderActionsProps) {
@@ -671,7 +672,18 @@ export const HeaderActions = React.memo(function HeaderActions({
<div
className={`notification-menu${
notificationTrayUsesDrawer ? ' notification-menu--app-drawer' : ''
+ }${
+ notificationTrayUsesDrawer && notificationTrayLeft !== null
+ ? ' notification-menu--embed-aligned'
+ : ''
}`}
+ style={
+ notificationTrayUsesDrawer && notificationTrayLeft !== null
+ ? ({
+ '--notification-drawer-left': `${notificationTrayLeft}px`,
+ } as React.CSSProperties)
+ : undefined
+ }
role="dialog"
aria-label="Notifications and approvals"
>
diff --git a/desktop-app/ui/src/components/HeaderActions/types.ts b/desktop-app/ui/src/components/HeaderActions/types.ts
index 779ce4003..d34e0f91f 100644
--- a/desktop-app/ui/src/components/HeaderActions/types.ts
+++ b/desktop-app/ui/src/components/HeaderActions/types.ts
@@ -4,6 +4,7 @@ export type HeaderActionsProps = {
notificationOpenRequestId?: number
notificationTrayMode?: 'overlay' | 'drawer'
notificationTrayReady?: boolean
+ notificationTrayLeft?: number | null
onNotificationTrayOpenChange?: (open: boolean) => void
onShellOverlayOpenChange?: (open: boolean) => void
}
diff --git a/desktop-app/ui/src/pages/SandboxUiPage.tsx b/desktop-app/ui/src/pages/SandboxUiPage.tsx
index 0b4e0634c..763912aaf 100644
--- a/desktop-app/ui/src/pages/SandboxUiPage.tsx
+++ b/desktop-app/ui/src/pages/SandboxUiPage.tsx
@@ -113,12 +113,14 @@ function useEmbedBounds(
parked: boolean,
refreshKey: string | number,
onBoundsApplied?: () => void,
- onSlotTopChange?: (topPx: number) => void
+ onSlotTopChange?: (topPx: number) => void,
+ onSlotRightChange?: (rightPx: number) => void
): void {
// Dedupe the emitted slot-top across pushes AND across effect re-runs, so a
// resize/scroll storm (or a dep change) never churns the parent's state when
// the measured top is unchanged.
const lastEmittedTopRef = useRef<number | null>(null)
+ const lastEmittedRightRef = useRef<number | null>(null)
useLayoutEffect(() => {
if (!enabled) return
const target = ref.current
@@ -136,6 +138,13 @@ function useEmbedBounds(
onSlotTopChange(top)
}
}
+ if (onSlotRightChange) {
+ const right = Math.round(rect.right)
+ if (lastEmittedRightRef.current !== right) {
+ lastEmittedRightRef.current = right
+ onSlotRightChange(right)
+ }
+ }
void window.clerum.sandboxUi
.setBounds(boundsFromRect(rect))
.then(() => onBoundsApplied?.())
@@ -153,7 +162,7 @@ function useEmbedBounds(
window.removeEventListener('resize', push)
window.removeEventListener('scroll', push, true)
}
- }, [parked, ref, enabled, onBoundsApplied, onSlotTopChange, refreshKey])
+ }, [parked, ref, enabled, onBoundsApplied, onSlotTopChange, onSlotRightChange, refreshKey])
}
const APP_PAGE_SIZE = 6
@@ -181,6 +190,7 @@ export function SandboxUiPage({
onEmbeddedAppRemoved,
onEmbedBoundsApplied,
onEmbedSlotTopChange,
+ onEmbedSlotRightChange,
onNotify,
onShortcutOpenResult,
}: SandboxUiPageProps = {}) {
@@ -510,7 +520,8 @@ export function SandboxUiPage({
shellOverlayOpen,
boundsRefreshKey,
onEmbedBoundsApplied,
- onEmbedSlotTopChange
+ onEmbedSlotTopChange,
+ onEmbedSlotRightChange
)
// Native WebContentsView content always paints above renderer DOM. Capture
diff --git a/desktop-app/ui/src/pages/SandboxUiPage.types.ts b/desktop-app/ui/src/pages/SandboxUiPage.types.ts
index d801b44a9..387826d60 100644
--- a/desktop-app/ui/src/pages/SandboxUiPage.types.ts
+++ b/desktop-app/ui/src/pages/SandboxUiPage.types.ts
@@ -39,6 +39,7 @@ export type SandboxUiPageProps = {
onEmbeddedAppRemoved?: () => void
onEmbedBoundsApplied?: () => void
onEmbedSlotTopChange?: (topPx: number) => void
+ onEmbedSlotRightChange?: (rightPx: number) => void
onNotify?: (message: string, tone: Tone) => void
onShortcutOpenResult?: (
requestId: number,
diff --git a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
index 1abfd50ae..02a1ab2b4 100644
--- a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
@@ -813,6 +813,33 @@ describe('SandboxUiPage', () => {
expect(onEmbedSlotTopChange.mock.calls.length).toBe(calls)
})
+ it('publishes the measured embed slot right edge for the notification drawer rail', 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)
+ const onEmbedSlotRightChange = vi.fn()
+
+ render(<SandboxUiPage onEmbedSlotRightChange={onEmbedSlotRightChange} />)
+
+ fireEvent.click(await screen.findByRole('button', { name: "Open Andy's Sales CRM" }))
+ await screen.findByRole('button', { name: 'Back to apps' })
+
+ // The real slot rect is x=16 and width=400 in this producer-backed fixture.
+ await waitFor(() => {
+ expect(onEmbedSlotRightChange).toHaveBeenCalledWith(416)
+ })
+ })
+
it('reloads the embed in place when the Refresh button is clicked (no navigate-away needed)', async () => {
sandboxUi.listApps.mockResolvedValueOnce({
apps: [
diff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.css
index 543dfa464..cd3b018f9 100644
--- a/desktop-app/ui/src/styles.css
+++ b/desktop-app/ui/src/styles.css
@@ -774,6 +774,11 @@ h3 {
max-height: none;
}
+.notification-menu--app-drawer.notification-menu--embed-aligned {
+ left: var(--notification-drawer-left);
+ width: auto;
+}
+
.notification-menu-title-row {
display: inline-flex;
align-items: center;