From a6a37b568d7cc8a84c91c5822b21319414a13db5 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Sat, 14 Nov 2026 13:44:33 +0700 Subject: [PATCH] fix(app): correct composer glyph and placeholder tones (#9608) * fix(app): mute labelled toolbar glyphs to match their labels Touch-sized composer glyphs rested at foreground while the label beside them used foregroundMuted. Use the existing label/icon glyph roles: a labelled glyph takes the muted tone, while an icon-only glyph keeps the foreground header-icon treatment from #8909. * test(app): keep toolbar tone coverage in the browser journey The component-level probe asserted the color prop handed to a stub icon in JSDOM, which the testing rules forbid. The real-browser journey already checks the rendered stroke and label colors for both glyph roles. * test(app): expect the muted tone for a labelled toolbar glyph The composer layout test still asserted the old foreground tone for the label role. * fix(app): quiet the composer placeholder to extra muted The empty composer painted its placeholder with surface4, a surface token, instead of a text tone. Use foregroundExtraMuted so it sits below foregroundMuted and above the background, and document the composer-specific exception. * test(app): clean up a composer tone fixture when setup fails The helper now releases the seeded agent and repository if navigation or the readiness check throws before the test owns cleanup. --- docs/design.md | 8 +- .../e2e/browser/composer-toolbar-tone.spec.ts | 131 ++++++++++++++++++ .../support/helpers/composer-toolbar-tone.ts | 55 ++++++++ .../components/ui/control-geometry.test.ts | 11 +- .../app/src/components/ui/control-geometry.ts | 9 +- .../composer/agent-controls/layout.test.ts | 2 +- packages/app/src/composer/input/input.tsx | 2 +- 7 files changed, 207 insertions(+), 11 deletions(-) create mode 100644 packages/app/e2e/browser/composer-toolbar-tone.spec.ts create mode 100644 packages/app/e2e/support/helpers/composer-toolbar-tone.ts diff --git a/docs/design.md b/docs/design.md index 662e714a3..57b3a7c9e 100644 --- a/docs/design.md +++ b/docs/design.md @@ -40,9 +40,9 @@ Weight has three tiers, applied by role: The rule, condensed: text that _names_ a surface or a group is `medium`. Text that lives _inside_ a surface or a group is `normal`. Top-of-screen titles are ``, which is lighter still. -Foreground is for the thing being acted on: row titles, section headings, the selected sidebar item. `foregroundMuted` is for context: hints, descriptions, secondary metadata, idle sidebar items, placeholders, status text. +Foreground is for the thing being acted on: row titles, section headings, the selected sidebar item. `foregroundMuted` is for context: hints, descriptions, secondary metadata, idle sidebar items, placeholders, status text. The composer's empty placeholder is quieter; it uses `foregroundExtraMuted`. -`foregroundExtraMuted` is reserved for passive chrome that must sit behind muted text, such as an always-visible window control. Use the solid token instead of lowering SVG opacity; per-path opacity makes overlapping icon strokes render unevenly. Interactive hover and pressed states return to `foreground`. +`foregroundExtraMuted` is reserved for passive chrome that must sit behind muted text, such as an always-visible window control, and for the composer's empty placeholder. Use the solid token instead of lowering SVG opacity; per-path opacity makes overlapping icon strokes render unevenly. Interactive hover and pressed states return to `foreground`. A theme states places and identity; `packages/app/src/styles/derive-colors.ts` derives their relationships. Sidebar hover and selected fills step from the sidebar toward the foreground. For plugin themes, passive text on those states derives against the actual state surface; page tertiary text is a separate relationship. Explicit plugin semantic overrides take precedence over derived defaults. Built-in themes retain their chosen passive text. `packages/app/src/styles/theme-contrast.test.ts` checks the built-in and representative plugin palettes against contrast floors. @@ -72,7 +72,7 @@ the sidebar. Apply it as `backgroundColor`; setting `opacity` on the control als Controls come in two sizes, defined once in `control-geometry.ts`. The default is the right size almost everywhere — pages, dialogs, forms, settings rows, the setup flow — so don't pass a size. It is 32px tall where a pointer drives it and 44px where controls are touch-sized, so every touch control meets the iOS HIG's 44pt hit region. `sm` is 28px pointer and 32px touch, with `fontSize.sm` labels, and is for tight chrome only: toolbars, nested settings rows, dense inline row actions. A `size="sm"` on an ordinary page or dialog is wrong, and so is choosing a size from `useIsCompactFormFactor()`. -Dense toolbar rows, such as the composer's, are the exception to the 44pt control. Touch-sized the row is 44pt tall and each control is a 36pt circle (`TOOLBAR_DISC_SIZE`): send and stop fill it, and every other control's pressed highlight fills it, so every highlight is the same fully rounded shape. Labelled pickers are 36pt pills. A control lays out at its full highlight (`toolbarSlot`, `toolbarContentSlot`) with no gap between controls (`TOOLBAR_CONTROL_GAP`), so neighbouring highlights touch and never overlap. Toolbar glyphs match the header icons: 20pt, the app's 1.5px stroke, resting at `foreground` (`toolbarGlyphsFor`). The context ring is 18pt with a 2px stroke (`TOOLBAR_RINGS`): a circle fills its box where an outline glyph does not, and a thin circle reads lighter than a glyph at the same stroke. A disc's solid glyph, such as the stop square, stays at the `md` size (`TOOLBAR_DISC_GLYPH_SIZES`). Pointer-sized toolbars keep 28px controls, a 4px gap, and a 16pt muted glyph that brightens on hover. +Dense toolbar rows, such as the composer's, are the exception to the 44pt control. Touch-sized the row is 44pt tall and each control is a 36pt circle (`TOOLBAR_DISC_SIZE`): send and stop fill it, and every other control's pressed highlight fills it, so every highlight is the same fully rounded shape. Labelled pickers are 36pt pills. A control lays out at its full highlight (`toolbarSlot`, `toolbarContentSlot`) with no gap between controls (`TOOLBAR_CONTROL_GAP`), so neighbouring highlights touch and never overlap. Touch-sized toolbar glyphs are 20pt at the app's 1.5px stroke. An icon-only control's glyph matches the header icons and rests at `foreground`; a glyph beside a label rests at `foregroundMuted` so the two read as one quiet unit (`toolbarGlyphsFor`). The context ring is 18pt with a 2px stroke (`TOOLBAR_RINGS`): a circle fills its box where an outline glyph does not, and a thin circle reads lighter than a glyph at the same stroke. A disc's solid glyph, such as the stop square, stays at the `md` size (`TOOLBAR_DISC_GLYPH_SIZES`). Pointer-sized toolbars keep 28px controls, a 4px gap, and a 16pt muted glyph that brightens on hover. In the composer, the first glyph's ink starts on the text column's edge, and the trailing control is always a disc, so the row does not shift as it changes between voice mode, send and stop. The disc nests into the corner, as far from the right edge as from the bottom, and touch-sized the composer's corner radius is concentric with it (`packages/app/src/composer/input/toolbar-rails.ts`). Touch-sized the disc keeps a 6pt clearance from its neighbour, because it is always painted and a pressed neighbour would merge with it. The attach button sits 2pt closer to the picker than its highlight would put it: the plus is all thin arms, so the full gap reads wide. That offset is set by eye. @@ -269,7 +269,7 @@ New status pills use ``. Identity, shortcut, and interactive link b - A "Settings" CTA on a detail page. Detail pages are settings; settings is reached from the sidebar, the host entry, or a row's kebab menu. - The word "checkout" in UI strings or identifiers. The term is "workspace". - New color tokens or hardcoded hex outside the palette. The identity color table is the documented exception (§13), not a license. -- Placeholder text dimmed beyond `foregroundMuted`. No extra opacity, no italics, no ghost-text. +- Placeholder text dimmed beyond `foregroundMuted`, except the composer's empty placeholder, which uses `foregroundExtraMuted`. No extra opacity, no italics, no ghost-text. - `onPointerEnter` and `onPointerLeave`. They do not fire on native iOS. Hover uses Pressable's `onHoverIn`/`onHoverOut` gated with `isHovered || isCompact || isNative`. - Raw DOM APIs without an `isWeb` guard. - Spacing values outside the scale. `padding: 20` and `gap: 10` are wrong. diff --git a/packages/app/e2e/browser/composer-toolbar-tone.spec.ts b/packages/app/e2e/browser/composer-toolbar-tone.spec.ts new file mode 100644 index 000000000..6d4b0a704 --- /dev/null +++ b/packages/app/e2e/browser/composer-toolbar-tone.spec.ts @@ -0,0 +1,131 @@ +import { expect, test } from "../support/fixtures"; +import { composerLocator, expectComposerVisible } from "../support/helpers/composer"; +import { + composerControl, + expectGlyphMatchesLabel, + expectIconOnlyGlyph, + readComposerControlTone, + readComposerPlaceholderTone, + readComposerTextTone, +} from "../support/helpers/composer-toolbar-tone"; +import { openAgentRoute, seedMockAgentWorkspace } from "../support/helpers/mock-agent"; + +const THINKING = "agent-thinking-selector"; +const MODE = "mode-control"; +const ATTACH = "message-input-attach-button"; +const COMBINED_MODEL = "combined-model-selector"; + +async function openSeededComposer( + page: import("@playwright/test").Page, + repoPrefix: string, + readyTestId = MODE, +) { + const agent = await seedMockAgentWorkspace({ + repoPrefix, + title: "Toolbar tone", + model: "ten-second-stream", + }); + try { + await openAgentRoute(page, agent); + await expectComposerVisible(page); + await expect(composerControl(page, readyTestId)).toBeVisible({ timeout: 30_000 }); + return agent; + } catch (error) { + await agent.cleanup(); + throw error; + } +} + +test.describe("Composer toolbar glyph tone", () => { + test.describe.configure({ timeout: 180_000 }); + + test.describe("on a touch screen", () => { + test.use({ hasTouch: true, viewport: { width: 1024, height: 1366 } }); + + test("a glyph beside its label matches the label while an icon-only glyph stays foreground", async ({ + page, + }) => { + const agent = await openSeededComposer(page, "composer-tone-touch-"); + try { + const thinking = await readComposerControlTone(composerControl(page, THINKING)); + const mode = await readComposerControlTone(composerControl(page, MODE)); + const attach = await readComposerControlTone(composerControl(page, ATTACH)); + + expectGlyphMatchesLabel(thinking, "thinking"); + expectGlyphMatchesLabel(mode, "mode"); + expectIconOnlyGlyph(attach, "attach"); + expect(attach.glyph, "an icon-only glyph is brighter than a labelled glyph").not.toBe( + thinking.label, + ); + } finally { + await agent.cleanup(); + } + }); + }); + + test.describe("on a compact non-touch window", () => { + test.use({ hasTouch: false, viewport: { width: 590, height: 844 } }); + + test("the icon-only thinking glyph stays foreground and the labelled mode glyph matches its label", async ({ + page, + }) => { + const agent = await openSeededComposer(page, "composer-tone-compact-"); + try { + const thinking = await readComposerControlTone(composerControl(page, THINKING)); + const mode = await readComposerControlTone(composerControl(page, MODE)); + const attach = await readComposerControlTone(composerControl(page, ATTACH)); + + expectIconOnlyGlyph(thinking, "thinking"); + expectGlyphMatchesLabel(mode, "mode"); + expectIconOnlyGlyph(attach, "attach"); + expect(thinking.glyph, "the icon-only glyphs share one tone").toBe(attach.glyph); + expect(thinking.glyph, "an icon-only glyph is brighter than a labelled glyph").not.toBe( + mode.label, + ); + } finally { + await agent.cleanup(); + } + }); + }); + + test.describe("on a folded compact non-touch window", () => { + test.use({ hasTouch: false, viewport: { width: 480, height: 844 } }); + + test("the empty composer placeholder is quieter than its labels", async ({ page }) => { + const agent = await openSeededComposer(page, "composer-tone-placeholder-", COMBINED_MODEL); + try { + const placeholder = await readComposerPlaceholderTone(composerLocator(page)); + const extraMuted = await readComposerTextTone( + composerControl(page, "combined-model-selector-thinking-label"), + ); + const muted = await readComposerTextTone( + composerControl(page, "combined-model-selector-model-label"), + ); + + expect(placeholder, "the composer paints a placeholder").not.toBeNull(); + expect(extraMuted, "the folded thinking label paints the extra-muted tone").not.toBeNull(); + expect(placeholder, "the placeholder uses the extra-muted tone").toBe(extraMuted); + expect(placeholder, "the placeholder is quieter than a labelled glyph").not.toBe(muted); + } finally { + await agent.cleanup(); + } + }); + }); + + test.describe("with a wide pointer", () => { + test.use({ hasTouch: false, viewport: { width: 1280, height: 800 } }); + + test("a labelled glyph stays muted and matches its label", async ({ page }) => { + const agent = await openSeededComposer(page, "composer-tone-pointer-"); + try { + const thinking = await readComposerControlTone(composerControl(page, THINKING)); + const mode = await readComposerControlTone(composerControl(page, MODE)); + + expectGlyphMatchesLabel(thinking, "thinking"); + expectGlyphMatchesLabel(mode, "mode"); + } finally { + await agent.cleanup(); + } + }); + }); +}); diff --git a/packages/app/e2e/support/helpers/composer-toolbar-tone.ts b/packages/app/e2e/support/helpers/composer-toolbar-tone.ts new file mode 100644 index 000000000..e64caf7a4 --- /dev/null +++ b/packages/app/e2e/support/helpers/composer-toolbar-tone.ts @@ -0,0 +1,55 @@ +import { expect, type Locator, type Page } from "@playwright/test"; + +/** The tones a composer toolbar control paints: its glyph's stroke and its label's text color. */ +export interface ComposerControlTone { + /** The visible glyph's stroke, or null when the control paints no glyph. */ + glyph: string | null; + /** The visible label's color, or null when the control is icon-only. */ + label: string | null; +} + +export function composerControl(page: Page, testId: string): Locator { + return page.getByTestId(testId).filter({ visible: true }).first(); +} + +/** + * Reads the colors the control actually paints. The toolbar glyph and its label are separate + * nodes, so this is the only way to tell whether they match. + */ +export async function readComposerControlTone(control: Locator): Promise { + return control.evaluate((element) => { + const visible = (node: Element) => node.getClientRects().length > 0; + const glyph = Array.from(element.querySelectorAll("svg")).find(visible); + const label = Array.from(element.querySelectorAll("*")) + .filter(visible) + .find((node) => + [...node.childNodes].some( + (child) => child.nodeType === Node.TEXT_NODE && child.textContent?.trim(), + ), + ); + return { + glyph: glyph ? getComputedStyle(glyph).stroke : null, + label: label ? getComputedStyle(label).color : null, + }; + }); +} + +export function expectGlyphMatchesLabel(tone: ComposerControlTone, name: string): void { + expect(tone.label, `${name} paints a label`).not.toBeNull(); + expect(tone.glyph, `${name}'s glyph matches its label`).toBe(tone.label); +} + +export function expectIconOnlyGlyph(tone: ComposerControlTone, name: string): void { + expect(tone.label, `${name} is icon-only`).toBeNull(); + expect(tone.glyph, `${name} paints a glyph`).not.toBeNull(); +} + +/** The color the browser paints in a text input's placeholder. */ +export async function readComposerPlaceholderTone(input: Locator): Promise { + return input.evaluate((element) => getComputedStyle(element, "::placeholder").color); +} + +/** The color the browser paints for a text node. */ +export async function readComposerTextTone(text: Locator): Promise { + return text.evaluate((element) => getComputedStyle(element).color); +} diff --git a/packages/app/src/components/ui/control-geometry.test.ts b/packages/app/src/components/ui/control-geometry.test.ts index 2e3352397..58086cf21 100644 --- a/packages/app/src/components/ui/control-geometry.test.ts +++ b/packages/app/src/components/ui/control-geometry.test.ts @@ -144,11 +144,20 @@ describe("toolbar glyphs and spacing", () => { expect(toolbarGlyphsFor("touch").label).toEqual({ size: 20, strokeWidth: 1.5, - tone: "foreground", + tone: "muted", }); expect(TOOLBAR_GLYPH_SIZES.label).toEqual({ xs: 20, md: 16 }); }); + it("mutes a touch glyph paired with a label while keeping an icon-only touch glyph foreground", () => { + const { icon, label } = toolbarGlyphsFor("touch"); + const colors = { foreground: "#fafafa", foregroundMuted: "#a1a5a4" }; + const palette = { colors } as unknown as Theme; + + expect(toolbarGlyphColor(palette, label.tone)).toBe(colors.foregroundMuted); + expect(toolbarGlyphColor(palette, icon.tone)).toBe(colors.foreground); + }); + it("sizes the touch context ring to the toolbar glyph's ink and keeps the pointer ring", () => { expect(TOOLBAR_RINGS).toEqual({ touch: { size: 18, strokeWidth: 2 }, diff --git a/packages/app/src/components/ui/control-geometry.ts b/packages/app/src/components/ui/control-geometry.ts index f8d3132e3..bec7819b7 100644 --- a/packages/app/src/components/ui/control-geometry.ts +++ b/packages/app/src/components/ui/control-geometry.ts @@ -132,9 +132,10 @@ export function iconSizeFor(size: IconSize): SizingValue { } /** - * The glyph a toolbar control paints. Touch-sized every toolbar glyph matches the header icons: - * 20pt at the app's 1.5px stroke, resting at `foreground`. Pointer-sized it is the `md` glyph at - * the same stroke and rests muted until hovered. + * The glyph a toolbar control paints. Touch-sized every toolbar glyph is 20pt at the app's 1.5px + * stroke. An icon-only control's glyph matches the header icons and rests at `foreground`; a glyph + * paired with a label rests muted so the control reads as one quiet unit with its label. + * Pointer-sized it is the `md` glyph at the same stroke and rests muted until hovered. */ export type ToolbarGlyphTone = "foreground" | "muted"; @@ -160,7 +161,7 @@ const POINTER_TOOLBAR_GLYPH: ToolbarGlyph = { const TOOLBAR_GLYPHS: Record = { touch: { icon: { size: TOUCH_ICON_SIZE.md, strokeWidth: ICON_STROKE_WIDTH, tone: "foreground" }, - label: { size: TOUCH_ICON_SIZE.md, strokeWidth: ICON_STROKE_WIDTH, tone: "foreground" }, + label: { size: TOUCH_ICON_SIZE.md, strokeWidth: ICON_STROKE_WIDTH, tone: "muted" }, }, pointer: { icon: POINTER_TOOLBAR_GLYPH, label: POINTER_TOOLBAR_GLYPH }, }; diff --git a/packages/app/src/composer/agent-controls/layout.test.ts b/packages/app/src/composer/agent-controls/layout.test.ts index 75dc07451..4a985f184 100644 --- a/packages/app/src/composer/agent-controls/layout.test.ts +++ b/packages/app/src/composer/agent-controls/layout.test.ts @@ -251,7 +251,7 @@ describe("composer control layout", () => { controlSize: 36, glyphs: { icon: { size: 20, strokeWidth: 1.5, tone: "foreground" }, - label: { size: 20, strokeWidth: 1.5, tone: "foreground" }, + label: { size: 20, strokeWidth: 1.5, tone: "muted" }, }, controlGap: 0, labelPadding: 8, diff --git a/packages/app/src/composer/input/input.tsx b/packages/app/src/composer/input/input.tsx index 6c7ddd7d8..b0ed62330 100644 --- a/packages/app/src/composer/input/input.tsx +++ b/packages/app/src/composer/input/input.tsx @@ -97,7 +97,7 @@ import { } from "@/components/ui/text-input"; const ComposerTextInput = withUnistyles(EditingTextInput, (theme) => ({ - placeholderTextColor: theme.colors.foregroundMuted, + placeholderTextColor: theme.colors.foregroundExtraMuted, })); import { resolveSendTooltipLabel,