From 6b9c01996fccb9789db7faff1c0e39b4fabd923c Mon Sep 17 00:00:00 2001 From: Turtle Date: Sun, 20 Sep 2026 19:54:54 +0800 Subject: [PATCH 1/7] fix(web): refresh favicon colors with the system scheme --- apps/web/src/favicon.ts | 26 +++++++++++++ apps/web/src/main.ts | 2 + apps/web/tests/favicon.spec.ts | 55 +++++++++++++++++++++++++++ apps/web/tests/settings-chrome.e2e.ts | 13 +++++++ 4 files changed, 96 insertions(+) create mode 100644 apps/web/src/favicon.ts create mode 100644 apps/web/tests/favicon.spec.ts diff --git a/apps/web/src/favicon.ts b/apps/web/src/favicon.ts new file mode 100644 index 0000000000..ac08a9f84f --- /dev/null +++ b/apps/web/src/favicon.ts @@ -0,0 +1,26 @@ +/** Browser-tab icons follow the system scheme independently of the application theme. */ +import favicon from '../public/favicon.svg?raw' + +/** + * Install fixed-color icons and a document-lifetime system-scheme listener. + * Browser favicon rasterizers can cache SVG media-query results across scheme changes. + * Distinct data URLs select explicit colors without duplicating the source artwork. + */ +export function installFavicon(): void { + const link = document.querySelector('link[rel="icon"]') + if (link === null) throw new Error('web app: missing favicon link') + const svg = new DOMParser().parseFromString(favicon, 'image/svg+xml') + svg.querySelector('style')?.remove() + const path = svg.querySelector('path') + if (path === null) throw new Error('web app: missing favicon path') + const icon = (fill: string): string => { + path.setAttribute('fill', fill) + return `data:image/svg+xml,${encodeURIComponent(new XMLSerializer().serializeToString(svg))}` + } + const light = icon('#000') + const dark = icon('#fff') + const scheme = window.matchMedia('(prefers-color-scheme: dark)') + const update = (): void => { link.href = scheme.matches ? dark : light } + update() + scheme.addEventListener('change', update) +} diff --git a/apps/web/src/main.ts b/apps/web/src/main.ts index 1a84cd5f63..9f1fa593a1 100644 --- a/apps/web/src/main.ts +++ b/apps/web/src/main.ts @@ -1,5 +1,6 @@ /** Browser entry for the Web client. */ import { AppWebEntry, applyIndexInjections } from '@deepseek-ai/dsh-client-web' +import { installFavicon } from './favicon.ts' interface DesktopBootGlobal { dshDesktopBoot?: { @@ -14,6 +15,7 @@ const reportFailure = (reason: unknown): void => { } try { + installFavicon() const el = document.getElementById('root') if (el === null) throw new Error('web app: missing #root') const entry = new AppWebEntry(el) diff --git a/apps/web/tests/favicon.spec.ts b/apps/web/tests/favicon.spec.ts new file mode 100644 index 0000000000..af932bc4fc --- /dev/null +++ b/apps/web/tests/favicon.spec.ts @@ -0,0 +1,55 @@ +// @vitest-environment jsdom +import { afterEach, expect, it, vi } from 'vitest' +import { installFavicon } from '../src/favicon.ts' + +const originalHead = document.head.innerHTML + +afterEach(() => { + document.head.innerHTML = originalHead + document.documentElement.style.removeProperty('color-scheme') + vi.unstubAllGlobals() +}) + +it.each([false, true])('selects fixed-color tab icons on boot and system changes (dark=%s)', (initialDark) => { + const link = document.createElement('link') + link.rel = 'icon' + link.href = '/favicon.svg' + document.head.append(link) + let dark = initialDark + let onChange = (): void => { throw new Error('missing scheme listener') } + const matchMedia = vi.fn(() => ({ + get matches() { return dark }, + addEventListener: (event: string, listener: () => void) => { + expect(event).toBe('change') + onChange = listener + }, + })) + vi.stubGlobal('matchMedia', matchMedia) + const readIcon = (): string => decodeURIComponent(link.href.slice('data:image/svg+xml,'.length)) + const expectFill = (fill: string): void => { + expect(link.href).toMatch(/^data:image\/svg\+xml,/) + const svg = new DOMParser().parseFromString(readIcon(), 'image/svg+xml') + expect(svg.querySelector('parsererror')).toBeNull() + expect(svg.querySelector('style')).toBeNull() + expect(svg.querySelector('path')?.getAttribute('fill')).toBe(fill) + expect(svg.documentElement.getAttribute('viewBox')).toBe('0 0 50 50') + } + + document.documentElement.style.colorScheme = initialDark ? 'light' : 'dark' + installFavicon() + expect(matchMedia).toHaveBeenCalledWith('(prefers-color-scheme: dark)') + expectFill(initialDark ? '#fff' : '#000') + const initial = link.href + dark = !initialDark + onChange() + expectFill(initialDark ? '#000' : '#fff') + expect(link.href).not.toBe(initial) + dark = initialDark + onChange() + expect(link.href).toBe(initial) +}) + +it('requires the document favicon link', () => { + document.querySelector('link[rel="icon"]')?.remove() + expect(installFavicon).toThrow('web app: missing favicon link') +}) diff --git a/apps/web/tests/settings-chrome.e2e.ts b/apps/web/tests/settings-chrome.e2e.ts index 0c6e79308a..4153763a97 100644 --- a/apps/web/tests/settings-chrome.e2e.ts +++ b/apps/web/tests/settings-chrome.e2e.ts @@ -376,12 +376,18 @@ describe('web e2e: settings modal and General preferences', () => { legacy: string | null themeColor: string | null themeColorCount: number + faviconFill: string | null token: string } const readState = async (target: Page = page): Promise => await target.evaluate(() => { const metas = document.head.querySelectorAll('meta[name="theme-color"]') const computed = getComputedStyle(document.body) + const icon = document.querySelector('link[rel="icon"]')?.href ?? '' + if (!icon.startsWith('data:image/svg+xml,')) throw new Error('favicon is not an explicit-color SVG') + const svg = new DOMParser().parseFromString(decodeURIComponent(icon.slice('data:image/svg+xml,'.length)), 'image/svg+xml') + if (svg.querySelector('style') !== null) throw new Error('favicon still depends on SVG media queries') return { + faviconFill: svg.querySelector('path')?.getAttribute('fill') ?? null, attr: document.body.hasAttribute('data-ds-dark-theme'), background: computed.backgroundColor, legacy: localStorage.getItem('dsh.theme'), @@ -400,6 +406,7 @@ describe('web e2e: settings modal and General preferences', () => { await page.emulateMedia({ colorScheme: 'light' }) const light = await readState() expect(light.attr).toBe(false) + expect(light.faviconFill).toBe('#000') expectThemeColorSynchronized(light) await page.getByRole('button', { name: '设置', exact: true }).click() @@ -413,6 +420,7 @@ describe('web e2e: settings modal and General preferences', () => { await expect.poll(() => darkCube.getAttribute('aria-pressed'), { timeout: 5_000 }).toBe('true') const dark = await readState() expect(dark.attr).toBe(true) + expect(dark.faviconFill).toBe('#000') expect(dark.legacy).toBeNull() expect(dark.token).not.toBe(light.token) expectThemeColorSynchronized(dark) @@ -429,6 +437,7 @@ describe('web e2e: settings modal and General preferences', () => { await expect.poll(async () => (await readState()).attr, { timeout: 5_000 }).toBe(true) const reloaded = await readState() expect(reloaded.legacy).toBeNull() + expect(reloaded.faviconFill).toBe('#000') expectThemeColorSynchronized(reloaded) // A second live Host binds another ephemeral port but shares the same @@ -462,11 +471,15 @@ describe('web e2e: settings modal and General preferences', () => { expectThemeColorSynchronized(await readState()) await page.emulateMedia({ colorScheme: 'dark' }) await expect.poll(async () => (await readState()).attr, { timeout: 5_000 }).toBe(true) + await expect.poll(async () => (await readState()).faviconFill).toBe('#fff') expectThemeColorSynchronized(await readState()) // Restore for the specs that follow: light preference beats the emulated // dark OS scheme, leaving the shared page in the light default. await selectTheme(page.getByRole('dialog', { name: '设置' }).getByRole('button', { name: '浅色' }), 'light') await expect.poll(async () => (await readState()).attr, { timeout: 5_000 }).toBe(false) + expect((await readState()).faviconFill).toBe('#fff') + await page.emulateMedia({ colorScheme: 'light' }) + await expect.poll(async () => (await readState()).faviconFill).toBe('#000') expectThemeColorSynchronized(await readState()) await page.keyboard.press('Escape') expect(tripwire.pageErrors).toEqual([]) From f2a22a31082b3de6dd2e20fbeb7cf058056ec6a6 Mon Sep 17 00:00:00 2001 From: Turtle Date: Sun, 20 Sep 2026 20:05:17 +0800 Subject: [PATCH 2/7] test(web): provide favicon environment in desktop boot fixture --- apps/web/tests/desktop-boot.spec.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/web/tests/desktop-boot.spec.ts b/apps/web/tests/desktop-boot.spec.ts index cac91ad7e7..9bea3def5f 100644 --- a/apps/web/tests/desktop-boot.spec.ts +++ b/apps/web/tests/desktop-boot.spec.ts @@ -1,5 +1,5 @@ // @vitest-environment jsdom -import { afterEach, expect, it, vi } from 'vitest' +import { afterEach, beforeEach, expect, it, vi } from 'vitest' const boot = vi.hoisted(() => ({ run: vi.fn(), @@ -10,10 +10,16 @@ vi.mock('@deepseek-ai/dsh-client-web', () => ({ applyIndexInjections: boot.applyIndexInjections, })) +beforeEach(() => { + document.head.innerHTML = '' + vi.stubGlobal('matchMedia', () => ({ matches: false, addEventListener: vi.fn() })) +}) + afterEach(() => { vi.unstubAllGlobals() vi.clearAllMocks() vi.resetModules() + document.head.replaceChildren() document.body.replaceChildren() }) From c136d821dd98d7992c1e38f6bdc20f1418fd477e Mon Sep 17 00:00:00 2001 From: Turtle Date: Mon, 21 Sep 2026 13:56:47 +0800 Subject: [PATCH 3/7] fix(web): collapse model text when composer controls cannot fit --- apps/web/tests/plan-control-row.e2e.ts | 137 +++++++++++++++++- .../client/ui-conversation/README.i18n.yaml | 4 +- packages/client/ui-conversation/README.md | 2 + packages/client/ui-conversation/README.zh.md | 2 + .../src/client/skeleton/InputBar.module.css | 10 +- .../src/client/skeleton/InputBar.tsx | 11 +- .../src/client/skeleton/control-row-layout.ts | 39 +++++ .../tests/assembly-surfaces.client.spec.tsx | 2 + .../ui-conversation/tests/control-row-dom.ts | 16 ++ .../tests/control-row-layout.client.spec.ts | 93 ++++++++++++ .../tests/input-bar.client.spec.tsx | 1 + .../tests/input-matrix.client.spec.tsx | 1 + .../tests/input-scenarios.client.spec.tsx | 1 + .../tests/skeleton.client.spec.tsx | 1 + .../ui-model-selection/README.i18n.yaml | 4 +- packages/client/ui-model-selection/README.md | 2 + .../client/ui-model-selection/README.zh.md | 2 + .../src/client/ModelSelect.module.css | 24 +-- .../tests/assembly-surfaces.client.spec.tsx | 5 + .../tests/toolview-slot.client.spec.tsx | 5 + .../client-runtime/README.i18n.yaml | 4 +- .../test-support/client-runtime/README.md | 2 +- .../test-support/client-runtime/README.zh.md | 2 +- .../src/assembly/test-client.ts | 15 +- .../tests/assembly-test-client.client.spec.ts | 26 +++- .../plan-narrow-viewport/layout.expected.md | 8 + 26 files changed, 381 insertions(+), 38 deletions(-) create mode 100644 packages/client/ui-conversation/src/client/skeleton/control-row-layout.ts create mode 100644 packages/client/ui-conversation/tests/control-row-dom.ts create mode 100644 packages/client/ui-conversation/tests/control-row-layout.client.spec.ts diff --git a/apps/web/tests/plan-control-row.e2e.ts b/apps/web/tests/plan-control-row.e2e.ts index a9a1faec95..58c5ff1ae3 100644 --- a/apps/web/tests/plan-control-row.e2e.ts +++ b/apps/web/tests/plan-control-row.e2e.ts @@ -46,6 +46,73 @@ const VIEWPORT = { width: 800, height: 720 } as const /** Chip aria-label on the English page; the seat renders only while plan is the effective target. */ const CHIP_ARIA = 'Plan mode on, press to turn off' +const SHORT_MODEL = 'DeepSeek-V4-Flash' +const LONG_MODEL = 'DeepSeek-V4-Flash-Vision-Exp' + +/** Observe painted controls rather than the composer's internal compact flag. */ +async function controlLayout(page: Page) { + return page.getByRole('button', { name: /Select model/ }).evaluate((trigger) => { + const card = trigger.closest('[data-composer-card]') + const row = Array.from(card?.children ?? []).find(child => child.contains(trigger)) + if (!(row instanceof HTMLElement)) throw new Error('composer control row is missing') + const visible = (element: Element): boolean => { + const style = getComputedStyle(element) + const rect = element.getBoundingClientRect() + return style.display !== 'none' && style.visibility !== 'hidden' && rect.width > 0 && rect.height > 0 + } + const label = trigger.querySelector(':scope > span') + const icon = trigger.querySelector(':scope > svg') + if (label === null || icon === null) throw new Error('model trigger label or icon is missing') + const rect = row.getBoundingClientRect() + const controls = Array.from(row.querySelectorAll('button')).filter(visible) + .map(button => button.getBoundingClientRect()) + return { + width: rect.width, + text: visible(label), + icon: visible(icon), + singleLine: controls.length > 1 + && Math.max(...controls.map(box => box.top)) < Math.min(...controls.map(box => box.bottom)), + contained: controls.every(box => box.left >= rect.left && box.right <= rect.right), + } + }) +} + +/** Wait for the responsive column and control row to finish changing width. */ +async function resizeControls(page: Page, width: number): Promise { + await page.setViewportSize({ width, height: VIEWPORT.height }) + await page.locator('[data-composer-card]').evaluate(async (card) => { + let previous = card.getBoundingClientRect().width + let stable = 0 + const deadline = performance.now() + 5_000 + while (performance.now() < deadline) { + await new Promise((resolve) => { requestAnimationFrame(() => { resolve() }) }) + const current = card.getBoundingClientRect().width + stable = Math.abs(current - previous) < 0.01 ? stable + 1 : 0 + if (stable >= 5) return + previous = current + } + throw new Error('composer width did not settle') + }) +} + +/** Change the real Session selection without starting a model turn. */ +async function selectModel(page: Page, name: string): Promise { + const trigger = page.getByRole('button', { name: /Select model/ }) + await trigger.click() + await page.getByRole('menuitem', { name: /^Model/ }).click() + await page.getByRole('menuitemradio', { name, exact: true }).click() + await expect.poll(() => trigger.getAttribute('title')).toMatch(new RegExp(`^${name}(?: ·|$)`)) +} + +/** A compact decision must remain stable across observer deliveries and paints. */ +async function expectControlLayout(page: Page, compact: boolean): Promise { + const expected = { text: !compact, icon: compact, singleLine: true, contained: true } + await expect.poll(() => controlLayout(page), { timeout: 10_000 }).toMatchObject(expected) + for (let frame = 0; frame < 6; frame += 1) { + await page.evaluate(() => new Promise((resolve) => { requestAnimationFrame(() => { resolve() }) })) + expect(await controlLayout(page)).toMatchObject(expected) + } +} describe('web e2e: plan chip click area at the narrow viewport', () => { let scaffold: WebScaffold @@ -75,7 +142,7 @@ describe('web e2e: plan chip click area at the narrow viewport', () => { await scaffold?.close() }) - it('keeps the plan chip and model trigger disjoint and exits plan mode by click', async () => { + it('keeps controls clickable and collapses model text only when the row needs space', async () => { onTestFailed(() => saveFailureShot(page, 'web-e2e-plan-narrow-viewport')) const input = page.locator('[data-composer-input]').first() await input.waitFor({ timeout: 10_000 }) @@ -111,14 +178,13 @@ describe('web e2e: plan chip click area at the narrow viewport', () => { const overlapBottom = Math.min(chipBox!.y + chipBox!.height, triggerBox!.y + triggerBox!.height) const overlapArea = Math.max(0, overlapRight - overlapLeft) * Math.max(0, overlapBottom - overlapTop) - const golden = [ + const layoutGolden = [ '# Plan chip and model trigger at the 800×720 viewport', '', '- Plan chip fully in viewport: ' + (chipInViewport ? 'true' : 'false'), '- Model trigger fully in viewport: ' + (triggerInViewport ? 'true' : 'false'), '- Click areas disjoint: ' + (overlapArea === 0 ? 'true' : 'false'), - ].join('\n').trimEnd() - await compareOrRefreshGolden(LAYOUT_EXPECTED, golden, MODE) + ] expect(overlapArea).toBe(0) expect(chipInViewport).toBe(true) expect(triggerInViewport).toBe(true) @@ -138,6 +204,69 @@ describe('web e2e: plan chip click area at the narrow viewport', () => { (event): event is SessionEvent<'plan/mode'> => event.type === 'plan/mode', ) expect(planModes.at(-1)?.data.active).toBe(false) + + await page.evaluate(async () => { await document.fonts.ready }) + await resizeControls(page, 1680) + await input.fill('/plan ') + await input.press('Enter') + await chip.waitFor({ timeout: 15_000 }) + await selectModel(page, LONG_MODEL) + await expectControlLayout(page, false) + + // Find the content-dependent transition on this platform's fonts, never a + // committed pixel threshold. The old 360px rule cannot satisfy this case. + let narrowViewport: number | undefined + for (let width = 1100; width >= 650; width -= 10) { + await resizeControls(page, width) + const layout = await controlLayout(page) + if (layout.width > 360 && layout.icon && !layout.text) { + narrowViewport = width + break + } + } + expect(narrowViewport, 'long model collapses while the row is wider than 360px').toBeDefined() + if (narrowViewport === undefined) throw new Error('no content-driven collapse above 360px') + await expectControlLayout(page, true) + const collapsed = await controlLayout(page) + const narrowRowWidth = collapsed.width + expect(await trigger.getAttribute('aria-label')).toContain(LONG_MODEL) + expect(await trigger.getAttribute('title')).toContain(LONG_MODEL) + expect(await trigger.getAttribute('aria-label')).toMatch(/high/i) + + await selectModel(page, SHORT_MODEL) + await expectControlLayout(page, false) + const shorter = await controlLayout(page) + expect(shorter.width).toBe(narrowRowWidth) + await selectModel(page, LONG_MODEL) + await expectControlLayout(page, true) + + await resizeControls(page, 1680) + await expectControlLayout(page, false) + const widened = await controlLayout(page) + await resizeControls(page, narrowViewport) + await expectControlLayout(page, true) + await chip.click() + await expect.poll(() => chip.count()).toBe(0) + await expectControlLayout(page, false) + const withoutPlan = await controlLayout(page) + await input.fill('/plan ') + await input.press('Enter') + await chip.waitFor({ timeout: 15_000 }) + await expectControlLayout(page, true) + await chip.click() + await selectModel(page, SHORT_MODEL) + const golden = [ + ...layoutGolden, + '', + '## Content-driven model collapse', + '', + `- Model icon replaces text above a 360px row: ${String(collapsed.width > 360 && collapsed.icon && !collapsed.text)}`, + `- Compact controls share a line and stay within the row: ${String(collapsed.singleLine && collapsed.contained)}`, + `- Shorter model restores text at the same width: ${String(shorter.width === collapsed.width && shorter.text && !shorter.icon)}`, + `- Widening restores model text: ${String(widened.text && !widened.icon)}`, + `- Removing the plan chip restores model text: ${String(withoutPlan.text && !withoutPlan.icon)}`, + ].join('\n').trimEnd() + await compareOrRefreshGolden(LAYOUT_EXPECTED, golden, MODE) expect(tripwire.pageErrors).toEqual([]) expect(tripwire.warnings).toEqual([]) }, 200_000) diff --git a/packages/client/ui-conversation/README.i18n.yaml b/packages/client/ui-conversation/README.i18n.yaml index 2f52a3e505..b01e5a48be 100644 --- a/packages/client/ui-conversation/README.i18n.yaml +++ b/packages/client/ui-conversation/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/client/ui-conversation/README.md -README.md: 31b35ef7460c9fecd119e32ae5f696f55585a726 -README.zh.md: 1fb648bf9539cebc307e094c2fe46b1d1749edab +README.md: eb4650067a1e18dccd4fc8d6d78db0639f57c486 +README.zh.md: d55ca9ef8abce7f32db510e05acfdf673184bab7 diff --git a/packages/client/ui-conversation/README.md b/packages/client/ui-conversation/README.md index 31b35ef746..eb4650067a 100644 --- a/packages/client/ui-conversation/README.md +++ b/packages/client/ui-conversation/README.md @@ -38,6 +38,8 @@ Target packages declaration-merge their snapshot and Location data maps, then re The shared image slot props keep display choices separate from durable references: `thumbnail` requests a contained attachment-list thumbnail, while `compact` requests a cropped gallery tile. An optional per-image `label` supplies the accessible display name; loading and cache identity still use the original attachment reference. [ui-attachment](../ui-attachment/README.md) owns rendering and the lightbox. +The composer measures its expanded control groups after size, content, visibility, or font-loading changes. If they cannot share a line, the row sets `--dsh-composer-model-text-display: none` and `--dsh-composer-model-icon-display: block` for the model seat; their defaults are `block` and `none`. Wrapping remains available if even the icon cannot fit. + The context-occupancy button shows a ring and percentage below the input card, after the Session statistics. Clicking it opens the token breakdown in a panel kept inside the viewport, including when no statistics are shown; the button stays hidden until context usage and capacity are available. With Developer tools off, the shell hides only Trajectory; other plugin-contributed Views remain available. The View tab bar is hidden when fewer than two Views are available. Turning Developer tools off while Trajectory is active returns to Chat; stored View preferences and recorded Session data remain intact. Turning it on makes Trajectory available again. View owners receive the available roster so their navigation actions can follow the same visibility. diff --git a/packages/client/ui-conversation/README.zh.md b/packages/client/ui-conversation/README.zh.md index 1fb648bf95..d55ca9ef8a 100644 --- a/packages/client/ui-conversation/README.zh.md +++ b/packages/client/ui-conversation/README.zh.md @@ -38,6 +38,8 @@ target package 通过 declaration merge 扩展 snapshot 与 Location data map, 共享图片插槽属性将展示选择与持久化引用分开:`thumbnail` 请求完整缩放的附件列表缩略图,`compact` 请求裁剪的图片方块。每张图片可通过可选的 `label` 提供无障碍展示名称;加载和缓存标识仍使用原始附件引用。[ui-attachment](../ui-attachment/README.zh.md) 负责渲染与灯箱。 +控件组的尺寸、内容、可见性或字体加载状态变化后,composer 测量展开状态下的控件组。若无法排在同一行,控制栏为模型位设置 `--dsh-composer-model-text-display: none` 和 `--dsh-composer-model-icon-display: block`;两者默认值分别为 `block` 和 `none`。若连图标也放不下,仍允许换行。 + 上下文占用按钮在输入卡片下方、会话统计右侧显示圆环和百分比。点击按钮可在视口内的面板查看 token 构成,没有统计项时面板也不会越界;上下文用量和容量尚不可用时,按钮保持隐藏。 关闭开发者工具时,外壳仅隐藏 Trajectory;其他插件贡献的 View 仍然可用。可用 View 少于两个时隐藏 View 标签栏。在 Trajectory 激活时关闭开发者工具会返回 Chat;已保存的 View 偏好和 Session 记录保持不变。开启后,Trajectory 恢复可用。View 所有者接收可用列表,使导航操作跟随相同的可见性。 diff --git a/packages/client/ui-conversation/src/client/skeleton/InputBar.module.css b/packages/client/ui-conversation/src/client/skeleton/InputBar.module.css index fbd07f2810..bc78bb3097 100644 --- a/packages/client/ui-conversation/src/client/skeleton/InputBar.module.css +++ b/packages/client/ui-conversation/src/client/skeleton/InputBar.module.css @@ -266,6 +266,11 @@ container-type: inline-size; } +.row[data-model-compact] { + --dsh-composer-model-text-display: none; + --dsh-composer-model-icon-display: block; +} + .tools, .modes, .trailing { @@ -296,10 +301,7 @@ gap: 12px; } -/* Narrow rows drop the roomy control gaps: the mode chips and the send circle - are fixed-width, so a long model name beside the plan chip wraps the - trailing group while the first line still has room to spare. The 8px rhythm - keeps the row on one line down to the icon-only model trigger. */ +/* Compact spacing preserves room for the fixed-width controls in narrow cards. */ @container (max-width: 560px) { .tools, .modes, diff --git a/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx b/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx index 7016ea8f9d..dea8a86934 100644 --- a/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx +++ b/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx @@ -13,7 +13,7 @@ * trigger instead of a parallel tree. */ -import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' +import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react' import type { ChangeEvent, KeyboardEvent, MouseEvent } from 'react' import clsx from 'clsx' import { @@ -37,6 +37,7 @@ import { import { resolveSubmitMode } from '../input/submission-policy.ts' import { attachmentErrorText, imageSizeText } from '../image-labels.ts' import { ContextMeter } from './ContextMeter.tsx' +import { observeControlRow } from './control-row-layout.ts' import css from './InputBar.module.css' export type InputBarProps = ComposerBarProps @@ -117,6 +118,12 @@ export const InputBar = memo(function InputBar({ useEffect(() => { if (notice?.level === 'error') showToast(notice.text) }, [notice, showToast]) + const rowRef = useRef(null) + useLayoutEffect(() => { + const row = rowRef.current + if (row === null) return + return observeControlRow(row) + }, []) const cardRef = useRef(null) const scrollRef = useRef(null) @@ -407,7 +414,7 @@ export const InputBar = memo(function InputBar({ hint={hint} showPlaceholder={draft === '' && attachments.length === 0 && !claimActive} /> -
+