The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): native Desktop's composer collapses at main's widths whatever the theme's text size
emozillaf6f9bf0535a2
diff --git a/apps/desktop/DESIGN.md b/apps/desktop/DESIGN.mdindex d8d827accac..675ea1052e3 100644--- a/apps/desktop/DESIGN.md+++ b/apps/desktop/DESIGN.md@@ -270,9 +270,11 @@ blurred backdrop.## Layout-Composer controls retain 44px targets on coarse-pointer surfaces. Collapse-stages budget the actual control-size token; below the two-target width budget,-the context menu and Send occupy separate rows rather than clipping or shrinking.+In the browser-hosted Desktop, composer controls retain 44px targets on+coarse-pointer surfaces. Its collapse stages budget the actual control-size+token; below the two-target width budget, the context menu and Send occupy+separate rows rather than clipping or shrinking. Native Desktop keeps the+compact stages sized for 24px controls.The voice engine split-button uses `--composer-voice-menu-size`: compact ondesktop, matching `--composer-control-size` on touch surfaces.Narrow browser touch layouts show the current session tab with an open-tabdiff --git a/apps/desktop/src/app/chat/composer/controls-row-layout.test.tsx b/apps/desktop/src/app/chat/composer/controls-row-layout.test.tsxnew file mode 100644index 00000000000..134fdbf60a0--- /dev/null+++ b/apps/desktop/src/app/chat/composer/controls-row-layout.test.tsx@@ -0,0 +1,72 @@+import { cleanup, render } from '@testing-library/react'+import { afterEach, expect, it, vi } from 'vitest'++import type { ChatBarState } from '@/app/chat/composer/types'+import { I18nProvider } from '@/i18n'++import { ComposerControls } from './controls'++vi.mock('./model-pill', () => ({ ModelPill: () => null }))++const state: ChatBarState = {+ model: { canSwitch: false, model: '', provider: '' },+ tools: { enabled: false, label: '' },+ voice: { active: false, enabled: false }+}++function controlsRow() {+ const { container } = render(+ <I18nProvider configClient={null} initialLocale="en">+ <ComposerControls+ autoSpeak={false}+ busy={false}+ busyAction="stop"+ canSubmit={true}+ conversation={{+ active: false,+ level: 0,+ muted: false,+ onEnd: vi.fn(),+ onStart: vi.fn(),+ onStopTurn: vi.fn(),+ onToggleMute: vi.fn(),+ status: 'idle'+ }}+ disabled={false}+ hasComposerPayload={true}+ minimal+ onDictate={vi.fn()}+ onQueue={vi.fn()}+ onToggleAutoSpeak={vi.fn()}+ state={state}+ voiceStatus="idle"+ />+ </I18nProvider>+ )++ return container.firstElementChild as HTMLElement+}++afterEach(() => {+ cleanup()+ delete window.document.documentElement.dataset.hermesDesktopHost+})++// Native Desktop lays out the minimal controls row as on main: packed from the+// start, on one line.+it('keeps the minimal controls row on one line, packed from the start, in native Desktop', () => {+ const row = controlsRow()++ expect(row.className).not.toContain('justify-end')+ expect(row.style.flexWrap).toBe('')+})++// The browser host's touch-size controls can outgrow a minimal row: they pack+// to the end and wrap onto a second line instead of clipping Send.+it('packs the minimal controls row to the end and lets it wrap in browser-hosted Desktop', () => {+ window.document.documentElement.dataset.hermesDesktopHost = 'browser'+ const row = controlsRow()++ expect(row.className).toContain('justify-end')+ expect(row.style.flexWrap).toBe('wrap')+})diff --git a/apps/desktop/src/app/chat/composer/controls.tsx b/apps/desktop/src/app/chat/composer/controls.tsxindex 9beeddfc755..3ff157ff800 100644--- a/apps/desktop/src/app/chat/composer/controls.tsx+++ b/apps/desktop/src/app/chat/composer/controls.tsx@@ -134,10 +134,14 @@ export function ComposerControls({/>)+ // The browser host's touch-size controls can outgrow a minimal row, so there+ // they pack to the end and wrap. Native Desktop keeps main's single row.+ const browserHost = isBrowserHostedDesktop()+return (<div- className="flex min-w-0 shrink items-center justify-end gap-(--composer-control-gap)"- style={{ flexWrap: minimal ? 'wrap' : undefined }}+ className={cn('flex min-w-0 shrink items-center gap-(--composer-control-gap)', browserHost && 'justify-end')}+ style={{ flexWrap: browserHost && minimal ? 'wrap' : undefined }}>{minimal ? null : (<>diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-metrics.test.tsx b/apps/desktop/src/app/chat/composer/hooks/use-composer-metrics.test.tsxindex a5e8ba864cb..472eb714d7c 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-metrics.test.tsx+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-metrics.test.tsx@@ -107,9 +107,33 @@ describe('useComposerMetrics — published clearance survives an effect replay',afterEach(() => {cleanup()vi.unstubAllGlobals()+ delete window.document.documentElement.dataset.hermesDesktopHost+ })++ // Native Desktop collapses its composer at main's fixed widths and never+ // splits the row into one column, whatever --composer-control-size resolves+ // to (a theme's larger base font size grows that rem token).+ it('keeps main\'s collapse widths in native Desktop whatever the control-size token measures', () => {+ const fitAt = (width: number) => {+ const style = vi.spyOn(window, 'getComputedStyle').mockReturnValue({+ getPropertyValue: (name: string) => (name === '--composer-control-size' ? '30px' : '')+ } as unknown as CSSStyleDeclaration)++ const { getByTestId, unmount } = render(<Harness dockHeight={200} surfaceHeight={120} width={width} />)+ const fit = JSON.parse(getByTestId('fit').textContent!) as { minimal: boolean; singleColumn: boolean }+ unmount()+ style.mockRestore()++ return fit+ }++ expect(fitAt(COMPOSER_MINIMAL_PX + 1)).toMatchObject({ minimal: false, singleColumn: false })+ expect(fitAt(COMPOSER_MINIMAL_PX - 1)).toMatchObject({ minimal: true, singleColumn: false })+ expect(fitAt(60)).toMatchObject({ minimal: true, singleColumn: false })})it('uses a single control column below the two-touch-target budget', () => {+ window.document.documentElement.dataset.hermesDesktopHost = 'browser'vi.spyOn(window, 'getComputedStyle').mockReturnValue({ getPropertyValue: () => '44px' } as unknown as CSSStyleDeclaration)const { getByTestId } = render(<Harness dockHeight={200} surfaceHeight={120} width={80} />)expect(JSON.parse(getByTestId('fit').textContent!)).toMatchObject({ minimal: true, singleColumn: true })@@ -117,6 +141,8 @@ describe('useComposerMetrics — published clearance survives an effect replay',})it('collapses extra controls earlier when touch targets consume more width', () => {+ window.document.documentElement.dataset.hermesDesktopHost = 'browser'+const minimalAt = (controlPx: number) => {const style = vi.spyOn(window, 'getComputedStyle').mockReturnValue({getPropertyValue: (name: string) => (name === '--composer-control-size' ? `${controlPx}px` : '')diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-metrics.ts b/apps/desktop/src/app/chat/composer/hooks/use-composer-metrics.tsindex 3300046aece..19c69d04223 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-metrics.ts+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-metrics.ts@@ -9,6 +9,7 @@ import {setSurfaceVar} from '@/app/chat/surface-vars'import { useResizeObserver } from '@/hooks/use-resize-observer'+import { isBrowserHostedDesktop } from '@/lib/platform'import {COMPOSER_COMPACT_PILL_PX,@@ -58,6 +59,26 @@ const sameFit = (a: ComposerFit, b: ComposerFit) =>a.tight === b.tight &&a.singleColumn === b.singleColumn+// The compact controls the collapse stages were sized for.+const DESKTOP_CONTROL_PX = 24++/** Collapse stages for a composer `width` wide. The browser host's touch layout+ * grows the controls to 44px (styles.css), so it budgets the live+ * `--composer-control-size` token and splits into one column below two+ * targets. Native Desktop keeps the compact stages and the row, as on main. */+function composerFit(composer: HTMLElement, width: number): ComposerFit {+ if (!isBrowserHostedDesktop()) {+ return { ...fitForWidth(width, DESKTOP_CONTROL_PX), singleColumn: false }+ }++ const token = getComputedStyle(composer).getPropertyValue('--composer-control-size').trim()++ const size =+ parseFloat(token) * (token.endsWith('rem') ? parseFloat(getComputedStyle(document.documentElement).fontSize) : 1)++ return fitForWidth(width, Number.isFinite(size) ? size : DESKTOP_CONTROL_PX)+}+interface UseComposerMetricsResult extends ComposerFit {stacked: boolean}@@ -142,13 +163,7 @@ export function useComposerMetrics({const surfaceHeight = composerSurfaceRef.current?.getBoundingClientRect().heightif (width > 0) {- const token = getComputedStyle(composer).getPropertyValue('--composer-control-size').trim()-- const size =- parseFloat(token) *- (token.endsWith('rem') ? parseFloat(getComputedStyle(document.documentElement).fontSize) : 1)-- const nextFit = fitForWidth(width, Number.isFinite(size) ? size : 24)+ const nextFit = composerFit(composer, width)if (!sameFit(nextFit, lastFitRef.current)) {lastFitRef.current = nextFit