Files
buzz/desktop/scripts
df543aeb99 feat(desktop): add read-aloud playback for agent chat messages
Let a user explicitly play/stop a delivered agent response from the
message action bar, reusing the local Pocket TTS stack while keeping
read-aloud fully independent from huddle orchestration.

Backend (src-tauri):
- New app-scoped message_tts module with its own TtsPipeline instance
  and fresh active/cancel flags — zero STT/barge-in/huddle-phase
  coupling. Commands: speak_chat_message / stop_chat_message_speech.
- Message-keyed lifecycle (preparing/playing/completed/stopped/
  superseded/failed) emitted as message-tts-state-changed events.
  Generation tokens guarantee stale watcher completions can never
  overwrite a newer request; one playback app-wide, newer play
  supersedes older.
- Huddle exclusion both ways: speak refuses while huddle phase is not
  Idle, and start/join_huddle stop any message playback before taking
  the audio device.
- Long-message limit mirrors the huddle cap (2000 chars, char-counted)
  with a spoken suffix and a truncated flag so the cut is disclosed,
  not silent. Missing voice model kicks off the download and surfaces
  a retryable error. No persisted audio cache.

Frontend (desktop/src):
- MessageTtsProvider (mounted in AppShell inside HuddleProvider) folds
  backend events through a pure reducer (playbackReducer.mjs) so stale
  terminal events for superseded messages can't clear newer playback.
  Errors surface as toasts + per-message state; truncation is disclosed
  via toast at playback start.
- ReadAloudButton in MessageActionBar for delivered agent text only
  (isAgent, not pending, has body), with aria-label/aria-pressed,
  tooltip, and disabled-with-reason during active huddles.

Tests: 16 Rust unit tests (truncation UTF-8 safety, supersede/stop
races, concurrent stops, event payload shape) and 13 node:test reducer
tests (out-of-order supersede delivery, detached errors, rapid
play/stop). Full suites green: cargo test (1576), pnpm test (3414),
typecheck, biome + file-size checks, desktop build.

Co-authored-by: Taylor Ho <taylorkmho@gmail.com>
Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
2026-07-27 16:13:47 -07:00
..