Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
391c5f3
CONTRACT: feat(ui-server): register selectable dictation providers (WIP)
schlessera Nov 8, 2026
9a9ce76
CONTRACT: feat(ui-server): complete selectable dictation provider proof
schlessera Nov 8, 2026
9c08f9b
CONTRACT: fix(ui-server): allow bound dictation uploads across origins
schlessera Nov 8, 2026
63251dc
fix(ui-server): keep legacy speech misconfiguration a route error, no…
schlessera Nov 8, 2026
fe4dce3
Merge remote-tracking branch 'origin/main' into fix/3707-review
schlessera Nov 8, 2026
8d11639
docs: repair dictation citations moved by the speech registry
schlessera Nov 8, 2026
12d7f1c
Merge remote-tracking branch 'origin/main' into fix/3707-review
schlessera Nov 8, 2026
de5b76c
CONTRACT: feat(ui-react): select the dictation provider in Voice sett…
schlessera Nov 8, 2026
1188f5c
CONTRACT: fix(ui-react): keep dictation choices, takes and tray uploa…
schlessera Nov 8, 2026
d82c673
fix(ui-react): bind dictation settings writes and authority to one id…
schlessera Nov 8, 2026
d279a6a
Merge remote-tracking branch 'origin/main' into feat/3709-dictation-v…
schlessera Nov 8, 2026
bc55e98
fix(ui-react): end standalone probe authority only on account or auth…
schlessera Nov 8, 2026
880e11e
Merge remote-tracking branch 'origin/main' into int/3709
schlessera Nov 8, 2026
2c7d662
test(ui-react): prime dictation selection in the Gemini offline suite
schlessera Nov 8, 2026
83ef720
Merge remote-tracking branch 'origin/main' into int/3709
schlessera Nov 8, 2026
62ceaf8
Merge remote-tracking branch 'origin/main' into int/3709
schlessera Nov 8, 2026
20b0ff0
test: prime dictation selection in the remaining capture suites
schlessera Nov 8, 2026
a8ba2b8
Merge remote-tracking branch 'origin/main' into int/3709
schlessera Nov 8, 2026
0029859
Merge remote-tracking branch 'origin/main' into int/3709
schlessera Nov 8, 2026
88050f5
Merge remote-tracking branch 'origin/main' into int/3709
schlessera Nov 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/dictation-voice-settings.md
Original file line number Diff line number Diff line change
@@ -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 <service>".

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.
2 changes: 2 additions & 0 deletions api-report/ui-kit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion api-report/ui-react.txt
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ signatures (every public export and the types it is made of)
saveTranscript(partition: PartitionId, id: string, text: string): Promise<void>;
accept(partition: PartitionId, id: string, draftId: string, sessionId: string | null, expectedTranscript?: string): Promise<void>;
assign(id: string): Promise<void>;
transcribe(partition: PartitionId, id: string, progress: (percent: number) => void, retry?: string): Promise<void>;
transcribe(partition: PartitionId, id: string, progress: (percent: number) => void, retry?: string, provider?: string): Promise<void>;
syncTranscriptions(): Promise<void>;
busy(): boolean;
subscribe(listener: () => void): () => void;
Expand Down
14 changes: 14 additions & 0 deletions docs/extending/speech.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions docs/integration-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions docs/integration-contract/package-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 36 additions & 15 deletions packages/ui-kit/src/chrome/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -329,7 +340,7 @@ export function Composer(p: ComposerProps) {
onChange={editable ? (e: ChangeEvent<HTMLTextAreaElement>) => p.onChange?.(e.target.value) : undefined}
onKeyDown={onKeyDown}
/>
{showMic ? <IconButton icon="mic" label={p.micLabel ?? (dictating ? "Stop dictation" : "Dictate")} targetSize={dictating ? 44 : 28} onClick={p.onMic} /> : null}
{showMic ? <IconButton icon="mic" label={p.micLabel ?? (dictating ? "Stop dictation" : "Dictate")} tip={p.micTip === true && !dictating} unavailable={dictating ? undefined : p.micUnavailable} targetSize={dictating ? 44 : 28} onClick={p.onMic} /> : null}
{showStop ? (
<span
style={{ ...disc(28, accent.red.fill, false), cursor: stopAct ? "pointer" : "default" }}
Expand Down Expand Up @@ -360,15 +371,19 @@ export function Composer(p: ComposerProps) {
</div>
{v === "voice" && p.mic !== false ? (
<span
style={disc(54, accent.amber.fill, true)}
className={p.onMic ? "bk-control" : undefined}
role={p.onMic ? "button" : undefined}
aria-label={p.onMic ? (p.micLabel ?? "Hold to talk") : undefined}
tabIndex={p.onMic ? 0 : undefined}
onClick={p.onMic}
onKeyDown={p.onMic ? pressable(() => 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}
>
<Icon icon="mic" size={24} color={color.onFill} />
{voiceUnavailable ? <span id={voiceReasonId} hidden>{p.micUnavailable}</span> : null}
</span>
) : null}
</div>
Expand Down Expand Up @@ -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 (
<span
Expand All @@ -503,13 +521,16 @@ function IconButton(props: { icon: "attach" | "mic"; label: string; haspopup?: "
display: "flex",
alignItems: "center",
justifyContent: "center",
cursor: act ? "pointer" : "default",
cursor: unavailable !== undefined ? "not-allowed" : act ? "pointer" : "default",
opacity: unavailable !== undefined ? 0.45 : undefined,
"--hv-bg": token("hover-veil-strong"),
} as CSSProperties
}
className={act ? (tip ? "bk-control bk-tip-host" : "bk-control") : undefined}
role={act ? "button" : undefined}
aria-label={act ? props.label : undefined}
aria-disabled={unavailable !== undefined ? true : undefined}
aria-describedby={unavailable !== undefined ? reasonId : undefined}
aria-haspopup={act ? props.haspopup : undefined}
tabIndex={act ? 0 : undefined}
onClick={act ? (event) => activate(event.currentTarget) : undefined}
Expand All @@ -523,7 +544,7 @@ function IconButton(props: { icon: "attach" | "mic"; label: string; haspopup?: "
onBlur={tip ? (event) => resetTip(event.currentTarget, false) : undefined}
>
<Icon icon={props.icon} size={17} color={color.inkMute} />
{tip ? <span className="bk-tip" data-composer-tip="" aria-hidden="true">{props.label}</span> : null}
{tip ? <span id={unavailable !== undefined ? reasonId : undefined} className="bk-tip" data-composer-tip="" aria-hidden="true">{unavailable ?? props.label}</span> : null}
</span>
);
}
Expand Down
15 changes: 15 additions & 0 deletions packages/ui-kit/tests/composer-mic.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<Composer variant={variant} onMic={onMic} micUnavailable={reason} />);
const mic = html.match(/<span[^>]*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("'", "&#x27;")}<`));
}
// Without a reason the mic is an ordinary control.
expect(renderToStaticMarkup(<Composer onMic={onMic} />)).not.toContain("aria-disabled");
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions packages/ui-kit/tests/visual/dictation-panel.visual.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(<BrainUiProvider root={ui}>
Expand All @@ -95,7 +98,7 @@ async function mount(width = 1280, height = 800, theme = "dark", cssEntry: "prec
const frame = host.querySelector<HTMLElement>("[data-composer]")!;
await userEvent.click(frame.querySelector("textarea")!);
await userEvent.keyboard("Keep the existing draft");
const mic = () => frame.querySelector<HTMLElement>('[aria-label="Dictate"], [aria-label="Stop dictation"]')!;
const mic = () => frame.querySelector<HTMLElement>('[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
Expand Down Expand Up @@ -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<HTMLElement>("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<HTMLElement>("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);
Expand Down
Loading
Loading