Skip to content

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

TypeScript

feat(desktop): make chat drawer close a toggle and add full-screen CTA

Diego Zacarias3923878058dd
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsx
index 3325e1679..0bda41b5f 100644
--- a/desktop-app/ui/src/App.tsx
+++ b/desktop-app/ui/src/App.tsx
@@ -460,6 +460,17 @@ export function App() {
}
}, [closeChatDrawer, openChatDrawer])
+ const expandChatDrawerToFullScreen = React.useCallback(() => {
+ // Ejects the drawer's active conversation into the full-screen chat route.
+ // `revealChatViewTab(_, false)` forces the non-drawer branch: it tears the
+ // live embed down and navigates to the chat route. Reset the open intent so a
+ // stale `chatDrawerOpen` doesn't linger now that the drawer is gone (a later
+ // app launch from a chat re-sets it explicitly).
+ revealChatViewTab(activeChatViewTab(chatViewTabsRef.current), false)
+ setChatDrawerOpen(false)
+ setComposerFocusRequestId(value => value + 1)
+ }, [revealChatViewTab])
+
// minispec 04 approach C: while the app embed is live, an "open conversation"
// gesture (notification / approval) must surface the chat IN the drawer — open
// the drawer and pass `keepNavItem` so the vm swaps the shared <ChatPage>
@@ -2166,7 +2177,8 @@ export function App() {
/>
}
onNewChat={handleNewChatViewTab}
- onClose={closeChatDrawer}
+ onExpandFullScreen={expandChatDrawerToFullScreen}
+ onToggle={toggleChatDrawer}
containerRef={chatDrawerRef}
ready={chatDrawerReady}
onResizeHandleMouseDown={
diff --git a/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx b/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx
index fbe3d2083..61e11a132 100644
--- a/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx
+++ b/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx
@@ -271,6 +271,52 @@ describe('App chat drawer — reopen preserves the last-viewed chat', () => {
expect(screen.getByRole('button', { name: 'Open chats' }).textContent).toContain('Second chat')
})
+ // The header's "Open chat in full screen" CTA must EJECT the drawer's active
+ // conversation to the full-screen chat route — the non-drawer branch of
+ // revealChatViewTab (leaveSandboxForChat + a selection WITHOUT keepNavItem),
+ // not the in-drawer swap. Assert the observable result: navItem lands on the
+ // chat route and the drawer (its collapse CTA) is gone.
+ it('ejects the drawer conversation to the full-screen chat route on "Open chat in full screen"', () => {
+ currentController = makeController({
+ selectedAgent: 'alpha',
+ activeChatId: 'chat-1',
+ navItem: DESKTOP_ROUTES.chat,
+ chatList: CHAT_LIST,
+ } as Partial<AppController>)
+ render(<App />)
+
+ // Launch from chat-1: the drawer opens over the live embed on the apps route.
+ act(() => {
+ sidebarHarness.props?.onOpenSandboxUiApp?.({
+ appRef: 'ns/app',
+ label: 'App',
+ defaultPath: '/',
+ })
+ })
+ expect(sandboxUiPageHarness.props?.chatDrawerOpen).toBe(true)
+ expect(currentController.navItem).toBe(DESKTOP_ROUTES.apps)
+ expect(screen.getByRole('button', { name: 'Collapse chat drawer' })).toBeTruthy()
+
+ // Ignore the selection the launch itself performed; assert only on the CTA.
+ vi.mocked(currentController.handleSelectChatAgent).mockClear()
+
+ act(() => fireEvent.click(screen.getByRole('button', { name: 'Open chat in full screen' })))
+
+ // Ejected: navItem flips to the full-screen chat route. The mock only flips
+ // navItem when the selection omits keepNavItem, so this pins the non-drawer
+ // (eject) branch — contrast the in-drawer composer.focus case above.
+ expect(currentController.navItem).toBe(DESKTOP_ROUTES.chat)
+ expect(currentController.handleSelectChatAgent).toHaveBeenLastCalledWith(
+ 'alpha',
+ expect.objectContaining({ chatId: 'chat-1' })
+ )
+ expect(
+ vi.mocked(currentController.handleSelectChatAgent).mock.calls.at(-1)?.[1]?.keepNavItem
+ ).not.toBe(true)
+ // The drawer unmounts once the embed is torn down: its collapse CTA is gone.
+ expect(screen.queryByRole('button', { name: 'Collapse chat drawer' })).toBeNull()
+ })
+
// The drawer's not-ready subtree is `inert`, and a `focus()` fired inside an
// inert subtree is a silent no-op. So the `chat.switcher` shortcut (which opens
// the drawer, then opens+focuses the switcher) must defer the open until the
diff --git a/desktop-app/ui/src/components/ChatDrawer/ChatDrawer.test.tsx b/desktop-app/ui/src/components/ChatDrawer/ChatDrawer.test.tsx
index 9aec4b516..7218b2d09 100644
--- a/desktop-app/ui/src/components/ChatDrawer/ChatDrawer.test.tsx
+++ b/desktop-app/ui/src/components/ChatDrawer/ChatDrawer.test.tsx
@@ -26,7 +26,8 @@ afterEach(() => {
function renderDrawer(props: Partial<React.ComponentProps<typeof ChatDrawer>> = {}) {
const onNewChat = props.onNewChat ?? vi.fn()
- const onClose = props.onClose ?? vi.fn()
+ const onToggle = props.onToggle ?? vi.fn()
+ const onExpandFullScreen = props.onExpandFullScreen ?? vi.fn()
const onResizeHandleMouseDown = props.onResizeHandleMouseDown ?? vi.fn()
const onResizeHandleKeyDown = props.onResizeHandleKeyDown ?? vi.fn()
const containerRef = props.containerRef ?? createRef<HTMLElement>()
@@ -34,7 +35,8 @@ function renderDrawer(props: Partial<React.ComponentProps<typeof ChatDrawer>> =
<ChatDrawer
header={props.header ?? <span className="chat-drawer__title">Drawer chat</span>}
onNewChat={onNewChat}
- onClose={onClose}
+ onExpandFullScreen={onExpandFullScreen}
+ onToggle={onToggle}
containerRef={containerRef}
ready={props.ready ?? true}
onResizeHandleMouseDown={onResizeHandleMouseDown}
@@ -45,7 +47,14 @@ function renderDrawer(props: Partial<React.ComponentProps<typeof ChatDrawer>> =
<div data-testid="drawer-chat-page">chat page</div>
</ChatDrawer>
)
- return { ...utils, onNewChat, onClose, onResizeHandleMouseDown, onResizeHandleKeyDown }
+ return {
+ ...utils,
+ onNewChat,
+ onExpandFullScreen,
+ onToggle,
+ onResizeHandleMouseDown,
+ onResizeHandleKeyDown,
+ }
}
describe('ChatDrawer', () => {
@@ -54,21 +63,24 @@ describe('ChatDrawer', () => {
expect(screen.getByText('Drawer chat')).toBeTruthy()
expect(screen.getByTestId('drawer-chat-page')).toBeTruthy()
expect(screen.getByRole('button', { name: 'New chat' })).toBeTruthy()
- expect(screen.getByRole('button', { name: 'Close chat drawer' })).toBeTruthy()
+ expect(screen.getByRole('button', { name: 'Open chat in full screen' })).toBeTruthy()
+ expect(screen.getByRole('button', { name: 'Collapse chat drawer' })).toBeTruthy()
})
- it('wires the new-chat and close actions', () => {
- const { onNewChat, onClose } = renderDrawer()
+ it('wires the new-chat, full-screen, and collapse actions', () => {
+ const { onNewChat, onExpandFullScreen, onToggle } = renderDrawer()
fireEvent.click(screen.getByRole('button', { name: 'New chat' }))
- fireEvent.click(screen.getByRole('button', { name: 'Close chat drawer' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Open chat in full screen' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Collapse chat drawer' }))
expect(onNewChat).toHaveBeenCalledTimes(1)
- expect(onClose).toHaveBeenCalledTimes(1)
+ expect(onExpandFullScreen).toHaveBeenCalledTimes(1)
+ expect(onToggle).toHaveBeenCalledTimes(1)
})
it('sizes the header CTA icons to the app standard (16px), not the raw viewBox', () => {
const { container } = renderDrawer()
const svgs = container.querySelectorAll('.chat-drawer__header-actions .ui-icon-button svg')
- expect(svgs.length).toBe(2)
+ expect(svgs.length).toBe(3)
svgs.forEach(svg => {
expect(getComputedStyle(svg as Element).width).toBe('16px')
expect(getComputedStyle(svg as Element).height).toBe('16px')
diff --git a/desktop-app/ui/src/components/ChatDrawer/index.tsx b/desktop-app/ui/src/components/ChatDrawer/index.tsx
index 0b48f85dd..53e5b708a 100644
--- a/desktop-app/ui/src/components/ChatDrawer/index.tsx
+++ b/desktop-app/ui/src/components/ChatDrawer/index.tsx
@@ -1,5 +1,5 @@
import { IconButton } from '@components/Common'
-import { IconClose, IconNewChat } from '@components/SidebarNav/icons'
+import { IconMaximize, IconNewChat, IconPanelRightClose } from '@components/SidebarNav/icons'
import { CHAT_DRAWER_MAX_ABSOLUTE, CHAT_DRAWER_MIN_WIDTH } from '@hooks/useChatDrawerResize'
import type { ChatDrawerProps } from './types'
@@ -17,7 +17,8 @@ import type { ChatDrawerProps } from './types'
export function ChatDrawer({
header,
onNewChat,
- onClose,
+ onExpandFullScreen,
+ onToggle,
containerRef,
ready,
onResizeHandleMouseDown,
@@ -67,11 +68,21 @@ export function ChatDrawer({
color="neutral"
variant="ghost"
size="sm"
- label="Close chat drawer"
- title="Close chat drawer"
- onClick={onClose}
+ label="Open chat in full screen"
+ title="Open chat in full screen"
+ onClick={onExpandFullScreen}
>
- <IconClose />
+ <IconMaximize />
+ </IconButton>
+ <IconButton
+ color="neutral"
+ variant="ghost"
+ size="sm"
+ label="Collapse chat drawer"
+ title="Collapse chat drawer"
+ onClick={onToggle}
+ >
+ <IconPanelRightClose />
</IconButton>
</div>
</header>
diff --git a/desktop-app/ui/src/components/ChatDrawer/types.ts b/desktop-app/ui/src/components/ChatDrawer/types.ts
index 15cdf3087..31476842c 100644
--- a/desktop-app/ui/src/components/ChatDrawer/types.ts
+++ b/desktop-app/ui/src/components/ChatDrawer/types.ts
@@ -12,7 +12,10 @@ export type ChatDrawerProps = {
*/
header: ReactNode
onNewChat: () => void
- onClose: () => void
+ /** Toggles the drawer. In this header it only ever collapses it — the reopen control lives on the embed title bar. */
+ onToggle: () => void
+ /** Ejects the visible conversation into the full-screen chat route. */
+ onExpandFullScreen: () => void
/** Scroll container the embedded <ChatPage> anchors to. */
containerRef: RefObject<HTMLElement | null>
/**
diff --git a/desktop-app/ui/src/components/SidebarNav/icons.tsx b/desktop-app/ui/src/components/SidebarNav/icons.tsx
index 3177dc6ba..f7a1ea174 100644
--- a/desktop-app/ui/src/components/SidebarNav/icons.tsx
+++ b/desktop-app/ui/src/components/SidebarNav/icons.tsx
@@ -256,6 +256,32 @@ export function IconChat(props: IconProps) {
)
}
+// "Open chat in full screen" — maximize (corner arrows) glyph. Ejects the
+// drawer's conversation into the full-screen chat tab.
+export function IconMaximize(props: IconProps) {
+ return (
+ <svg viewBox="0 0 24 24" aria-hidden="true" {...BASE_STROKE_PROPS} {...props}>
+ <path d="M8 3H5a2 2 0 0 0-2 2v3" />
+ <path d="M21 8V5a2 2 0 0 0-2-2h-3" />
+ <path d="M3 16v3a2 2 0 0 0 2 2h3" />
+ <path d="M16 21h3a2 2 0 0 0 2-2v-3" />
+ </svg>
+ )
+}
+
+// "Collapse chat drawer" — panel-right-close glyph. The drawer's own toggle;
+// it is only visible while the drawer is open, so it always collapses it (the
+// reopen affordance lives on the sandbox-ui embed's title bar).
+export function IconPanelRightClose(props: IconProps) {
+ return (
+ <svg viewBox="0 0 24 24" aria-hidden="true" {...BASE_STROKE_PROPS} {...props}>
+ <rect width="18" height="18" x="3" y="3" rx="2" />
+ <path d="M15 3v18" />
+ <path d="m8 9 3 3-3 3" />
+ </svg>
+ )
+}
+
export function IconMoreHorizontal(props: IconProps) {
return (
<svg viewBox="0 0 24 24" aria-hidden="true" {...BASE_STROKE_PROPS} {...props}>