From 1e7be6f03c111897ead816a71fa93c007a95d9fc Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Fri, 5 Sep 2025 15:24:39 -0700 Subject: [PATCH 1/3] Added CLI version to `/status` output --- codex-rs/tui/src/history_cell.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/codex-rs/tui/src/history_cell.rs b/codex-rs/tui/src/history_cell.rs index 01583958aa8..2cbb398042d 100644 --- a/codex-rs/tui/src/history_cell.rs +++ b/codex-rs/tui/src/history_cell.rs @@ -950,6 +950,12 @@ pub(crate) fn new_status_output( lines.push("".into()); + // 💻 Client + let cli_version = env!("CARGO_PKG_VERSION"); + lines.push(vec![padded_emoji("💻").into(), "Client".bold()].into()); + lines.push(vec![" • CLI Version: ".into(), cli_version.into()].into()); + lines.push("".into()); + // 📊 Token Usage lines.push(vec!["📊 ".into(), "Token Usage".bold()].into()); if let Some(session_id) = session_id { From 695e57d4b4253c1b48fdb637bf82a7604602ae99 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Fri, 5 Sep 2025 16:04:30 -0700 Subject: [PATCH 2/3] Code review feedback: added centralized `version` crate with `current_version` function. --- codex-rs/tui/src/history_cell.rs | 2 +- codex-rs/tui/src/lib.rs | 1 + codex-rs/tui/src/updates.rs | 4 +++- codex-rs/tui/src/version.rs | 14 ++++++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 codex-rs/tui/src/version.rs diff --git a/codex-rs/tui/src/history_cell.rs b/codex-rs/tui/src/history_cell.rs index 2cbb398042d..dbf557f64fe 100644 --- a/codex-rs/tui/src/history_cell.rs +++ b/codex-rs/tui/src/history_cell.rs @@ -951,7 +951,7 @@ pub(crate) fn new_status_output( lines.push("".into()); // 💻 Client - let cli_version = env!("CARGO_PKG_VERSION"); + let cli_version = crate::version::current_version(); lines.push(vec![padded_emoji("💻").into(), "Client".bold()].into()); lines.push(vec![" • CLI Version: ".into(), cli_version.into()].into()); lines.push("".into()); diff --git a/codex-rs/tui/src/lib.rs b/codex-rs/tui/src/lib.rs index 76ca93a368e..dc5569bfe58 100644 --- a/codex-rs/tui/src/lib.rs +++ b/codex-rs/tui/src/lib.rs @@ -58,6 +58,7 @@ mod streaming; mod text_formatting; mod tui; mod user_approval_widget; +mod version; mod wrapping; // Internal vt100-based replay tests live as a separate source file to keep them diff --git a/codex-rs/tui/src/updates.rs b/codex-rs/tui/src/updates.rs index 39d084b407a..eaf33ead20f 100644 --- a/codex-rs/tui/src/updates.rs +++ b/codex-rs/tui/src/updates.rs @@ -11,6 +11,8 @@ use std::path::PathBuf; use codex_core::config::Config; use codex_core::default_client::create_client; +use crate::version::current_version; + pub fn get_upgrade_version(config: &Config) -> Option { let version_file = version_filepath(config); let info = read_version_info(&version_file).ok(); @@ -31,7 +33,7 @@ pub fn get_upgrade_version(config: &Config) -> Option { } info.and_then(|info| { - let current_version = env!("CARGO_PKG_VERSION"); + let current_version = current_version(); if is_newer(&info.latest_version, current_version).unwrap_or(false) { Some(info.latest_version) } else { diff --git a/codex-rs/tui/src/version.rs b/codex-rs/tui/src/version.rs new file mode 100644 index 00000000000..6733b179e02 --- /dev/null +++ b/codex-rs/tui/src/version.rs @@ -0,0 +1,14 @@ +/// Returns the current Codex CLI version as embedded at compile time. +pub fn current_version() -> &'static str { + env!("CARGO_PKG_VERSION") +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn current_version_matches_env() { + assert_eq!(current_version(), env!("CARGO_PKG_VERSION")); + } +} From 515622e9a06ab7b355484a0ab97590dd6ea4a7f1 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Fri, 5 Sep 2025 16:16:57 -0700 Subject: [PATCH 3/3] Switched to constant as suggested --- codex-rs/tui/src/history_cell.rs | 2 +- codex-rs/tui/src/updates.rs | 5 ++--- codex-rs/tui/src/version.rs | 16 ++-------------- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/codex-rs/tui/src/history_cell.rs b/codex-rs/tui/src/history_cell.rs index dbf557f64fe..7e1cf25e92b 100644 --- a/codex-rs/tui/src/history_cell.rs +++ b/codex-rs/tui/src/history_cell.rs @@ -951,7 +951,7 @@ pub(crate) fn new_status_output( lines.push("".into()); // 💻 Client - let cli_version = crate::version::current_version(); + let cli_version = crate::version::CODEX_CLI_VERSION; lines.push(vec![padded_emoji("💻").into(), "Client".bold()].into()); lines.push(vec![" • CLI Version: ".into(), cli_version.into()].into()); lines.push("".into()); diff --git a/codex-rs/tui/src/updates.rs b/codex-rs/tui/src/updates.rs index eaf33ead20f..90ef6d85804 100644 --- a/codex-rs/tui/src/updates.rs +++ b/codex-rs/tui/src/updates.rs @@ -11,7 +11,7 @@ use std::path::PathBuf; use codex_core::config::Config; use codex_core::default_client::create_client; -use crate::version::current_version; +use crate::version::CODEX_CLI_VERSION; pub fn get_upgrade_version(config: &Config) -> Option { let version_file = version_filepath(config); @@ -33,8 +33,7 @@ pub fn get_upgrade_version(config: &Config) -> Option { } info.and_then(|info| { - let current_version = current_version(); - if is_newer(&info.latest_version, current_version).unwrap_or(false) { + if is_newer(&info.latest_version, CODEX_CLI_VERSION).unwrap_or(false) { Some(info.latest_version) } else { None diff --git a/codex-rs/tui/src/version.rs b/codex-rs/tui/src/version.rs index 6733b179e02..8c8d108dc61 100644 --- a/codex-rs/tui/src/version.rs +++ b/codex-rs/tui/src/version.rs @@ -1,14 +1,2 @@ -/// Returns the current Codex CLI version as embedded at compile time. -pub fn current_version() -> &'static str { - env!("CARGO_PKG_VERSION") -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn current_version_matches_env() { - assert_eq!(current_version(), env!("CARGO_PKG_VERSION")); - } -} +/// The current Codex CLI version as embedded at compile time. +pub const CODEX_CLI_VERSION: &str = env!("CARGO_PKG_VERSION");