Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Preserve voice indicator styles during composer sparkle effects (#44198)

Benjamin Carlssonccf470c060d1
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs
index acc1425c1e..85198a0ccd 100644
--- a/codex-rs/tui/src/bottom_pane/chat_composer.rs
+++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs
@@ -4,7 +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 live voice strip renders after effort ignition and before stars, which skip its text.
//!
//! The plain-text preset keeps command prefixes literal, including `!`, so Enter and Tab
//! submit ordinary text without enabling shell mode.
@@ -5054,6 +5054,7 @@ impl ChatComposer {
}
}
drop(state);
+ self.render_voice_strip(composer_rect, buf);
if self.astra_sparkle.is_some() {
self.render_sparkle(
composer_rect,
@@ -5061,7 +5062,6 @@ impl ChatComposer {
buf,
);
}
- self.render_voice_strip(composer_rect, buf);
}
}
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__sparkle__tests__astra_voice_composer.snap b/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__sparkle__tests__astra_voice_composer.snap
new file mode 100644
index 0000000000..28deb77590
--- /dev/null
+++ b/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__sparkle__tests__astra_voice_composer.snap
@@ -0,0 +1,12 @@
+---
+source: tui/src/bottom_pane/chat_composer/sparkle_tests.rs
+assertion_line: 361
+expression: "baseline.content.chunks(60).map(|row|\nrow.iter().map(ratatui::buffer::Cell::symbol).collect::<String>()).collect::<Vec<_>>().join(\"\\n\")"
+---
+
+ voice ● listening /voice mute /voice stop
+ mic ▁▃▄▅▆█ codex █▆▅▄▃▁
+
+› Ask Codex to do anything
+
+ ? for shortcuts 100% context left
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/sparkle_tests.rs b/codex-rs/tui/src/bottom_pane/chat_composer/sparkle_tests.rs
index 83a82902ea..81795f4844 100644
--- a/codex-rs/tui/src/bottom_pane/chat_composer/sparkle_tests.rs
+++ b/codex-rs/tui/src/bottom_pane/chat_composer/sparkle_tests.rs
@@ -312,3 +312,82 @@ fn sparkle_waits_for_terminal_colors() {
},
);
}
+
+#[test]
+fn sparkle_preserves_voice_indicator_styles() {
+ use crate::bottom_pane::voice_strip::VoiceStripPhase;
+ use crate::bottom_pane::voice_strip::VoiceStripState;
+ use crate::tui::FrameRequester;
+
+ with_test_default_colors(
+ DefaultColors {
+ fg: (230, 216, 255),
+ bg: (36, 27, 53),
+ },
+ || {
+ let (mut composer, _rx) = new_test_composer();
+ composer.set_voice_strip(
+ Some(VoiceStripState {
+ mute_hint: None,
+ phase: VoiceStripPhase::Active,
+ microphone_live: true,
+ microphone_muted: false,
+ microphone_history: vec![0, 37, 73, 110, 146, 255],
+ speaker_history: vec![255, 146, 110, 73, 37, 0],
+ activity: "listening",
+ animations: false,
+ }),
+ FrameRequester::test_dummy(),
+ );
+ let area = Rect::new(
+ /*x*/ 0,
+ /*y*/ 0,
+ /*width*/ 60,
+ composer.desired_height(/*width*/ 60),
+ );
+ let mut baseline = Buffer::empty(area);
+ composer.render(area, &mut baseline);
+ let mut saw_stars = false;
+ for tick in 0..80 {
+ composer.astra_sparkle = Some(Sparkle {
+ started: Instant::now() - FRAME_TICK * tick,
+ ..new_test_sparkle()
+ });
+ let mut actual = Buffer::empty(area);
+ composer.render(area, &mut actual);
+ saw_stars |= actual
+ .content
+ .iter()
+ .any(|cell| DOTS.contains(&cell.symbol()));
+ // Compare whole cells: an unchanged glyph can still inherit a star's color.
+ let content = baseline
+ .content
+ .iter()
+ .enumerate()
+ .filter(|(_, cell)| cell.symbol() != " ")
+ .map(|(index, _)| actual.content[index].clone())
+ .collect::<Vec<_>>();
+ let expected = baseline
+ .content
+ .iter()
+ .filter(|cell| cell.symbol() != " ")
+ .cloned()
+ .collect::<Vec<_>>();
+ assert_eq!(content, expected, "sparkle frame {tick}");
+ }
+ assert!(saw_stars);
+ insta::assert_snapshot!(
+ "astra_voice_composer",
+ baseline
+ .content
+ .chunks(60)
+ .map(|row| row
+ .iter()
+ .map(ratatui::buffer::Cell::symbol)
+ .collect::<String>())
+ .collect::<Vec<_>>()
+ .join("\n")
+ );
+ },
+ );
+}