mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:10:47 +00:00
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:
committed by
copyberry
parent
4110342321
commit
b01c3986fd
@@ -357,6 +357,7 @@ mod mcp_startup;
|
||||
use self::mcp_startup::McpStartupStatus;
|
||||
mod misalignment_policy;
|
||||
pub(crate) use misalignment_policy::MisalignmentReview;
|
||||
pub(crate) use misalignment_policy::MisalignmentTurnSource;
|
||||
mod pets;
|
||||
mod session_flow;
|
||||
mod session_header;
|
||||
@@ -406,7 +407,17 @@ mod recap;
|
||||
mod reset_credits;
|
||||
pub(crate) use self::rate_limits::limit_label_for_window;
|
||||
mod completion;
|
||||
mod realtime;
|
||||
pub(crate) use realtime::MAX_REPLAY_TRANSCRIPT_CELLS;
|
||||
pub(crate) use realtime::MAX_TRANSCRIPT_BYTES;
|
||||
pub(crate) use realtime::RealtimeTranscriptRecord;
|
||||
pub(crate) use realtime::is_private_realtime_agent_item;
|
||||
pub(crate) use realtime::realtime_delegation_display_text;
|
||||
pub(crate) use realtime::realtime_delegation_input;
|
||||
#[cfg(test)]
|
||||
pub(crate) use realtime::tests::activate_voice_for_thread;
|
||||
mod reasoning_shortcuts;
|
||||
use self::realtime::RealtimeConversationUiState;
|
||||
mod rendering;
|
||||
mod replay;
|
||||
mod review;
|
||||
@@ -631,6 +642,8 @@ pub(crate) struct ChatWidget {
|
||||
last_unified_wait: Option<UnifiedExecWaitState>,
|
||||
unified_exec_wait_streak: Option<UnifiedExecWaitStreak>,
|
||||
turn_lifecycle: TurnLifecycleState,
|
||||
realtime_conversation: RealtimeConversationUiState,
|
||||
realtime_conversation_available_for_thread: bool,
|
||||
safety_buffering: SafetyBufferingState,
|
||||
task_complete_pending: bool,
|
||||
unified_exec_processes: Vec<UnifiedExecProcessSummary>,
|
||||
@@ -1179,6 +1192,8 @@ impl ChatWidget {
|
||||
self.update_due_hook_visibility();
|
||||
self.schedule_hook_timer_if_needed();
|
||||
self.bottom_pane.pre_draw_tick();
|
||||
self.flush_realtime_transcript_history();
|
||||
self.refresh_realtime_microphone_level();
|
||||
if let Some(pet) = self.ambient_pet.as_ref() {
|
||||
pet.schedule_next_frame();
|
||||
}
|
||||
@@ -1295,7 +1310,20 @@ impl ChatWidget {
|
||||
items: &[UserInput],
|
||||
client_id: Option<&str>,
|
||||
from_replay: bool,
|
||||
turn_id: &str,
|
||||
) {
|
||||
if let Some(input) = realtime::realtime_delegation_input(items) {
|
||||
if !from_replay && self.should_hide_realtime_delegation(turn_id) {
|
||||
return;
|
||||
}
|
||||
let input = realtime::realtime_delegation_display_text(input);
|
||||
let projected = [UserInput::Text {
|
||||
text: input,
|
||||
text_elements: Vec::new(),
|
||||
}];
|
||||
self.on_committed_user_message(&projected, client_id, from_replay, turn_id);
|
||||
return;
|
||||
}
|
||||
let display = Self::user_message_display_from_inputs(items);
|
||||
if from_replay {
|
||||
if self.review.is_review_mode {
|
||||
@@ -1920,9 +1948,14 @@ impl ChatWidget {
|
||||
/// the main viewport updates.
|
||||
pub(crate) fn active_cell_transcript_key(&self) -> Option<ActiveCellTranscriptKey> {
|
||||
let cell = self.transcript.active_cell.as_ref();
|
||||
let realtime_cell = self.realtime_conversation.live_transcript_cell.as_ref();
|
||||
let token_activity_cell = self.pending_token_activity_output();
|
||||
let rate_limit_reset_hint = self.pending_rate_limit_reset_hint();
|
||||
if cell.is_none() && token_activity_cell.is_none() && rate_limit_reset_hint.is_none() {
|
||||
if cell.is_none()
|
||||
&& realtime_cell.is_none()
|
||||
&& token_activity_cell.is_none()
|
||||
&& rate_limit_reset_hint.is_none()
|
||||
{
|
||||
return None;
|
||||
}
|
||||
Some(ActiveCellTranscriptKey {
|
||||
@@ -1948,6 +1981,13 @@ impl ChatWidget {
|
||||
if let Some(cell) = self.transcript.active_cell.as_ref() {
|
||||
lines.extend(cell.transcript_hyperlink_lines(width));
|
||||
}
|
||||
if let Some(cell) = self.realtime_conversation.live_transcript_cell.as_ref() {
|
||||
let realtime_lines = cell.transcript_hyperlink_lines(width);
|
||||
if !realtime_lines.is_empty() && !lines.is_empty() {
|
||||
lines.push(HyperlinkLine::from(""));
|
||||
}
|
||||
lines.extend(realtime_lines);
|
||||
}
|
||||
if let Some(token_activity_cell) = self.pending_token_activity_output() {
|
||||
let token_activity_lines = token_activity_cell.transcript_hyperlink_lines(width);
|
||||
if !token_activity_lines.is_empty() && !lines.is_empty() {
|
||||
@@ -1998,6 +2038,13 @@ fn has_websocket_timing_metrics(summary: RuntimeMetricsSummary) -> bool {
|
||||
|
||||
impl Drop for ChatWidget {
|
||||
fn drop(&mut self) {
|
||||
if self.realtime_conversation.handle.is_some()
|
||||
&& let Some(thread_id) = self.thread_id
|
||||
{
|
||||
self.app_event_tx
|
||||
.send(AppEvent::StopRealtimeConversation { thread_id });
|
||||
}
|
||||
self.reset_realtime_conversation();
|
||||
self.stop_rate_limit_poller();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user