Skip to content

CONTRACT: feat(ui-server, ui-react): configure the default live-conversation service in Settings › Voice (#3616) - #3956

Merged
schlessera merged 17 commits into
mainfrom
feat/3616-live-provider-default
Nov 11, 2026
Merged

schlessera merged 17 commits into
mainfrom
feat/3616-live-provider-default

Conversation

@schlessera

@schlessera schlessera commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Closes #3616

What changed

A host can register both live-conversation adapters, and the brain's owner picks the default in Settings › Voice → Live service. The design is the one signed off on #3616 (§1–§7, L1–L3, R1).

  • Registration. createApp({ conversationProviders, defaultConversationProviderId }). The legacy conversationProvider still means a list of one. Startup fails on any of:
    • both options given;
    • duplicate ids;
    • a default that names no registered service.
  • Precedence for a new Start. A one-time pick wins. Otherwise the saved default is used, but only if it is still registered. If nothing is saved, the host default is used, then the only service. Otherwise there is none.
    • A saved default that is no longer registered stops there. The Start needs an explicit pick, and the host default is never substituted (L2).
    • "Usable" means registered at boot. Nothing probes a credential.
  • Wire (additive).
    • server_hello adds conversationProfiles and liveDefault. It keeps conversationProfile only while a service is effective (R1), so a single-provider host sends exactly what it sent before.
    • A save sends live_settings to every open connection.
    • conversation_start accepts providerId. It must equal disclosed.providerId and name a registered service, or the existing CONVERSATION_DISCLOSURE refusal applies and nothing opens.
    • A resume keeps the service its conversation opened with.
    • conversation_opened adds providerSource (change | saved | host | only).
  • HTTP. GET/PUT /api/settings/voice takes { defaultProvider, revision } and stores it in the ui-server settings store under voice.live.defaultProvider.
    • Writes have a new owner-only guard, isLiveSettingsWriter. It accepts the owner's password or passkey session, or the ambient human. Any other principal gets 403 with an empty body, before the body is read.
    • An unknown id returns 400 LIVE_PROVIDER_UNKNOWN. A stale revision returns 409 LIVE_SETTINGS_CHANGED with current.
  • UI.
    • Kit. LiveServiceSettings covers every state: zero, one and several services, host default, saved default, in use now, saved-but-unavailable as a dashed row that can't be chosen, saving, 409, failed, and read-only. On a wide container the label sits in a 140px column and two services sit side by side.
    • Settings › Voice. Adds the group under Dictation and changes the subtitle to "dictation and live conversation · where your spoken words go".
    • Conversation client. It reads the roster and live_settings, and pins the service an explicit Start agreed to for that entry. It exposes chooseService() for a one-time pick that is never saved, and sends providerId.
  • Minimal Start-flow piece (named, per the brief). The existing pre-Start disclosure sheet offers a "Live service for this conversation" radio pick in two cases: when two or more services are usable (L1 Change), or when the saved default is unavailable or nothing is effective (L2/S3d). Without it, those acceptance criteria could not be met in the shipped UI before ui-react: wire the Start card (S1–S5) — service, persona and recovery #3698. The Start card (ui-react: wire the Start card (S1–S5) — service, persona and recovery #3698) replaces it.

What #3698 should consume

  • liveServiceView(conversation.state.getState()) in packages/ui-react/src/voice/live-service.ts returns:
    • services: the usable profiles;
    • selected: what Start would disclose and open, or null;
    • source: change | saved | host | only | none | legacy;
    • savedUnavailable: the S3d id;
    • pickRequired;
    • canChange: whether to show Change (L1);
    • liveDefault.
  • The interface is not exported yet, because of the unused-exports gate. Export it when the Start card imports it.
  • conversation.chooseService(id | null) is the per-Start override. It applies to this entry only, is never saved, and is ignored after Start. null returns to the effective service.
  • conversation.state conversationProfile is always the profile Start sends. conversation.start() sends providerId automatically.

Why this shape

  • Spec name differs from the code. The spec names createBrainUiServer, but the host entry point is createApp(CreateAppOptions). The options live there.
  • Choices the spec left open:
    • the 400 code for a malformed body is LIVE_SETTINGS_INVALID;
    • the start-echo source field is providerSource;
    • live_settings goes to every connection, the same audience as hello. Older clients drop it as an unknown frame: parseServerMessage returns ok: false and nothing else happens.
  • Agent principals. The read route is also refused to agent principals ("any authenticated human session").
  • Pinning. The client pins the service at explicit Start, so a save from another device never trips the disclosure gate of a running entry. The server independently pins it on the conversation for resumes.

Proof

bun run check:pr --base origin/main
{"version":1,"kind":"brain-check-pr-receipt","head":"e928c04f0bd1eb9a0865199713794171de8cb188","base":"origin/main","mode":"focused","startedAt":"2026-11-11T04:07:22.060Z","finishedAt":"2026-11-11T04:08:53.795Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":12342.181754000001},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":101.73596700000053},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":65.13855800000056},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":24.207178999999087},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":79185.9151}]}
  • packages/ui-server/tests/live-provider-selection.test.ts (new, 18 pass). Two keyless adapter doubles cover:
    • registration failures;
    • every §4 row: the hello a client gets, R1 (no conversationProfile), and which double's open ran, or neither;
    • Change opens the pick and is not saved;
    • an unusable saved default refuses until an explicit pick;
    • a mismatched or unregistered providerId opens nothing;
    • a save mid-conversation sends live_settings, doesn't close or retarget, and the resume keeps its service;
    • a default changed between disclosure and Start refuses a legacy Start.
    • Route coverage: 401, 403 with an empty body for a delegated principal (before validation), 415, 400 invalid and unknown, concurrent 200/409, persistence read through a second DB connection, a host restarted without the saved service (kept, unusable, no substitution), the ambient-human write and broadcast, no provider opened, no credentials in answers, and the model default untouched.
  • packages/ui-react/tests/live-service-runtime.test.ts (new, real Chrome against a real password-mode server, 8 pass at 320 and 1280px):
    • pick, keyboard arrow, reload and server restart persistence;
    • SETTINGS_OPENS_NO_MICROPHONE and SETTINGS_OPENS_NO_PROVIDER;
    • the next Start opens the saved default;
    • a save from another device leaves the running conversation on its service;
    • Change opens the pick, is not saved, and ends with the entry;
    • NO_PROVIDER_BEFORE_START and NO_MICROPHONE_BEFORE_START: no audio or history crosses before Start, because open is where history is handed over;
    • S3d: the dashed row, Start disabled until a pick, no substitution, the pick opens, and the saved value is kept;
    • the non-owner view is read-only and its PUT gets 403;
    • 44px targets and no horizontal scroll.
  • Kit stories Voice/Settings · Live service (12 stories × light/dark = 24 pass): axe, 52px rows, 320 stacked, the desktop 140px column with two services side by side, and the full pane showing that Dictation, Live service and Persona don't interact.
  • SDK server-schemas.test.ts: live_settings is in the frame inventory, and a malformed roster or liveDefault is dropped without losing the hello.
  • Existing suites, with no regression from this change:
    • ws-conversation (120), gemini-/gpt-live-conversation, selectable-dictation, http-inventory and http-supported-mounts (the new rows pass) all pass.
    • host-capability-note and ws-live-policy-parity fail the same 25 tests on an untouched origin/main worktree, because of the sandbox's worker boundary.
    • The provider-history guard can't start in this sandbox (WorkerHostError). Nothing on a turn's path changed: provider.open options and history assembly are untouched.
  • Screenshots of Settings, the sheet and S3d at 320 and 1280 were captured and reviewed, not committed. That review caught a centered-radio defect, which is fixed and now guarded by a story assertion.

