Lightweight coding agent that runs in your terminal
Rust
[codex] Remove unused Rust helpers (#17146)
pakrym-oai0c8f3173e4bd
diff --git a/codex-rs/shell-command/src/powershell.rs b/codex-rs/shell-command/src/powershell.rsindex d6ae79245b..0b118f7279 100644--- a/codex-rs/shell-command/src/powershell.rs+++ b/codex-rs/shell-command/src/powershell.rs@@ -68,19 +68,6 @@ pub fn extract_powershell_command(command: &[String]) -> Option<(&str, &str)> {None}-/// This function attempts to find a valid PowerShell executable on the system.-/// It first tries to find pwsh.exe, and if that fails, it tries to find-/// powershell.exe.-#[cfg(windows)]-#[allow(dead_code)]-pub(crate) fn try_find_powershellish_executable_blocking() -> Option<AbsolutePathBuf> {- if let Some(pwsh_path) = try_find_pwsh_executable_blocking() {- Some(pwsh_path)- } else {- try_find_powershell_executable_blocking()- }-}-/// This function attempts to find a powershell.exe executable on the system.pub fn try_find_powershell_executable_blocking() -> Option<AbsolutePathBuf> {try_find_powershellish_executable_in_path(&["powershell.exe"])diff --git a/codex-rs/tui/src/app_command.rs b/codex-rs/tui/src/app_command.rsindex 0646cc297d..e94dced053 100644--- a/codex-rs/tui/src/app_command.rs+++ b/codex-rs/tui/src/app_command.rs@@ -126,11 +126,6 @@ impl AppCommand {Self(Op::RealtimeConversationAudio(params))}- #[allow(dead_code)]- pub(crate) fn realtime_conversation_text(params: ConversationTextParams) -> Self {- Self(Op::RealtimeConversationText(params))- }-pub(crate) fn realtime_conversation_close() -> Self {Self(Op::RealtimeConversationClose)}@@ -265,16 +260,6 @@ impl AppCommand {Self(Op::Review { review_request })}- #[allow(dead_code)]- pub(crate) fn kind(&self) -> &'static str {- self.0.kind()- }-- #[allow(dead_code)]- pub(crate) fn as_core(&self) -> &Op {- &self.0- }-pub(crate) fn into_core(self) -> Op {self.0}diff --git a/codex-rs/tui/src/app_server_session.rs b/codex-rs/tui/src/app_server_session.rsindex 5f75bd390a..d53d564da0 100644--- a/codex-rs/tui/src/app_server_session.rs+++ b/codex-rs/tui/src/app_server_session.rs@@ -777,16 +777,6 @@ pub(crate) fn status_account_display_from_auth_mode(}}-#[allow(dead_code)]-pub(crate) fn feedback_audience_from_account_email(- account_email: Option<&str>,-) -> FeedbackAudience {- match account_email {- Some(email) if email.ends_with("@openai.com") => FeedbackAudience::OpenAiEmployee,- Some(_) | None => FeedbackAudience::External,- }-}-fn model_preset_from_api_model(model: ApiModel) -> ModelPreset {let upgrade = model.upgrade.map(|upgrade_id| {let upgrade_info = model.upgrade_info.clone();diff --git a/codex-rs/tui/src/ascii_animation.rs b/codex-rs/tui/src/ascii_animation.rsindex 9354608ef9..50bb2cb2c2 100644--- a/codex-rs/tui/src/ascii_animation.rs+++ b/codex-rs/tui/src/ascii_animation.rs@@ -90,11 +90,6 @@ impl AsciiAnimation {true}- #[allow(dead_code)]- pub(crate) fn request_frame(&self) {- self.request_frame.schedule_frame();- }-fn frames(&self) -> &'static [&'static str] {self.variants[self.variant_idx]}diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rsindex 03c5910cea..6c96e1598b 100644--- a/codex-rs/tui/src/chatwidget.rs+++ b/codex-rs/tui/src/chatwidget.rs@@ -4735,14 +4735,6 @@ impl ChatWidget {Self::new_with_op_target(common, CodexOpTarget::AppEvent)}- #[allow(dead_code)]- pub(crate) fn new_with_op_sender(- common: ChatWidgetInit,- codex_op_tx: UnboundedSender<Op>,- ) -> Self {- Self::new_with_op_target(common, CodexOpTarget::Direct(codex_op_tx))- }-fn new_with_op_target(common: ChatWidgetInit, codex_op_target: CodexOpTarget) -> Self {let ChatWidgetInit {config,diff --git a/codex-rs/tui/src/live_wrap.rs b/codex-rs/tui/src/live_wrap.rsindex 91d7e6f045..363d17c5a7 100644--- a/codex-rs/tui/src/live_wrap.rs+++ b/codex-rs/tui/src/live_wrap.rs@@ -81,11 +81,6 @@ impl RowBuilder {self.flush_current_line(/*explicit_break*/ true);}- /// Drain and return all produced rows.- pub fn drain_rows(&mut self) -> Vec<Row> {- std::mem::take(&mut self.rows)- }-/// Return a snapshot of produced rows (non-draining).pub fn rows(&self) -> &[Row] {&self.rowsdiff --git a/codex-rs/tui/src/render/renderable.rs b/codex-rs/tui/src/render/renderable.rsindex eb514b3b0f..2bb78a3cde 100644--- a/codex-rs/tui/src/render/renderable.rs+++ b/codex-rs/tui/src/render/renderable.rs@@ -200,15 +200,6 @@ impl<'a> ColumnRenderable<'a> {pub fn push(&mut self, child: impl Into<Box<dyn Renderable + 'a>>) {self.children.push(RenderableItem::Owned(child.into()));}-- #[allow(dead_code)]- pub fn push_ref<R>(&mut self, child: &'a R)- where- R: Renderable + 'a,- {- self.children- .push(RenderableItem::Borrowed(child as &'a dyn Renderable));- }}pub struct FlexChild<'a> {@@ -374,15 +365,6 @@ impl<'a> RowRenderable<'a> {self.children.push((width, RenderableItem::Owned(child.into())));}-- #[allow(dead_code)]- pub fn push_ref<R>(&mut self, width: u16, child: &'a R)- where- R: Renderable + 'a,- {- self.children- .push((width, RenderableItem::Borrowed(child as &'a dyn Renderable)));- }}pub struct InsetRenderable<'a> {diff --git a/codex-rs/tui/src/terminal_palette.rs b/codex-rs/tui/src/terminal_palette.rsindex 304b8df087..83f9f8283d 100644--- a/codex-rs/tui/src/terminal_palette.rs+++ b/codex-rs/tui/src/terminal_palette.rs@@ -1,13 +1,5 @@use crate::color::perceptual_distance;use ratatui::style::Color;-use std::sync::atomic::AtomicU64;-use std::sync::atomic::Ordering;--static DEFAULT_PALETTE_VERSION: AtomicU64 = AtomicU64::new(0);--fn bump_palette_version() {- DEFAULT_PALETTE_VERSION.fetch_add(1, Ordering::Relaxed);-}#[derive(Clone, Copy, Debug, Eq, PartialEq)]pub enum StdoutColorLevel {@@ -56,7 +48,6 @@ pub fn best_color(target: (u8, u8, u8)) -> Color {pub fn requery_default_colors() {imp::requery_default_colors();- bump_palette_version();}#[derive(Clone, Copy)]@@ -77,14 +68,6 @@ pub fn default_bg() -> Option<(u8, u8, u8)> {default_colors().map(|c| c.bg)}-/// Returns a monotonic counter that increments whenever `requery_default_colors()` runs-/// successfully so cached renderers can know when their styling assumptions (e.g.-/// background colors baked into cached transcript rows) are stale and need invalidation.-#[allow(dead_code)]-pub fn palette_version() -> u64 {- DEFAULT_PALETTE_VERSION.load(Ordering::Relaxed)-}-#[cfg(all(unix, not(test)))]mod imp {use super::DefaultColors;diff --git a/codex-rs/utils/elapsed/src/lib.rs b/codex-rs/utils/elapsed/src/lib.rsindex 297832b1ec..209657e8c4 100644--- a/codex-rs/utils/elapsed/src/lib.rs+++ b/codex-rs/utils/elapsed/src/lib.rs@@ -1,11 +1,4 @@use std::time::Duration;-use std::time::Instant;--/// Returns a string representing the elapsed time since `start_time` like-/// "1m 15s" or "1.50s".-pub fn format_elapsed(start_time: Instant) -> String {- format_duration(start_time.elapsed())-}/// Convert a [`std::time::Duration`] into a human-readable, compact string.///diff --git a/codex-rs/utils/fuzzy-match/src/lib.rs b/codex-rs/utils/fuzzy-match/src/lib.rsindex 836848d6a4..d644b31677 100644--- a/codex-rs/utils/fuzzy-match/src/lib.rs+++ b/codex-rs/utils/fuzzy-match/src/lib.rs@@ -68,15 +68,6 @@ pub fn fuzzy_match(haystack: &str, needle: &str) -> Option<(Vec<usize>, i32)> {Some((result_orig_indices, score))}-/// Convenience wrapper to get only the indices for a fuzzy match.-pub fn fuzzy_indices(haystack: &str, needle: &str) -> Option<Vec<usize>> {- fuzzy_match(haystack, needle).map(|(mut idx, _)| {- idx.sort_unstable();- idx.dedup();- idx- })-}-#[cfg(test)]mod tests {use super::*;diff --git a/codex-rs/utils/path-utils/src/env.rs b/codex-rs/utils/path-utils/src/env.rsindex c99b242777..5370c0ffd8 100644--- a/codex-rs/utils/path-utils/src/env.rs+++ b/codex-rs/utils/path-utils/src/env.rs@@ -1,9 +1,5 @@//! Functions for environment detection that need to be shared across crates.-fn env_var_set(key: &str) -> bool {- std::env::var(key).is_ok_and(|v| !v.trim().is_empty())-}-/// Returns true if the current process is running under Windows Subsystem for Linux.pub fn is_wsl() -> bool {#[cfg(target_os = "linux")]@@ -21,26 +17,3 @@ pub fn is_wsl() -> bool {false}}--/// Returns true when Codex is likely running in an environment without a usable GUI.-///-/// This is intentionally conservative and is used by frontends to avoid flows that would try to-/// open a browser (e.g. device-code auth fallback).-pub fn is_headless_environment() -> bool {- if env_var_set("CI")- || env_var_set("SSH_CONNECTION")- || env_var_set("SSH_CLIENT")- || env_var_set("SSH_TTY")- {- return true;- }-- #[cfg(target_os = "linux")]- {- if !env_var_set("DISPLAY") && !env_var_set("WAYLAND_DISPLAY") {- return true;- }- }-- false-}diff --git a/codex-rs/utils/path-utils/src/lib.rs b/codex-rs/utils/path-utils/src/lib.rsindex 5390250a1b..71b0a6473d 100644--- a/codex-rs/utils/path-utils/src/lib.rs+++ b/codex-rs/utils/path-utils/src/lib.rs@@ -1,7 +1,6 @@//! Path normalization, symlink resolution, and atomic writes shared across Codex crates.pub(crate) mod env;-pub use env::is_headless_environment;pub use env::is_wsl;use codex_utils_absolute_path::AbsolutePathBuf;diff --git a/codex-rs/utils/string/src/lib.rs b/codex-rs/utils/string/src/lib.rsindex a667a517b2..d7b6f153ac 100644--- a/codex-rs/utils/string/src/lib.rs+++ b/codex-rs/utils/string/src/lib.rs@@ -23,28 +23,6 @@ pub fn take_bytes_at_char_boundary(s: &str, maxb: usize) -> &str {&s[..last_ok]}-// Take a suffix of a &str within a byte budget at a char boundary-#[inline]-pub fn take_last_bytes_at_char_boundary(s: &str, maxb: usize) -> &str {- if s.len() <= maxb {- return s;- }- let mut start = s.len();- let mut used = 0usize;- for (i, ch) in s.char_indices().rev() {- let nb = ch.len_utf8();- if used + nb > maxb {- break;- }- start = i;- used += nb;- if start == 0 {- break;- }- }- &s[start..]-}-/// Sanitize a tag value to comply with metric tag validation rules:/// only ASCII alphanumeric, '.', '_', '-', and '/' are allowed.pub fn sanitize_metric_tag_value(value: &str) -> String {