+ {(Object.keys(COMPOSER_MIC_TITLES) as ComposerMicId[]).map((id) => (
+
+ {composerWithMic(id)}
+
+ ))}
+
+ ),
+ play: async ({ canvasElement }) => {
+ await expect(canvasElement.querySelectorAll("[data-state]")).toHaveLength(6);
+ await expect(canvasElement.querySelector(".bk-uncertain"), "M2: no mark anywhere").toBeNull();
+ },
+});
diff --git a/packages/ui-kit/stories/chrome/_composer-mic.tsx b/packages/ui-kit/stories/chrome/_composer-mic.tsx
new file mode 100644
index 0000000000..5bb85afacb
--- /dev/null
+++ b/packages/ui-kit/stories/chrome/_composer-mic.tsx
@@ -0,0 +1,49 @@
+import type { ReactElement } from "react";
+import { fn } from "storybook/test";
+
+import { Composer, type ComposerProps } from "../../src/chrome/Composer.js";
+import { MicButton, type MicButtonProps } from "../../src/voice/MicButton.js";
+
+/**
+ * The composer states with a caller's `MicButton` (#3727), built once so the
+ * stories and the visual baselines draw the same thing. Odysseus world copy.
+ */
+export const PROVIDER = "local · 8b";
+export const REVIEW = "Ask Calypso about the axe and the sail cloth.";
+export const REVIEW_LINES = "Ask Calypso\nabout the axe\nand the sail cloth.";
+
+export type ComposerMicId = "D1" | "S1" | "S1-talk-live" | "D6" | "D6-three-lines" | "offline";
+
+export const COMPOSER_MIC_TITLES: Record = {
+ D1: "Rest",
+ S1: "Holding · hint above the mic",
+ "S1-talk-live": "“Talk live…” focused",
+ D6: "Review · one line",
+ "D6-three-lines": "Review · three lines",
+ offline: "Offline · Record on this device",
+};
+
+/** The composer as the app draws it, with a caller's `MicButton` in the mic slot. */
+export function composerWithMic(id: ComposerMicId, value?: string): ReactElement {
+ const composer = (mic: MicButtonProps, props: ComposerProps = {}) => (
+ } />
+ );
+ switch (id) {
+ case "D1":
+ return composer({ name: "Dictate", onTalkLive: fn() });
+ case "S1":
+ // Nothing is captured during a hold: the ring fills and the hint explains.
+ return composer({ name: "Dictate", onTalkLive: fn(), phase: "holding", progress: 0.6, hint: true });
+ case "S1-talk-live":
+ return composer({ name: "Dictate", onTalkLive: fn() });
+ case "D6":
+ // M2: the dictated words are plain editable text, and the hint line is the normal `ready` one.
+ return composer({ name: "Dictate more" }, { value: value ?? REVIEW });
+ case "D6-three-lines":
+ return composer({ name: "Dictate more" }, { value: value ?? REVIEW_LINES });
+ case "offline":
+ // M1: no `onTalkLive`, no hint and always `idle`, so a hold is a tap.
+ return composer({ name: "Record on this device" }, { state: "offline" });
+ }
+}
+
diff --git a/packages/ui-kit/tests/composer-mic-control.test.tsx b/packages/ui-kit/tests/composer-mic-control.test.tsx
new file mode 100644
index 0000000000..99f309b28a
--- /dev/null
+++ b/packages/ui-kit/tests/composer-mic-control.test.tsx
@@ -0,0 +1,66 @@
+/**
+ * A caller-drawn mic in the composer (#3727): `micControl` takes the mic slot
+ * of the `send` and `plain` field, and the kit mic's own props (`mic`,
+ * `onMic`, `micLabel`, `micTip`, `micUnavailable`) no longer apply. Without
+ * it the composer is the one it always was, which the visual baselines prove
+ * pixel for pixel; this file holds the markup half, so a default composer that
+ * picked up the last-line alignment fails here by name.
+ */
+import { describe, expect, test } from "bun:test";
+import { renderToStaticMarkup } from "react-dom/server";
+
+import { Composer } from "../src/chrome/Composer.js";
+import { MicButton } from "../src/voice/MicButton.js";
+
+const noop = () => {};
+const labels = (html: string) => [...html.matchAll(/aria-label="([^"]*)"/g)].map((m) => m[1]);
+const fieldStyle = (html: string) => html.match(//)?.[1] ?? "";
+const mic = ;
+
+describe("Composer micControl", () => {
+ test("absent, the field centres its controls and nothing is lifted", () => {
+ for (const html of [
+ renderToStaticMarkup(),
+ renderToStaticMarkup(),
+ renderToStaticMarkup(),
+ renderToStaticMarkup(),
+ ]) {
+ expect(fieldStyle(html)).toContain("align-items:center");
+ expect(html).not.toContain("margin-bottom");
+ expect(html).not.toContain("data-composer-mic");
+ }
+ });
+
+ test("set, the caller's mic replaces the kit's, and the kit mic's props are ignored", () => {
+ for (const html of [
+ renderToStaticMarkup(),
+ renderToStaticMarkup(),
+ renderToStaticMarkup(),
+ ]) {
+ expect(labels(html)).toEqual(["Attach — photo, camera, files", "Ask your brain anything…", "Dictate", "Send"]);
+ expect(html).toContain("Talk live…");
+ expect(html).toContain('');
+ }
+ });
+
+ test("set, the field aligns to its last line and centres the 28px controls and the text on the mic", () => {
+ const html = renderToStaticMarkup();
+ expect(fieldStyle(html)).toContain("align-items:flex-end");
+ // (36 - 28) / 2 for attach and Send; (36 - 13.5 × 1.45) / 2 for the text's last line.
+ expect(html.match(/margin-bottom:4px/g)).toHaveLength(2);
+ expect(html).toContain("margin-bottom:8.2125px");
+ });
+
+ test("set while streaming, Stop sits on the last line as Send would", () => {
+ const html = renderToStaticMarkup();
+ expect(html).toContain('aria-label="Stop generating"');
+ expect(html.match(/margin-bottom:4px/g)).toHaveLength(2);
+ });
+
+ test("the voice variant keeps its own hold-to-talk disc", () => {
+ const html = renderToStaticMarkup();
+ expect(html).not.toContain("data-composer-mic");
+ expect(labels(html)).toContain("Hold to talk");
+ expect(fieldStyle(html)).toContain("align-items:center");
+ });
+});
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d1-320-dark-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d1-320-dark-chromium-linux.png
new file mode 100644
index 0000000000..b6930c36cf
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d1-320-dark-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d1-320-light-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d1-320-light-chromium-linux.png
new file mode 100644
index 0000000000..e61c3e9dac
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d1-320-light-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d1-desktop-dark-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d1-desktop-dark-chromium-linux.png
new file mode 100644
index 0000000000..cc0bc28012
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d1-desktop-dark-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d1-desktop-light-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d1-desktop-light-chromium-linux.png
new file mode 100644
index 0000000000..2053c2fc34
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d1-desktop-light-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-320-dark-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-320-dark-chromium-linux.png
new file mode 100644
index 0000000000..a771c68219
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-320-dark-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-320-light-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-320-light-chromium-linux.png
new file mode 100644
index 0000000000..0c9656980e
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-320-light-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-desktop-dark-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-desktop-dark-chromium-linux.png
new file mode 100644
index 0000000000..b3092c43b8
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-desktop-dark-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-desktop-light-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-desktop-light-chromium-linux.png
new file mode 100644
index 0000000000..e7abf86512
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-desktop-light-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-three-lines-320-dark-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-three-lines-320-dark-chromium-linux.png
new file mode 100644
index 0000000000..bd996a4ea8
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-three-lines-320-dark-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-three-lines-320-light-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-three-lines-320-light-chromium-linux.png
new file mode 100644
index 0000000000..6e4210861d
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-three-lines-320-light-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-three-lines-desktop-dark-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-three-lines-desktop-dark-chromium-linux.png
new file mode 100644
index 0000000000..2bae7efb39
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-three-lines-desktop-dark-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-three-lines-desktop-light-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-three-lines-desktop-light-chromium-linux.png
new file mode 100644
index 0000000000..524acfdfb3
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-d6-three-lines-desktop-light-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-offline-320-dark-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-offline-320-dark-chromium-linux.png
new file mode 100644
index 0000000000..6f219b0e4a
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-offline-320-dark-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-offline-320-light-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-offline-320-light-chromium-linux.png
new file mode 100644
index 0000000000..5ed1fb0b4d
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-offline-320-light-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-offline-desktop-dark-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-offline-desktop-dark-chromium-linux.png
new file mode 100644
index 0000000000..be88c8edb8
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-offline-desktop-dark-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-offline-desktop-light-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-offline-desktop-light-chromium-linux.png
new file mode 100644
index 0000000000..4693ac15f6
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-offline-desktop-light-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-320-dark-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-320-dark-chromium-linux.png
new file mode 100644
index 0000000000..84cd2ae670
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-320-dark-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-320-light-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-320-light-chromium-linux.png
new file mode 100644
index 0000000000..5e1debdef2
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-320-light-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-desktop-dark-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-desktop-dark-chromium-linux.png
new file mode 100644
index 0000000000..4f7680fe3d
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-desktop-dark-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-desktop-light-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-desktop-light-chromium-linux.png
new file mode 100644
index 0000000000..1b30b635a3
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-desktop-light-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-talk-live-320-dark-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-talk-live-320-dark-chromium-linux.png
new file mode 100644
index 0000000000..04f0cb1e4f
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-talk-live-320-dark-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-talk-live-320-light-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-talk-live-320-light-chromium-linux.png
new file mode 100644
index 0000000000..99f5b8be39
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-talk-live-320-light-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-talk-live-desktop-dark-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-talk-live-desktop-dark-chromium-linux.png
new file mode 100644
index 0000000000..edffd5e7a7
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-talk-live-desktop-dark-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-talk-live-desktop-light-chromium-linux.png b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-talk-live-desktop-light-chromium-linux.png
new file mode 100644
index 0000000000..5f7537d57e
Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/composer-mic.visual.tsx/composer-mic-s1-talk-live-desktop-light-chromium-linux.png differ
diff --git a/packages/ui-kit/tests/visual/composer-mic.visual.tsx b/packages/ui-kit/tests/visual/composer-mic.visual.tsx
new file mode 100644
index 0000000000..1caeabd8f3
--- /dev/null
+++ b/packages/ui-kit/tests/visual/composer-mic.visual.tsx
@@ -0,0 +1,69 @@
+/**
+ * The hold-to-talk `MicButton` in the real composer: visual baselines (#3727).
+ *
+ * One baseline per state, D1 rest, S1 holding with the hint, S1 with "Talk
+ * live…" focused, D6 review on one line and on three, and the offline "Record
+ * on this device" mic, at 320px and at a desktop width, in both themes.
+ *
+ * Each state is captured from its cell in `AllStates`, rendered through CSF
+ * Next's `run()`, so the baseline is exactly what Storybook shows. On the
+ * desktop the cells are the 720px composer column. The viewport stays 720px
+ * tall, so the runner never scales the frame down.
+ *
+ * Motion is emulated as reduced through the real media query, as
+ * `voice.visual.tsx` does, so the ring is one still frame. Tolerance and
+ * determinism follow `subjects.visual.tsx`: generated and compared only inside
+ * the pinned Playwright image.
+ *
+ * The composer without `micControl` is unchanged: every existing baseline
+ * that draws it stays byte-identical in the same run.
+ */
+///
+import { afterEach, expect, test } from "vitest";
+import { commands, page } from "vitest/browser";
+
+import * as composerMic from "../../stories/chrome/ComposerMic.stories.js";
+
+interface ComposedStory {
+ run: (context?: { globals?: Record }) => Promise;
+}
+
+const TOLERANCE = { comparatorOptions: { threshold: 0.01, allowedMismatchedPixelRatio: 0.001 } } as const;
+
+const before = { width: window.innerWidth, height: window.innerHeight };
+
+afterEach(async () => {
+ await commands.dictationMotion("no-preference");
+ await page.viewport(before.width, before.height);
+});
+
+const WIDTHS = [[320, "320"], [1280, "desktop"]] as const;
+
+for (const theme of ["dark", "light"] as const) {
+ for (const [width, size] of WIDTHS) {
+ test(`composer with MicButton, every state, ${size}, ${theme}`, async () => {
+ await commands.dictationMotion("reduce");
+ await page.viewport(width, 720);
+ await (composerMic.AllStates as unknown as ComposedStory).run({ globals: { theme } });
+ expect(document.documentElement.dataset.theme).toBe(theme);
+ expect(matchMedia("(prefers-reduced-motion: reduce)").matches).toBe(true);
+ expect(document.documentElement.scrollWidth, "no horizontal overflow").toBeLessThanOrEqual(width);
+ for (const ring of document.querySelectorAll(".bk-voice-ring-fill")) expect(getComputedStyle(ring).transitionDuration, "no easing").toBe("0s");
+
+ const cells = [...document.querySelectorAll("[data-state]")];
+ expect(cells).toHaveLength(6);
+ for (const cell of cells) {
+ const id = cell.dataset.state!.toLowerCase();
+ if (id === "s1-talk-live") {
+ const talk = cell.querySelector(".bk-voice-talk-live")!;
+ talk.focus();
+ expect(talk.matches(":focus-visible"), "Talk live… shown by keyboard focus").toBe(true);
+ } else {
+ (document.activeElement as HTMLElement | null)?.blur();
+ }
+ expect(cell.getBoundingClientRect().height, `${id} fits the viewport`).toBeLessThan(720);
+ await expect(cell).toMatchScreenshot(`composer-mic-${id}-${size}-${theme}`, TOLERANCE);
+ }
+ });
+ }
+}