Mutation receipts. Each was broken, the named test was run, then restored and re-run green:

Mutation Failed assertion
Write guard accepts any principal LIVE_SETTINGS_OWNER_ONLY expected 403, received 200, plus the guard unit test
Saved-but-unusable default falls through to host/only one, saved removed, two, saved unusable, host default not substituted and an unusable saved default needs an explicit pick: expected CONVERSATION_DISCLOSURE, the provider opened
Client ignores the one-time pick runtime 320 Change: "Clicking the checkbox did not change its state"
Client doesn't pin the service at Start runtime 320: running.disclosed expected gpt-live, received gemini-live (another device's save retargeted the entry)
Kit label rows lose justify-content: flex-start 10 stories: "radio at the row's start: expected 52 to be ≤ 14"

#3617 landed first (#3955), merged and adapted. Per design §6, the two groups share one GET/PUT /api/settings/voice. #3955 had created the route with persona: { value, revision }. This PR adds the top-level defaultProvider/revision pair (VoiceLiveSettings) beside it, so VoiceSettingsResponse now extends VoiceLiveSettings, and a PUT may carry either group or both (the live default is saved first). The route's writes now also pass isLiveSettingsWriter. My separate route module is gone; the route count stays at #3955's 187. The shared route has no requireJson, matching #3955, so the 415 assertion is dropped. ConversationHost keeps #3955's echo-only disclosure (voices are described, not disclosed) per registered service, and personas resolve against the Start's target service. After the merge, all of these pass: live-provider-selection, live-personas, live-persona-host, live-persona-adapters, ws-conversation, http-inventory and the settings/voice mounted checks (232); live-service-runtime with #3955's persona-settings-runtime and render tests in real Chrome (18); and lint, typecheck, build and check:pr (receipt above).

