Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(desktop-app): make the chat drawer resizable with overlay fallback
Diego Zacarias5c3b598280ed
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex ce1795c3e..525eea9d6 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -26,6 +26,7 @@ import { DESKTOP_ROUTES, SIDEBAR_COLLAPSED_KEY } from '@constants/navigation'import { THEME_STORAGE_KEY } from '@constants/theme'import { useAgentChatActionsValue } from '@hooks/useAgentChatActionsValue'import { useAppController } from '@hooks/useAppController'+import { useChatDrawerResize } from '@hooks/useChatDrawerResize'import type { ChatLocalMatch } from '@lib/chatLocalSearch'import { buildLoadedChatSemanticModels } from '@lib/chatMessageSemantics'import {@@ -521,6 +522,9 @@ 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.+ 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// visible; while the chat drawer is up it reverts to its popover/overlay form@@ -1993,7 +1997,16 @@ export function App() {appNotificationDrawerOpen? ' content-panel--app-notification-drawer-open': ''- }${chatDrawerVisible ? ' content-panel--chat-drawer-open' : ''}`}+ }${chatDrawerVisible ? ' content-panel--chat-drawer-open' : ''}${+ chatDrawerVisible && chatDrawerResize.isOverlay+ ? ' content-panel--chat-drawer-overlay'+ : ''+ }`}+ style={+ chatDrawerVisible+ ? { '--chat-drawer-width': `${chatDrawerResize.width}px` }+ : undefined+ }><AppHeadersearchFocusRequestId={globalSearchFocusRequestId}@@ -2083,6 +2096,10 @@ export function App() {onClose={closeChatDrawer}containerRef={chatDrawerRef}ready={chatDrawerReady}+ onResizeHandleMouseDown={+ chatDrawerResize.onResizeHandleMouseDown+ }+ resizing={chatDrawerResize.isResizing}><ChatPage scrollContainerRef={chatDrawerRef} /></ChatDrawer>diff --git a/desktop-app/ui/src/components/ChatDrawer/ChatDrawer.test.tsx b/desktop-app/ui/src/components/ChatDrawer/ChatDrawer.test.tsxindex b9ff44946..c218df98d 100644--- a/desktop-app/ui/src/components/ChatDrawer/ChatDrawer.test.tsx+++ b/desktop-app/ui/src/components/ChatDrawer/ChatDrawer.test.tsx@@ -6,10 +6,7 @@ import { readFileSync } from 'node:fs'import path from 'node:path'import { ChatDrawer } from '.'-const stylesheet = readFileSync(- path.join(process.cwd(), 'ui', 'src', 'styles.css'),- 'utf8'-)+const stylesheet = readFileSync(path.join(process.cwd(), 'ui', 'src', 'styles.css'), 'utf8')beforeEach(() => {const style = document.createElement('style')@@ -30,6 +27,7 @@ afterEach(() => {function renderDrawer(props: Partial<React.ComponentProps<typeof ChatDrawer>> = {}) {const onNewChat = props.onNewChat ?? vi.fn()const onClose = props.onClose ?? vi.fn()+ const onResizeHandleMouseDown = props.onResizeHandleMouseDown ?? vi.fn()const containerRef = props.containerRef ?? createRef<HTMLElement>()const utils = render(<ChatDrawer@@ -38,11 +36,13 @@ function renderDrawer(props: Partial<React.ComponentProps<typeof ChatDrawer>> =onClose={onClose}containerRef={containerRef}ready={props.ready ?? true}+ onResizeHandleMouseDown={onResizeHandleMouseDown}+ resizing={props.resizing ?? false}><div data-testid="drawer-chat-page">chat page</div></ChatDrawer>)- return { ...utils, onNewChat, onClose }+ return { ...utils, onNewChat, onClose, onResizeHandleMouseDown }}describe('ChatDrawer', () => {@@ -86,14 +86,22 @@ describe('ChatDrawer', () => {// stay anchored rightward (left: 100%+, right: auto) to render over drawer DOM// instead of being occluded by the native view. A left flip would cross the// embed rect — the confinement guards against that.- const rule = stylesheet.match(- /\.chat-drawer \.composer-reference-submenu\s*\{([^}]*)\}/- )?.[1]+ const rule = stylesheet.match(/\.chat-drawer \.composer-reference-submenu\s*\{([^}]*)\}/)?.[1]expect(rule).toBeTruthy()expect(rule).toMatch(/left:\s*calc\(100% \+ var\(--space-1\)\)/)expect(rule).toMatch(/right:\s*auto/)})+ it('exposes a left-edge resize handle that fires the drag callback on mousedown', () => {+ const { container, onResizeHandleMouseDown } = renderDrawer()+ const handle = container.querySelector('.chat-drawer__resize-handle') as HTMLElement+ expect(handle).toBeTruthy()+ expect(handle.getAttribute('aria-orientation')).toBe('vertical')+ expect(getComputedStyle(handle).cursor).toBe('col-resize')+ fireEvent.mouseDown(handle)+ expect(onResizeHandleMouseDown).toHaveBeenCalledTimes(1)+ })+it('reveals once ready', () => {const { container } = renderDrawer({ ready: true })const drawer = container.querySelector('.chat-drawer') as HTMLElementdiff --git a/desktop-app/ui/src/components/ChatDrawer/index.tsx b/desktop-app/ui/src/components/ChatDrawer/index.tsxindex e32aaacb2..753eecbc3 100644--- a/desktop-app/ui/src/components/ChatDrawer/index.tsx+++ b/desktop-app/ui/src/components/ChatDrawer/index.tsx@@ -17,14 +17,23 @@ export function ChatDrawer({onClose,containerRef,ready,+ onResizeHandleMouseDown,+ resizing,children,}: ChatDrawerProps) {return (<aside- className={`chat-drawer${ready ? ' is-ready' : ''}`}+ className={`chat-drawer${ready ? ' is-ready' : ''}${resizing ? ' is-resizing' : ''}`}aria-label="Chat"data-ready={ready ? 'true' : 'false'}>+ <div+ className="chat-drawer__resize-handle"+ role="separator"+ aria-orientation="vertical"+ aria-label="Resize chat drawer"+ onMouseDown={onResizeHandleMouseDown}+ /><header className="chat-drawer__header"><div className="chat-drawer__header-main">{header}</div><div className="chat-drawer__header-actions">diff --git a/desktop-app/ui/src/components/ChatDrawer/types.ts b/desktop-app/ui/src/components/ChatDrawer/types.tsindex 6bed6bfa5..1f04046c4 100644--- a/desktop-app/ui/src/components/ChatDrawer/types.ts+++ b/desktop-app/ui/src/components/ChatDrawer/types.ts@@ -1,4 +1,4 @@-import type { ReactNode, RefObject } from 'react'+import type { MouseEvent as ReactMouseEvent, ReactNode, RefObject } from 'react'export type ChatDrawerProps = {/**@@ -16,5 +16,12 @@ export type ChatDrawerProps = {* bounds-ack anti-flash gate.*/ready: boolean+ /**+ * mousedown handler for the left-edge drag handle that resizes the drawer.+ * Wired from `useChatDrawerResize`.+ */+ onResizeHandleMouseDown: (event: ReactMouseEvent<HTMLElement>) => void+ /** True while a resize drag is in progress — highlights the drag handle. */+ resizing: booleanchildren: ReactNode}diff --git a/desktop-app/ui/src/global.d.ts b/desktop-app/ui/src/global.d.tsindex e2be24b80..3f9fe9eaa 100644--- a/desktop-app/ui/src/global.d.ts+++ b/desktop-app/ui/src/global.d.ts@@ -19,6 +19,9 @@ declare module 'react' {interface CSSProperties {/** Column template for `.da-grid` (consumed by `.da-grid__head` / `.da-grid__row`). */'--da-grid-cols'?: string+ /** Session-only chat-drawer width, set inline on `.content-panel` and read by+ * `.chat-drawer` + its embed gutter (see `useChatDrawerResize`). */+ '--chat-drawer-width'?: string}}diff --git a/desktop-app/ui/src/hooks/useChatDrawerResize.ts b/desktop-app/ui/src/hooks/useChatDrawerResize.tsnew file mode 100644index 000000000..274e5f5a4--- /dev/null+++ b/desktop-app/ui/src/hooks/useChatDrawerResize.ts@@ -0,0 +1,170 @@+import * as React from 'react'+import type { RefObject } from 'react'++/**+ * Session-only sizing + overlay policy for the Cursor-style chat 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.+ */++/** Hard floor — below this the drawer's own chrome (composer, header, switcher)+ * starts to overflow. Also the minimum the resize drag can reach. */+export const CHAT_DRAWER_MIN_WIDTH = 340+/** Default session width (matches the top of the old CSS clamp). */+export const CHAT_DRAWER_DEFAULT_WIDTH = 420+/** Generous absolute ceiling for the drag. */+const CHAT_DRAWER_MAX_ABSOLUTE = 820+/** 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+/** 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++function readPanelWidth(ref: RefObject<HTMLElement | null>): number {+ return ref.current?.clientWidth ?? 0+}++/** Clamp a requested width to [MIN, dynamicMax], rounded to a whole pixel. */+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)+ )+ : CHAT_DRAWER_MAX_ABSOLUTE+ return Math.round(Math.max(CHAT_DRAWER_MIN_WIDTH, Math.min(dynamicMax, requested)))+}++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. */+ onResizeHandleMouseDown: (event: React.MouseEvent<HTMLElement>) => void+}++export function useChatDrawerResize(+ contentPanelRef: RefObject<HTMLElement | null>,+ 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+ // Teardown of an in-progress drag, stored so a cleanup effect can invoke it+ // 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+ const embedWidth = panelWidth - nextWidth - CHAT_DRAWER_GUTTER_EXTRA+ setIsOverlay(embedWidth < CHAT_DRAWER_OVERLAY_EMBED_MIN)+ },+ [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.+ React.useEffect(() => {+ if (!active) return+ const panel = contentPanelRef.current+ if (!panel) return+ const sync = () => {+ const panelWidth = readPanelWidth(contentPanelRef)+ const clamped = clampWidth(widthRef.current, panelWidth)+ setWidth(prev => (clamped === prev ? prev : clamped))+ recomputeOverlay(clamped)+ }+ sync()+ if (typeof ResizeObserver === 'undefined') return+ const observer = new ResizeObserver(sync)+ observer.observe(panel)+ return () => observer.disconnect()+ }, [active, contentPanelRef, recomputeOverlay])++ const onResizeHandleMouseDown = React.useCallback(+ (event: React.MouseEvent<HTMLElement>) => {+ event.preventDefault()+ // The drawer's right edge is fixed while docked; measure it once from the+ // live element (robust to any transformed ancestor) so the width tracks+ // `rightEdge - cursorX` for the whole drag.+ const drawerEl = event.currentTarget.closest('.chat-drawer')+ const rightEdge = drawerEl+ ? drawerEl.getBoundingClientRect().right+ : window.innerWidth - CHAT_DRAWER_RIGHT_INSET++ let frame = 0+ let pointerX = event.clientX+ const apply = () => {+ frame = 0+ const panelWidth = readPanelWidth(contentPanelRef)+ const next = clampWidth(rightEdge - pointerX, panelWidth)+ setWidth(next)+ recomputeOverlay(next)+ }+ const onMove = (moveEvent: MouseEvent) => {+ pointerX = moveEvent.clientX+ if (!frame) frame = window.requestAnimationFrame(apply)+ }+ // Idempotent teardown. Also runs on `blur` (mouse released outside the+ // window never fires `mouseup`) and from the cleanup effect below.+ const endDrag = () => {+ if (endDragRef.current !== endDrag) return+ if (frame) window.cancelAnimationFrame(frame)+ window.removeEventListener('mousemove', onMove)+ window.removeEventListener('mouseup', endDrag)+ window.removeEventListener('blur', endDrag)+ document.body.style.userSelect = ''+ document.body.style.cursor = ''+ endDragRef.current = null+ setIsResizing(false)+ }+ endDragRef.current = endDrag+ document.body.style.userSelect = 'none'+ document.body.style.cursor = 'col-resize'+ setIsResizing(true)+ window.addEventListener('mousemove', onMove)+ window.addEventListener('mouseup', endDrag)+ window.addEventListener('blur', endDrag)+ },+ [contentPanelRef, recomputeOverlay]+ )++ // If the drawer hides or the hook unmounts while a drag is live, tear it down+ // so window listeners and the body cursor/user-select overrides never leak.+ React.useEffect(() => {+ if (active) return+ endDragRef.current?.()+ }, [active])+ React.useEffect(() => () => endDragRef.current?.(), [])++ return { width, isOverlay, isResizing, onResizeHandleMouseDown }+}diff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.cssindex 250736258..c74034ab3 100644--- a/desktop-app/ui/src/styles.css+++ b/desktop-app/ui/src/styles.css@@ -2159,6 +2159,11 @@ h3 {.content-panel {--app-notification-drawer-width: clamp(280px, 42vw, 420px);--app-header-utilities-width: calc(var(--app-notification-drawer-width) + var(--space-2) + 36px);+ /* Chat drawer owns its own width, decoupled from the notification drawer.+ React sets `--chat-drawer-width` inline (session-only, drag-resizable); this+ clamp is only the pre-mount / closed-state fallback. Floor 340px == the+ drawer's min-width (see useChatDrawerResize). */+ --chat-drawer-width: clamp(340px, 32vw, 420px);height: 100vh;min-height: 0;@@ -12536,10 +12541,16 @@ pre {padding-left: var(--space-4);}-/* Chat drawer — Cursor-style chat column beside the live app embed. Reuses the- notification drawer's rect-shrink gutter (padding-right on the embed slot's- page) so the native WebContentsView shrinks to sit left of the drawer instead- of painting over it. */+/* 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`)+ so resizing the chat drawer never disturbs the notification drawer. The two+ drawer-open states are mutually exclusive (see App.tsx notificationTrayUsesDrawer),+ so this higher-specificity override is unambiguous. */+.content-panel.content-panel--chat-drawer-open {+ --app-header-utilities-width: calc(var(--chat-drawer-width) + var(--space-2) + 36px);+}+.content-panel.content-panel--chat-drawer-open > .page:has(.sandbox-ui-mounted-header) {padding-right: var(--app-header-utilities-width);}@@ -12548,6 +12559,23 @@ 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,@@ -12564,7 +12592,7 @@ pre {top: calc(var(--space-4) + 36px + var(--space-2));right: var(--space-4);bottom: var(--space-4);- width: var(--app-notification-drawer-width);+ width: var(--chat-drawer-width);z-index: var(--layer-chat-overlay);display: flex;flex-direction: column;@@ -12585,6 +12613,74 @@ pre {pointer-events: auto;}+/* Drag handle on the drawer's LEFT edge. A comfortable ~8px grab strip with a+ slim accent rule that surfaces on hover / during a drag. Sits inside the+ drawer (which clips overflow), above the header/surface content. */+.chat-drawer__resize-handle {+ position: absolute;+ top: 0;+ left: 0;+ width: 8px;+ height: 100%;+ z-index: 2;+ cursor: col-resize;+ background: transparent;+ touch-action: none;+}++.chat-drawer__resize-handle::after {+ content: '';+ position: absolute;+ top: 0;+ left: 0;+ width: 2px;+ height: 100%;+ background: transparent;+ transition: background var(--motion-fast);+}++.chat-drawer__resize-handle:hover::after,+.chat-drawer.is-resizing .chat-drawer__resize-handle::after {+ background: rgba(var(--accent-rgb), 0.55);+}++/* Compact chrome — narrow-column only. Scoped entirely under `.chat-drawer`, so+ the full-screen chat route (which renders the same <ChatPage> OUTSIDE this+ ancestor) is untouched. Trims the padding/margins that read as "loose" in the+ slim column and neutralizes the full-height grid the workspace uses in+ full-screen (which would overflow this fixed rail and leave odd gaps). */+.chat-drawer .agent-page {+ height: 100%;+}++.chat-drawer .agent-workspace-shell .chat-thread {+ padding: var(--space-2);+}++.chat-drawer .agent-workspace-shell .chat-empty-state {+ padding: var(--space-4) 0 var(--space-2);+}++.chat-drawer .agent-workspace-shell .agent-workspace-top {+ padding: var(--space-1) var(--space-2);+}++.chat-drawer .agent-workspace-shell .agent-workspace-tabs {+ padding: 0 var(--space-2);+}++.chat-drawer .composer {+ margin-top: var(--space-1);+ padding: var(--space-2);+}++/* Tighter table cells so the data table breathes in the slim column; the+ `.da-table__scroll` horizontal overflow still handles anything too wide. */+.chat-drawer .da-table {+ --table-cell-padding-x: var(--space-1-5);+ --table-cell-padding-y: var(--space-1);+}+.chat-drawer__header {display: flex;align-items: center;