Speaker icon in the message toolbar + auto-read toggle #24

Closed
opened 2026-10-25 17:30:32 +00:00 by dsh · 3 comments
Owner

Goal

Two controls on the chat surface:

  1. Speaker icon in the finished assistant message toolbar (the copy / like / dislike / share row from the screenshot): click to read that answer aloud, click again to stop. Shows a speaking state.
  2. Auto-read toggle in the composer tool row: when on, every completed assistant answer is read automatically. It is the same persisted setting the Settings page exposes.

Auto-read must read everything generated that is not a thought — assistant text blocks only; reasoning, tool calls and tool results stay silent.

Placement (verified against @deepseek-ai/dsh 0.2.1-rc.2)

Control Slot Contract
Per-message speaker conversation.chat.assistant-actions list, session scope, owner props { messageId }; rendered by MessageIconActions in the turn-tail row (dsh-client-ui-chat/lib/client.js:6988, .../contract/slots.d.ts:395)
Auto-read toggle conversation.input.left (left of the composer tool row) or .right (before submit) list, session scope (dsh-client-ui-conversation/.../contract/slots.d.ts:311-320)
  • Registration shape to copy: dsh-client-ui-message-feedback/lib/client.js:815 — { name, id, order, locale, inject: (sessionId) => ({...}) }, component gets { messageId, ...injected, t }.
  • Styling: the 28 px icon button from the same package (--dsw-alias-label-tertiary, hover --dsw-alias-interactive-bg-hover, focus ring) so it sits naturally next to copy/share.
  • Text lookup: our retained session event window (see #5); find the durable assistant/message with message.id === messageId and take only text blocks. The action row only renders for loaded messages, so no history fetch is needed.

Behaviour

  • Manual read works even with auto-read off; it never speaks reasoning/tool content; clicking while speaking stops; clicking another message stops the previous one.
  • Auto-read persists (localStorage), mirrors the Settings switch, never replays history on load, and respects mute (#13).
  • Audio unlock: if the AudioContext has not been resumed yet, the first click unlocks it and then speaks (autoplay policy).
  • Engine not ready (no voice downloaded / OPFS unsupported): the button points at the Settings download instead of failing silently; tooltip explains why.
  • States: idle / speaking / unavailable, with aria-label "Read aloud" / "Stop reading", aria-pressed, tooltip, keyboard activation, reduced-motion friendly.
  • i18n strings in locale/en.json (German later). No new dependency.

Acceptance

  • Chrome + Firefox (Arch Linux): a speaker icon appears in the finalized assistant action row next to copy/share; click speaks that answer, click again stops within ~100 ms.
  • Auto-read toggle in the composer row turns on, persists across reload, and speaks the next completed answer without a click; reasoning/tool output is never spoken.
  • Toggle and Settings switch stay in sync; mute/stop from #13 wins over both.
  • Keyboard-only user can reach and activate both controls; screen-reader labels are correct.

Notes

  • Depends on #5 (message indexing/capture), #7 (queue), #12 (settings + persistence), #13 (mute/stop). Part of M2.
  • Scope split: #13 owns the global stop/mute chip; this issue owns the per-message action and the composer auto-read switch. When building, do not duplicate the toggle.
  • This is the "make you read this one" plus "read everything" pair the operator asked for on 2026-10-25.
## Goal Two controls on the chat surface: 1. **Speaker icon in the finished assistant message toolbar** (the copy / like / dislike / share row from the screenshot): click to read *that* answer aloud, click again to stop. Shows a speaking state. 2. **Auto-read toggle in the composer tool row**: when on, every completed assistant answer is read automatically. It is the same persisted setting the Settings page exposes. Auto-read must read **everything generated that is not a thought** — assistant `text` blocks only; reasoning, tool calls and tool results stay silent. ## Placement (verified against `@deepseek-ai/dsh 0.2.1-rc.2`) | Control | Slot | Contract | |---|---|---| | Per-message speaker | `conversation.chat.assistant-actions` | `list`, session scope, owner props `{ messageId }`; rendered by `MessageIconActions` in the turn-tail row (`dsh-client-ui-chat/lib/client.js:6988`, `.../contract/slots.d.ts:395`) | | Auto-read toggle | `conversation.input.left` (left of the composer tool row) or `.right` (before submit) | `list`, session scope (`dsh-client-ui-conversation/.../contract/slots.d.ts:311-320`) | - Registration shape to copy: `dsh-client-ui-message-feedback/lib/client.js:815` — `{ name, id, order, locale, inject: (sessionId) => ({...}) }`, component gets `{ messageId, ...injected, t }`. - Styling: the 28 px icon button from the same package (`--dsw-alias-label-tertiary`, hover `--dsw-alias-interactive-bg-hover`, focus ring) so it sits naturally next to copy/share. - Text lookup: our retained session event window (see #5); find the durable `assistant/message` with `message.id === messageId` and take only `text` blocks. The action row only renders for loaded messages, so no history fetch is needed. ## Behaviour - **Manual read** works even with auto-read off; it never speaks reasoning/tool content; clicking while speaking stops; clicking another message stops the previous one. - **Auto-read** persists (localStorage), mirrors the Settings switch, never replays history on load, and respects mute (#13). - **Audio unlock**: if the AudioContext has not been resumed yet, the first click unlocks it and then speaks (autoplay policy). - **Engine not ready** (no voice downloaded / OPFS unsupported): the button points at the Settings download instead of failing silently; tooltip explains why. - **States**: idle / speaking / unavailable, with aria-label "Read aloud" / "Stop reading", `aria-pressed`, tooltip, keyboard activation, reduced-motion friendly. - i18n strings in `locale/en.json` (German later). No new dependency. ## Acceptance - Chrome + Firefox (Arch Linux): a speaker icon appears in the finalized assistant action row next to copy/share; click speaks that answer, click again stops within ~100 ms. - Auto-read toggle in the composer row turns on, persists across reload, and speaks the next completed answer without a click; reasoning/tool output is never spoken. - Toggle and Settings switch stay in sync; mute/stop from #13 wins over both. - Keyboard-only user can reach and activate both controls; screen-reader labels are correct. ## Notes - Depends on #5 (message indexing/capture), #7 (queue), #12 (settings + persistence), #13 (mute/stop). Part of **M2**. - Scope split: #13 owns the global stop/mute chip; this issue owns the per-message action and the composer auto-read switch. When building, do not duplicate the toggle. - This is the "make you read this one" plus "read everything" pair the operator asked for on 2026-10-25.
Author
Owner

Implemented in the #24 commit.

  • conversation.chat.assistant-actions speaker button on every finalized assistant message: reads that message (looks up assistant/message text in the retained session window, so loaded history works too, not only live capture); clicking while it plays stops it; it shares the spool, so it never overlaps other speech.
  • conversation.input.left composer toggle for auto-read, persisted with the settings switch (both stay in sync).
  • Audio unlock stays inside the click gesture; an undownloaded voice warns instead of silently downloading.
  • Styling mirrors the message-action strip / composer row (28 px icon buttons, DSH CSS variables).

141 tests (controls render/actions + capture history lookup), CI green. Pending the operator's visual check on the bare UI.

**Implemented** in the `#24` commit. - `conversation.chat.assistant-actions` speaker button on every finalized assistant message: reads that message (looks up `assistant/message` text in the retained session window, so loaded **history** works too, not only live capture); clicking while it plays stops it; it shares the spool, so it never overlaps other speech. - `conversation.input.left` composer toggle for **auto-read**, persisted with the settings switch (both stay in sync). - Audio unlock stays inside the click gesture; an undownloaded voice warns instead of silently downloading. - Styling mirrors the message-action strip / composer row (28 px icon buttons, DSH CSS variables). 141 tests (controls render/actions + capture history lookup), CI green. Pending the operator's visual check on the bare UI.
Author
Owner

Follow-up fixes from the operator's visual check:

  • Mascot was oversized: switched to the operator's final 114×167 PNGs at native size (no rescale blur) with an exact 7px edge overlap via translateX(calc(±100% ∓ 7px)); card height stays 34vh.
  • Read-aloud action did nothing: history entries were rejected by the surfaceOp === 'append' predicate, and the slot's injected sessionId can be absent. findAssistantMessage now accepts any durable assistant/message, and the client falls back to scanning every retained session; a console line reports {messageId, sessionId, found}.
  • Icon showed the muted speaker: the message action now always renders the on-speaker (waves); active playback is indicated by colour.

142 tests green.

Follow-up fixes from the operator's visual check: - Mascot was oversized: switched to the operator's **final 114×167 PNGs at native size** (no rescale blur) with an exact **7px** edge overlap via `translateX(calc(±100% ∓ 7px))`; card height stays 34vh. - Read-aloud action did nothing: history entries were rejected by the `surfaceOp === 'append'` predicate, and the slot's injected `sessionId` can be absent. `findAssistantMessage` now accepts any durable `assistant/message`, and the client falls back to scanning every retained session; a console line reports `{messageId, sessionId, found}`. - Icon showed the muted speaker: the message action now always renders the on-speaker (waves); active playback is indicated by colour. 142 tests green.
Author
Owner

Confirmed working by the operator after the turn-tail fallback (0d30f3c): clicking the speaker now reads the answer above it, regardless of the slot id.

Final UI: panel has a fixed 270 px height with the native-size mascot. Closing — the message speaker and composer auto-read toggle both pass their manual check.

Confirmed working by the operator after the **turn-tail fallback** (`0d30f3c`): clicking the speaker now reads the answer above it, regardless of the slot id. Final UI: panel has a fixed **270 px** height with the native-size mascot. Closing — the message speaker and composer auto-read toggle both pass their manual check.
dsh closed this issue 2026-10-27 20:21:01 +00:00
Sign in to join this conversation.
No description provided.