Skip to content

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

TypeScript

fix(desktop): r3-m3 connect active tab to chat workspace

Josué40dca2152068
diff --git a/desktop-app/package.json b/desktop-app/package.json
index b76db7d60..e341d9fac 100644
--- a/desktop-app/package.json
+++ b/desktop-app/package.json
@@ -16,6 +16,7 @@
"test:e2e:playwright": "npm run build && playwright test --config test/e2e-playwright/playwright.config.ts",
"test:native:sandbox-find": "npm run build:main --silent && node ./scripts/run-native-sandbox-find.mjs",
"test:native:sandbox-shortcut-focus": "npm run build:main --silent && node ./scripts/run-native-sandbox-shortcut-focus.mjs",
+ "test:native:chat-workspace-geometry": "node ./scripts/run-native-chat-workspace-geometry.mjs",
"qa:recorder:auth": "npm run build && playwright test --config test/e2e-playwright/playwright.qa-recorder.config.ts qa-recorder-auth.spec.ts",
"qa:recorder:navigation": "npm run build && playwright test --config test/e2e-playwright/playwright.qa-recorder.config.ts qa-recorder-navigation.spec.ts",
"qa:recorder:agents": "npm run build && playwright test --config test/e2e-playwright/playwright.qa-recorder.config.ts qa-recorder-agents.spec.ts",
diff --git a/desktop-app/scripts/run-native-chat-workspace-geometry.mjs b/desktop-app/scripts/run-native-chat-workspace-geometry.mjs
new file mode 100644
index 000000000..85f278d7d
--- /dev/null
+++ b/desktop-app/scripts/run-native-chat-workspace-geometry.mjs
@@ -0,0 +1,19 @@
+import electronPath from 'electron'
+import { spawn } from 'node:child_process'
+
+const childEnvironment = { ...process.env }
+delete childEnvironment.ELECTRON_RUN_AS_NODE
+
+const child = spawn(electronPath, ['./test/native/chat-workspace-geometry.fixture.cjs'], {
+ cwd: new URL('..', import.meta.url),
+ env: childEnvironment,
+ stdio: 'inherit',
+})
+
+child.on('error', error => {
+ console.error(error)
+ process.exitCode = 1
+})
+child.on('exit', code => {
+ process.exitCode = code ?? 1
+})
diff --git a/desktop-app/test/native/chat-workspace-geometry.fixture.cjs b/desktop-app/test/native/chat-workspace-geometry.fixture.cjs
new file mode 100644
index 000000000..f3b177f81
--- /dev/null
+++ b/desktop-app/test/native/chat-workspace-geometry.fixture.cjs
@@ -0,0 +1,87 @@
+const assert = require('node:assert/strict')
+const { readFileSync } = require('node:fs')
+const path = require('node:path')
+const { app, BrowserWindow } = require('electron')
+
+function tab(title, active = false) {
+ return `<div class="chat-view-tab${active ? ' is-active' : ''}">
+ <button class="ui-button chat-view-tab__select"><span class="chat-view-tab__label">${title}</span></button>
+ <button class="ui-button chat-view-tab__close" aria-label="Close ${title}">×</button>
+ </div>`
+}
+
+async function geometry(window) {
+ return window.webContents.executeJavaScript(`(() => {
+ const workspace = document.querySelector('.chat-view-workspace').getBoundingClientRect()
+ const tabs = document.querySelector('.chat-view-tabs').getBoundingClientRect()
+ const active = document.querySelector('.chat-view-tab.is-active').getBoundingClientRect()
+ const list = document.querySelector('.chat-view-tabs__list')
+ const surface = document.querySelector('.chat-view-surface').getBoundingClientRect()
+ const surfaceStyle = getComputedStyle(document.querySelector('.chat-view-surface'))
+ const activeStyle = getComputedStyle(document.querySelector('.chat-view-tab.is-active'))
+ return {
+ activeBottom: active.bottom,
+ activeBorderTop: activeStyle.borderTopColor,
+ listClientWidth: list.clientWidth,
+ listOverflowX: getComputedStyle(list).overflowX,
+ listScrollWidth: list.scrollWidth,
+ surfaceBorderTop: surfaceStyle.borderTopColor,
+ surfaceTop: surface.top,
+ surfaceWidth: surface.width,
+ tabsBottom: tabs.bottom,
+ workspaceWidth: workspace.width,
+ }
+ })()`)
+}
+
+app.whenReady().then(async () => {
+ const window = new BrowserWindow({ show: true, x: -10000, y: -10000, width: 1000, height: 700 })
+ try {
+ const css = readFileSync(path.join(__dirname, '../../ui/src/styles.css'), 'utf8')
+ const html = `<!doctype html><style>${css}</style>
+ <main style="width:100%;height:600px">
+ <section class="chat-view-workspace">
+ <div class="chat-view-tabs" role="toolbar"><div class="chat-view-tabs__list">
+ ${tab('First chat', true)}
+ ${tab('A long second conversation title')}
+ ${tab('A long third conversation title')}
+ ${tab('A long fourth conversation title')}
+ </div></div>
+ <section class="chat-view-surface">
+ <div class="current-content-search">Current chat find</div>
+ <div class="chat-view-surface__content">Active chat</div>
+ </section>
+ </section>
+ </main>`
+ await window.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html)}`)
+
+ const wide = await geometry(window)
+ assert.ok(
+ Math.abs(wide.surfaceWidth - wide.workspaceWidth) <= 1,
+ 'wide surface stays full width'
+ )
+ assert.ok(wide.surfaceTop <= wide.activeBottom + 1, 'active tab meets the selected surface')
+ assert.equal(
+ wide.activeBorderTop,
+ wide.surfaceBorderTop,
+ 'tab and surface share accent treatment'
+ )
+
+ window.setSize(420, 700)
+ await new Promise(resolve => setTimeout(resolve, 50))
+ const narrow = await geometry(window)
+ assert.equal(narrow.listOverflowX, 'auto', 'only the tab list owns horizontal overflow')
+ assert.ok(narrow.listScrollWidth > narrow.listClientWidth, 'long narrow tabs remain scrollable')
+ assert.ok(
+ Math.abs(narrow.surfaceWidth - narrow.workspaceWidth) <= 1,
+ 'narrow surface stays full width'
+ )
+ assert.ok(narrow.surfaceTop <= narrow.activeBottom + 1, 'narrow active tab keeps its seam')
+
+ console.log('chat workspace native geometry fixture: PASS')
+ app.exit(0)
+ } catch (error) {
+ console.error(error)
+ app.exit(1)
+ }
+})
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsx
index ed9eb4a3a..30758a366 100644
--- a/desktop-app/ui/src/App.tsx
+++ b/desktop-app/ui/src/App.tsx
@@ -12,7 +12,7 @@ import {
import { AppHeader } from '@components/AppHeader'
import { BootSplash } from '@components/BootSplash'
import { ChatLocalSearch } from '@components/ChatLocalSearch'
-import { ChatTabs } from '@components/ChatTabs'
+import { ChatViewWorkspace } from '@components/ChatViewWorkspace'
import { CommandPalette } from '@components/CommandPalette'
import { Button, ToastStack } from '@components/Common'
import { ConfirmDialog } from '@components/ConfirmDialog'
@@ -1827,22 +1827,24 @@ export function App() {
/>
<ToastStack items={vm.toasts} />
{vm.navItem === DESKTOP_ROUTES.chat && (
- <section className="chat-view-workspace" id="chat-view-panel">
- <ChatTabs
- tabs={chatViewTabs.tabs}
- activeTabId={chatViewTabs.activeTabId}
- onSelect={handleSelectChatViewTab}
- onClose={handleCloseChatViewTab}
- />
- {chatLocalSearchOpen ? (
- <ChatLocalSearch
- models={chatSemanticModels}
- onClose={closeChatLocalSearch}
- onSearchStateChange={handleChatLocalSearchStateChange}
- />
- ) : null}
+ <ChatViewWorkspace
+ activeTabId={chatViewTabs.activeTabId}
+ localSearch={
+ chatLocalSearchOpen ? (
+ <ChatLocalSearch
+ models={chatSemanticModels}
+ onClose={closeChatLocalSearch}
+ onSearchStateChange={handleChatLocalSearchStateChange}
+ />
+ ) : null
+ }
+ onClose={handleCloseChatViewTab}
+ onSelect={handleSelectChatViewTab}
+ surfaceId="chat-view-panel"
+ tabs={chatViewTabs.tabs}
+ >
<ChatPage scrollContainerRef={contentPanelRef} />
- </section>
+ </ChatViewWorkspace>
)}
{vm.navItem === DESKTOP_ROUTES.agents && (
<AgentsPage scrollContainerRef={contentPanelRef} />
diff --git a/desktop-app/ui/src/components/ChatTabs/ChatTabs.surfaceAssociation.test.tsx b/desktop-app/ui/src/components/ChatTabs/ChatTabs.surfaceAssociation.test.tsx
new file mode 100644
index 000000000..33b2ccd0c
--- /dev/null
+++ b/desktop-app/ui/src/components/ChatTabs/ChatTabs.surfaceAssociation.test.tsx
@@ -0,0 +1,39 @@
+// @vitest-environment jsdom
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { cleanup, render, screen } from '@testing-library/react'
+import { ChatTabs } from '.'
+
+afterEach(cleanup)
+
+describe('ChatTabs selected surface association', () => {
+ it('associates the active tab control with its owned chat surface', () => {
+ render(
+ <ChatTabs
+ activeTabId="one"
+ onClose={vi.fn()}
+ onSelect={vi.fn()}
+ {...({ panelId: 'current-chat-surface' } as Record<string, string>)}
+ tabs={[
+ { id: 'one', agentRef: 'alpha', chatId: 'chat-1', title: 'First chat' },
+ {
+ id: 'two',
+ agentRef: 'alpha',
+ chatId: 'chat-2',
+ title: 'A second conversation with a long title that must remain usable',
+ },
+ ]}
+ />
+ )
+
+ expect(screen.getByRole('button', { name: 'First chat' }).getAttribute('aria-controls')).toBe(
+ 'current-chat-surface'
+ )
+ expect(
+ screen
+ .getByRole('button', {
+ name: 'A second conversation with a long title that must remain usable',
+ })
+ .getAttribute('aria-controls')
+ ).toBeNull()
+ })
+})
diff --git a/desktop-app/ui/src/components/ChatTabs/index.tsx b/desktop-app/ui/src/components/ChatTabs/index.tsx
index 11de2efcf..84ca6d988 100644
--- a/desktop-app/ui/src/components/ChatTabs/index.tsx
+++ b/desktop-app/ui/src/components/ChatTabs/index.tsx
@@ -1,7 +1,7 @@
import { Button } from '@components/Common'
import type { ChatTabsProps } from './types'
-export function ChatTabs({ tabs, activeTabId, onSelect, onClose }: ChatTabsProps) {
+export function ChatTabs({ tabs, activeTabId, onSelect, onClose, panelId }: ChatTabsProps) {
return (
<div className="chat-view-tabs" role="toolbar" aria-label="Chat tabs">
<div className="chat-view-tabs__list">
@@ -11,6 +11,7 @@ export function ChatTabs({ tabs, activeTabId, onSelect, onClose }: ChatTabsProps
<div className={`chat-view-tab${active ? ' is-active' : ''}`} key={tab.id}>
<Button
align="start"
+ aria-controls={active ? panelId : undefined}
aria-pressed={active}
className="chat-view-tab__select"
color="neutral"
diff --git a/desktop-app/ui/src/components/ChatTabs/types.ts b/desktop-app/ui/src/components/ChatTabs/types.ts
index bc05773e8..39acf8ea7 100644
--- a/desktop-app/ui/src/components/ChatTabs/types.ts
+++ b/desktop-app/ui/src/components/ChatTabs/types.ts
@@ -5,4 +5,5 @@ export type ChatTabsProps = {
activeTabId: string
onSelect: (id: string) => void
onClose: (id: string) => void
+ panelId?: string
}
diff --git a/desktop-app/ui/src/components/ChatViewWorkspace/ChatViewWorkspace.test.tsx b/desktop-app/ui/src/components/ChatViewWorkspace/ChatViewWorkspace.test.tsx
new file mode 100644
index 000000000..89037bb2e
--- /dev/null
+++ b/desktop-app/ui/src/components/ChatViewWorkspace/ChatViewWorkspace.test.tsx
@@ -0,0 +1,84 @@
+// @vitest-environment jsdom
+import type { ReactNode } from 'react'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { cleanup, render, screen } from '@testing-library/react'
+import { readFileSync } from 'node:fs'
+import path from 'node:path'
+import { ChatViewWorkspace } from '.'
+
+const tabs = [
+ { id: 'one', agentRef: 'alpha', chatId: 'chat-1', title: 'First chat' },
+ {
+ id: 'two',
+ agentRef: 'alpha',
+ chatId: 'chat-2',
+ title: 'A second conversation with a long title that must remain usable in narrow windows',
+ },
+]
+
+beforeEach(() => {
+ const style = document.createElement('style')
+ style.dataset.testStyles = 'chat-workspace'
+ style.textContent = `:root { --accent: #3b82f6; --surface-strong: #111827; }
+${readFileSync(path.join(process.cwd(), 'ui', 'src', 'styles.css'), 'utf8')}`
+ document.head.append(style)
+})
+
+afterEach(() => {
+ cleanup()
+ document.querySelector('[data-test-styles="chat-workspace"]')?.remove()
+})
+
+function renderWorkspace(contentLabel: string, localSearch: ReactNode = null) {
+ return render(
+ <ChatViewWorkspace
+ activeTabId="one"
+ localSearch={localSearch}
+ onClose={vi.fn()}
+ onSelect={vi.fn()}
+ tabs={tabs}
+ >
+ <div data-testid="chat-state">{contentLabel}</div>
+ </ChatViewWorkspace>
+ )
+}
+
+describe('ChatViewWorkspace', () => {
+ it('owns the active tab, local search, and current chat as one selected surface', () => {
+ const { container } = renderWorkspace('active chat', <div role="search">Current chat find</div>)
+ const surface = screen.getByRole('region', { name: 'Current chat' })
+ const active = screen.getByRole('button', { name: 'First chat' })
+ const list = container.querySelector('.chat-view-tabs__list') as HTMLElement
+
+ expect(active.getAttribute('aria-controls')).toBe(surface.id)
+ expect(surface.getAttribute('data-selected-surface')).toBe('chat')
+ expect(surface.contains(screen.getByRole('search'))).toBe(true)
+ expect(surface.contains(screen.getByTestId('chat-state'))).toBe(true)
+ expect(getComputedStyle(list).overflowX).toBe('auto')
+ expect(getComputedStyle(surface).borderTopStyle).toBe('solid')
+ expect(container.querySelector('.chat-view-tab.is-active')).toBeTruthy()
+ })
+
+ it.each(['loading chat', 'blank chat', 'active chat'])(
+ 'keeps the %s state inside the selected surface',
+ state => {
+ renderWorkspace(state)
+ const surface = screen.getByRole('region', { name: 'Current chat' })
+ expect(surface.contains(screen.getByText(state))).toBe(true)
+ }
+ )
+
+ it('keeps tab overflow separate from a full-width surface at narrow widths', () => {
+ const { container } = renderWorkspace('narrow chat')
+ const workspace = container.querySelector('.chat-view-workspace') as HTMLElement
+ const list = container.querySelector('.chat-view-tabs__list') as HTMLElement
+ const surface = screen.getByRole('region', { name: 'Current chat' })
+ workspace.style.width = '320px'
+
+ expect(getComputedStyle(workspace).display).toBe('flex')
+ expect(getComputedStyle(list).overflowX).toBe('auto')
+ expect(getComputedStyle(surface).width).toBe('100%')
+ expect(screen.getByText(/A second conversation/)).toBeTruthy()
+ expect(screen.getByRole('button', { name: /Close A second conversation/ })).toBeTruthy()
+ })
+})
diff --git a/desktop-app/ui/src/components/ChatViewWorkspace/index.tsx b/desktop-app/ui/src/components/ChatViewWorkspace/index.tsx
new file mode 100644
index 000000000..59d787f9c
--- /dev/null
+++ b/desktop-app/ui/src/components/ChatViewWorkspace/index.tsx
@@ -0,0 +1,33 @@
+import { ChatTabs } from '../ChatTabs'
+import type { ChatViewWorkspaceProps } from './types'
+
+export function ChatViewWorkspace({
+ activeTabId,
+ children,
+ localSearch,
+ onClose,
+ onSelect,
+ surfaceId = 'current-chat-surface',
+ tabs,
+}: ChatViewWorkspaceProps) {
+ return (
+ <section className="chat-view-workspace" data-active-chat-tab={activeTabId}>
+ <ChatTabs
+ activeTabId={activeTabId}
+ onClose={onClose}
+ onSelect={onSelect}
+ panelId={surfaceId}
+ tabs={tabs}
+ />
+ <section
+ aria-label="Current chat"
+ className="chat-view-surface"
+ data-selected-surface="chat"
+ id={surfaceId}
+ >
+ {localSearch}
+ <div className="chat-view-surface__content">{children}</div>
+ </section>
+ </section>
+ )
+}
diff --git a/desktop-app/ui/src/components/ChatViewWorkspace/types.ts b/desktop-app/ui/src/components/ChatViewWorkspace/types.ts
new file mode 100644
index 000000000..de2ad1e66
--- /dev/null
+++ b/desktop-app/ui/src/components/ChatViewWorkspace/types.ts
@@ -0,0 +1,8 @@
+import type { ReactNode } from 'react'
+import type { ChatTabsProps } from '../ChatTabs/types'
+
+export type ChatViewWorkspaceProps = ChatTabsProps & {
+ children: ReactNode
+ localSearch?: ReactNode
+ surfaceId?: string
+}
diff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.css
index 7174481af..20ceda55f 100644
--- a/desktop-app/ui/src/styles.css
+++ b/desktop-app/ui/src/styles.css
@@ -14900,10 +14900,13 @@ pre {
}
/* Keyboard-first chat view tabs */
.chat-view-tabs {
+ flex: 0 0 auto;
display: flex;
min-width: 0;
padding: var(--space-2) 0 0;
+ position: relative;
width: 100%;
+ z-index: 1;
}
.chat-view-tabs__list {
@@ -14911,6 +14914,7 @@ pre {
gap: var(--space-1);
min-width: 0;
overflow-x: auto;
+ overflow-y: hidden;
width: 100%;
}
@@ -14928,6 +14932,8 @@ pre {
.chat-view-tab.is-active {
background: var(--surface-strong);
border-color: var(--accent);
+ border-bottom-color: var(--surface-strong);
+ margin-bottom: -1px;
}
.chat-view-tab__select {
@@ -14950,7 +14956,51 @@ pre {
}
.chat-view-workspace {
- display: contents;
+ display: flex;
+ flex: 1 1 0;
+ flex-direction: column;
+ min-height: 0;
+ min-width: 0;
+ width: 100%;
+}
+
+.chat-view-surface {
+ background: var(--surface-strong);
+ border-top-color: var(--accent);
+ border-top-style: solid;
+ border-top-width: 1px;
+ border-radius: 0 var(--radius-sm) 0 0;
+ display: flex;
+ flex: 1 1 0;
+ flex-direction: column;
+ min-height: 0;
+ min-width: 0;
+ overflow: hidden;
+ width: 100%;
+}
+
+.chat-view-surface__content {
+ display: flex;
+ flex: 1 1 0;
+ min-height: 0;
+ min-width: 0;
+ width: 100%;
+}
+
+.content-panel:has(.agent-page) > .chat-view-workspace,
+.content-panel.content-panel--agent-chat > .chat-view-workspace,
+.chat-view-surface__content > .agent-page {
+ flex: 1 1 0;
+ height: auto;
+ min-height: 0;
+ overflow: hidden;
+}
+
+.chat-view-surface__content > .page {
+ flex: 1 1 auto;
+ min-width: 0;
+ overflow: auto;
+ width: 100%;
}
/* Contextual find surfaces remain in trusted Desktop chrome. */