Add live WebRTC voice conversations to the TUI (#43581)

## What changed

- Add feature-gated `/voice`, `/voice mute`, and `/voice stop` commands with local WebRTC audio and app-server signaling.
- Show live transcripts, conversation status, and microphone and speaker levels. Preserve captions and undelivered answers across thread switches.
- Speak final answers from voice handoffs while keeping delegated reasoning and commentary hidden and typed answers unspoken.
- Retry eligible startup failures once and clean up voice sessions on thread switches and disconnects.
- Stop voice and block late handoffs after a misalignment policy violation. Remove realtime event payloads and spoken text from receipt and debug logs.

## Testing

Add coverage for voice command mapping, rejected starts, disconnect cleanup, delegated final-answer speech, late handoff rejection, and transcript and footer rendering.

GitOrigin-RevId: 11def1f86b0e023b21d0d92072d6636ccad89815
This commit is contained in:
Benjamin Carlsson authored and copyberry committed 2026-09-07 20:25:30 +00:00
1 parent 4110342321
commit b01c3986fd
70 files changed
+4421 -69

No files matched your search

@@ -333,6 +333,9 @@ impl ChatWidget {
);
}
}
SlashCommand::Voice => {
self.toggle_realtime_conversation();
}
SlashCommand::Side | SlashCommand::Btw => {
self.request_empty_side_conversation(cmd);
}
@@ -757,6 +760,11 @@ impl ChatWidget {
}
}
}
SlashCommand::Voice => match trimmed.to_ascii_lowercase().as_str() {
"mute" => self.toggle_realtime_microphone(),
"stop" => self.stop_realtime_conversation(),
_ => self.add_error_message("Usage: /voice [mute|stop]".to_string()),
},
SlashCommand::Ide => {
self.handle_ide_command_args(trimmed);
}
@@ -1144,6 +1152,7 @@ impl ChatWidget {
goal_command_enabled: self.config.features.enabled(Feature::Goals),
service_tier_commands_enabled: self.fast_mode_enabled(),
personality_command_enabled: self.config.features.enabled(Feature::Personality),
voice_command_enabled: self.realtime_conversation_available_for_thread,
worktrees_enabled: self.config.features.enabled(Feature::Worktrees)
&& self.local_worktree_operations,
allow_elevate_sandbox,
@@ -1183,6 +1192,7 @@ impl ChatWidget {
| SlashCommand::Diff
| SlashCommand::App
| SlashCommand::Rename
| SlashCommand::Voice
| SlashCommand::Recap
| SlashCommand::TestApproval => QueueDrain::Continue,
SlashCommand::Cd => match self.thread_id {