Candidate proof fix. The first confirmation (head 5006da660) failed unit (1) because tests/runtime-build-selection.test.ts expected 22 runtime package hooks and found 23. The new live-service-runtime proof was missing from scripts/runtime-test-builds.ts, the same inventory #3955 extended for its own runtime test. It is added now and the count is updated.

Refresh. Merged main after #3827 landed (overlapping contract docs and the HTTP inventory; route count now 182), re-ran check:pr on the merged head (receipt above) and fixed a test-only type error the merge-time typecheck caught.

Collisions (bun scripts/collisions.ts --json --pr 3956 at head 63c9a48a8): textual overlaps with #3056, #3059, #3393, #3622, #3827, #3955 (shared contract docs, api-report and conversation-client.ts); the rest are closure-only test-selection overlaps. No path overlap with a ready PR blocks this. #3617 (personas) is being worked in parallel on the same pane and route; whichever lands second merges main and adapts.

Owner-only guard (proportionate-containment checklist)

  • Trigger. A PUT /api/settings/voice from any principal other than the owner's password or passkey session or the ambient human. It does not cover CSRF (the global origin policy does) or reads.
  • Restriction. Only this one write. Nothing narrower exists: this is a single brain-wide preference.
  • Restricted mode. The read stays available to humans, and the Settings group shows read-only with "Only the owner can change this."
  • Clearing. It needs no clearing. It is stateless and per request.
  • Cause. The 403 answer itself. The UI turns it into the read-only line.
  • Scope. The rest of the app is unaffected; covered by live-provider-selection and the runtime non-owner test.

Checklist

  • Focused local preflight/behavioral receipts passed; complete selected hosted proof is requested through integrate.ts confirm.
  • Acceptance criteria from the issue are met. The Start card itself is ui-react: wire the Start card (S1–S5) — service, persona and recovery #3698, and this PR ships the minimal pick described above.
  • The PR and completed/advanced issues have verified release milestones (0.45.0, set before merge).
  • A changeset is included (minor).
  • No personal data in the diff (leakage gate).
  • The integration contract index, wire, HTTP and package-api components are updated.
  • Docs under docs/ reflect the change: http-api, coverage, extending/speech, the decision record, and the ui-react README.
  • The new guard answers the proportionate-containment checklist above.
  • Provider history stays append-only. Nothing on a turn's path changed; the guard is left to hosted CI because the sandbox can't run it.

Anything left open

🤖 Generated with Claude Code

