Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): r3-h2 prove chat drawer paint order
Josuéecaef9329e19
diff --git a/desktop-app/test/browser/chatDrawerHeaderStacking.browser.test.ts b/desktop-app/test/browser/chatDrawerHeaderStacking.browser.test.tsnew file mode 100644index 000000000..d2011cfed--- /dev/null+++ b/desktop-app/test/browser/chatDrawerHeaderStacking.browser.test.ts@@ -0,0 +1,104 @@+import { afterAll, beforeAll, describe, expect, it } from 'vitest'+import fs from 'node:fs'+import path from 'node:path'+import { type Browser, type Page, chromium } from 'playwright'++const UI_ROOT = path.resolve(__dirname, '../../ui/src')+const SYSTEM_CHROME = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'++let browser: Browser | undefined++function launchOptions() {+ if (process.platform === 'darwin' && fs.existsSync(SYSTEM_CHROME)) {+ return { executablePath: SYSTEM_CHROME, headless: true }+ }+ return { headless: true }+}++async function mountPortalEraShell(page: Page, drawerOpen: boolean): Promise<void> {+ await page.setContent(`+ <div class="app-frame">+ <header class="window-titlebar">+ <div class="window-titlebar__actions">+ <div class="top-bar top-bar--titlebar">+ <div class="header-left">+ <div class="global-search global-search--titlebar is-open">+ <input class="search-input" aria-label="Search" />+ <div class="global-search-results">+ <div class="search-results-card"><button id="search-result">Search result</button></div>+ </div>+ </div>+ </div>+ </div>+ </div>+ </header>+ <div class="app-root">+ <section class="content-panel${drawerOpen ? ' content-panel--chat-drawer-open' : ''}">+ ${drawerOpen ? '<aside class="chat-drawer is-ready">Chat drawer</aside>' : ''}+ </section>+ </div>+ </div>+ `)+ await page.addStyleTag({ path: path.join(UI_ROOT, 'styles/tokens.css') })+ await page.addStyleTag({ path: path.join(UI_ROOT, 'styles.css') })+}++async function topmostAtOverlap(page: Page): Promise<string | null> {+ return page.evaluate(() => {+ const result = document.querySelector('.global-search-results')+ const drawer = document.querySelector('.chat-drawer')+ if (!result || !drawer) return null++ const resultRect = result.getBoundingClientRect()+ const drawerRect = drawer.getBoundingClientRect()+ const left = Math.max(resultRect.left, drawerRect.left)+ const right = Math.min(resultRect.right, drawerRect.right)+ const top = Math.max(resultRect.top, drawerRect.top)+ const bottom = Math.min(resultRect.bottom, drawerRect.bottom)+ if (left >= right || top >= bottom) return null++ const topmost = document.elementFromPoint((left + right) / 2, (top + bottom) / 2)+ if (topmost?.closest('.global-search-results')) return 'search-result'+ if (topmost?.closest('.chat-drawer')) return 'chat-drawer'+ return null+ })+}++describe('chat drawer titlebar overlay paint order', () => {+ beforeAll(async () => {+ browser = await chromium.launch(launchOptions())+ })++ afterAll(async () => {+ await browser?.close()+ })++ it('keeps portalled search results above an open chat drawer', async () => {+ const page = await browser!.newPage({ viewport: { width: 1280, height: 800 } })+ await mountPortalEraShell(page, true)++ expect(await topmostAtOverlap(page)).toBe('search-result')+ await page.close()+ })++ it('detects a broken root stacking context instead of comparing local z-index tokens', async () => {+ const page = await browser!.newPage({ viewport: { width: 1280, height: 800 } })+ await mountPortalEraShell(page, true)++ await page.locator('.content-panel').evaluate(element => {+ ;(element as HTMLElement).style.zIndex = '200'+ })++ expect(await topmostAtOverlap(page)).toBe('chat-drawer')+ await page.close()+ })++ it('keeps titlebar search interactive without a chat drawer', async () => {+ const page = await browser!.newPage({ viewport: { width: 1280, height: 800 } })+ await mountPortalEraShell(page, false)++ await page.getByRole('button', { name: 'Search result' }).click()+ expect(await page.locator('#search-result').count()).toBe(1)+ await page.close()+ })+})diff --git a/desktop-app/ui/src/__tests__/chatDrawerHeaderStacking.test.tsx b/desktop-app/ui/src/__tests__/chatDrawerHeaderStacking.test.tsxindex 4f6243390..12805365a 100644--- a/desktop-app/ui/src/__tests__/chatDrawerHeaderStacking.test.tsx+++ b/desktop-app/ui/src/__tests__/chatDrawerHeaderStacking.test.tsx@@ -1,134 +1,34 @@// @vitest-environment jsdomimport React from 'react'-import { afterEach, beforeEach, describe, expect, it } from 'vitest'+import { afterEach, describe, expect, it } from 'vitest'import { cleanup, render, screen } from '@testing-library/react'-import { readFileSync } from 'node:fs'-import path from 'node:path'-import { ChatDrawer } from '@components/ChatDrawer'import { TitlebarActionsPortal, WindowTitleBar } from '@components/WindowTitleBar'-// The titlebar actions are rendered through a React portal. Exercise that DOM-// topology instead of recreating the pre-portal content-panel header.--const tokensCss = readFileSync(- path.join(process.cwd(), 'ui', 'src', 'styles', 'tokens.css'),- 'utf8'-)-const stylesCss = readFileSync(path.join(process.cwd(), 'ui', 'src', 'styles.css'), 'utf8')--function layer(name: string): number {- const match = new RegExp(`--${name}:\\s*(\\d+)`).exec(tokensCss)- if (!match) throw new Error(`token --${name} not found`)- return Number(match[1])-}--// The `.toast-stack` sits on a raw z-index literal (not a token) in styles.css.-// Read it from the real rule so a change there is reflected here instead of the-// assertion passing against a phantom constant (T4).-function toastStackZIndex(): number {- const match = /\.toast-stack\s*\{[^}]*z-index:\s*(\d+)/.exec(stylesCss)- if (!match) throw new Error('.toast-stack z-index not found')- return Number(match[1])-}--function toastStackTop(): string {- const match = /\.toast-stack\s*\{[^}]*top:\s*([^;]+);/.exec(stylesCss)- if (!match) throw new Error('.toast-stack top offset not found')- return match[1].trim()-}--beforeEach(() => {- const style = document.createElement('style')- style.dataset.testStyles = 'header-stacking'- style.textContent = `${tokensCss}\n${stylesCss}`- document.head.append(style)-})--afterEach(() => {- cleanup()- document.querySelector('[data-test-styles="header-stacking"]')?.remove()- document.body.innerHTML = ''-})--function PortalStackingHarness({ chatDrawerOpen }: { chatDrawerOpen: boolean }) {- const [actionsRoot, setActionsRoot] = React.useState<HTMLDivElement | null>(null)- const drawerRef = React.useRef<HTMLDivElement>(null)-- return (- <div className="app-frame">- <WindowTitleBar actionsRef={setActionsRoot} />- <div className="app-root">- <section- className={- chatDrawerOpen ? 'content-panel content-panel--chat-drawer-open' : 'content-panel'- }- >- {chatDrawerOpen ? (- <ChatDrawer- containerRef={drawerRef}- header={<span>Chat</span>}- onClose={() => undefined}- onNewChat={() => undefined}- onResizeHandleKeyDown={() => undefined}- onResizeHandleMouseDown={() => undefined}- ready- resizing={false}- width={340}- >- <span>Chat content</span>- </ChatDrawer>- ) : null}- </section>- </div>- <TitlebarActionsPortal container={actionsRoot}>- <header className="top-bar">- <div className="global-search-results" data-testid="titlebar-search-results" />- </header>- </TitlebarActionsPortal>- </div>- )-}--describe('chat drawer header stacking', () => {- it('lifts the real titlebar portal above the chat drawer while it is open', async () => {- render(<PortalStackingHarness chatDrawerOpen />)-- const searchResults = await screen.findByTestId('titlebar-search-results')- const titlebar = searchResults.closest('.window-titlebar') as HTMLElement- const drawer = screen.getByRole('complementary', { name: 'Chat' })-- expect(titlebar).toBeTruthy()- expect(searchResults.closest('.content-panel')).toBeNull()- expect(getComputedStyle(titlebar).zIndex).toBe('var(--layer-dropdown)')- expect(getComputedStyle(drawer).zIndex).toBe('var(--layer-chat-overlay)')- expect(layer('layer-dropdown')).toBeGreaterThan(layer('layer-chat-overlay'))- expect(toastStackZIndex()).toBeGreaterThan(layer('layer-dropdown'))- })-- it('keeps the titlebar at its normal layer when no chat drawer exists', async () => {- render(<PortalStackingHarness chatDrawerOpen={false} />)-- const searchResults = await screen.findByTestId('titlebar-search-results')- const titlebar = searchResults.closest('.window-titlebar') as HTMLElement-- expect(getComputedStyle(titlebar).zIndex).toBe('var(--layer-header)')- })-- it('anchors alerts below the custom titlebar with the shared spacing token', () => {- expect(toastStackTop()).toBe('calc(var(--window-titlebar-height) + var(--space-2))')- })-- it('shares the titlebar divider border with its interactive controls', () => {- expect(stylesCss).toMatch(- /\.window-titlebar\s*\{[^}]*border-bottom:\s*1px solid var\(--titlebar-divider-border\)/- )- expect(tokensCss).toMatch(/--titlebar-control-border:\s*var\(--titlebar-divider-border\)/)- })-- it('reserves exactly the notification drawer rail for a mounted app', () => {- expect(stylesCss).toMatch(- /--app-header-utilities-width:\s*calc\(var\(--app-notification-drawer-width\) \+ var\(--space-4\)\)/- )- expect(stylesCss).toMatch(/\.notification-menu--app-drawer\s*\{[^}]*right:\s*var\(--space-4\)/)+afterEach(() => cleanup())++describe('chat drawer titlebar portal', () => {+ it('mounts actions in the titlebar instead of the content panel', async () => {+ function Harness() {+ const [actionsRoot, setActionsRoot] = React.useState<HTMLDivElement | null>(null)++ return (+ <div className="app-frame">+ <WindowTitleBar actionsRef={setActionsRoot} />+ <div className="app-root">+ <section className="content-panel">+ <TitlebarActionsPortal container={actionsRoot}>+ <button type="button">Search</button>+ </TitlebarActionsPortal>+ </section>+ </div>+ </div>+ )+ }++ render(<Harness />)++ const search = await screen.findByRole('button', { name: 'Search' })+ expect(search.closest('.window-titlebar')).toBeTruthy()+ expect(search.closest('.content-panel')).toBeNull()})})