Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Move voice controls into a dedicated composer strip (#43683)

Benjamin Carlsson98c7c0415bf4
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs
index 6d084e067f..acc1425c1e 100644
--- a/codex-rs/tui/src/bottom_pane/chat_composer.rs
+++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs
@@ -4,6 +4,7 @@
//! completed slash commands to atomic elements, and handles Enter submission/newlines.
//! It also shows Luna Reserve's yellow prompt arrow and detects unbracketed paste bursts
//! from raw key streams, particularly on Windows.
+//! The live voice strip renders after decorative effects so its controls stay legible.
//!
//! The plain-text preset keeps command prefixes literal, including `!`, so Enter and Tab
//! submit ordinary text without enabling shell mode.
@@ -281,6 +282,7 @@ use super::skill_popup::MentionItem;
use super::skill_popup::SkillPopup;
use super::slash_commands::ServiceTierCommand;
use super::slash_commands::SlashCommandItem;
+use super::voice_strip::VoiceStrip;
use crate::bottom_pane::paste_burst::FlushResult;
use crate::history_cell::sanitize_user_text;
use crate::key_hint::KeyBindingListExt;
@@ -304,6 +306,7 @@ use codex_protocol::user_input::TextElement;
mod agents_navigation;
mod attachment_state;
mod completion_target;
+mod composer_layout;
mod draft_state;
mod footer_state;
mod history_search;
@@ -526,6 +529,7 @@ pub(crate) struct ChatComposer {
effort_tier: Option<EffortTier>,
effort_animation_style: Option<IgnitionStyle>,
effort_ignition: Option<EffortIgnition>,
+ voice_strip: Option<VoiceStrip>,
astra_sparkle: Option<sparkle::Sparkle>,
effort_status_line_transition: Option<EffortStatusLineTransition>,
effort_observed: bool,
@@ -695,6 +699,7 @@ impl ChatComposer {
effort_tier: None,
effort_animation_style: None,
effort_ignition: None,
+ voice_strip: None,
astra_sparkle: None,
effort_status_line_transition: None,
effort_observed: false,
@@ -1039,17 +1044,19 @@ impl ChatComposer {
let footer_hint_height = self
.custom_footer_height()
.unwrap_or_else(|| footer_height(&footer_props));
- let footer_spacing = Self::footer_spacing(footer_hint_height);
- let footer_total_height = footer_hint_height + footer_spacing;
- let popup_constraint = Constraint::Max(
- self.popups
- .active
- .required_height(area.width, footer_total_height),
- );
+ let footer_total_height = footer_hint_height + Self::footer_spacing(footer_hint_height);
+ let popup_height = self
+ .popups
+ .active
+ .required_height(area.width, footer_total_height);
+ let popup_constraint = Constraint::Max(popup_height);
+ let voice_rows = if self.voice_strip.is_some() { 3 } else { 0 };
let [composer_rect, popup_rect] =
- Layout::vertical([Constraint::Min(3), popup_constraint]).areas(area);
+ Layout::vertical([Constraint::Min(3 + voice_rows), popup_constraint]).areas(area);
+ // Keep the draft visible when clipped.
+ let voice_rows = voice_rows * u16::from(composer_rect.height >= 6);
let mut textarea_rect = composer_rect.inset(Insets::tlbr(
- /*top*/ 1,
+ /*top*/ 1 + voice_rows,
LIVE_PREFIX_COLS,
/*bottom*/ 1,
/*right*/ 1u16.saturating_add(textarea_right_reserve),
@@ -4638,8 +4645,7 @@ impl ChatComposer {
let footer_hint_height = self
.custom_footer_height()
.unwrap_or_else(|| footer_height(&footer_props));
- let footer_spacing = Self::footer_spacing(footer_hint_height);
- let footer_total_height = footer_hint_height + footer_spacing;
+ let footer_total_height = footer_hint_height + Self::footer_spacing(footer_hint_height);
const COLS_WITH_MARGIN: u16 = LIVE_PREFIX_COLS + 1;
let inner_width =
width.saturating_sub(COLS_WITH_MARGIN.saturating_add(textarea_right_reserve));
@@ -4654,6 +4660,7 @@ impl ChatComposer {
+ remote_images_height
+ remote_images_separator
+ 2
+ + if self.voice_strip.is_some() { 3 } else { 0 }
+ self
.popups
.active
@@ -5054,6 +5061,7 @@ impl ChatComposer {
buf,
);
}
+ self.render_voice_strip(composer_rect, buf);
}
}
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/composer_layout.rs b/codex-rs/tui/src/bottom_pane/chat_composer/composer_layout.rs
new file mode 100644
index 0000000000..ec966b8d73
--- /dev/null
+++ b/codex-rs/tui/src/bottom_pane/chat_composer/composer_layout.rs
@@ -0,0 +1,36 @@
+//! Reserves popup and voice-control space around the editable draft.
+
+use super::ChatComposer;
+use crate::bottom_pane::voice_strip::VoiceStrip;
+use crate::bottom_pane::voice_strip::VoiceStripState;
+use crate::render::renderable::Renderable;
+use crate::tui::FrameRequester;
+use ratatui::buffer::Buffer;
+use ratatui::layout::Rect;
+
+impl ChatComposer {
+ pub(crate) fn set_voice_strip(
+ &mut self,
+ state: Option<VoiceStripState>,
+ frame_requester: FrameRequester,
+ ) {
+ match (self.voice_strip.as_mut(), state) {
+ (Some(strip), Some(state)) => strip.update(state),
+ (_, Some(state)) => self.voice_strip = Some(VoiceStrip::new(state, frame_requester)),
+ (_, None) => self.voice_strip = None,
+ }
+ }
+
+ pub(super) fn render_voice_strip(&self, composer_rect: Rect, buf: &mut Buffer) {
+ if let Some(strip) = &self.voice_strip
+ && composer_rect.height >= 6
+ {
+ let voice_rect = Rect {
+ y: composer_rect.y.saturating_add(/*rhs*/ 1),
+ height: 2,
+ ..composer_rect
+ };
+ strip.render(voice_rect, buf);
+ }
+ }
+}
diff --git a/codex-rs/tui/src/bottom_pane/mod.rs b/codex-rs/tui/src/bottom_pane/mod.rs
index 00712baab9..653da8dffa 100644
--- a/codex-rs/tui/src/bottom_pane/mod.rs
+++ b/codex-rs/tui/src/bottom_pane/mod.rs
@@ -77,6 +77,7 @@ mod status_line_setup;
mod status_line_style;
mod status_surface_preview;
mod title_setup;
+mod voice_strip;
pub(crate) use action_required_title::ACTION_REQUIRED_PREVIEW_PREFIX;
pub(crate) use action_required_title::build_action_required_title_text;
pub(crate) use actionable_banner::ActionableBanner;
@@ -99,6 +100,8 @@ pub(crate) use mcp_server_elicitation::McpServerElicitationFormRequest;
pub(crate) use mcp_server_elicitation::McpServerElicitationOverlay;
pub(crate) use request_user_input::RequestUserInputOverlay;
pub(crate) use status_line_style::status_line_from_segments;
+pub(crate) use voice_strip::VoiceStripPhase;
+pub(crate) use voice_strip::VoiceStripState;
mod bottom_pane_view;
mod effort_ignition;
@@ -1078,6 +1081,12 @@ impl BottomPane {
self.request_redraw();
}
+ pub(crate) fn set_voice_strip(&mut self, state: Option<VoiceStripState>) {
+ self.composer
+ .set_voice_strip(state, self.frame_requester.clone());
+ self.request_redraw();
+ }
+
pub(crate) fn set_remote_image_urls(&mut self, urls: Vec<String>) {
self.composer.set_remote_image_urls(urls);
self.request_redraw();
diff --git a/codex-rs/tui/src/bottom_pane/voice_strip.rs b/codex-rs/tui/src/bottom_pane/voice_strip.rs
new file mode 100644
index 0000000000..5385c9a555
--- /dev/null
+++ b/codex-rs/tui/src/bottom_pane/voice_strip.rs
@@ -0,0 +1,185 @@
+//! Renders compact voice controls and caller-owned microphone/speaker sample histories.
+//! Keep control positions stable and show mute only when the current phase permits it.
+
+use crate::motion::MotionMode;
+use crate::render::renderable::Renderable;
+use crate::tui::FrameRequester;
+use ratatui::buffer::Buffer;
+use ratatui::layout::Rect;
+use ratatui::style::Color;
+use ratatui::style::Style;
+use ratatui::style::Stylize;
+use ratatui::text::Line;
+use ratatui::text::Span;
+use ratatui::widgets::Paragraph;
+use ratatui::widgets::Widget;
+use std::time::Duration;
+use std::time::Instant;
+
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
+pub(crate) enum VoiceStripPhase {
+ Connecting,
+ Active,
+}
+
+#[derive(Clone, Debug, Eq, PartialEq)]
+pub(crate) struct VoiceStripState {
+ pub(crate) phase: VoiceStripPhase,
+ pub(crate) microphone_live: bool,
+ pub(crate) microphone_muted: bool,
+ pub(crate) microphone_history: Vec<u8>,
+ pub(crate) speaker_history: Vec<u8>,
+ pub(crate) activity: &'static str,
+ pub(crate) animations: bool,
+}
+
+pub(super) struct VoiceStrip {
+ state: VoiceStripState,
+ started_at: Instant,
+ frame_requester: FrameRequester,
+}
+
+impl VoiceStrip {
+ pub(super) fn new(state: VoiceStripState, frame_requester: FrameRequester) -> Self {
+ Self {
+ state,
+ started_at: Instant::now(),
+ frame_requester,
+ }
+ }
+
+ pub(super) fn update(&mut self, state: VoiceStripState) {
+ if self.state.activity != state.activity {
+ self.started_at = Instant::now();
+ }
+ self.state = state;
+ }
+}
+
+pub(super) fn loading_glyph(started_at: Instant, mode: MotionMode) -> &'static str {
+ const FRAMES: [&str; 10] = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
+ if mode == MotionMode::Reduced {
+ "◌"
+ } else {
+ let frame = started_at.elapsed().as_millis() / 100;
+ FRAMES[usize::try_from(frame).unwrap_or_default() % FRAMES.len()]
+ }
+}
+
+impl Renderable for VoiceStrip {
+ fn desired_height(&self, width: u16) -> u16 {
+ if width == 0 { 0 } else { 2 }
+ }
+
+ fn render(&self, area: Rect, buf: &mut Buffer) {
+ let area = Rect {
+ x: area.x.saturating_add(/*rhs*/ 1),
+ width: area.width.saturating_sub(/*rhs*/ 2),
+ ..area
+ };
+ if area.is_empty() {
+ return;
+ }
+ let connecting = self.state.phase == VoiceStripPhase::Connecting;
+ let mode = MotionMode::from_animations_enabled(self.state.animations);
+ if connecting && mode == MotionMode::Animated {
+ self.frame_requester
+ .schedule_frame_in(Duration::from_millis(100));
+ }
+ let marker = if connecting && self.state.microphone_live && !self.state.microphone_muted {
+ loading_glyph(self.started_at, mode).red().bold()
+ } else if connecting {
+ loading_glyph(self.started_at, mode).cyan()
+ } else if self.state.microphone_live && !self.state.microphone_muted {
+ "●".red().bold()
+ } else {
+ "◌".dark_gray()
+ };
+ let activity = format!(" {}", self.state.activity).into();
+ let mut status = Line::from(vec!["voice ".dim(), marker, activity]);
+ let mute = if self.state.microphone_muted {
+ "ctrl+x unmute"
+ } else {
+ "ctrl+x mute "
+ };
+ let full_controls = format!("{mute} /voice stop");
+ let available = usize::from(area.width);
+ let can_mute = !connecting || self.state.microphone_live || self.state.microphone_muted;
+ if can_mute
+ && available < status.width() + full_controls.len() + 1
+ && available >= "voice ".len() + full_controls.len() + 2
+ {
+ status.spans.pop();
+ }
+ let controls = if can_mute && available > status.width() + full_controls.len() {
+ full_controls.as_str()
+ } else {
+ "/voice stop"
+ };
+ if available < status.width() + controls.len() + 1 {
+ status = Line::from(vec!["voice".dim()]);
+ }
+ status.spans.push(
+ " ".repeat(available.saturating_sub(status.width() + controls.len()))
+ .into(),
+ );
+ status.spans.push(controls.dim());
+ Paragraph::new(status).render(Rect::new(area.x, area.y, area.width, /*height*/ 1), buf);
+ if area.height < 2 {
+ return;
+ }
+ let meter_width = available
+ .saturating_sub(/*rhs*/ 14)
+ .saturating_div(/*rhs*/ 2)
+ .min(/*other*/ 6);
+ let mut meters = Vec::with_capacity(meter_width * 2 + 2);
+ meters.push(" mic ".dim());
+ append_voice_history(
+ &mut meters,
+ &self.state.microphone_history,
+ meter_width,
+ Color::Cyan,
+ self.state.microphone_muted || !self.state.microphone_live,
+ );
+ meters.push(" codex ".dim());
+ append_voice_history(
+ &mut meters,
+ &self.state.speaker_history,
+ meter_width,
+ Color::Magenta,
+ /*muted*/ false,
+ );
+ Paragraph::new(Line::from(meters))
+ .render(Rect::new(area.x, area.y + 1, area.width, /*height*/ 1), buf);
+ }
+}
+
+fn append_voice_history(
+ spans: &mut Vec<Span<'static>>,
+ samples: &[u8],
+ meter_width: usize,
+ color: Color,
+ muted: bool,
+) {
+ let samples = &samples[samples.len().saturating_sub(meter_width)..];
+ for intensity in std::iter::repeat_n(/*element*/ 0, meter_width - samples.len())
+ .chain(samples.iter().copied())
+ {
+ let height = if muted {
+ 0
+ } else {
+ usize::from(intensity)
+ .saturating_mul(/*rhs*/ 7)
+ .div_ceil(/*rhs*/ 255)
+ };
+ let style = Style::new().fg(if height == 0 { Color::DarkGray } else { color });
+ spans.push(Span::styled(
+ ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"][height],
+ style,
+ ));
+ }
+}
+
+#[cfg(test)]
+#[path = "voice_strip_tests.rs"]
+mod tests;
diff --git a/codex-rs/tui/src/bottom_pane/voice_strip_tests.rs b/codex-rs/tui/src/bottom_pane/voice_strip_tests.rs
new file mode 100644
index 0000000000..61cd4b8192
--- /dev/null
+++ b/codex-rs/tui/src/bottom_pane/voice_strip_tests.rs
@@ -0,0 +1,132 @@
+//! Snapshot and layout regressions for compact voice controls across widths and states.
+//! Supplied microphone and speaker histories remain independent when rendered.
+
+use super::*;
+use pretty_assertions::assert_eq;
+use ratatui::style::Color;
+
+fn active_strip() -> VoiceStrip {
+ VoiceStrip::new(
+ VoiceStripState {
+ phase: VoiceStripPhase::Active,
+ microphone_live: true,
+ microphone_muted: false,
+ microphone_history: vec![
+ 0, 1, 37, 73, 110, 146, 183, 219, 183, 146, 110, 73, 37, 1, 0,
+ ],
+ speaker_history: vec![0, 37, 73, 110, 146, 219],
+ activity: "listening",
+ animations: true,
+ },
+ FrameRequester::test_dummy(),
+ )
+}
+
+fn rows(strip: &VoiceStrip, width: u16) -> (String, Buffer) {
+ let area = Rect::new(/*x*/ 0, /*y*/ 0, width, /*height*/ 2);
+ let mut buffer = Buffer::empty(area);
+ strip.render(area, &mut buffer);
+ let text = buffer
+ .content
+ .chunks(usize::from(width))
+ .map(|cells| {
+ cells
+ .iter()
+ .map(ratatui::buffer::Cell::symbol)
+ .collect::<String>()
+ })
+ .map(|line| line.trim_end().to_string())
+ .collect::<Vec<_>>()
+ .join("\n");
+ (text, buffer)
+}
+
+#[test]
+fn active_dashboard_preserves_live_colors_controls_and_width() {
+ let mut strip = active_strip();
+ let (actual, buffer) = rows(&strip, /*width*/ 47);
+ assert_eq!(buffer[(45, 0)].symbol(), "p");
+ assert_eq!(buffer[(46, 0)].symbol(), " ");
+ assert!(actual.starts_with(" voice "));
+ assert!(actual.lines().nth(1).unwrap().starts_with(" mic "));
+ insta::assert_snapshot!(actual, @r"
+ voice ● listening ctrl+x mute /voice stop
+ mic ▆▅▄▃▂▁ codex ▁▃▄▅▆█
+ ");
+ assert_eq!(buffer[(7, 0)].fg, Color::Red);
+ assert_eq!(buffer[(7, 1)].fg, Color::Cyan);
+ assert_eq!(buffer[(22, 1)].fg, Color::Magenta);
+ assert!(actual.contains("/voice stop"));
+ let (compact, buffer) = rows(&strip, /*width*/ 37);
+ assert!(compact.contains("ctrl+x mute") && compact.contains("/voice stop"));
+ assert_eq!(buffer[(36, 0)].symbol(), " ");
+ let (narrow, buffer) = rows(&strip, /*width*/ 22);
+ assert!(narrow.contains("/voice stop"));
+ assert_eq!(buffer[(21, 0)].symbol(), " ");
+ assert!(narrow.contains("mic") && narrow.contains("codex"));
+ let started_at = strip.started_at;
+ let state = VoiceStripState {
+ microphone_history: vec![255],
+ ..strip.state.clone()
+ };
+ strip.update(state);
+ assert_eq!(strip.started_at, started_at);
+ let (full, _) = rows(&strip, /*width*/ 45);
+ assert!(full.lines().nth(1).unwrap().contains('█'));
+}
+
+#[test]
+fn connecting_and_muted_indicators_follow_actual_capture() {
+ let mut strip = active_strip();
+ strip.state.phase = VoiceStripPhase::Connecting;
+ strip.state.activity = "connecting";
+ strip.state.microphone_live = false;
+ strip.state.animations = false;
+ let (connecting, buffer) = rows(&strip, /*width*/ 45);
+ assert!(connecting.contains("voice ◌ connecting"));
+ assert!(!connecting.contains("ctrl+x mute"));
+ assert_ne!(buffer[(7, 0)].fg, Color::Red);
+ strip.state.microphone_live = true;
+ let (_, buffer) = rows(&strip, /*width*/ 45);
+ assert_eq!(buffer[(7, 0)].symbol(), "◌");
+ assert_eq!(buffer[(7, 0)].fg, Color::Red);
+ strip.state.phase = VoiceStripPhase::Active;
+ strip.state.activity = "listening";
+ strip.state.microphone_history = vec![255];
+ let (reduced, _) = rows(&strip, /*width*/ 45);
+ assert!(reduced.lines().nth(1).unwrap().contains('█'));
+ let stop_column = reduced.lines().next().unwrap().find("/voice stop");
+ strip.state.microphone_muted = true;
+ strip.state.activity = "muted";
+ let (muted, buffer) = rows(&strip, /*width*/ 45);
+ assert!(muted.contains("voice ◌ muted"));
+ assert!(
+ muted
+ .lines()
+ .nth(1)
+ .unwrap()
+ .starts_with(" mic ▁▁▁▁▁▁ codex ")
+ );
+ assert!(muted.lines().nth(1).unwrap().ends_with("▁▃▄▅▆█"));
+ assert_eq!(
+ muted.lines().next().unwrap().find("/voice stop"),
+ stop_column
+ );
+ assert_eq!(buffer[(7, 1)].fg, Color::DarkGray);
+ assert_eq!(buffer[(22, 1)].fg, Color::Magenta);
+ assert_ne!(buffer[(7, 0)].fg, Color::Red);
+}
+
+#[test]
+fn waveform_preserves_real_sample_order_width_and_channel_colors() {
+ let mut strip = active_strip();
+ let (history, _) = rows(&strip, /*width*/ 45);
+ assert!(history.ends_with("mic ▆▅▄▃▂▁ codex ▁▃▄▅▆█"));
+ let (clipped, _) = rows(&strip, /*width*/ 22);
+ assert!(clipped.ends_with("mic ▃▂▁ codex ▅▆█"));
+ strip.state.microphone_history = vec![0, 0];
+ let (silent, buffer) = rows(&strip, /*width*/ 45);
+ assert!(silent.contains("mic ▁▁▁▁▁▁ codex ▁▃▄▅▆█"));
+ assert_eq!(buffer[(7, 1)].fg, Color::DarkGray);
+ assert_eq!(buffer[(22, 1)].fg, Color::Magenta);
+}
diff --git a/codex-rs/tui/src/chatwidget/realtime.rs b/codex-rs/tui/src/chatwidget/realtime.rs
index c3dc17683c..799f6d57b7 100644
--- a/codex-rs/tui/src/chatwidget/realtime.rs
+++ b/codex-rs/tui/src/chatwidget/realtime.rs
@@ -10,6 +10,8 @@ use super::realtime_split_flap::SplitFlapTranscriptCell;
use super::realtime_split_flap::VoiceAmplitudeHistory;
use crate::app_command::AppCommand;
use crate::app_event::AppEvent;
+use crate::bottom_pane::VoiceStripPhase;
+use crate::bottom_pane::VoiceStripState;
use crate::history_cell;
use crate::key_hint;
use crate::motion::MotionMode;
@@ -51,7 +53,7 @@ const MAX_SPEAKABLE_FINAL_TOKENS: usize = 990;
const AUDIO_METER_SEGMENTS: usize = 5;
const AUDIO_METER_NOISE_FLOOR: u16 = 512;
const AUDIO_METER_FULL_SCALE: u16 = 8192;
-const MAX_REALTIME_AUDIO_METER_FRAMES: usize = 24;
+const MAX_REALTIME_AUDIO_METER_FRAMES: usize = 12;
const MICROPHONE_METER_INTERVAL: Duration = Duration::from_millis(100);
const SPEAKER_ACTIVITY_HOLD: Duration = Duration::from_millis(500);
const INTERRUPTION_ACKNOWLEDGMENT: Duration = Duration::from_millis(400);
@@ -140,9 +142,11 @@ pub(super) struct RealtimeConversationUiState {
microphone_muted: bool,
microphone_level: usize,
speaker_level: usize,
+ microphone_intensity: u8,
+ speaker_intensity: u8,
microphone_history: VoiceAmplitudeHistory,
speaker_history: VoiceAmplitudeHistory,
- audio_meter_history: VecDeque<(VoiceAmplitudeHistory, VoiceAmplitudeHistory)>,
+ audio_meter_history: VecDeque<(u8, u8)>,
speaker_active_until: Option<Instant>,
interruption_acknowledged_until: Option<Instant>,
speaker_suppression_generation: Option<u64>,
@@ -318,7 +322,7 @@ impl ChatWidget {
handle.close();
self.realtime_conversation.phase = RealtimeConversationPhase::Stopping;
self.refresh_terminal_title();
- self.set_footer_hint_override(/*items*/ None);
+ self.bottom_pane.set_voice_strip(/*state*/ None);
let Some(thread_id) = self.realtime_conversation.thread_id else {
self.reset_realtime_conversation();
return;
@@ -1674,7 +1678,7 @@ impl ChatWidget {
if had_live_transcript {
self.bump_active_cell_revision();
}
- self.set_footer_hint_override(/*items*/ None);
+ self.bottom_pane.set_voice_strip(/*state*/ None);
self.flush_realtime_transcript_history();
if should_refresh_terminal_title {
self.refresh_terminal_title();
diff --git a/codex-rs/tui/src/chatwidget/realtime/recording_controls.rs b/codex-rs/tui/src/chatwidget/realtime/recording_controls.rs
index d51187bc1a..cdb56ed1bc 100644
--- a/codex-rs/tui/src/chatwidget/realtime/recording_controls.rs
+++ b/codex-rs/tui/src/chatwidget/realtime/recording_controls.rs
@@ -18,9 +18,12 @@ impl ChatWidget {
self.realtime_conversation.microphone_muted = muted;
self.realtime_conversation.microphone_level = 0;
+ self.realtime_conversation.microphone_intensity = 0;
if muted {
self.realtime_conversation.microphone_history = VoiceAmplitudeHistory::default();
- self.realtime_conversation.audio_meter_history.clear();
+ for (microphone, _) in &mut self.realtime_conversation.audio_meter_history {
+ *microphone = 0;
+ }
self.realtime_conversation.interruption_acknowledged_until = None;
}
self.update_realtime_footer();
@@ -33,7 +36,9 @@ impl ChatWidget {
) -> bool {
if key_event.kind != KeyEventKind::Press
|| !REALTIME_MICROPHONE_SHORTCUT.is_press(key_event)
- || self.realtime_conversation.phase != RealtimeConversationPhase::Active
+ || !(self.realtime_conversation.phase == RealtimeConversationPhase::Active
+ || (self.realtime_conversation.phase == RealtimeConversationPhase::Starting
+ && self.realtime_conversation.handle.is_some()))
|| self.realtime_conversation.thread_id.is_none()
|| self.realtime_conversation.thread_id != self.thread_id()
|| !self.bottom_pane.no_modal_or_popup_active()
@@ -78,6 +83,10 @@ impl ChatWidget {
handle.set_speaker_suppressed(/*suppressed*/ true);
}
self.realtime_conversation.speaker_level = 0;
+ self.realtime_conversation.speaker_intensity = 0;
+ for (_, speaker) in &mut self.realtime_conversation.audio_meter_history {
+ *speaker = 0;
+ }
self.realtime_conversation.speaker_active_until = None;
self.update_realtime_footer();
}
@@ -114,16 +123,22 @@ impl ChatWidget {
.schedule_frame_in(MICROPHONE_METER_INTERVAL);
return;
}
- let microphone_level = if self.realtime_conversation.microphone_muted {
+ let microphone_peak = if self.realtime_conversation.microphone_muted {
0
} else {
- audio_meter_level(handle.take_microphone_peak())
+ handle.take_microphone_peak()
};
- let speaker_level = audio_meter_level(handle.take_speaker_peak());
+ let speaker_peak = handle.take_speaker_peak();
+ let microphone_level = audio_meter_level(microphone_peak);
+ let speaker_level = audio_meter_level(speaker_peak);
+ let microphone_intensity = audio_meter_intensity(microphone_peak);
+ let speaker_intensity = audio_meter_intensity(speaker_peak);
let previous_microphone_history = self.realtime_conversation.microphone_history;
let previous_speaker_history = self.realtime_conversation.speaker_history;
let mut changed = self.realtime_conversation.microphone_level != microphone_level
- || self.realtime_conversation.speaker_level != speaker_level;
+ || self.realtime_conversation.speaker_level != speaker_level
+ || self.realtime_conversation.microphone_intensity != microphone_intensity
+ || self.realtime_conversation.speaker_intensity != speaker_intensity;
if speaker_level > 0 {
self.realtime_conversation.speaker_active_until =
Some(Instant::now() + SPEAKER_ACTIVITY_HOLD);
@@ -141,21 +156,28 @@ impl ChatWidget {
.is_some();
self.realtime_conversation.microphone_level = microphone_level;
self.realtime_conversation.speaker_level = speaker_level;
+ self.realtime_conversation.microphone_intensity = microphone_intensity;
+ self.realtime_conversation.speaker_intensity = speaker_intensity;
self.realtime_conversation
.microphone_history
.push(microphone_level);
self.realtime_conversation
.speaker_history
.push(speaker_level);
+ let had_meter_activity = self
+ .realtime_conversation
+ .audio_meter_history
+ .iter()
+ .any(|(microphone, speaker)| *microphone > 0 || *speaker > 0);
if self.realtime_conversation.audio_meter_history.len() >= MAX_REALTIME_AUDIO_METER_FRAMES {
self.realtime_conversation.audio_meter_history.pop_front();
}
- self.realtime_conversation.audio_meter_history.push_back((
- self.realtime_conversation.microphone_history,
- self.realtime_conversation.speaker_history,
- ));
+ self.realtime_conversation
+ .audio_meter_history
+ .push_back((microphone_intensity, speaker_intensity));
changed |= previous_microphone_history != self.realtime_conversation.microphone_history
- || previous_speaker_history != self.realtime_conversation.speaker_history;
+ || previous_speaker_history != self.realtime_conversation.speaker_history
+ || had_meter_activity;
if changed {
self.update_realtime_footer();
}
@@ -164,47 +186,73 @@ impl ChatWidget {
}
pub(super) fn update_realtime_footer(&mut self) {
- let status = if self.realtime_conversation.phase == RealtimeConversationPhase::Starting {
- "◌ connecting"
+ let microphone_live = self.realtime_microphone_is_listening();
+ let active = self.realtime_conversation.phase == RealtimeConversationPhase::Active;
+ if !matches!(
+ self.realtime_conversation.phase,
+ RealtimeConversationPhase::Starting | RealtimeConversationPhase::Active
+ ) || self.realtime_conversation.thread_id != self.thread_id()
+ {
+ self.bottom_pane.set_voice_strip(/*state*/ None);
+ return;
+ }
+
+ let activity = if self.realtime_conversation.phase == RealtimeConversationPhase::Starting {
+ "connecting"
} else if self.realtime_conversation.microphone_muted {
- "◌ muted"
+ "muted"
} else if self
.realtime_conversation
.interruption_acknowledged_until
.is_some_and(|deadline| deadline > Instant::now())
{
- "● heard"
+ "heard"
} else if self.realtime_conversation.speaker_level > 0
|| self
.realtime_conversation
.speaker_active_until
.is_some_and(|deadline| deadline > Instant::now())
{
- "● speaking"
+ "speaking"
} else {
- "● listening"
+ "listening"
};
- let mut hints = vec![
- ("voice".to_string(), status.to_string()),
- ("/voice".to_string(), "stop".to_string()),
- ];
- if self.realtime_conversation.phase == RealtimeConversationPhase::Active {
- let microphone = if self.realtime_conversation.microphone_muted {
- "off".to_string()
+ self.bottom_pane.set_voice_strip(Some(VoiceStripState {
+ phase: if active {
+ VoiceStripPhase::Active
} else {
- audio_meter_braille(self.realtime_conversation.microphone_history)
- };
- let speaker = audio_meter_braille(self.realtime_conversation.speaker_history);
- hints.push(("mic".to_string(), format!("{microphone} codex {speaker}")));
- }
- let mute_shortcut = REALTIME_MICROPHONE_SHORTCUT
- .display_label()
- .replace(" + ", "+");
- hints.push(("/voice".to_string(), format!("mute {mute_shortcut}")));
- self.set_footer_hint_override(Some(hints));
+ VoiceStripPhase::Connecting
+ },
+ microphone_live,
+ microphone_muted: self.realtime_conversation.microphone_muted,
+ microphone_history: self
+ .realtime_conversation
+ .audio_meter_history
+ .iter()
+ .map(|(microphone, _)| *microphone)
+ .collect(),
+ speaker_history: self
+ .realtime_conversation
+ .audio_meter_history
+ .iter()
+ .map(|(_, speaker)| *speaker)
+ .collect(),
+ activity,
+ animations: self.config.animations,
+ }));
}
}
+pub(super) fn audio_meter_intensity(peak: u16) -> u8 {
+ let intensity = usize::from(peak.saturating_sub(AUDIO_METER_NOISE_FLOOR))
+ .saturating_mul(usize::from(u8::MAX))
+ .div_ceil(usize::from(
+ AUDIO_METER_FULL_SCALE - AUDIO_METER_NOISE_FLOOR,
+ ))
+ .min(usize::from(u8::MAX));
+ u8::try_from(intensity).unwrap_or(u8::MAX)
+}
+
pub(super) fn audio_meter_level(peak: u16) -> usize {
usize::from(peak.saturating_sub(AUDIO_METER_NOISE_FLOOR))
.saturating_mul(AUDIO_METER_SEGMENTS)
@@ -213,11 +261,3 @@ pub(super) fn audio_meter_level(peak: u16) -> usize {
))
.min(AUDIO_METER_SEGMENTS)
}
-
-fn audio_meter_braille(samples: VoiceAmplitudeHistory) -> String {
- if samples.peak() == 0 {
- "⠄⠄".to_string()
- } else {
- samples.glyphs()
- }
-}
diff --git a/codex-rs/tui/src/chatwidget/realtime/recording_controls_tests.rs b/codex-rs/tui/src/chatwidget/realtime/recording_controls_tests.rs
index 334ddf4e90..e801ac4577 100644
--- a/codex-rs/tui/src/chatwidget/realtime/recording_controls_tests.rs
+++ b/codex-rs/tui/src/chatwidget/realtime/recording_controls_tests.rs
@@ -76,18 +76,61 @@ async fn voice_composer_preserves_normal_colors_across_microphone_states() {
let check = |chat: &mut ChatWidget, recording| {
chat.update_realtime_footer();
let area = Rect::new(
- /*x*/ 0, /*y*/ 0, /*width*/ 24, /*height*/ 4,
+ /*x*/ 0,
+ /*y*/ 0,
+ /*width*/ 47,
+ chat.bottom_pane.desired_height(/*width*/ 47),
);
let mut buffer = Buffer::empty(area);
chat.bottom_pane.render(area, &mut buffer);
assert_eq!(chat.realtime_microphone_is_listening(), recording);
assert!(buffer.content.iter().all(|cell| cell.bg != Color::Red));
+ if recording {
+ let marker = buffer
+ .content
+ .iter()
+ .find(|cell| cell.symbol() == "●")
+ .expect("actual capture must show a recording marker");
+ assert_eq!(marker.fg, Color::Red);
+ assert_ne!(marker.bg, Color::Red);
+ }
+ if recording && chat.config.animations {
+ let rows = buffer
+ .content
+ .chunks(/*chunk_size*/ 47)
+ .take(/*n*/ 5)
+ .enumerate()
+ .map(|(index, cells)| {
+ let row = cells
+ .iter()
+ .map(ratatui::buffer::Cell::symbol)
+ .collect::<String>();
+ format!("{index}: {}", row.trim_end())
+ .trim_end()
+ .to_string()
+ })
+ .collect::<Vec<_>>()
+ .join("\n");
+ insta::assert_snapshot!(rows, @r"
+ 0:
+ 1: voice ● listening ctrl+x mute /voice stop
+ 2: mic ▁▁▁▁▁▁ codex ▁▁▁▁▁▁
+ 3:
+ 4: › typed
+ ");
+ }
buffer
.content
- .iter()
- .find(|cell| cell.symbol() == "t")
+ .windows(/*size*/ 5)
+ .find(|cells| {
+ cells
+ .iter()
+ .map(ratatui::buffer::Cell::symbol)
+ .collect::<String>()
+ == "typed"
+ })
+ .map(|cells| cells[0].fg)
.unwrap()
- .fg
};
let foreground = check(&mut chat, /*recording*/ true);
chat.config.animations = false;
@@ -108,7 +151,10 @@ async fn voice_preserves_the_normal_composer_prompt() {
let thread_id = activate_voice(&mut chat);
let prompt = |chat: &mut ChatWidget| {
chat.update_realtime_footer();
- render_bottom_popup(chat, /*width*/ 80).chars().next()
+ render_bottom_popup(chat, /*width*/ 80)
+ .lines()
+ .filter_map(|line| line.chars().next())
+ .find(|glyph| matches!(glyph, '›' | '!'))
};
for level in 0..=5 {
chat.realtime_conversation.microphone_level = level;
@@ -139,6 +185,9 @@ async fn voice_preserves_the_normal_composer_prompt() {
async fn voice_footer_renders_the_main_conversation_states() {
let (mut chat, _sender, _events, _ops) = make_chatwidget_manual_with_sender().await;
activate_voice(&mut chat);
+ chat.thread_name = Some("status line stays visible".to_string());
+ chat.local_settings.tui.status_line = Some(vec!["thread-title".to_string()]);
+ chat.refresh_status_surfaces();
let mut states = Vec::new();
for (label, phase, muted, level, speaker_level, role, transcript) in [
@@ -188,10 +237,18 @@ async fn voice_footer_renders_the_main_conversation_states() {
"Hello there",
),
] {
+ chat.config.animations = label != "connecting";
chat.realtime_conversation.phase = phase;
chat.realtime_conversation.microphone_muted = muted;
chat.realtime_conversation.microphone_level = level;
chat.realtime_conversation.speaker_level = speaker_level;
+ chat.realtime_conversation.microphone_intensity = (level * 255 / 5) as u8;
+ chat.realtime_conversation.speaker_intensity = (speaker_level * 255 / 5) as u8;
+ let intensities = (
+ chat.realtime_conversation.microphone_intensity,
+ chat.realtime_conversation.speaker_intensity,
+ );
+ chat.realtime_conversation.audio_meter_history = [intensities; 4].into();
chat.realtime_conversation.microphone_history =
super::super::VoiceAmplitudeHistory::default();
chat.realtime_conversation.speaker_history = super::super::VoiceAmplitudeHistory::default();
@@ -204,13 +261,13 @@ async fn voice_footer_renders_the_main_conversation_states() {
chat.realtime_conversation.transcript_role = role.map(str::to_string);
chat.realtime_conversation.transcript = transcript.to_string();
chat.update_realtime_footer();
- states.push(format!(
- "{label}:\n{}",
- render_bottom_popup(&chat, /*width*/ 80)
- ));
+ let rendered = render_bottom_popup(&chat, /*width*/ 80);
+ assert!(rendered.contains("status line stays visible"));
+ states.push(format!("{label}:\n{rendered}"));
}
chat.realtime_conversation.speaker_level = 0;
+ chat.realtime_conversation.speaker_intensity = 0;
chat.realtime_conversation.speaker_history = super::super::VoiceAmplitudeHistory::default();
chat.realtime_conversation.interruption_acknowledged_until =
Some(std::time::Instant::now() + super::super::INTERRUPTION_ACKNOWLEDGMENT);
@@ -232,23 +289,34 @@ async fn narrow_voice_footer_keeps_the_stop_control_before_meters() {
Some(std::time::Instant::now() + super::super::SPEAKER_ACTIVITY_HOLD);
chat.update_realtime_footer();
- let footer = render_bottom_popup(&chat, /*width*/ 45);
+ let footer = render_bottom_popup(&chat, /*width*/ 46);
assert!(footer.contains("voice ● speaking"));
+ assert!(footer.contains("ctrl+x mute"));
assert!(footer.contains("/voice stop"));
chat.realtime_conversation.speaker_active_until = None;
chat.realtime_conversation.speaker_level = 1;
+ chat.realtime_conversation.speaker_intensity = 51;
+ chat.realtime_conversation
+ .audio_meter_history
+ .push_back((99, 51));
chat.on_realtime_transcript_delta("user".to_string(), "stop".to_string());
assert_eq!(chat.realtime_conversation.speaker_level, 0);
+ assert_eq!(chat.realtime_conversation.speaker_intensity, 0);
+ assert_eq!(
+ chat.realtime_conversation.audio_meter_history.back(),
+ Some(&(99, 0))
+ );
assert_eq!(chat.realtime_conversation.speaker_active_until, None);
let interrupted = render_bottom_popup(&chat, /*width*/ 45);
assert!(interrupted.contains("voice ● heard"));
+ assert!(interrupted.contains("ctrl+x mute"));
assert!(interrupted.contains("/voice stop"));
chat.realtime_conversation.interruption_acknowledged_until =
Some(std::time::Instant::now() - super::super::INTERRUPTION_ACKNOWLEDGMENT);
chat.realtime_conversation.speaker_active_until =
Some(std::time::Instant::now() - super::super::SPEAKER_ACTIVITY_HOLD);
chat.update_realtime_footer();
- assert!(render_bottom_popup(&chat, /*width*/ 45).contains("voice ● listening"));
+ assert!(render_bottom_popup(&chat, /*width*/ 47).contains("voice ● listening"));
for (peak, expected) in [
(0, 0),
(1, 0),
@@ -268,6 +336,20 @@ async fn narrow_voice_footer_keeps_the_stop_control_before_meters() {
expected
);
}
+ for (peak, expected) in [(0, 0), (512, 0), (8192, 255), (u16::MAX, 255)] {
+ assert_eq!(
+ super::super::recording_controls::audio_meter_intensity(peak),
+ expected
+ );
+ }
+ assert_eq!(
+ super::super::recording_controls::audio_meter_level(/*peak*/ 542),
+ super::super::recording_controls::audio_meter_level(/*peak*/ 543)
+ );
+ assert!(
+ super::super::recording_controls::audio_meter_intensity(/*peak*/ 542)
+ < super::super::recording_controls::audio_meter_intensity(/*peak*/ 543)
+ );
}
#[tokio::test]
@@ -410,3 +492,95 @@ async fn startup_timeout_clears_recording_title_before_backend_closes() {
);
assert_eq!(chat.last_terminal_title.as_deref(), Some("project"));
}
+
+#[tokio::test]
+async fn clipped_voice_composer_keeps_the_draft_and_cursor_visible() {
+ use crate::render::renderable::Renderable;
+ use ratatui::prelude::Buffer;
+ use ratatui::prelude::Rect;
+
+ let (mut chat, _sender, _events, _ops) = make_chatwidget_manual_with_sender().await;
+ chat.config.animations = false;
+ activate_voice(&mut chat);
+ chat.bottom_pane
+ .set_composer_text("typed".to_string(), Vec::new(), Vec::new());
+ chat.update_realtime_footer();
+
+ let mut layouts = Vec::new();
+ for height in [5, 6, 8] {
+ let area = Rect::new(/*x*/ 0, /*y*/ 0, /*width*/ 47, height);
+ let mut buffer = Buffer::empty(area);
+ chat.bottom_pane.render(area, &mut buffer);
+ let rows = buffer
+ .content
+ .chunks(/*chunk_size*/ 47)
+ .map(|cells| {
+ cells
+ .iter()
+ .map(ratatui::buffer::Cell::symbol)
+ .collect::<String>()
+ .trim()
+ .to_string()
+ })
+ .filter(|line| line.contains("voice") || line.contains("typed"))
+ .collect::<Vec<_>>()
+ .join("\n");
+ assert!(rows.contains("› typed"));
+ assert!(matches!(chat.bottom_pane.cursor_pos(area), Some((_, y)) if y < height));
+ layouts.push(format!("{height} rows:\n{rows}"));
+ }
+
+ insta::assert_snapshot!(layouts.join("\n\n"), @r"
+ 5 rows:
+ › typed
+
+ 6 rows:
+ voice ● listening ctrl+x mute /voice stop
+ › typed
+
+ 8 rows:
+ voice ● listening ctrl+x mute /voice stop
+ › typed
+ ");
+}
+
+#[tokio::test]
+async fn compact_voice_meters_keep_real_speaker_history_when_the_microphone_is_muted() {
+ let (mut chat, _sender, _events, _ops) = make_chatwidget_manual_with_sender().await;
+ chat.config.animations = false;
+ let thread_id = activate_voice(&mut chat);
+ chat.realtime_conversation.audio_meter_history = [
+ (0, 255),
+ (37, 183),
+ (73, 128),
+ (110, 64),
+ (183, 1),
+ (255, 0),
+ ]
+ .into();
+ chat.update_realtime_footer();
+ let live = render_bottom_popup(&chat, /*width*/ 45);
+ let meters = live.lines().find(|line| line.contains("mic")).unwrap();
+ assert!(meters.contains("mic ▁▃▄▅▇█"));
+ assert!(meters.contains("codex █▇▅▃▂▁"));
+ assert_eq!(
+ live.lines().filter(|line| line.contains("codex")).count(),
+ 1
+ );
+
+ chat.realtime_conversation.microphone_muted = true;
+ for role in ["user", "assistant"] {
+ chat.realtime_conversation.transcript_role = Some(role.to_string());
+ chat.update_realtime_footer();
+ let muted = render_bottom_popup(&chat, /*width*/ 45);
+ assert!(muted.contains("mic ▁▁▁▁▁▁"));
+ assert!(muted.contains("codex █▇▅▃▂▁"));
+ }
+ chat.thread_id = Some(ThreadId::new());
+ chat.update_realtime_footer();
+ assert!(!render_bottom_popup(&chat, /*width*/ 45).contains("codex"));
+ chat.thread_id = Some(thread_id);
+ chat.realtime_conversation.phase = RealtimeConversationPhase::Stopping;
+ chat.update_realtime_footer();
+ assert!(!render_bottom_popup(&chat, /*width*/ 45).contains("codex"));
+}
diff --git a/codex-rs/tui/src/chatwidget/realtime/snapshots/codex_tui__chatwidget__realtime__tests__recording_controls_tests__voice_footer_renders_the_main_conversation_states.snap b/codex-rs/tui/src/chatwidget/realtime/snapshots/codex_tui__chatwidget__realtime__tests__recording_controls_tests__voice_footer_renders_the_main_conversation_states.snap
index 9da849000d..4d9bf3dc1e 100644
--- a/codex-rs/tui/src/chatwidget/realtime/snapshots/codex_tui__chatwidget__realtime__tests__recording_controls_tests__voice_footer_renders_the_main_conversation_states.snap
+++ b/codex-rs/tui/src/chatwidget/realtime/snapshots/codex_tui__chatwidget__realtime__tests__recording_controls_tests__voice_footer_renders_the_main_conversation_states.snap
@@ -3,31 +3,49 @@ source: tui/src/chatwidget/realtime/recording_controls_tests.rs
expression: "states.join(\"\\n\\n\")"
---
connecting:
+ voice ◌ connecting /voice stop
+ mic ▁▁▁▁▁▁ codex ▁▁▁▁▁▁
+
› Ask Codex to do anything
- voice ◌ connecting /voice stop /voice mute ctrl+x
+ status line stays visible
listening:
+ voice ● listening ctrl+x mute /voice stop
+ mic ▁▁▁▁▁▁ codex ▁▁▁▁▁▁
+
› Ask Codex to do anything
- voice ● listening /voice stop mic ⠄⠄ codex ⠄⠄ /voice mute ctrl+x
+ status line stays visible
speaking:
+ voice ● speaking ctrl+x mute /voice stop
+ mic ▁▁▇▇▇▇ codex ▁▁████
+
› Ask Codex to do anything
- voice ● speaking /voice stop mic ⣿⣿ codex ⣿⣿ /voice mute ctrl+x
+ status line stays visible
muted:
+ voice ◌ muted ctrl+x unmute /voice stop
+ mic ▁▁▁▁▁▁ codex ▁▁▇▇▇▇
+
› Ask Codex to do anything
- voice ◌ muted /voice stop mic off codex ⣿⣿ /voice mute ctrl+x
+ status line stays visible
transcript:
+ voice ● speaking ctrl+x mute /voice stop
+ mic ▁▁▄▄▄▄ codex ▁▁▄▄▄▄
+
› Ask Codex to do anything
- voice ● speaking /voice stop mic ⣤⣤ codex ⣤⣤ /voice mute ctrl+x
+ status line stays visible
interrupted:
+ voice ● heard ctrl+x mute /voice stop
+ mic ▁▁▄▄▄▄ codex ▁▁▄▄▄▄
+
› Ask Codex to do anything
- voice ● heard /voice stop mic ⣤⣤ codex ⠄⠄ /voice mute ctrl+x
+ status line stays visible
diff --git a/codex-rs/tui/src/chatwidget/realtime_split_flap.rs b/codex-rs/tui/src/chatwidget/realtime_split_flap.rs
index 85a68e3b92..9612a2123a 100644
--- a/codex-rs/tui/src/chatwidget/realtime_split_flap.rs
+++ b/codex-rs/tui/src/chatwidget/realtime_split_flap.rs
@@ -32,23 +32,6 @@ impl VoiceAmplitudeHistory {
self.0.rotate_left(/*mid*/ 1);
self.0[3] = level.min(/*other*/ 5);
}
-
- pub(super) fn glyphs(&self) -> String {
- const LEFT_DOTS: [u32; 6] = [0, 0x40, 0x44, 0x46, 0x47, 0x47];
- const RIGHT_DOTS: [u32; 6] = [0, 0x80, 0xa0, 0xb0, 0xb8, 0xb8];
-
- self.0
- .chunks_exact(/*chunk_size*/ 2)
- .map(|levels| {
- char::from_u32(0x2800 | LEFT_DOTS[levels[0]] | RIGHT_DOTS[levels[1]])
- .unwrap_or('\u{2800}')
- })
- .collect()
- }
-
- pub(super) fn peak(&self) -> usize {
- self.0.iter().copied().max().unwrap_or_default()
- }
}
#[derive(Debug)]
diff --git a/codex-rs/tui/src/chatwidget/realtime_split_flap_tests.rs b/codex-rs/tui/src/chatwidget/realtime_split_flap_tests.rs
index b3c1597ced..8ebf0c3eed 100644
--- a/codex-rs/tui/src/chatwidget/realtime_split_flap_tests.rs
+++ b/codex-rs/tui/src/chatwidget/realtime_split_flap_tests.rs
@@ -212,11 +212,3 @@ fn settled_split_flap_stops_scheduling_animation_frames() {
);
assert!(requests.try_recv().is_err());
}
-
-#[test]
-fn voice_meter_shows_four_real_amplitude_samples_in_two_braille_cells() {
- let samples = VoiceAmplitudeHistory([1, 4, 2, 5]);
- insta::assert_snapshot!(samples.glyphs(), @"⣸⣼");
- assert_eq!(samples.peak(), 5);
- assert_eq!(VoiceAmplitudeHistory::default().peak(), 0);
-}
diff --git a/codex-rs/tui/src/chatwidget/realtime_tests/transcripts.rs b/codex-rs/tui/src/chatwidget/realtime_tests/transcripts.rs
index 99768e31a0..14cc273430 100644
--- a/codex-rs/tui/src/chatwidget/realtime_tests/transcripts.rs
+++ b/codex-rs/tui/src/chatwidget/realtime_tests/transcripts.rs
@@ -731,7 +731,7 @@ async fn live_voice_split_flap_animates_without_changing_final_history() {
async fn spoken_user_transcript_preserves_red_chevron_and_canonical_history() {
let (mut chat, _sender, mut events, _ops) = make_chatwidget_manual_with_sender().await;
activate_voice(&mut chat);
- chat.on_realtime_transcript_delta("user".to_string(), "hello".to_string());
+ chat.on_realtime_transcript_delta("user".to_string(), " hello".to_string());
let marker = chat
.realtime_conversation
.live_transcript_cell
@@ -749,10 +749,26 @@ async fn spoken_user_transcript_preserves_red_chevron_and_canonical_history() {
.add_modifier
.contains(ratatui::style::Modifier::BOLD)
);
- chat.on_realtime_transcript_done("user".to_string(), "hello".to_string());
+ chat.config.animations = false;
+ chat.on_realtime_transcript_delta("user".to_string(), " world".to_string());
+ assert!(
+ chat.realtime_conversation
+ .live_transcript_cell
+ .as_ref()
+ .unwrap()
+ .display_lines(/*width*/ 32)
+ .iter()
+ .any(|line| line.to_string() == "› hello world")
+ );
+ chat.on_realtime_transcript_done("user".to_string(), " hello world".to_string());
let Ok(AppEvent::InsertHistoryCell(cell)) = events.try_recv() else {
panic!("completed voice transcript should retain its ordinary history cell");
};
assert!(cell.as_any().is::<crate::history_cell::UserHistoryCell>());
- assert_eq!(cell.raw_lines()[0].to_string(), "hello");
+ assert_eq!(cell.raw_lines()[0].to_string(), " hello world");
+ assert!(
+ cell.display_lines(/*width*/ 32)
+ .iter()
+ .any(|line| line.to_string() == "› hello world")
+ );
}
diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__voice_live_transcript_and_stream.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__voice_live_transcript_and_stream.snap
index 6ce009e557..1b7dcfb504 100644
--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__voice_live_transcript_and_stream.snap
+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__voice_live_transcript_and_stream.snap
@@ -11,6 +11,9 @@ expression: rendered
" "
" "
" "
+" voice ● listening ctrl+x mute /voice stop "
+" mic ▁▁▁▁▁▁ codex ▁▁▁▁▁▁ "
+" "
"› Ask Codex to do anything "
" "
-" voice ● listening /voice stop mic ⠄⠄ codex ⠄⠄ /voi"
+" gpt-5.6-sol default · /tmp/project "