diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rs index a3a5875b86..6d5e1f2f85 100644 --- a/codex-rs/tui/src/app.rs +++ b/codex-rs/tui/src/app.rs @@ -2719,9 +2719,7 @@ impl App { } AppEvent::UpdateRecordingMeter { id, text } => { // Update in place to preserve the element id for subsequent frames. - let updated = self - .chat_widget - .update_named_placeholder_in_place(&id, &text); + let updated = self.chat_widget.update_transcription_in_place(&id, &text); if updated { tui.frame_requester().schedule_frame(); } diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs index 1cd60b775c..fbcc463b49 100644 --- a/codex-rs/tui/src/bottom_pane/chat_composer.rs +++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs @@ -1009,18 +1009,6 @@ impl ChatComposer { self.sync_popups(); } - pub(crate) fn insert_named_placeholder(&mut self, id: &str, text: &str) { - self.textarea.insert_named_element(text, id.to_string()); - } - - pub(crate) fn update_named_placeholder_in_place(&mut self, id: &str, text: &str) -> bool { - self.textarea.update_named_element_by_id(id, text) - } - - pub(crate) fn remove_named_placeholder(&mut self, id: &str) { - let _ = self.textarea.replace_element_by_id(id, ""); - } - pub(crate) fn clear_for_ctrl_c(&mut self) -> Option { if self.is_empty() { return None; @@ -3956,6 +3944,10 @@ impl ChatComposer { let _ = self.textarea.replace_element_by_id(id, text); } + pub fn update_transcription_in_place(&mut self, id: &str, text: &str) -> bool { + self.textarea.update_named_element_by_id(id, text) + } + pub fn remove_transcription_placeholder(&mut self, id: &str) { self.stop_transcription_spinner(id); let _ = self.textarea.replace_element_by_id(id, ""); diff --git a/codex-rs/tui/src/bottom_pane/mod.rs b/codex-rs/tui/src/bottom_pane/mod.rs index de12c46603..fa2410a5c8 100644 --- a/codex-rs/tui/src/bottom_pane/mod.rs +++ b/codex-rs/tui/src/bottom_pane/mod.rs @@ -14,9 +14,6 @@ //! Some UI is time-based rather than input-based, such as the transient "press again to quit" //! hint. The pane schedules redraws so those hints can expire even when the UI is otherwise idle. use std::path::PathBuf; -use std::sync::Arc; -use std::sync::atomic::AtomicBool; -use std::sync::atomic::AtomicU16; use crate::app_event::ConnectorsSnapshot; use crate::app_event_sender::AppEventSender; @@ -569,33 +566,12 @@ impl BottomPane { self.request_redraw(); } - pub(crate) fn insert_named_placeholder(&mut self, id: &str, text: &str) { - self.composer.insert_named_placeholder(id, text); - self.composer.sync_popups(); - self.request_redraw(); - } - - pub(crate) fn update_named_placeholder_in_place(&mut self, id: &str, text: &str) -> bool { - let updated = self.composer.update_named_placeholder_in_place(id, text); - if updated { - self.composer.sync_popups(); - self.request_redraw(); - } - updated - } - - pub(crate) fn remove_named_placeholder(&mut self, id: &str) { - self.composer.remove_named_placeholder(id); - self.composer.sync_popups(); - self.request_redraw(); - } - pub(crate) fn spawn_live_meter_updates( &self, id: String, prefix: Option, - last_peak: Arc, - stop: Arc, + last_peak: std::sync::Arc, + stop: std::sync::Arc, ) { self.composer .spawn_live_meter_updates(id, prefix, last_peak, stop); @@ -1043,7 +1019,6 @@ impl BottomPane { } } -#[cfg(not(target_os = "linux"))] impl BottomPane { pub(crate) fn replace_transcription(&mut self, id: &str, text: &str) { self.composer.replace_transcription(id, text); @@ -1051,6 +1026,15 @@ impl BottomPane { self.request_redraw(); } + pub(crate) fn update_transcription_in_place(&mut self, id: &str, text: &str) -> bool { + let updated = self.composer.update_transcription_in_place(id, text); + if updated { + self.composer.sync_popups(); + self.request_redraw(); + } + updated + } + pub(crate) fn remove_transcription_placeholder(&mut self, id: &str) { self.composer.remove_transcription_placeholder(id); self.composer.sync_popups(); diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index d5f30ecc7e..ec5730260d 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -3436,23 +3436,6 @@ impl ChatWidget { self.bottom_pane.set_footer_hint_override(items); } - pub(crate) fn insert_named_placeholder(&mut self, id: &str, text: &str) { - self.bottom_pane.insert_named_placeholder(id, text); - } - - pub(crate) fn update_named_placeholder_in_place(&mut self, id: &str, text: &str) -> bool { - let updated = self.bottom_pane.update_named_placeholder_in_place(id, text); - if updated { - self.request_redraw(); - } - updated - } - - pub(crate) fn remove_named_placeholder(&mut self, id: &str) { - self.bottom_pane.remove_named_placeholder(id); - self.request_redraw(); - } - pub(crate) fn show_selection_view(&mut self, params: SelectionViewParams) { self.bottom_pane.show_selection_view(params); self.request_redraw(); @@ -3469,7 +3452,7 @@ impl ChatWidget { "Stop voice chat".to_string(), )])); let id = REALTIME_METER_PLACEHOLDER_ID.to_string(); - self.insert_named_placeholder(&id, "Realtime listening ⠤⠤⠤⠤"); + self.replace_transcription(&id, "Realtime listening ⠤⠤⠤⠤"); if let Some(controller) = &self.realtime_audio_controller && let Some(RealtimeMicMeterHandles { last_peak, stop }) = controller.meter_handles() @@ -3488,7 +3471,7 @@ impl ChatWidget { fn disable_realtime_ui(&mut self) { self.set_footer_hint_override(None); if let Some(id) = self.realtime_meter_placeholder_id.take() { - self.remove_named_placeholder(&id); + self.remove_transcription_placeholder(&id); } } @@ -7771,7 +7754,6 @@ impl ChatWidget { } } -#[cfg(not(target_os = "linux"))] impl ChatWidget { pub(crate) fn replace_transcription(&mut self, id: &str, text: &str) { self.bottom_pane.replace_transcription(id, text); @@ -7779,6 +7761,14 @@ impl ChatWidget { self.request_redraw(); } + pub(crate) fn update_transcription_in_place(&mut self, id: &str, text: &str) -> bool { + let updated = self.bottom_pane.update_transcription_in_place(id, text); + if updated { + self.request_redraw(); + } + updated + } + pub(crate) fn remove_transcription_placeholder(&mut self, id: &str) { self.bottom_pane.remove_transcription_placeholder(id); // Ensure the UI redraws to reflect placeholder removal.