diff --git a/.changeset/dictation-voice-settings.md b/.changeset/dictation-voice-settings.md new file mode 100644 index 0000000000..cc5e7cb025 --- /dev/null +++ b/.changeset/dictation-voice-settings.md @@ -0,0 +1,10 @@ +--- +"@schlessera/brain-ui-react": minor +"@schlessera/brain-ui-kit": minor +--- + +Choose the dictation service in Settings › Voice (#3709). The new Voice pane, between Models and Accounts, lists every dictation service the host registered and saves the brain-wide choice the moment one is picked, with **Clean up as I speak** (on by default) for services that support it. It shows a single service without a choice, says when dictation isn't set up, marks a saved service the host no longer has as unavailable, reverts a failed save with **Try again**, reloads a choice changed on another device, and is read-only for non-owners. Opening or saving Settings never opens the microphone, requests a session or calls a provider. + +The mic is named for the service the next take goes to ("Dictate · Deepgram"). The first take to a service on a device shows where its audio goes, with **Cancel** and **Start dictation**, before any session request or microphone access; the acknowledgement is stored on the device. A take is bound to the service it disclosed: a default saved meanwhile applies to the next take, and a session for any other service is refused. With nowhere to send audio, the sheet says so and offers **Open Settings**, without falling back to another service. The listening sheet reads "To ". + +Saved recordings are confirmed for the effective service when it can transcribe them; otherwise the tray offers an unsaved choice among the services that can. The upload names the confirmed service. `RecordingStore.transcribe` accepts that provider id as an optional fifth argument; a retry refused for naming another service keeps the recording and says why. The kit `Composer` adds `micTip` to show the mic's name as its pointer tooltip, and `micUnavailable`, which draws the mic disabled (`aria-disabled`) with the reason as its description and tooltip; the composer uses it when the host registers no dictation service. diff --git a/api-report/ui-kit.txt b/api-report/ui-kit.txt index 03bf5baaab..c029d6ebe4 100644 --- a/api-report/ui-kit.txt +++ b/api-report/ui-kit.txt @@ -881,6 +881,8 @@ signatures (every public export and the types it is made of) onMic?: () => void; mic?: boolean; micLabel?: string; + micTip?: boolean; + micUnavailable?: string; maxRows?: number; } ComposerRecall (packages/ui-kit/src/chrome/Composer.tsx) diff --git a/api-report/ui-react.txt b/api-report/ui-react.txt index e01ed418f9..d590ebd06a 100644 --- a/api-report/ui-react.txt +++ b/api-report/ui-react.txt @@ -714,7 +714,7 @@ signatures (every public export and the types it is made of) saveTranscript(partition: PartitionId, id: string, text: string): Promise; accept(partition: PartitionId, id: string, draftId: string, sessionId: string | null, expectedTranscript?: string): Promise; assign(id: string): Promise; - transcribe(partition: PartitionId, id: string, progress: (percent: number) => void, retry?: string): Promise; + transcribe(partition: PartitionId, id: string, progress: (percent: number) => void, retry?: string, provider?: string): Promise; syncTranscriptions(): Promise; busy(): boolean; subscribe(listener: () => void): () => void; diff --git a/docs/extending/speech.md b/docs/extending/speech.md index b7a3f41515..d979f7450d 100644 --- a/docs/extending/speech.md +++ b/docs/extending/speech.md @@ -64,6 +64,20 @@ See the [HTTP specification](../http-api.md#selectable-dictation-providers) for settings revisions, exact selection errors and the no-fallback rule. Gemini's built-in factory is implemented separately in #3708; no placeholder is registered. +The shipped app does exactly that. Settings › Voice lists every registered +provider by its `label` (an id without one is shown as is) and saves the choice +brain-wide. The mic names the next take's provider. The first take to a provider +on a device shows its `destination` text and waits for **Start dictation** +before requesting a session or the microphone, so write `destination` as the +sentence a user should read before speaking ("Microphone audio streams from this +browser to …"). Changing that text asks every device again. A provider without +`destination` is described generically. The saved-recordings tray uses the +effective provider when it implements `transcribeRecording`, and otherwise +offers the registered providers that do. See the +[ui-react guide](../../packages/ui-react/README.md#choosing-the-dictation-service). +The [selection Chrome proof](../../packages/ui-react/tests/dictation-selection-runtime.test.ts) +registers two keyless providers this way and checks which one each take reached. + The four streaming capabilities are boolean. Optional `savedAudio` is derived from a callable `transcribeRecording`; a contradictory explicit declaration is rejected. Optional `smartTranscription` is boolean when supplied: it declares that `createSession` honours its optional `mode` option, `"smart"` for cleaned-up diff --git a/docs/integration-contract.md b/docs/integration-contract.md index 1cc686b22d..b291714a37 100644 --- a/docs/integration-contract.md +++ b/docs/integration-contract.md @@ -20,6 +20,18 @@ same-commit update of the index or relevant authoritative component. How they ar The reasoning is in [decisions/contract-versioning.md](decisions/contract-versioning.md). +## Choosing the dictation provider in the app (additive, 0.45.0, #3709) + +`openSettings("voice")` opens a new Settings › Voice pane, which holds the +brain-wide dictation default. `RecordingStore.transcribe` accepts an optional +provider id, sent as `Speech-Provider`; a retry refused for naming another +provider applies the returned receipt and rejects; a pre-claim refusal +carries the server's code as `code`. The kit `Composer` adds +`micTip?: boolean` and `micUnavailable?: string`. Existing calls behave as before, and no HTTP or protocol +shape changes. See +[the package API](integration-contract/package-api.md#dictation-speech-integration-and-conformance). +This ships in a minor. + ## Bounded multi-read (additive, 0.45.0, #3642) A new read tool, `brain_read_many`, on the MCP server and the pi backend, and a diff --git a/docs/integration-contract/package-api.md b/docs/integration-contract/package-api.md index 757326f160..b69d982233 100644 --- a/docs/integration-contract/package-api.md +++ b/docs/integration-contract/package-api.md @@ -1538,6 +1538,27 @@ protocol types for the [HTTP shapes](../http-api.md#selectable-dictation-provide If-Match). `voiceSession(signal?, selection?: VoiceSessionRequest)` sends no body when selection is omitted. Explicit selection never substitutes another provider. +**Additive (0.45.0, #3709): choosing the dictation provider in the app.** The +ui-react Settings selection accepts `voice`; `openSettings("voice")` opens the +lazy Voice pane between Models and Accounts, and Models remains the default. +The pane reads discovery and writes the dictation settings only; it requests no +session, microphone or provider. The shipped composer sends +`voiceSession(signal, { providerId, smart })` with the provider it disclosed and +refuses a response naming another. The first take to a provider on a device +waits for an explicit acknowledgement of its `destination` (device-local, per +account, keyed by provider id and destination text) before either request. +`RecordingStore.transcribe(partition, id, progress, retry?, provider?)` gains an +optional fifth argument, sent as `Speech-Provider`; without it the upload +behaves as before. A retry refused with `transcription_provider_mismatch` +applies the returned receipt and rejects, keeping the recording. `@schlessera/brain-ui-kit`'s `Composer` adds `micTip?: boolean`, which +shows `micLabel` as the mic's pointer tooltip outside dictation, and +`micUnavailable?: string`, which keeps the mic named and focusable but +`aria-disabled`, uses the string as its accessible description and tooltip, and +ignores taps and keys; the shipped composer sets it when discovery reports no +registered dictation service. `RecordingStore.transcribe` rejections for a +pre-claim refusal carry the server's error code as `code`. No wire, HTTP or +protocol shape changes. + The route builds keyterms only when supported, snapshots provider identity and capabilities, and publishes `VoiceSessionResponse` with connection material. The client's matching `AsrClientFactory` receives that whole session through diff --git a/packages/ui-kit/src/chrome/Composer.tsx b/packages/ui-kit/src/chrome/Composer.tsx index 2d2b81f0db..5f01c7edbe 100644 --- a/packages/ui-kit/src/chrome/Composer.tsx +++ b/packages/ui-kit/src/chrome/Composer.tsx @@ -142,8 +142,16 @@ export interface ComposerProps { * so no mic is drawn as if it worked. */ mic?: boolean; - /** The mic's accessible name, when the app's capture is not dictation ("Record on this device"). */ + /** The mic's accessible name, when the app's capture is not dictation ("Record on this device"), or names its service ("Dictate · Deepgram"). */ micLabel?: string; + /** Shows `micLabel` as the pointer tooltip too, as the attach trigger does. Off while dictating. */ + micTip?: boolean; + /** + * Why the mic cannot be used now ("Dictation isn't set up on this host."). + * The mic stays focusable and named but is `aria-disabled`, takes this as + * its accessible description and tooltip, and a tap or key does nothing. + */ + micUnavailable?: string; /** Rows the field may grow to, on ⇧⏎ or on soft wrap, before it scrolls. Five when omitted. */ maxRows?: number; } @@ -200,6 +208,9 @@ export function Composer(p: ComposerProps) { const showAttach = p.attach !== false && v !== "plain"; const showMic = p.mic !== false && (v === "send" || v === "plain"); + const voiceReasonId = useId(); + const voiceUnavailable = p.micUnavailable !== undefined; + const voiceAct = Boolean(p.onMic) || voiceUnavailable; const showSend = v === "send" && !streaming; const showStop = v === "send" && streaming; const editable = Boolean(p.onChange) && !dictating; @@ -329,7 +340,7 @@ export function Composer(p: ComposerProps) { onChange={editable ? (e: ChangeEvent) => p.onChange?.(e.target.value) : undefined} onKeyDown={onKeyDown} /> - {showMic ? : null} + {showMic ? : null} {showStop ? ( {v === "voice" && p.mic !== false ? ( p.onMic?.()) : undefined} + style={{ ...disc(54, accent.amber.fill, true), ...(voiceUnavailable ? { opacity: 0.45, cursor: "not-allowed" } : {}) }} + className={voiceAct ? "bk-control" : undefined} + role={voiceAct ? "button" : undefined} + aria-label={voiceAct ? (p.micLabel ?? "Hold to talk") : undefined} + aria-disabled={voiceUnavailable ? true : undefined} + aria-describedby={voiceUnavailable ? voiceReasonId : undefined} + title={p.micUnavailable} + tabIndex={voiceAct ? 0 : undefined} + onClick={voiceUnavailable ? undefined : p.onMic} + onKeyDown={p.onMic && !voiceUnavailable ? pressable(() => p.onMic?.()) : undefined} > + {voiceUnavailable ? : null} ) : null} @@ -485,12 +500,15 @@ function resetTip(trigger: HTMLElement, left: boolean) { * keystroke: Escape, or opening the menu, hides it until the pointer leaves or * focus moves away. An inert trigger — a dictating composer — has no tooltip. */ -function IconButton(props: { icon: "attach" | "mic"; label: string; haspopup?: "menu"; tip?: boolean; targetSize?: number; onClick?: () => void }) { - const act = Boolean(props.onClick); - const tip = act && props.tip === true; +function IconButton(props: { icon: "attach" | "mic"; label: string; haspopup?: "menu"; tip?: boolean; unavailable?: string; targetSize?: number; onClick?: () => void }) { + const reasonId = useId(); + const unavailable = props.unavailable; + // Unavailable still names itself and explains why, so it stays reachable. + const act = Boolean(props.onClick) || unavailable !== undefined; + const tip = act && (props.tip === true || unavailable !== undefined); const activate = (target: HTMLElement) => { if (tip) dismissTip(target); - props.onClick?.(); + if (unavailable === undefined) props.onClick?.(); }; return ( activate(event.currentTarget) : undefined} @@ -523,7 +544,7 @@ function IconButton(props: { icon: "attach" | "mic"; label: string; haspopup?: " onBlur={tip ? (event) => resetTip(event.currentTarget, false) : undefined} > - {tip ? : null} + {tip ? : null} ); } diff --git a/packages/ui-kit/tests/composer-mic.test.tsx b/packages/ui-kit/tests/composer-mic.test.tsx index a7d2cfa443..b92362cdad 100644 --- a/packages/ui-kit/tests/composer-mic.test.tsx +++ b/packages/ui-kit/tests/composer-mic.test.tsx @@ -37,4 +37,19 @@ describe("Composer microphone", () => { expect(html.includes("lucide-mic"), `${variant}: no mic icon`).toBe(false); } }); + + test("micUnavailable keeps the mic named and focusable, aria-disabled, and described by its reason", () => { + const reason = "Dictation isn't set up on this host."; + for (const variant of ["send", "voice"] as const) { + const html = renderToStaticMarkup(); + const mic = html.match(/]*role="button"[^>]*aria-disabled="true"[^>]*>/)?.[0] ?? ""; + expect(mic, `${variant}: an aria-disabled button`).not.toBe(""); + expect(mic, `${variant}: still reachable by keyboard`).toContain('tabindex="0"'); + const described = mic.match(/aria-describedby="([^"]+)"/)?.[1]; + expect(described, `${variant}: described by its reason`).toBeTruthy(); + expect(html, `${variant}: the reason is the description`).toMatch(new RegExp(`id="${described}"[^>]*>${reason.replace("'", "'")}<`)); + } + // Without a reason the mic is an ordinary control. + expect(renderToStaticMarkup()).not.toContain("aria-disabled"); + }); }); diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-1280-connecting--existing-cancellation-semantics-and-scroll-restoration-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-1280-connecting--existing-cancellation-semantics-and-scroll-restoration-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-1280-connecting--existing-cancellation-semantics-and-scroll-restoration-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-1280-draining--existing-cancellation-semantics-and-scroll-restoration-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-1280-draining--existing-cancellation-semantics-and-scroll-restoration-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-1280-draining--existing-cancellation-semantics-and-scroll-restoration-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-1280-listening--existing-cancellation-semantics-and-scroll-restoration-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-1280-listening--existing-cancellation-semantics-and-scroll-restoration-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-1280-listening--existing-cancellation-semantics-and-scroll-restoration-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-320-connecting--existing-cancellation-semantics-and-scroll-restoration-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-320-connecting--existing-cancellation-semantics-and-scroll-restoration-1.png new file mode 100644 index 0000000000..c2f66f133d Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-320-connecting--existing-cancellation-semantics-and-scroll-restoration-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-320-draining--existing-cancellation-semantics-and-scroll-restoration-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-320-draining--existing-cancellation-semantics-and-scroll-restoration-1.png new file mode 100644 index 0000000000..c2f66f133d Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-320-draining--existing-cancellation-semantics-and-scroll-restoration-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-320-listening--existing-cancellation-semantics-and-scroll-restoration-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-320-listening--existing-cancellation-semantics-and-scroll-restoration-1.png new file mode 100644 index 0000000000..c2f66f133d Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-Escape-320-listening--existing-cancellation-semantics-and-scroll-restoration-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-breakpoint--a-live-capture-moves-between-899-and-900-without-stopping-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-breakpoint--a-live-capture-moves-between-899-and-900-without-stopping-1.png new file mode 100644 index 0000000000..de04ec1cc9 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-breakpoint--a-live-capture-moves-between-899-and-900-without-stopping-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-cap-waits-for-translated-entrance-before-exact-rendered-measurement-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-cap-waits-for-translated-entrance-before-exact-rendered-measurement-1.png new file mode 100644 index 0000000000..c2f66f133d Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-cap-waits-for-translated-entrance-before-exact-rendered-measurement-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-1280-dark--reviewable-screenshot-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-1280-dark--reviewable-screenshot-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-1280-dark--reviewable-screenshot-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-1280-light--reviewable-screenshot-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-1280-light--reviewable-screenshot-1.png new file mode 100644 index 0000000000..b50c43ea27 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-1280-light--reviewable-screenshot-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-1920-dark--reviewable-screenshot-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-1920-dark--reviewable-screenshot-1.png new file mode 100644 index 0000000000..979d89fe3e Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-1920-dark--reviewable-screenshot-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-1920-light--reviewable-screenshot-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-1920-light--reviewable-screenshot-1.png new file mode 100644 index 0000000000..7de7a2a40f Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-1920-light--reviewable-screenshot-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-320-dark--reviewable-screenshot-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-320-dark--reviewable-screenshot-1.png new file mode 100644 index 0000000000..c2f66f133d Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-320-dark--reviewable-screenshot-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-320-light--reviewable-screenshot-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-320-light--reviewable-screenshot-1.png new file mode 100644 index 0000000000..f22b4375ab Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-capture-320-light--reviewable-screenshot-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-cleanup--renderer-failure-still-releases-touch--motion-and-document-state-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-cleanup--renderer-failure-still-releases-touch--motion-and-document-state-1.png new file mode 100644 index 0000000000..fa94250437 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-cleanup--renderer-failure-still-releases-touch--motion-and-document-state-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--Done-stops-once--drains-into-review-and-restores-mic-focus-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--Done-stops-once--drains-into-review-and-restores-mic-focus-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--Done-stops-once--drains-into-review-and-restores-mic-focus-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--Enter-on-Cancel-cancels-rather-than-committing-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--Enter-on-Cancel-cancels-rather-than-committing-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--Enter-on-Cancel-cancels-rather-than-committing-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--Enter-stops-once--drains-into-review-and-restores-mic-focus-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--Enter-stops-once--drains-into-review-and-restores-mic-focus-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--Enter-stops-once--drains-into-review-and-restores-mic-focus-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--Space-stops-once--drains-into-review-and-restores-mic-focus-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--Space-stops-once--drains-into-review-and-restores-mic-focus-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--Space-stops-once--drains-into-review-and-restores-mic-focus-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--mic-Enter-stops-once--drains-into-review-and-restores-mic-focus-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--mic-Enter-stops-once--drains-into-review-and-restores-mic-focus-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--mic-Enter-stops-once--drains-into-review-and-restores-mic-focus-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--mic-Space-stops-once--drains-into-review-and-restores-mic-focus-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--mic-Space-stops-once--drains-into-review-and-restores-mic-focus-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--mic-Space-stops-once--drains-into-review-and-restores-mic-focus-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--mic-stops-once--drains-into-review-and-restores-mic-focus-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--mic-stops-once--drains-into-review-and-restores-mic-focus-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--mic-stops-once--drains-into-review-and-restores-mic-focus-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--opening-focuses-Done--conversation-selection-and-Enter-elsewhere-keep-capture-live-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--opening-focuses-Done--conversation-selection-and-Enter-elsewhere-keep-capture-live-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--opening-focuses-Done--conversation-selection-and-Enter-elsewhere-keep-capture-live-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--the-composer-cannot-type-or-Send-past-review-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--the-composer-cannot-type-or-Send-past-review-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop--the-composer-cannot-type-or-Send-past-review-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop-1280-dark--bounded-above-composer-with-an-8px-gap-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop-1280-dark--bounded-above-composer-with-an-8px-gap-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop-1280-dark--bounded-above-composer-with-an-8px-gap-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop-1280-light--bounded-above-composer-with-an-8px-gap-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop-1280-light--bounded-above-composer-with-an-8px-gap-1.png new file mode 100644 index 0000000000..b50c43ea27 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop-1280-light--bounded-above-composer-with-an-8px-gap-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop-1920-dark--bounded-above-composer-with-an-8px-gap-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop-1920-dark--bounded-above-composer-with-an-8px-gap-1.png new file mode 100644 index 0000000000..979d89fe3e Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop-1920-dark--bounded-above-composer-with-an-8px-gap-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop-1920-light--bounded-above-composer-with-an-8px-gap-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop-1920-light--bounded-above-composer-with-an-8px-gap-1.png new file mode 100644 index 0000000000..7de7a2a40f Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop-1920-light--bounded-above-composer-with-an-8px-gap-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop-error--existing-error-replaces-disclosure-and-controls-still-drain-to-review-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop-error--existing-error-replaces-disclosure-and-controls-still-drain-to-review-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-desktop-error--existing-error-replaces-disclosure-and-controls-still-drain-to-review-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-disclosure-1280-dark--unchanged-browser-speech-warning-precedes-transcript-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-disclosure-1280-dark--unchanged-browser-speech-warning-precedes-transcript-1.png new file mode 100644 index 0000000000..dc9a8229fa Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-disclosure-1280-dark--unchanged-browser-speech-warning-precedes-transcript-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-disclosure-1280-light--unchanged-browser-speech-warning-precedes-transcript-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-disclosure-1280-light--unchanged-browser-speech-warning-precedes-transcript-1.png new file mode 100644 index 0000000000..82fcbecb66 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-disclosure-1280-light--unchanged-browser-speech-warning-precedes-transcript-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-disclosure-320-dark--unchanged-browser-speech-warning-precedes-transcript-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-disclosure-320-dark--unchanged-browser-speech-warning-precedes-transcript-1.png new file mode 100644 index 0000000000..51b233af6f Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-disclosure-320-dark--unchanged-browser-speech-warning-precedes-transcript-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-disclosure-320-light--unchanged-browser-speech-warning-precedes-transcript-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-disclosure-320-light--unchanged-browser-speech-warning-precedes-transcript-1.png new file mode 100644 index 0000000000..24343729ea Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-disclosure-320-light--unchanged-browser-speech-warning-precedes-transcript-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-entrance-capture-survives-async-fixture-latency-beyond-200ms-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-entrance-capture-survives-async-fixture-latency-beyond-200ms-1.png new file mode 100644 index 0000000000..f22b4375ab Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-entrance-capture-survives-async-fixture-latency-beyond-200ms-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-long-transcript-1280--capped--internally-scrolled-to-newest-words-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-long-transcript-1280--capped--internally-scrolled-to-newest-words-1.png new file mode 100644 index 0000000000..faa9dd6821 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-long-transcript-1280--capped--internally-scrolled-to-newest-words-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-long-transcript-1920--capped--internally-scrolled-to-newest-words-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-long-transcript-1920--capped--internally-scrolled-to-newest-words-1.png new file mode 100644 index 0000000000..979d89fe3e Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-long-transcript-1920--capped--internally-scrolled-to-newest-words-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-long-transcript-320--capped--internally-scrolled-to-newest-words-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-long-transcript-320--capped--internally-scrolled-to-newest-words-1.png new file mode 100644 index 0000000000..c2f66f133d Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-long-transcript-320--capped--internally-scrolled-to-newest-words-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-no-preference--desktop-stays-stationary-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-no-preference--desktop-stays-stationary-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-no-preference--desktop-stays-stationary-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-no-preference-Cancel--phone-entrance-and-controls-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-no-preference-Cancel--phone-entrance-and-controls-1.png new file mode 100644 index 0000000000..c2f66f133d Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-no-preference-Cancel--phone-entrance-and-controls-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-no-preference-Done--phone-entrance-and-controls-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-no-preference-Done--phone-entrance-and-controls-1.png new file mode 100644 index 0000000000..c2f66f133d Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-no-preference-Done--phone-entrance-and-controls-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-reduce--desktop-stays-stationary-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-reduce--desktop-stays-stationary-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-reduce--desktop-stays-stationary-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-reduce-Cancel--phone-entrance-and-controls-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-reduce-Cancel--phone-entrance-and-controls-1.png new file mode 100644 index 0000000000..6480a4fe69 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-reduce-Cancel--phone-entrance-and-controls-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-reduce-Done--phone-entrance-and-controls-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-reduce-Done--phone-entrance-and-controls-1.png new file mode 100644 index 0000000000..6480a4fe69 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-dark-reduce-Done--phone-entrance-and-controls-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-no-preference--desktop-stays-stationary-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-no-preference--desktop-stays-stationary-1.png new file mode 100644 index 0000000000..b50c43ea27 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-no-preference--desktop-stays-stationary-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-no-preference-Cancel--phone-entrance-and-controls-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-no-preference-Cancel--phone-entrance-and-controls-1.png new file mode 100644 index 0000000000..f22b4375ab Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-no-preference-Cancel--phone-entrance-and-controls-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-no-preference-Done--phone-entrance-and-controls-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-no-preference-Done--phone-entrance-and-controls-1.png new file mode 100644 index 0000000000..f22b4375ab Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-no-preference-Done--phone-entrance-and-controls-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-reduce--desktop-stays-stationary-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-reduce--desktop-stays-stationary-1.png new file mode 100644 index 0000000000..b50c43ea27 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-reduce--desktop-stays-stationary-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-reduce-Cancel--phone-entrance-and-controls-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-reduce-Cancel--phone-entrance-and-controls-1.png new file mode 100644 index 0000000000..07e925cc1e Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-reduce-Cancel--phone-entrance-and-controls-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-reduce-Done--phone-entrance-and-controls-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-reduce-Done--phone-entrance-and-controls-1.png new file mode 100644 index 0000000000..07e925cc1e Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-precompiled-light-reduce-Done--phone-entrance-and-controls-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-no-preference--desktop-stays-stationary-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-no-preference--desktop-stays-stationary-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-no-preference--desktop-stays-stationary-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-no-preference-Cancel--phone-entrance-and-controls-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-no-preference-Cancel--phone-entrance-and-controls-1.png new file mode 100644 index 0000000000..c2f66f133d Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-no-preference-Cancel--phone-entrance-and-controls-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-no-preference-Done--phone-entrance-and-controls-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-no-preference-Done--phone-entrance-and-controls-1.png new file mode 100644 index 0000000000..c2f66f133d Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-no-preference-Done--phone-entrance-and-controls-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-reduce--desktop-stays-stationary-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-reduce--desktop-stays-stationary-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-reduce--desktop-stays-stationary-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-reduce-Cancel--phone-entrance-and-controls-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-reduce-Cancel--phone-entrance-and-controls-1.png new file mode 100644 index 0000000000..6480a4fe69 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-reduce-Cancel--phone-entrance-and-controls-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-reduce-Done--phone-entrance-and-controls-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-reduce-Done--phone-entrance-and-controls-1.png new file mode 100644 index 0000000000..6480a4fe69 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-dark-reduce-Done--phone-entrance-and-controls-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-no-preference--desktop-stays-stationary-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-no-preference--desktop-stays-stationary-1.png new file mode 100644 index 0000000000..b50c43ea27 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-no-preference--desktop-stays-stationary-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-no-preference-Cancel--phone-entrance-and-controls-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-no-preference-Cancel--phone-entrance-and-controls-1.png new file mode 100644 index 0000000000..f22b4375ab Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-no-preference-Cancel--phone-entrance-and-controls-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-no-preference-Done--phone-entrance-and-controls-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-no-preference-Done--phone-entrance-and-controls-1.png new file mode 100644 index 0000000000..f22b4375ab Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-no-preference-Done--phone-entrance-and-controls-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-reduce--desktop-stays-stationary-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-reduce--desktop-stays-stationary-1.png new file mode 100644 index 0000000000..b50c43ea27 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-reduce--desktop-stays-stationary-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-reduce-Cancel--phone-entrance-and-controls-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-reduce-Cancel--phone-entrance-and-controls-1.png new file mode 100644 index 0000000000..07e925cc1e Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-reduce-Cancel--phone-entrance-and-controls-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-reduce-Done--phone-entrance-and-controls-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-reduce-Done--phone-entrance-and-controls-1.png new file mode 100644 index 0000000000..07e925cc1e Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-motion-theme-light-reduce-Done--phone-entrance-and-controls-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-phone-dark--baseline-sheet-geometry--animation-and-backdrop-to-stop-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-phone-dark--baseline-sheet-geometry--animation-and-backdrop-to-stop-1.png new file mode 100644 index 0000000000..c2f66f133d Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-phone-dark--baseline-sheet-geometry--animation-and-backdrop-to-stop-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-phone-light--baseline-sheet-geometry--animation-and-backdrop-to-stop-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-phone-light--baseline-sheet-geometry--animation-and-backdrop-to-stop-1.png new file mode 100644 index 0000000000..f22b4375ab Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-phone-light--baseline-sheet-geometry--animation-and-backdrop-to-stop-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-swipe-draining--words-stay-reviewable-and-Cancel-never-runs-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-swipe-draining--words-stay-reviewable-and-Cancel-never-runs-1.png new file mode 100644 index 0000000000..fa94250437 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-swipe-draining--words-stay-reviewable-and-Cancel-never-runs-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-swipe-mid-drag--words-stay-reviewable-and-Cancel-never-runs-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-swipe-mid-drag--words-stay-reviewable-and-Cancel-never-runs-1.png new file mode 100644 index 0000000000..fa94250437 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-swipe-mid-drag--words-stay-reviewable-and-Cancel-never-runs-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-swipe-recording--words-stay-reviewable-and-Cancel-never-runs-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-swipe-recording--words-stay-reviewable-and-Cancel-never-runs-1.png new file mode 100644 index 0000000000..fa94250437 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-swipe-recording--words-stay-reviewable-and-Cancel-never-runs-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-tall-phone--the-short-transcript-keeps-the-viewport-height-floor-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-tall-phone--the-short-transcript-keeps-the-viewport-height-floor-1.png new file mode 100644 index 0000000000..dcbe553f77 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-tall-phone--the-short-transcript-keeps-the-viewport-height-floor-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-unmount-1280--modal-lock-and-live-capture-are-released-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-unmount-1280--modal-lock-and-live-capture-are-released-1.png new file mode 100644 index 0000000000..9fc2f023a1 Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-unmount-1280--modal-lock-and-live-capture-are-released-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-unmount-320--modal-lock-and-live-capture-are-released-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-unmount-320--modal-lock-and-live-capture-are-released-1.png new file mode 100644 index 0000000000..c2f66f133d Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-unmount-320--modal-lock-and-live-capture-are-released-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-wide-touch-only--Cancel-has-a-real-44px-touch-target-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-wide-touch-only--Cancel-has-a-real-44px-touch-target-1.png new file mode 100644 index 0000000000..48f38e417a Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-wide-touch-only--Cancel-has-a-real-44px-touch-target-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-wide-touch-only--Done-has-a-real-44px-touch-target-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-wide-touch-only--Done-has-a-real-44px-touch-target-1.png new file mode 100644 index 0000000000..48f38e417a Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-wide-touch-only--Done-has-a-real-44px-touch-target-1.png differ diff --git a/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-wide-touch-only--mic-has-a-real-44px-touch-target-1.png b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-wide-touch-only--mic-has-a-real-44px-touch-target-1.png new file mode 100644 index 0000000000..48f38e417a Binary files /dev/null and b/packages/ui-kit/tests/visual/__screenshots__/dictation-panel.visual.tsx/dictation-wide-touch-only--mic-has-a-real-44px-touch-target-1.png differ diff --git a/packages/ui-kit/tests/visual/dictation-panel.visual.tsx b/packages/ui-kit/tests/visual/dictation-panel.visual.tsx index c840d0a088..cc64f5fcf3 100644 --- a/packages/ui-kit/tests/visual/dictation-panel.visual.tsx +++ b/packages/ui-kit/tests/visual/dictation-panel.visual.tsx @@ -5,6 +5,7 @@ import { createRoot, type Root } from "react-dom/client"; import { BrainUiProvider } from "../../../ui-react/src/root-context.js"; import { createBrainUiRoot, type BrainUiRoot } from "../../../ui-react/src/root.js"; import { Composer } from "../../../ui-react/src/components/chat/composer.js"; +import { primeDictation } from "../../../ui-react/tests/fixtures/dictation-discovery.js"; import type { AsrClient, AsrClientOptions } from "../../../ui-sdk/src/client/asr.js"; // Real composer + useDictation. The provider is a keyless scripted ASR client; @@ -86,6 +87,8 @@ async function mount(width = 1280, height = 800, theme = "dark", cssEntry: "prec vi.stubGlobal("fetch", request); ui = createBrainUiRoot({ storage: null, request }); ui.stores.connection.getState().setWsStatus("connected"); + // Selection and the one-time acknowledgement (#3709) precede every take. + primeDictation(ui, "fixture"); ui.asr.register("fixture", options => { const client = new FixtureClient(options); clients.push(client); return client; }); renderer = createRoot(host); flushSync(() => renderer!.render( @@ -95,7 +98,7 @@ async function mount(width = 1280, height = 800, theme = "dark", cssEntry: "prec const frame = host.querySelector("[data-composer]")!; await userEvent.click(frame.querySelector("textarea")!); await userEvent.keyboard("Keep the existing draft"); - const mic = () => frame.querySelector('[aria-label="Dictate"], [aria-label="Stop dictation"]')!; + const mic = () => frame.querySelector('[aria-label^="Dictate"], [aria-label="Stop dictation"]')!; // Observe the opening commit before yielding to the native click command. // A later getAnimations() lookup can miss the shipped 200ms entrance (#1521). // Flush styles on the actual surface and pause its own CSSAnimation in this @@ -342,8 +345,9 @@ for (const cssEntry of ["precompiled", "theme"] as const) for (const theme of [" for (const width of [320, 1280]) for (const theme of ["dark", "light"]) { test(`dictation disclosure ${width} ${theme}: unchanged browser-speech warning precedes transcript`, async () => { const { listen } = await mount(width, 800, theme); await listen(); - flushSync(() => ui!.stores.voice.getState().setProviderId("webspeech")); - const note = [...panel().querySelectorAll("div")].find(el => el.textContent === "via browser speech · audio goes to Google")!; + // The sheet names the take's frozen target (#3709); browser speech keeps its warning ink. + flushSync(() => ui!.stores.voice.setState({ dictationTarget: { id: "webspeech", label: "Browser speech", capabilities: { streaming: true, interimResults: true, keyterms: false, endpointing: false, savedAudio: false } } })); + const note = [...panel().querySelectorAll("div")].find(el => el.textContent === "To Browser speech")!; expect(note).not.toBeNull(); expect(note.compareDocumentPosition(transcript()) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); const css = getComputedStyle(note); diff --git a/packages/ui-react/README.md b/packages/ui-react/README.md index c7c8569f5b..ed2dd89f62 100644 --- a/packages/ui-react/README.md +++ b/packages/ui-react/README.md @@ -63,6 +63,47 @@ both stylesheet entry points. Both forms keep the provider disclosure, transcript scrolling and review flow. The composer preserves its draft and prevents typing or sending while capture or its final drain is active. +### Choosing the dictation service + +Settings › Voice (under This brain, between Models and Accounts) holds the +brain-wide dictation default: one radio per service the host registered, saved +the moment it is picked, and **Clean up as I speak** (on by default) when the +chosen service declares SMART transcription. The pane reads +`GET /api/voice/providers` and writes `PUT /api/voice/dictation/settings` +against its revision; it never opens the microphone, requests a session or +calls a provider. Writes belong to the root, not to the pane: a choice picked +while an earlier save is still on its way is written even if Settings closes. +A confirmed save is shown at once and makes the discovery snapshot stale, so +the next take reads discovery again before it discloses anything. A save that +fails reverts and offers **Try again**; a save another device overtook says +"Changed on another device" and reloads the current value; a read that fails is +reported even over an older snapshot, which is never called current. The +controls are enabled only once the authenticated probe has named an account, +which it does only for the owner; anyone else sees the choice read-only before +trying, and the server still refuses them. With one service the pane shows it +without a choice; with none it says dictation isn't set up and the mic is +disabled with that explanation (recording on the device is unaffected). A +saved service the host no longer registers is shown as a dashed "Saved choice +· not available" row and blocks dictation until another is picked; nothing +falls back. + +The mic is named for the next take's service ("Dictate · Deepgram"), as its +accessible name and pointer tooltip. The first take to a service on a device +shows where its audio goes, with **Cancel** and **Start dictation**, before any +session request or microphone access. The acknowledgement is stored on the +device per account, keyed by the service and its destination text; storage that +fails asks again. A take sends the service it disclosed and refuses a session +for any other; a default saved during a take applies to the next one. After +**Start dictation**, focus continues on **Done**. With no service to send to, +the sheet says so and offers **Open Settings**. Saved recordings are confirmed +for the effective service when it can transcribe them; otherwise the tray +offers an unsaved, per-recording choice among the services that can. Each new +confirmation is resolved from the root's current discovery and keeps that +target until it uploads; the upload names it (`Speech-Provider`). When the host +answers that the service is gone, the tray reads discovery again and the next +upload needs a new confirmation. Labels and destinations the server sends win; +built-ins registered without them fall back to client-side names. + When a provider ends dictation with an error, or dictation cannot start, a persistent amber notice explains the failure below review. Its safe copy refers only to words from that capture. Dismiss keeps the review words; a new capture @@ -705,8 +746,11 @@ offers **Refresh and retry**. Sync and reset use immediate layout updates. ## Settings organization -Settings exposes the same eight panes on phone, tablet and desktop: Appearance -& input, Models, Accounts, Skills, Modules, Storage, Security, and Devices & agents. +Settings exposes the same nine panes on phone, tablet and desktop: Appearance +& input, Models, Voice, Accounts, Skills, Modules, Storage, Security, and Devices & agents. +Voice holds the dictation service (see [Choosing the dictation service](#choosing-the-dictation-service)); +its groups each own their route and state, so the live-conversation service can +join the same pane without sharing a revision. Theme and the single-key shortcut switch apply only on this device and live in Appearance & input. Accounts holds provider sign-in and web-search settings; Security holds passkeys, always-allowed tool revocation and sign-out. diff --git a/packages/ui-react/src/components/chat/composer-view.tsx b/packages/ui-react/src/components/chat/composer-view.tsx index cff8dad4c9..ef0e913b34 100644 --- a/packages/ui-react/src/components/chat/composer-view.tsx +++ b/packages/ui-react/src/components/chat/composer-view.tsx @@ -63,8 +63,12 @@ export interface ComposerViewProps { dictationNotice?: string; onDismissDictationNotice?: () => void; onDismissCaptureNotice?: () => void; - /** The mic's accessible name when it does not dictate. */ + /** The mic's accessible name when it does not dictate, or names the dictation service. */ micLabel?: string; + /** Shows micLabel as the mic's pointer tooltip. */ + micTip?: boolean; + /** Why the mic cannot be used: it is drawn disabled with this explanation. */ + micUnavailable?: string; /** Off: no mic is drawn, because there is no capture to offer. */ mic?: boolean; value: string; @@ -297,6 +301,8 @@ export function ComposerView(p: ComposerViewProps) { onMic={p.onMic} mic={p.mic} micLabel={p.micLabel} + micTip={p.micTip} + micUnavailable={p.micUnavailable} /> ); diff --git a/packages/ui-react/src/components/chat/composer.tsx b/packages/ui-react/src/components/chat/composer.tsx index c35c31adb8..0eb5854990 100644 --- a/packages/ui-react/src/components/chat/composer.tsx +++ b/packages/ui-react/src/components/chat/composer.tsx @@ -24,6 +24,7 @@ import { DictationSheet } from "../voice/dictation-sheet.js"; import { ReviewCard } from "../voice/review-card.js"; import { dictationNoticeText } from "../../voice/dictation-failure.js"; import { useDictation } from "../../voice/use-dictation.js"; +import { dictationTarget, loadDiscovery, providerShortLabel } from "../../voice/dictation-providers.js"; import { useLocalCapture, useLocalCaptureSupport } from "../../voice/use-local-capture.js"; import { useVoiceStore } from "../../voice/voice-store.js"; import { detectClientEnvironment } from "../../lib/client-environment.js"; @@ -305,6 +306,15 @@ export function Composer({ send, handle }: { send: (msg: ClientMessage) => void const dictationNotice = useVoiceStore((s) => s.dictationNotice); const dismissDictationNotice = useVoiceStore((s) => s.dismissDictationNotice); const dictation = useDictation(); + // The mic names the service the next take goes to (D4), from the read-only + // discovery snapshot. Reading it mints nothing and opens no microphone. + // A stale snapshot may no longer be the server's, so it names nothing. + const discovery = useVoiceStore((s) => s.discovery && !s.discovery.stale ? s.discovery.snapshot : null); + const discoveryStale = useVoiceStore((s) => s.discovery?.stale === true); + // Before the microphone opens (the acknowledgement or a blocked take), nothing is being dictated yet. + const gated = useVoiceStore((s) => s.dictationGate !== null); + const nextTarget = discovery ? dictationTarget(discovery) : null; + const dictateLabel = nextTarget?.kind === "ready" ? `Dictate · ${providerShortLabel(nextTarget.provider)}` : undefined; const localCapture = useLocalCapture(); const localSupported = useLocalCaptureSupport(); const localPhase = useVoiceStore((s) => s.local); @@ -320,6 +330,14 @@ export function Composer({ send, handle }: { send: (msg: ClientMessage) => void : localSupported === null ? "pending" : localSupported ? "local" : "unsupported"; + useEffect(() => { + if (micMode === "dictate") void loadDiscovery(root).catch(() => {}); + }, [root, micMode, discoveryStale]); + // Plan §7: with no dictation service registered, the mic is disabled and + // says why. Recording on the device does not depend on one. + const dictationUnavailable = micMode === "dictate" && voiceMode !== "dictate" && discovery?.providers.length === 0 + ? "Dictation isn\u0027t set up on this host." : undefined; + const [dismissedLocalNotice, setDismissedLocalNotice] = useState(null); const captureNotice = micMode === "unsupported" ? "This browser can't save recordings on the device. You can type a note and send it when you're back online." @@ -333,7 +351,7 @@ export function Composer({ send, handle }: { send: (msg: ClientMessage) => void if (kind === "dictation") dismissDictationNotice(); else { setDismissedLocalNotice(captureNotice ?? null); root.stores.voice.getState().setLocalNotice(null); } if (heldFocus) { - const mic = frame?.querySelector('[aria-label="Dictate"], [aria-label="Record on this device"]'); + const mic = frame?.querySelector('[aria-label^="Dictate"], [aria-label="Record on this device"]'); if (mic) mic.focus(); else focusField(); } } @@ -715,7 +733,7 @@ export function Composer({ send, handle }: { send: (msg: ClientMessage) => void const [recordingNotice, setRecordingNotice] = useState(""); useEffect(() => root.recordings?.onEvent(event => { if (event.message) setRecordingNotice(event.message); }), [root]); const focusMic = () => setTimeout(() => frameRef.current?.querySelector( - '[aria-label="Record on this device"], [aria-label="Dictate"], [aria-label="Stop and save"]' + '[aria-label="Record on this device"], [aria-label^="Dictate"], [aria-label="Stop and save"]' )?.focus({ preventScroll: true }), 0); useEffect(() => root.stores.voice.subscribe((state, previous) => { // Observe the end before React removes the sheet's focused control. @@ -876,14 +894,17 @@ export function Composer({ send, handle }: { send: (msg: ClientMessage) => void { setAttachMenuOpen(false); root.connection.conversation.enter(); } : undefined} dictation={<> dictation.cancel()} /> + composerRef={frameRef} onStop={stopDictation} onCancel={() => dictation.cancel()} onConfirm={dictation.confirm} + onOpenSettings={() => { dictation.cancel(); root.stores.ui.getState().openSettings("voice"); }} /> {root.localCapture?.durable && }} dictationNotice={dictationNotice ? dictationNoticeText(dictationNotice) : undefined} onDismissDictationNotice={() => dismissNotice("dictation")} captureNotice={captureNotice !== dismissedLocalNotice ? captureNotice : undefined} onDismissCaptureNotice={() => dismissNotice("local")} mic={micMode !== "unsupported"} - micLabel={micMode !== "local" ? undefined : localPhase === "idle" || localPhase === "opening" ? "Record on this device" : "Stop and save"} + micLabel={micMode !== "local" ? voiceMode === "dictate" ? undefined : dictateLabel : localPhase === "idle" || localPhase === "opening" ? "Record on this device" : "Stop and save"} + micTip={micMode === "dictate" && voiceMode !== "dictate" && dictateLabel !== undefined} + micUnavailable={dictationUnavailable} value={input} // The kit's `state` drives placeholder, hint and the trailing control // together (D37): streaming shows the stop, reconnecting keeps send @@ -904,7 +925,7 @@ export function Composer({ send, handle }: { send: (msg: ClientMessage) => void : "offline" } placeholder={ - voiceMode === "dictate" ? "Dictating…" : wsStatus === "connected" && restorePhase !== null + voiceMode === "dictate" && !gated ? "Dictating…" : voiceMode === "dictate" ? root.config.composerPlaceholder : wsStatus === "connected" && restorePhase !== null ? "Sending waits until this conversation is restored" : wsStatus !== "connected" ? connectionIssue === "capacity" @@ -914,7 +935,7 @@ export function Composer({ send, handle }: { send: (msg: ClientMessage) => void : "Connecting..." : root.config.composerPlaceholder } - hint={localPhase === "recording" ? "Recording on this device" : heldSend ? heldHint() : voiceMode === "dictate" ? "Dictating… · stop to review your words" : localSaveFailed ? LOCAL_SAVE_FAILED : followUpHint ? `${followUpHint} · ${finePointer ? "esc or " : ""}the stop button ends the run` : undefined} + hint={localPhase === "recording" ? "Recording on this device" : heldSend ? heldHint() : voiceMode === "dictate" && !gated ? "Dictating… · stop to review your words" : localSaveFailed ? LOCAL_SAVE_FAILED : followUpHint ? `${followUpHint} · ${finePointer ? "esc or " : ""}the stop button ends the run` : undefined} blockedWhy={ wsStatus === "connected" && sessionProfile.saving ? "saving this chat profile · your draft is kept" : wsStatus === "connected" && sessionProfile.awaitingDraftFacts ? "waiting for this chat profile · reopen the model picker to retry" diff --git a/packages/ui-react/src/components/settings/dictation-settings.tsx b/packages/ui-react/src/components/settings/dictation-settings.tsx new file mode 100644 index 0000000000..06df91911c --- /dev/null +++ b/packages/ui-react/src/components/settings/dictation-settings.tsx @@ -0,0 +1,195 @@ +import { useEffect, useId, useState, useSyncExternalStore } from "react"; +import { Button, Callout, Placeholder, Toggle } from "@schlessera/brain-ui-kit"; +import type { VoiceProvidersResponse } from "@schlessera/brain-ui-sdk/protocol"; +import { useBrainUiRoot, useRootStore } from "../../root-context.js"; +import { useVoiceStore, type DictationChoice, type DictationSaveState } from "../../voice/voice-store.js"; +import { providerLabel, type DictationProvider } from "../../voice/dictation-providers.js"; +import { dictationSaveRunning, refreshDictationDiscovery, saveDictationChoice } from "../../voice/dictation-settings-save.js"; + +type Choice = DictationChoice; +type Status = DictationSaveState["status"]; + +/** + * The Dictation group of Settings › Voice (#3709; plan §7, D1, D2). + * + * One radio per registered provider, saved brain-wide the moment it is + * picked, as the Models default is, and the Clean up as I speak switch when + * the effective provider declares SMART. The writes and their outcome live on + * the root (`dictation-settings-save.ts`), so closing the pane never drops an + * accepted choice; this only presents them. It never requests a session, a + * microphone or a provider. A save changes the next take only: a running take + * keeps the service it disclosed. + */ +export function DictationSettings({ active }: { active: boolean }) { + const root = useBrainUiRoot(); + const snapshot = useVoiceStore((s) => s.discovery?.snapshot ?? null); + const save = useVoiceStore((s) => s.dictationSave); + const take = useVoiceStore((s) => s.mode === "dictate" ? s.dictationTarget : null); + // Authority comes before any control is enabled. The authenticated probe + // names an account only for the owner (or an ambient principal), exactly + // the principals the settings write accepts; the server still decides. + // Every authority belongs to one auth generation: sign-out, a lock or a + // restore moves `root.authLock.epoch()` on and ends what was established. + const epoch = useSyncExternalStore(root.authLock.state.subscribe, () => root.authLock.epoch()); + const account = useRootStore("connection", (s) => s.accountKey); + const probed = useRootStore("connection", (s) => s.vpnStatus === "connected"); + // Every change of the connection's account starts a new account generation; + // a probe answer holds only in the generation it was asked in. + const [seen, setSeen] = useState({ account, generation: 0 }); + if (seen.account !== account) setSeen({ account, generation: seen.generation + 1 }); + const accountGeneration = seen.account === account ? seen.generation : seen.generation + 1; + // Mounted without the connection gate, nothing has probed yet: ask the + // same probe the gate would have, and keep its answer, with the account it + // named and the generations it was asked in, to this pane. + const [ownProbe, setOwnProbe] = useState<{ root: object; epoch: number; accountGeneration: number; account: string | null } | null>(null); + useEffect(() => { + if (!active || account !== null || probed) return; + let live = true; + void root.request(root.backendUrl("/api/vpn-check"), { cache: "no-store" }) + .then((response) => response.ok ? response.json() as Promise<{ accountKey?: unknown }> : null) + .then((body) => { + if (!live || !body || root.authLock.epoch() !== epoch) return; + setOwnProbe({ root, epoch, accountGeneration, account: typeof body.accountKey === "string" && body.accountKey !== "" ? body.accountKey : null }); + }) + .catch(() => { /* Unknown authority keeps the controls disabled. */ }); + return () => { live = false; }; + }, [active, account, probed, root, epoch, accountGeneration]); + // An account change or a new auth generation ends what an earlier probe established. + const probe = ownProbe?.root === root && ownProbe.epoch === epoch && ownProbe.accountGeneration === accountGeneration ? ownProbe : null; + // The account this pane would write for, once authority is established. + const writerAccount = account ?? (probed ? null : probe?.account ?? null); + const probedOwner = account !== null ? true : probed ? false : probe ? probe.account !== null : null; + // A refusal holds for the identity that was refused, and no other. + const refused = save.refused !== null && save.refused.account === writerAccount && save.refused.epoch === epoch; + const readOnly = refused || probedOwner === false; + const canWrite = probedOwner === true && !refused && writerAccount !== null; + const write = (choice: Choice) => { if (canWrite && writerAccount !== null) void saveDictationChoice(root, choice, { account: writerAccount, epoch }); }; + + useEffect(() => { + if (!active) return; + // Opening Settings reads the current choice; it mints nothing. An earlier + // outcome is not news any more, unless a write is still on its way. + if (!dictationSaveRunning(root)) root.stores.voice.setState((s) => ({ dictationSave: { ...s.dictationSave, status: null } })); + void refreshDictationDiscovery(root); + }, [active, root]); + + const pending = save.pending; + return void refreshDictationDiscovery(root)} + onChoose={(id) => { if (snapshot) write({ defaultProvider: id, smart: pending?.smart ?? snapshot.dictation.smart }); }} + onSmart={(smart) => { if (snapshot) write({ defaultProvider: pending ? pending.defaultProvider : snapshot.dictation.saved, smart }); }} + onRetry={write} + />; +} + +interface ViewProps { + snapshot: VoiceProvidersResponse | null; + loading: boolean; + loadError: boolean; + pending: Choice | null; + status: Status; + /** Not the owner: the controls stay disabled and say why. */ + readOnly: boolean; + /** No write is possible yet (read-only, or authority not established). */ + disabled: boolean; + /** The service a running take was sent to. */ + take: DictationProvider | null; + onReload: () => void; + onChoose: (id: string) => void; + onSmart: (smart: boolean) => void; + onRetry: (choice: Choice) => void; +} + +function capabilityLine(provider: DictationProvider): string { + const saved = provider.capabilities.savedAudio ? "Also transcribes saved recordings." : "Can't transcribe saved recordings."; + return provider.destination ? `${provider.destination} ${saved}` : saved; +} + +/** The Dictation group, drawn from props. */ +function DictationSettingsView(p: ViewProps) { + const id = useId(); + const heading = `${id}-heading`; + const snapshot = p.snapshot; + const dictation = snapshot?.dictation; + const providers = snapshot?.providers ?? []; + // What the radios show: the choice being saved, else the server's effective one. + const savedChoice = p.pending ? p.pending.defaultProvider : dictation?.saved ?? null; + const checked = p.pending ? p.pending.defaultProvider ?? dictation?.host ?? null + : dictation?.source === "saved" || dictation?.source === "host" || dictation?.source === "only" ? dictation.effective : null; + const effective = providers.find((provider) => provider.id === checked); + const smart = p.pending?.smart ?? dictation?.smart ?? true; + const unavailable = !p.pending && dictation?.source === "unavailable" ? dictation.saved : null; + const single = providers.length === 1 && !unavailable; + const disabled = p.disabled; + + return
+
+

Dictation

+

Where your spoken words are turned into draft text. Live conversation is set separately.

+
+ + {p.loading && } + {p.loadError &&
+ +
+
} + + {snapshot && providers.length === 0 &&

Dictation isn{"'"}t set up on this host.

} + + {snapshot && single &&
+ {providerLabel(providers[0]!)} + The only dictation service on this host. {capabilityLine(providers[0]!)} +
} + + {snapshot && !single && providers.length > 0 && <> + {!checked && !unavailable &&

Choose a dictation service

} + {unavailable &&
+ Saved choice · not available + {unavailable} isn{"'"}t available on this host. Dictation is off until you choose another service. +
} +
+ {providers.map((provider) => { + const isChecked = provider.id === checked; + const marks = [dictation?.host === provider.id ? "host default" : null, savedChoice === provider.id ? "saved" : null].filter(Boolean).join(" · "); + return ; + })} +
+ } + + {snapshot && effective?.capabilities.smartTranscription &&
+
+

Clean up as I speak

+

Removes fillers, applies spoken corrections and formats lists. Applies from your next dictation.

+
+ p.onSmart(!smart)} /> +
} + + {p.take && checked !== p.take.id &&

Dictating with {providerLabel(p.take)} now. Your change applies to the next take.

} + {p.readOnly &&

Only the owner can change this.

} +
{p.status?.kind === "saving" ? "Saving…" : p.status?.kind === "stale" ? p.status.current ? "Changed on another device. Showing the current choice." : "Changed on another device." : ""}
+ {p.status?.kind === "failed" &&
+ +
+
} +
; +} diff --git a/packages/ui-react/src/components/settings/settings-panel.tsx b/packages/ui-react/src/components/settings/settings-panel.tsx index 74c2549670..375aa558e6 100644 --- a/packages/ui-react/src/components/settings/settings-panel.tsx +++ b/packages/ui-react/src/components/settings/settings-panel.tsx @@ -1,5 +1,5 @@ import { Fragment, Suspense, useEffect, useLayoutEffect, useId, useMemo, useRef, useState, type CSSProperties, type KeyboardEvent } from "react"; -import { ChevronRight, HardDrive, KeyRound, Laptop, Puzzle, SlidersHorizontal, UserRound, Workflow } from "lucide-react"; +import { ChevronRight, HardDrive, KeyRound, Laptop, Mic, Puzzle, SlidersHorizontal, UserRound, Workflow } from "lucide-react"; import { useUIStore, type SettingsTab } from "../../stores/ui-store.js"; import { SlidePanel } from "../layout/slide-panel.js"; import { cn } from "../../lib/utils.js"; @@ -16,6 +16,7 @@ import { lazyChunk } from "../../lib/lazy-chunk.js"; // The frame stays eager; each data-owning pane loads only on activation. const ModelsTab = lazyChunk(() => import("./models-tab.js").then((m) => ({ default: m.ModelsTab }))); +const VoiceTab = lazyChunk(() => import("./voice-tab.js").then((m) => ({ default: m.VoiceTab }))); const AccountsTab = lazyChunk(() => import("./accounts-tab.js").then((m) => ({ default: m.AccountsTab }))); const PasskeyTab = lazyChunk(() => import("./passkey-tab.js").then((m) => ({ default: m.PasskeyTab }))); const DevicesAgentsTab = lazyChunk(() => import("./devices-agents-tab.js").then((m) => ({ default: m.DevicesAgentsTab }))); @@ -27,6 +28,7 @@ const StorageTab = lazyChunk(() => import("./storage-tab.js").then((m) => ({ def const SECTIONS: Array<{ id: SettingsTab; label: string; meta: string; group: string; icon: IconName; glyph: typeof KeyRound }> = [ { id: "appearance", label: "Appearance & input", meta: "this device", group: "This device", icon: "settings", glyph: SlidersHorizontal }, { id: "models", label: "Models", meta: "picker", group: "This brain", icon: "model", glyph: SlidersHorizontal }, + { id: "voice", label: "Voice", meta: "dictation", group: "This brain", icon: "mic", glyph: Mic }, { id: "accounts", label: "Accounts", meta: "providers", group: "This brain", icon: "wallet", glyph: UserRound }, { id: "skills", label: "Skills", meta: "catalog", group: "This brain", icon: "capability", glyph: Puzzle }, { id: "modules", label: "Modules", meta: "workflows", group: "This brain", icon: "steps", glyph: Workflow }, @@ -235,6 +237,7 @@ function SectionBody({ tab, open, moduleSession }: { tab: SettingsTab; open: boo return {tab === "appearance" ?
: tab === "models" ? + : tab === "voice" ? : tab === "accounts" ? : tab === "skills" ? : tab === "modules" ? diff --git a/packages/ui-react/src/components/settings/voice-tab.tsx b/packages/ui-react/src/components/settings/voice-tab.tsx new file mode 100644 index 0000000000..ccc47424e4 --- /dev/null +++ b/packages/ui-react/src/components/settings/voice-tab.tsx @@ -0,0 +1,18 @@ +import { ScreenHeader } from "@schlessera/brain-ui-kit"; +import { DictationSettings } from "./dictation-settings.js"; + +/** + * Settings › This brain › Voice (#3709, plan §7). The pane is a frame of + * independent groups: Dictation here, and the live-conversation service + * (#3616) beside it later. Each group owns its own route, revision and state, + * so saving one never touches the other, and nothing in the pane opens the + * microphone, mints a credential or sends audio. + */ +export function VoiceTab({ active }: { active: boolean }) { + return
+ +
+ +
+
; +} diff --git a/packages/ui-react/src/components/voice/dictation-sheet.tsx b/packages/ui-react/src/components/voice/dictation-sheet.tsx index 5fd997dae6..58f4bbc6d7 100644 --- a/packages/ui-react/src/components/voice/dictation-sheet.tsx +++ b/packages/ui-react/src/components/voice/dictation-sheet.tsx @@ -1,20 +1,30 @@ -import { IconButton, Overlay } from "@schlessera/brain-ui-kit"; -import { useEffect, useRef, type RefObject } from "react"; +import { Button, IconButton, Overlay } from "@schlessera/brain-ui-kit"; +import { useEffect, useId, useRef, type RefObject } from "react"; +import { providerDestination, providerLabel } from "../../voice/dictation-providers.js"; +import type { DictationGate } from "../../voice/voice-state.js"; import { useMediaQuery } from "../../hooks/use-media-query.js"; import { useFinePointer } from "../../hooks/use-fine-pointer.js"; import { Mic, X } from "lucide-react"; import { useVoiceStore } from "../../voice/voice-store.js"; import { cn } from "../../lib/utils.js"; +const MIC = '[aria-label^="Dictate"], [aria-label="Stop dictation"]'; + export function DictationSheet({ open, onStop, onCancel, + onConfirm, + onOpenSettings, composerRef, }: { open: boolean; onStop: () => void; onCancel: () => void; + /** Start dictation on the acknowledgement card. */ + onConfirm?: () => void; + /** Settings › Voice, from a take that has nowhere to go. */ + onOpenSettings?: () => void; composerRef?: RefObject; }) { const desktop = useMediaQuery("(min-width: 900px)"); @@ -28,20 +38,26 @@ export function DictationSheet({ // Mic still opening — the session is being fetched, so capture isn't live // yet. Drives the honest "Connecting…" state instead of claiming "Listening". const connecting = useVoiceStore((s) => s.connecting); - const providerId = useVoiceStore((s) => s.providerId); + const target = useVoiceStore((s) => s.dictationTarget); + const gate = useVoiceStore((s) => s.dictationGate); + const gateRef = useRef(null); // Text already under review — the current capture appends to it on stop, // so show it dimmed as the lead-in. const reviewText = useVoiceStore((s) => s.reviewText); const transcriptRef = useRef(null); - const statusLabel = connecting + const statusLabel = gate?.kind === "consent" + ? "Before you dictate" + : gate + ? "Dictation unavailable" + : connecting ? "Connecting…" : draining ? "Finalizing…" : "Listening"; - // Surface the active provider so a silent fallback to browser speech (which - // streams mic audio to Google on Chrome) isn't invisible. - const providerNote = providerNoteFor(providerId); + // The service this take was sent to, frozen with it (#3709). A provider + // that names a third-party destination, or browser speech, is called out. + const providerNote = target ? { text: `To ${providerLabel(target)}`, warn: Boolean(target.destination) || target.id === "webspeech" } : null; // Keep the newest words in view — the live transcript grows past the // sheet's height quickly when dictating longer prompts. @@ -55,10 +71,30 @@ export function DictationSheet({ const composer = composerRef?.current; doneRef.current?.focus(); return () => { - composer?.querySelector('[aria-label="Dictate"], [aria-label="Stop dictation"]')?.focus(); + composer?.querySelector(MIC)?.focus(); }; }, [open, desktop, composerRef]); + // The acknowledgement focuses Start dictation; a blocked take, Open Settings. + useEffect(() => { + if (open && gate) gateRef.current?.focus(); + }, [open, gate]); + + // Start dictation removes the control that held focus. When focus was in + // the card, it continues on Done, so the keyboard can finish the take; the + // phone sheet's initial focus has already run and does not run again. + const cardRef = useRef(null); + const continueFocus = useRef(false); + const confirm = onConfirm && (() => { + continueFocus.current = Boolean(cardRef.current?.contains(document.activeElement)); + onConfirm(); + }); + useEffect(() => { + if (gate || !continueFocus.current) return; + continueFocus.current = false; + if (open) doneRef.current?.focus(); + }, [open, gate]); + useEffect(() => { if (!open || !desktop || draining) return; const onKey = (event: KeyboardEvent) => { @@ -77,13 +113,13 @@ export function DictationSheet({ {/* Pulse only once capture is actually live — a "connecting" dot must not imply the mic is already open. */} - {!connecting && ( + {!connecting && !gate && ( )} @@ -91,7 +127,7 @@ export function DictationSheet({ {statusLabel} - {desktop &&
} + {desktop && !gate &&
} {desktop ? } onClick={onCancel} disabled={draining} /> :