Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop-ui): round-4 #1 divert new-chat/notification only to a valid drawer
Diego Zacariasbbbab008f634
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex c589f088b..4421d58cf 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -292,10 +292,13 @@ export function App() {// callbacks) can tell whether a reveal should target the in-app drawer or the// full-screen chat route without re-binding on every render.const chatDrawerVisibleRef = React.useRef(false)- // Mirrors `chatDrawerAvailable` (app live on the apps route): whenever the app- // is in the foreground, "new chat" must open a blank tab in the drawer instead- // of tearing the live embed down — even when the drawer is currently closed.- const chatDrawerAvailableRef = React.useRef(false)+ // Mirrors `chatDrawerDivertable`: the drawer is a VALID surface to divert a+ // gesture into only when the app is live AND the panel is wide enough to render+ // it. Below the minimum width the drawer is suppressed, so "new chat" /+ // notification gestures must fall back to the full-screen chat route instead of+ // landing in a hidden drawer (an unreachable chat). Read from stable callbacks,+ // hence a ref.+ const chatDrawerDivertableRef = React.useRef(false)// Set when `chat.switcher` fires with the drawer still closed: the switcher is// not mounted yet, so we open the drawer and defer the focus bump until its// column commits.@@ -399,12 +402,16 @@ export function App() {const handleNewChatViewTab = React.useCallback(() => {const next = addBlankChatViewTab(chatViewTabsRef.current, nextChatTabId(), vm.selectedAgent)setChatViewTabs(next)- if (chatDrawerAvailableRef.current) {- // App in foreground: open the blank chat in the drawer, never tear the- // live embed down (spec §5.3). Opens the drawer if it was closed.+ if (chatDrawerDivertableRef.current) {+ // Drawer is a valid surface (app live, panel wide enough): open the blank+ // chat in the drawer without tearing the live embed down. Opens the drawer+ // if it was closed.setChatDrawerOpen(true)revealChatViewTab(activeChatViewTab(next), true)} else {+ // No divertable drawer (no app live, or the panel is too narrow to render+ // one): fall back to the full-screen chat route so the new chat is reachable+ // instead of landing in a suppressed drawer.revealChatViewTab(activeChatViewTab(next))}setComposerFocusRequestId(value => value + 1)@@ -462,7 +469,7 @@ export function App() {(...args: Parameters<typeof vm.handleOpenNotification>) => {const [notification, options] = argsconst surfacesInDrawer =- chatDrawerAvailableRef.current &&+ chatDrawerDivertableRef.current &¬ification.kind !== 'workflow_completed' &¬ification.kind !== 'sdk_notification' &&// Mirror the controller's `if (!targetAgent) return`: an agent-less@@ -549,8 +556,14 @@ export function App() {// not persisted by design; it resets to the default each launch.const chatDrawerResize = useChatDrawerResize(contentPanelRef, chatDrawerDesired)const chatDrawerVisible = chatDrawerDesired && !chatDrawerResize.panelTooNarrow+ // Can a gesture be diverted INTO the drawer right now? Only if it is a valid+ // surface: app live AND wide enough to render. Kept SEPARATE from the hook's+ // `active` input on purpose — folding `!panelTooNarrow` into `chatDrawerAvailable`+ // or `chatDrawerDesired` would stop the ResizeObserver from observing the+ // re-widen, turning "suppressed" into "never returns".+ const chatDrawerDivertable = chatDrawerAvailable && !chatDrawerResize.panelTooNarrowchatDrawerVisibleRef.current = chatDrawerVisible- chatDrawerAvailableRef.current = chatDrawerAvailable+ chatDrawerDivertableRef.current = chatDrawerDivertable// 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 formdiff --git a/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx b/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsxindex 0676e1dfd..4dc0ef75d 100644--- a/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx+++ b/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx@@ -768,6 +768,59 @@ describe('App chat drawer — narrow-width suppression (mini-spec 05)', () => {expect(screen.queryByRole('button', { name: 'Open chats' })).toBeNull()})+ // Repro of round-4 #1: below the minimum panel width the drawer is suppressed+ // (correctly — there is no room to dock it beside the embed). A `Mod+T` new-chat+ // gesture must therefore fall back to the full-screen chat route, NOT be diverted+ // into the hidden drawer — which would create a chat no surface can reach. The+ // divert decision keys off `chatDrawerDivertable` (available && !panelTooNarrow),+ // not `chatDrawerAvailable`, so at a narrow width the gesture ejects to chat.+ it('routes a new-chat gesture to full-screen chat when the panel is too narrow to dock the drawer', () => {+ let commandCb: ((commandId: string, source: string) => void) | null = null+ Object.defineProperty(window, 'clerum', {+ configurable: true,+ value: {+ shortcuts: {+ onCommand: vi.fn((cb: (commandId: string, source: string) => void) => {+ commandCb = cb+ return vi.fn()+ }),+ },+ app: { rendererReady: vi.fn().mockResolvedValue(undefined) },+ sandboxUi: {+ listApps: vi.fn().mockResolvedValue({ apps: [] }),+ listPendingDeepLinks: vi.fn().mockResolvedValue({ links: [] }),+ clearPendingDeepLinks: vi.fn().mockResolvedValue(undefined),+ onDeepLink: vi.fn(() => vi.fn()),+ setVisible: vi.fn().mockResolvedValue(undefined),+ setBounds: vi.fn().mockResolvedValue(undefined),+ focusActive: vi.fn().mockResolvedValue(true),+ close: vi.fn().mockResolvedValue(undefined),+ },+ } as unknown as Window['clerum'],+ })++ render(<App />)++ // Launch the app (drawer available), then narrow the panel below 846 so the+ // drawer is suppressed: app is live, but the drawer is not a divertable surface.+ act(() => {+ sidebarHarness.props?.onOpenSandboxUiApp?.({+ appRef: 'ns/app',+ label: 'App',+ defaultPath: '/',+ })+ })+ resizeTo(800)+ expect(sandboxUiPageHarness.props?.chatDrawerOpen).toBe(false)+ expect(currentController.navItem).toBe(DESKTOP_ROUTES.apps)++ // Mod+T: the new chat must land on the full-screen chat route (reachable),+ // not in the suppressed drawer (orphaned).+ act(() => commandCb?.('chat.newTab', 'shortcut-host'))++ expect(currentController.navItem).toBe(DESKTOP_ROUTES.chat)+ })+it('publishes --chat-drawer-top from the measured embed slot, falling back until measured', () => {render(<App />)