Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
refactor(desktop-app): drop chat-drawer overlay mode; always dock beside the native embed
Diego Zacarias7d239f73e717
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex fd3e858c5..c8368adba 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -523,8 +523,8 @@ export function App() {const chatDrawerVisible = chatDrawerAvailable && chatDrawerOpenchatDrawerVisibleRef.current = chatDrawerVisiblechatDrawerAvailableRef.current = chatDrawerAvailable- // Session-only drawer sizing + docked/overlay policy. Width is not persisted- // by design; it resets to the default each launch.+ // Session-only drawer sizing (always docked beside the native embed). Width is+ // not persisted by design; it resets to the default each launch.const chatDrawerResize = useChatDrawerResize(contentPanelRef, chatDrawerVisible)// The notification tray's drawer form occupies the same fixed right-rail rect// as the chat drawer, so it only takes drawer form when the chat drawer is NOT@@ -2000,11 +2000,7 @@ export function App() {appNotificationDrawerOpen? ' content-panel--app-notification-drawer-open': ''- }${chatDrawerVisible ? ' content-panel--chat-drawer-open' : ''}${- chatDrawerVisible && chatDrawerResize.isOverlay- ? ' content-panel--chat-drawer-overlay'- : ''- }`}+ }${chatDrawerVisible ? ' content-panel--chat-drawer-open' : ''}`}style={chatDrawerVisible? { '--chat-drawer-width': `${chatDrawerResize.width}px` }diff --git a/desktop-app/ui/src/components/ChatDrawer/index.tsx b/desktop-app/ui/src/components/ChatDrawer/index.tsxindex 19d4b8be6..65c455c1d 100644--- a/desktop-app/ui/src/components/ChatDrawer/index.tsx+++ b/desktop-app/ui/src/components/ChatDrawer/index.tsx@@ -5,8 +5,10 @@ import type { ChatDrawerProps } from './types'/*** Cursor-style chat drawer that coexists with the live sandbox-ui embed on the- * `apps` route. It is a `position: fixed` right column; the embed slot is- * shrunk with `padding-right` so the native WebContentsView never overlaps it.+ * `apps` route. It is a `position: fixed` right column; the drawer and the embed+ * are always docked side by side — the embed slot is permanently shrunk with+ * `padding-right` so the native WebContentsView (which paints over the DOM+ * regardless of z-index) never overlaps the drawer.** The drawer mounts a single <ChatPage> (passed as children) driven by the same* global `chatViewTabs` state as the full-screen chat route — no duplicated tabdiff --git a/desktop-app/ui/src/hooks/__tests__/useChatDrawerResize.test.ts b/desktop-app/ui/src/hooks/__tests__/useChatDrawerResize.test.tsindex eec48f714..77a1e3712 100644--- a/desktop-app/ui/src/hooks/__tests__/useChatDrawerResize.test.ts+++ b/desktop-app/ui/src/hooks/__tests__/useChatDrawerResize.test.ts@@ -1,15 +1,13 @@import { describe, expect, it } from 'vitest'-import {- CHAT_DRAWER_MIN_WIDTH,- clampWidth,- computeChatDrawerOverlay,- widthForCursor,-} from '../useChatDrawerResize'+import { CHAT_DRAWER_MIN_WIDTH, clampWidth, widthForCursor } from '../useChatDrawerResize'-// R2-M1: the drawer resize hook's pure logic (clamp, overlay flip, drag mapping)-// had no direct coverage — an inverted min/max, a flipped overlay comparison, or a-// reversed drag direction would leave every DOM-level test green. These pin the-// three pieces at their boundaries so a sign/comparison mistake turns red.+// R2-M1: the drawer resize hook's pure logic (clamp, drag mapping) had no direct+// coverage — an inverted min/max or a reversed drag direction would leave every+// DOM-level test green. These pin the pieces at their boundaries so a+// sign/comparison mistake turns red.++// EMBED_FLOOR (460) + GUTTER_EXTRA (46) = 506 reserved for the docked embed.+const EMBED_RESERVE = 506describe('clampWidth', () => {it('floors a below-minimum request at CHAT_DRAWER_MIN_WIDTH', () => {@@ -25,34 +23,36 @@ describe('clampWidth', () => {expect(clampWidth(5000, 3000)).toBe(820)})- it('tightens the dynamic max to panelWidth - margin on a narrow panel', () => {- // panelWidth 600 - VIEWPORT_MARGIN 80 = 520, below the 820 absolute ceiling.- expect(clampWidth(5000, 600)).toBe(520)- })-it('falls back to the absolute ceiling when the panel is unmeasured (<= 0)', () => {expect(clampWidth(5000, 0)).toBe(820)})})-describe('computeChatDrawerOverlay', () => {- // embedWidth = panelWidth - drawerWidth - GUTTER_EXTRA(46); overlay when < OVERLAY_EMBED_MIN(460).- it('does not overlay when the embed column is exactly at the threshold (460)', () => {- // 966 - 460 - 46 = 460 -> not below 460 -> false- expect(computeChatDrawerOverlay(966, 460)).toBe(false)- })-- it('overlays as soon as the embed column drops one pixel below the threshold', () => {- // 965 - 460 - 46 = 459 -> below 460 -> true- expect(computeChatDrawerOverlay(965, 460)).toBe(true)+describe('clampWidth embed floor (docked sizing)', () => {+ // The dynamic max reserves EMBED_FLOOR + GUTTER_EXTRA for the app embed so a+ // narrowing panel shrinks the drawer instead of collapsing the embed. This is+ // the exact function the ResizeObserver `sync` re-clamps the width with, so+ // these cases mirror the runtime re-clamp on window narrowing.+ it('caps the drawer so exactly EMBED_FLOOR (460) of embed remains as the panel narrows', () => {+ // panel 1200 - 506 = 694 (below the 820 ceiling): drawer maxes at 694,+ // leaving embed = 1200 - 694 - 46(gutter) = 460 = EMBED_FLOOR.+ const panelWidth = 1200+ const width = clampWidth(5000, panelWidth)+ expect(width).toBe(panelWidth - EMBED_RESERVE) // 694+ expect(panelWidth - width - 46).toBe(460) // embed floor preserved})- it('does not overlay on a wide panel', () => {- expect(computeChatDrawerOverlay(2000, 420)).toBe(false)+ it('re-clamps a previously-wide width down when the panel shrinks below the reserve', () => {+ // A width picked at a wide panel (e.g. 700) no longer fits once the panel is+ // 1000 wide: dynamic max = 1000 - 506 = 494, so the width is pulled to 494.+ expect(clampWidth(700, 1000)).toBe(494)})- it('overlays on a narrow panel', () => {- expect(computeChatDrawerOverlay(800, 420)).toBe(true)+ it('never shrinks the drawer below CHAT_DRAWER_MIN_WIDTH when the panel is very narrow', () => {+ // panel 700 - 506 = 194, floored back up to MIN (340). Below this the embed+ // simply keeps shrinking and scrolls; the drawer holds its minimum.+ expect(clampWidth(5000, 700)).toBe(CHAT_DRAWER_MIN_WIDTH) // 340+ expect(clampWidth(300, 700)).toBe(CHAT_DRAWER_MIN_WIDTH) // 340})})diff --git a/desktop-app/ui/src/hooks/useChatDrawerResize.ts b/desktop-app/ui/src/hooks/useChatDrawerResize.tsindex 82098ed42..22a21c1c1 100644--- a/desktop-app/ui/src/hooks/useChatDrawerResize.ts+++ b/desktop-app/ui/src/hooks/useChatDrawerResize.ts@@ -2,17 +2,27 @@ import * as React from 'react'import type { RefObject } from 'react'/**- * Session-only sizing + overlay policy for the Cursor-style chat drawer.+ * Session-only sizing for the Cursor-style chat drawer. The drawer and the app+ * embed are ALWAYS docked side by side — there is no overlay/float mode.+ *+ * The app embed is a native Electron `WebContentsView`: it paints on top of the+ * whole renderer DOM regardless of z-index. A "float the drawer over the embed"+ * mode is therefore physically impossible — the native view would simply cover+ * the drawer. So the drawer stays docked at all times, the embed lives in its+ * own column shrunk by `padding-right`, and when the embed's column gets too+ * narrow the embed scrolls horizontally within it (its own `overflow-x`) rather+ * than ever overlapping the drawer.** The width is deliberately NOT persisted (no localStorage): it resets to the* default on every launch by design. The drawer is right-docked at* `right: var(--space-4)` with a fixed right edge, so a leftward drag widens it* (`newWidth = drawerRightEdge - cursorX`) and a rightward drag narrows it.*- * When the app embed's remaining column would be squeezed below- * `OVERLAY_EMBED_MIN`, the drawer stops pushing the embed and floats over it —- * the caller drops the embed gutter and the drawer's own `position: fixed`- * z-index does the rest.+ * Docked sizing reserves a legible floor for the embed: the dynamic max width+ * is `panelWidth - EMBED_FLOOR - GUTTER_EXTRA`, so as the window narrows the+ * drawer auto-shrinks (via the ResizeObserver `sync` re-clamp) down to its own+ * minimum while keeping ~`EMBED_FLOOR`px of embed. Once the drawer hits its+ * minimum and the panel keeps shrinking, the embed simply scrolls.*//** Hard floor — below this the drawer's own chrome (composer, header, switcher)@@ -24,15 +34,16 @@ export const CHAT_DRAWER_DEFAULT_WIDTH = 420export const CHAT_DRAWER_MAX_ABSOLUTE = 820/** Width step for arrow-key resize (WAI-ARIA window-splitter pattern). */const CHAT_DRAWER_KEY_STEP = 24-/** Always leave at least this much of the content panel for the app embed, so- * even at the widest drag the embed never collapses to nothing. */-const CHAT_DRAWER_VIEWPORT_MARGIN = 80+/** Legible floor reserved for the app embed's column while docked. The drawer's+ * dynamic max width is capped so at least this much embed remains; once the+ * window is too narrow for both this floor AND the drawer's own minimum, the+ * embed keeps shrinking and scrolls via its own `overflow-x` (never overlaps+ * the drawer). Reuses the value of the removed overlay threshold. */+const CHAT_DRAWER_EMBED_FLOOR = 460/** Fixed term added beside `--chat-drawer-width` in the embed gutter, mirroring* the CSS `--app-header-utilities-width` term `var(--space-2) + 36px`* (space-2 = 10px). Kept in sync with styles.css by hand. */const CHAT_DRAWER_GUTTER_EXTRA = 46-/** Flip to overlay once the app embed column would drop below this width. */-const CHAT_DRAWER_OVERLAY_EMBED_MIN = 460/** Fallback for the drawer's fixed right edge if the element can't be measured* (`--space-4` = 18px). */const CHAT_DRAWER_RIGHT_INSET = 18@@ -41,27 +52,23 @@ function readPanelWidth(ref: RefObject<HTMLElement | null>): number {return ref.current?.clientWidth ?? 0}-/** Clamp a requested width to [MIN, dynamicMax], rounded to a whole pixel. */+/** Clamp a requested width to [MIN, dynamicMax], rounded to a whole pixel. The+ * dynamic max reserves `EMBED_FLOOR + GUTTER_EXTRA` for the docked embed so a+ * narrowing window shrinks the drawer instead of collapsing the embed. */export function clampWidth(requested: number, panelWidth: number): number {const dynamicMax =panelWidth > 0? Math.max(CHAT_DRAWER_MIN_WIDTH,- Math.min(CHAT_DRAWER_MAX_ABSOLUTE, panelWidth - CHAT_DRAWER_VIEWPORT_MARGIN)+ Math.min(+ CHAT_DRAWER_MAX_ABSOLUTE,+ panelWidth - CHAT_DRAWER_EMBED_FLOOR - CHAT_DRAWER_GUTTER_EXTRA+ )): CHAT_DRAWER_MAX_ABSOLUTEreturn Math.round(Math.max(CHAT_DRAWER_MIN_WIDTH, Math.min(dynamicMax, requested)))}-/** True when the app embed column would fall below the overlay threshold at the- * given content-panel and drawer widths — the drawer then floats over the embed- * instead of pushing it. Pure decision extracted from `recomputeOverlay` so the- * `< OVERLAY_EMBED_MIN` flip is unit-testable at the boundary. */-export function computeChatDrawerOverlay(panelWidth: number, drawerWidth: number): boolean {- const embedWidth = panelWidth - drawerWidth - CHAT_DRAWER_GUTTER_EXTRA- return embedWidth < CHAT_DRAWER_OVERLAY_EMBED_MIN-}-/** Width the drawer should take for a cursor at `pointerX`, given the drawer's* fixed right edge. Leftward drag (smaller `pointerX`) widens, rightward narrows* (`rightEdge - pointerX`); result is clamped to the panel. Extracted so the drag@@ -73,8 +80,6 @@ export function widthForCursor(rightEdge: number, pointerX: number, panelWidth:export type ChatDrawerResize = {/** Current drawer width in px (session-only state). */width: number- /** True while the drawer should float over the embed instead of pushing it. */- isOverlay: boolean/** True while a drag is in progress (for handle feedback). */isResizing: boolean/** mousedown handler for the drag handle on the drawer's left edge. */@@ -88,7 +93,6 @@ export function useChatDrawerResize(active: boolean): ChatDrawerResize {const [width, setWidth] = React.useState(CHAT_DRAWER_DEFAULT_WIDTH)- const [isOverlay, setIsOverlay] = React.useState(false)const [isResizing, setIsResizing] = React.useState(false)const widthRef = React.useRef(width)widthRef.current = width@@ -96,23 +100,10 @@ export function useChatDrawerResize(// if the drawer hides or the hook unmounts mid-drag (see below).const endDragRef = React.useRef<(() => void) | null>(null)- // `overrideWidth` lets callers decide overlay from the width they just set- // this tick instead of `widthRef.current`, which still holds the previous- // render's value (avoids a one-frame-stale overlay flip during a drag).- const recomputeOverlay = React.useCallback(- (overrideWidth?: number) => {- const panelWidth = readPanelWidth(contentPanelRef)- if (panelWidth <= 0) return- const nextWidth = overrideWidth ?? widthRef.current- setIsOverlay(computeChatDrawerOverlay(panelWidth, nextWidth))- },- [contentPanelRef]- )-- // Keep the width inside the dynamic clamp as the content panel resizes, and- // refresh the overlay decision. A ResizeObserver on the content panel also- // fires on window resize (the panel is full-height flex), so no separate- // window listener is needed.+ // Keep the width inside the dynamic clamp as the content panel resizes. A+ // ResizeObserver on the content panel also fires on window resize (the panel+ // is full-height flex), so no separate window listener is needed. As the+ // panel narrows this re-clamp shrinks the drawer to preserve the embed floor.React.useEffect(() => {if (!active) returnconst panel = contentPanelRef.current@@ -121,14 +112,13 @@ export function useChatDrawerResize(const panelWidth = readPanelWidth(contentPanelRef)const clamped = clampWidth(widthRef.current, panelWidth)setWidth(prev => (clamped === prev ? prev : clamped))- recomputeOverlay(clamped)}sync()if (typeof ResizeObserver === 'undefined') returnconst observer = new ResizeObserver(sync)observer.observe(panel)return () => observer.disconnect()- }, [active, contentPanelRef, recomputeOverlay])+ }, [active, contentPanelRef])const onResizeHandleMouseDown = React.useCallback((event: React.MouseEvent<HTMLElement>) => {@@ -148,7 +138,6 @@ export function useChatDrawerResize(const panelWidth = readPanelWidth(contentPanelRef)const next = widthForCursor(rightEdge, pointerX, panelWidth)setWidth(next)- recomputeOverlay(next)}const onMove = (moveEvent: MouseEvent) => {pointerX = moveEvent.clientX@@ -175,7 +164,7 @@ export function useChatDrawerResize(window.addEventListener('mouseup', endDrag)window.addEventListener('blur', endDrag)},- [contentPanelRef, recomputeOverlay]+ [contentPanelRef])// Keyboard resize for the focusable separator handle (WAI-ARIA window-splitter@@ -205,9 +194,8 @@ export function useChatDrawerResize(const panelWidth = readPanelWidth(contentPanelRef)const next = clampWidth(requested, panelWidth)setWidth(next)- recomputeOverlay(next)},- [contentPanelRef, recomputeOverlay]+ [contentPanelRef])// If the drawer hides or the hook unmounts while a drag is live, tear it down@@ -218,5 +206,5 @@ export function useChatDrawerResize(}, [active])React.useEffect(() => () => endDragRef.current?.(), [])- return { width, isOverlay, isResizing, onResizeHandleMouseDown, onResizeHandleKeyDown }+ return { width, isResizing, onResizeHandleMouseDown, onResizeHandleKeyDown }}diff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.cssindex ffeac21c0..8f6f8e59b 100644--- a/desktop-app/ui/src/styles.css+++ b/desktop-app/ui/src/styles.css@@ -12664,23 +12664,6 @@ pre {padding-right: 0;}-/* Overlay mode — when the embed column would be squeezed below the readable- floor, stop pushing the embed (drop the gutter, embed goes full-width) and let- the drawer float over it. `.chat-drawer` is already `position: fixed`, so- removing the gutter is all it takes; a stronger elevation reads it as floating.- Both `--chat-drawer-open` and `--chat-drawer-overlay` are present here, so this- rule must follow the docked rule above to win at equal specificity. */-.content-panel.content-panel--chat-drawer-overlay > .page:has(.sandbox-ui-mounted-header) {- padding-right: 0;-}--.content-panel.content-panel--chat-drawer-overlay .chat-drawer {- border-color: rgba(var(--edge-rgb), 0.5);- box-shadow:- var(--shadow-hard),- 0 0 0 3px rgba(var(--edge-rgb), 0.12);-}-/* The chat drawer occupies the right rail at --layer-chat-overlay, above theheader (`.top-bar` at --layer-header) within the shared content-panel stackingcontext — so the header's transient dropdowns (the notification Inbox popover,