schlessera and others added 6 commits November 10, 2026 22:57
… each Start (#3616)

createApp accepts conversationProviders and defaultConversationProviderId;
conversationProvider still means a list of one. Startup fails on both
options, duplicate ids or an unregistered host default. A new Start uses a
one-time pick (conversation_start.providerId, which must equal the disclosed
profile), else the saved default only if registered, else the host default
or the only service when nothing is saved, else none. A saved but unusable
default never falls through. A resume keeps the service its conversation
opened with.

server_hello adds conversationProfiles and liveDefault and keeps
conversationProfile only while a service is effective (R1). A save sends
live_settings to open connections. conversation_opened adds providerSource.

GET/PUT /api/settings/voice read and save voice.live.defaultProvider in the
settings store, behind a new owner-only write guard (owner password/passkey
session or ambient human; 403 with an empty body otherwise), with 400
LIVE_PROVIDER_UNKNOWN and 409 LIVE_SETTINGS_CHANGED.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LiveServiceSettings draws the registered services as 52px radio rows with
saved default, host default and in use now marks, a dashed unavailable row
that cannot be chosen, the zero and one service variants, saving, stale and
failed states and the read-only owner line. A wide container puts the label
in a 140px column and two services side by side. Stories cover every state
at 320px and desktop in both themes, plus the full pane with Dictation and
Persona neighbours.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and before Start (#3616)

Settings › Voice adds the Live service group under Dictation. Picks save
brain-wide at once through a root-owned, latest-wins queue; 403 turns the
group read-only, 409 reloads with "Changed on another device". The
conversation client reads the hello roster and live_settings, pins the
service an explicit Start agreed to for that entry, and exposes
chooseService() for a one-time pick that is never saved; Start sends
providerId. The disclosure sheet offers that pick when several services are
usable or the saved default is unavailable, as a minimal stand-in until the
Start card (#3698).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#3616)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#3616)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added type: feat A new capability or a change in user-visible behaviour. area: ui-sdk Wire protocol, runtime schemas, the server and client SDK surfaces. area: ui-server Hono app factory: turn coordinator, auth, session catalog, routes, cron. area: ui-react React chat/files/voice components, stores, WebSocket transport. contract Touches the integration contract: CONTRACT: commit, contract doc updated in the same commit. labels Nov 10, 2026
@schlessera schlessera added this to the 0.45.0 milestone Nov 10, 2026
@uploads-sh

uploads-sh Bot commented Nov 10, 2026

Copy link
Copy Markdown

No uploads on this PR yet

This PR changes UI files (packages/ui-kit/src/tokens.css, packages/ui-kit/src/voice/LiveServiceSettings.tsx, packages/ui-kit/stories/voice/LiveService.stories.tsx and 4 more). Screenshots help reviewers see what changed.

  • From the CLI: uploads put before.png after.png --pr 3956
  • From an agent: ask it to attach screenshots with uploads.sh
  • By hand: drag images into the PR description and they're imported automatically
Tips for agents

Label each shot so reviewers know what they're seeing. Labels apply to every file in a call, so run one put per shot:

uploads put after.png --pr 3956 --meta path=/settings --state after --caption "Saved settings toast"
uploads put chat.png --pr 3956 --app ios --screen "Chat" --state after

No CLI? With the Uploads MCP, call sign_upload_url for files on disk (or put) with repo, pr: 3956 and the same screen, state and caption fields.

This comment updates with each upload, so you don't need to post the images yourself. A shot or two in the PR description is still welcome. Check what's attached with uploads list --pr 3956. More in the github-screenshots skill or the agent docs.

Workspace admins can turn this comment off in Settings → GitHub · docs

schlessera and others added 3 commits November 11, 2026 01:12
The live-service default joins the persona group on the one
/api/settings/voice route (design §6): top-level defaultProvider/revision
beside persona with its own revision, under the owner-only write guard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ith personas (#3616)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera
schlessera marked this pull request as draft November 11, 2026 04:10
@schlessera
schlessera marked this pull request as ready for review November 11, 2026 04:10
@schlessera
schlessera merged commit be9f6f4 into main Nov 11, 2026
49 of 52 checks passed
schlessera added a commit that referenced this pull request Nov 11, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ui-react React chat/files/voice components, stores, WebSocket transport. area: ui-sdk Wire protocol, runtime schemas, the server and client SDK surfaces. area: ui-server Hono app factory: turn coordinator, auth, session catalog, routes, cron. contract Touches the integration contract: CONTRACT: commit, contract doc updated in the same commit. type: feat A new capability or a change in user-visible behaviour.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ui-react: configure the default live-conversation provider through Settings

1 participant