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

@@ -258,6 +258,38 @@ async fn disconnected_command_center_keeps_input_and_blocks_actions() -> Result<
Ok(())
}
#[tokio::test]
async fn remote_disconnect_retires_voice_before_reconnecting() -> Result<()> {
let (mut app, _events, _ops) = make_test_app_with_channels().await;
let thread_id = ThreadId::new();
app.active_thread_id = Some(thread_id);
app.chat_widget
.handle_thread_session_quiet(test_thread_session(thread_id, app.config.cwd.to_path_buf()));
app.app_server_target = AppServerTarget::Remote {
endpoint: crate::resolve_remote_addr("ws://127.0.0.1:9")?,
};
crate::chatwidget::activate_voice_for_thread(&mut app.chat_widget, thread_id);
assert!(app.chat_widget.is_current_realtime_attempt(
thread_id, /*attempt_id*/ 0, /*input_generation*/ 0
));
assert!(app.begin_reconnect());
assert_eq!(
(
app.reconnect.offline,
app.chat_widget.is_current_realtime_attempt(
thread_id, /*attempt_id*/ 0, /*input_generation*/ 0
),
),
(true, false)
);
assert!(app.begin_reconnect());
assert!(!app.chat_widget.is_current_realtime_attempt(
thread_id, /*attempt_id*/ 0, /*input_generation*/ 0
));
Ok(())
}
// Common framing/bootstrap for both transports. Returning None deliberately loses a reply.
pub(super) async fn serve_reconnect_requests<S, F>(
mut socket: tokio_tungstenite::WebSocketStream<S>,