From e258f0f0441c56eac0623a514814733137d38ee4 Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Thu, 23 Oct 2025 20:04:15 -0700 Subject: [PATCH 1/3] Use Option symbol for mac key hints (#5582) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - show the Option (⌥) symbol in key hints when the TUI is built for macOS so the shortcut text matches the platform terminology ## Testing - cargo test -p codex-tui ------ https://chatgpt.com/codex/tasks/task_i_68fab7505530832992780a9e13fb707b --- codex-rs/tui/src/key_hint.rs | 3 +++ ...__tests__renders_with_queued_messages@macos.snap | 13 +++++++++++++ codex-rs/tui/src/status_indicator_widget.rs | 5 +++++ 3 files changed, 21 insertions(+) create mode 100644 codex-rs/tui/src/snapshots/codex_tui__status_indicator_widget__tests__renders_with_queued_messages@macos.snap diff --git a/codex-rs/tui/src/key_hint.rs b/codex-rs/tui/src/key_hint.rs index b79c2a2703..795d1545f8 100644 --- a/codex-rs/tui/src/key_hint.rs +++ b/codex-rs/tui/src/key_hint.rs @@ -6,6 +6,9 @@ use ratatui::style::Style; use ratatui::style::Stylize; use ratatui::text::Span; +#[cfg(target_os = "macos")] +const ALT_PREFIX: &str = "⌥ + "; +#[cfg(not(target_os = "macos"))] const ALT_PREFIX: &str = "alt + "; const CTRL_PREFIX: &str = "ctrl + "; const SHIFT_PREFIX: &str = "shift + "; diff --git a/codex-rs/tui/src/snapshots/codex_tui__status_indicator_widget__tests__renders_with_queued_messages@macos.snap b/codex-rs/tui/src/snapshots/codex_tui__status_indicator_widget__tests__renders_with_queued_messages@macos.snap new file mode 100644 index 0000000000..5974455c89 --- /dev/null +++ b/codex-rs/tui/src/snapshots/codex_tui__status_indicator_widget__tests__renders_with_queued_messages@macos.snap @@ -0,0 +1,13 @@ +--- +source: tui/src/status_indicator_widget.rs +assertion_line: 289 +expression: terminal.backend() +--- +"• Working (0s • esc to interrupt) " +" " +" ↳ first " +" ↳ second " +" ⌥ + ↑ edit " +" " +" " +" " diff --git a/codex-rs/tui/src/status_indicator_widget.rs b/codex-rs/tui/src/status_indicator_widget.rs index 4bcc5cf267..81efde71f2 100644 --- a/codex-rs/tui/src/status_indicator_widget.rs +++ b/codex-rs/tui/src/status_indicator_widget.rs @@ -284,6 +284,11 @@ mod tests { terminal .draw(|f| w.render_ref(f.area(), f.buffer_mut())) .expect("draw"); + #[cfg(target_os = "macos")] + insta::with_settings!({ snapshot_suffix => "macos" }, { + insta::assert_snapshot!(terminal.backend()); + }); + #[cfg(not(target_os = "macos"))] insta::assert_snapshot!(terminal.backend()); } From 0f4fd33ddd2233307953c45f3c73dc7d9f8e1ea1 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Thu, 23 Oct 2025 20:30:58 -0700 Subject: [PATCH 2/3] Moving `token_info` to `ConversationHistory` (#5581) I want to centralize input processing and management to `ConversationHistory`. This would need `ConversationHistory` to have access to `token_info` (i.e. preventing adding a big input to the history). Besides, it makes more sense to have it on `ConversationHistory` than `state`. --- codex-rs/core/src/conversation_history.rs | 33 ++++++++++++++++++++++- codex-rs/core/src/state/session.rs | 23 +++++----------- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/codex-rs/core/src/conversation_history.rs b/codex-rs/core/src/conversation_history.rs index 93234a4936..b7f153d29f 100644 --- a/codex-rs/core/src/conversation_history.rs +++ b/codex-rs/core/src/conversation_history.rs @@ -1,5 +1,7 @@ use codex_protocol::models::FunctionCallOutputPayload; use codex_protocol::models::ResponseItem; +use codex_protocol::protocol::TokenUsage; +use codex_protocol::protocol::TokenUsageInfo; use tracing::error; /// Transcript of conversation history @@ -7,11 +9,28 @@ use tracing::error; pub(crate) struct ConversationHistory { /// The oldest items are at the beginning of the vector. items: Vec, + token_info: Option, } impl ConversationHistory { pub(crate) fn new() -> Self { - Self { items: Vec::new() } + Self { + items: Vec::new(), + token_info: TokenUsageInfo::new_or_append(&None, &None, None), + } + } + + pub(crate) fn token_info(&self) -> Option { + self.token_info.clone() + } + + pub(crate) fn set_token_usage_full(&mut self, context_window: i64) { + match &mut self.token_info { + Some(info) => info.fill_to_context_window(context_window), + None => { + self.token_info = Some(TokenUsageInfo::full_context_window(context_window)); + } + } } /// `items` is ordered from oldest to newest. @@ -301,6 +320,18 @@ impl ConversationHistory { self.items.remove(pos); } } + + pub(crate) fn update_token_info( + &mut self, + usage: &TokenUsage, + model_context_window: Option, + ) { + self.token_info = TokenUsageInfo::new_or_append( + &self.token_info, + &Some(usage.clone()), + model_context_window, + ); + } } #[inline] diff --git a/codex-rs/core/src/state/session.rs b/codex-rs/core/src/state/session.rs index f8a58c3b2a..7c4603d9ec 100644 --- a/codex-rs/core/src/state/session.rs +++ b/codex-rs/core/src/state/session.rs @@ -12,7 +12,6 @@ use crate::protocol::TokenUsageInfo; pub(crate) struct SessionState { pub(crate) session_configuration: SessionConfiguration, pub(crate) history: ConversationHistory, - pub(crate) token_info: Option, pub(crate) latest_rate_limits: Option, } @@ -22,7 +21,6 @@ impl SessionState { Self { session_configuration, history: ConversationHistory::new(), - token_info: None, latest_rate_limits: None, } } @@ -54,11 +52,11 @@ impl SessionState { usage: &TokenUsage, model_context_window: Option, ) { - self.token_info = TokenUsageInfo::new_or_append( - &self.token_info, - &Some(usage.clone()), - model_context_window, - ); + self.history.update_token_info(usage, model_context_window); + } + + pub(crate) fn token_info(&self) -> Option { + self.history.token_info() } pub(crate) fn set_rate_limits(&mut self, snapshot: RateLimitSnapshot) { @@ -68,17 +66,10 @@ impl SessionState { pub(crate) fn token_info_and_rate_limits( &self, ) -> (Option, Option) { - (self.token_info.clone(), self.latest_rate_limits.clone()) + (self.token_info(), self.latest_rate_limits.clone()) } pub(crate) fn set_token_usage_full(&mut self, context_window: i64) { - match &mut self.token_info { - Some(info) => info.fill_to_context_window(context_window), - None => { - self.token_info = Some(TokenUsageInfo::full_context_window(context_window)); - } - } + self.history.set_token_usage_full(context_window); } - - // Pending input/approval moved to TurnState. } From abccd3e367296462c15cce54e2dea5f71b1ebfde Mon Sep 17 00:00:00 2001 From: Gabriel Peal Date: Thu, 23 Oct 2025 20:45:29 -0700 Subject: [PATCH 3/3] [MCP] Update rmcp to 0.8.3 (#5542) Picks up modelcontextprotocol/rust-sdk#497 which fixes #5208 by allowing 204 response to MCP initialize notifications instead of just 202. --- codex-rs/Cargo.lock | 8 ++++---- codex-rs/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lock index 1a274985e8..449774bf27 100644 --- a/codex-rs/Cargo.lock +++ b/codex-rs/Cargo.lock @@ -4954,9 +4954,9 @@ dependencies = [ [[package]] name = "rmcp" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e35d31f89beb59c83bc31363426da25b323ce0c2e5b53c7bf29867d16ee7898" +checksum = "1fdad1258f7259fdc0f2dfc266939c82c3b5d1fd72bcde274d600cdc27e60243" dependencies = [ "base64", "bytes", @@ -4988,9 +4988,9 @@ dependencies = [ [[package]] name = "rmcp-macros" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d88518b38110c439a03f0f4eee40e5105d648a530711cb87f98991e3f324a664" +checksum = "ede0589a208cc7ce81d1be68aa7e74b917fcd03c81528408bab0457e187dcd9b" dependencies = [ "darling 0.21.3", "proc-macro2", diff --git a/codex-rs/Cargo.toml b/codex-rs/Cargo.toml index d72c527bc2..c6e75dca61 100644 --- a/codex-rs/Cargo.toml +++ b/codex-rs/Cargo.toml @@ -153,7 +153,7 @@ ratatui = "0.29.0" ratatui-macros = "0.6.0" regex-lite = "0.1.7" reqwest = "0.12" -rmcp = { version = "0.8.2", default-features = false } +rmcp = { version = "0.8.3", default-features = false } schemars = "0.8.22" seccompiler = "0.5.0" sentry = "0.34.0"