From 89fda7a7764c783f590cd9d7bb07b2c53490963f Mon Sep 17 00:00:00 2001 From: pakrym-oai Date: Thu, 14 Aug 2025 07:47:01 -0700 Subject: [PATCH] Display session id in status --- codex-rs/tui/src/chatwidget.rs | 5 +++++ codex-rs/tui/src/chatwidget/tests.rs | 1 + codex-rs/tui/src/history_cell.rs | 13 ++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index 0d6911d202..eadf71cdfa 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -35,6 +35,7 @@ use ratatui::widgets::Widget; use ratatui::widgets::WidgetRef; use tokio::sync::mpsc::UnboundedSender; use tracing::debug; +use uuid::Uuid; use crate::app_event::AppEvent; use crate::app_event_sender::AppEventSender; @@ -81,6 +82,7 @@ pub(crate) struct ChatWidget<'a> { interrupts: InterruptManager, // Whether a redraw is needed after handling the current event needs_redraw: bool, + session_id: Option, } struct UserMessage { @@ -114,6 +116,7 @@ impl ChatWidget<'_> { } // --- Small event handlers --- fn on_session_configured(&mut self, event: codex_core::protocol::SessionConfiguredEvent) { + self.session_id = Some(event.session_id); self.bottom_pane .set_history_metadata(event.history_log_id, event.history_entry_count); self.add_to_history(HistoryCell::new_session_info(&self.config, event, true)); @@ -497,6 +500,7 @@ impl ChatWidget<'_> { task_complete_pending: false, interrupts: InterruptManager::new(), needs_redraw: false, + session_id: None, } } @@ -651,6 +655,7 @@ impl ChatWidget<'_> { self.add_to_history(HistoryCell::new_status_output( &self.config, &self.total_token_usage, + &self.session_id, )); } diff --git a/codex-rs/tui/src/chatwidget/tests.rs b/codex-rs/tui/src/chatwidget/tests.rs index 7349762039..4cf3e2359b 100644 --- a/codex-rs/tui/src/chatwidget/tests.rs +++ b/codex-rs/tui/src/chatwidget/tests.rs @@ -137,6 +137,7 @@ fn make_chatwidget_manual() -> ( task_complete_pending: false, interrupts: InterruptManager::new(), needs_redraw: false, + session_id: None, }; (widget, rx, op_rx) } diff --git a/codex-rs/tui/src/history_cell.rs b/codex-rs/tui/src/history_cell.rs index 8b26f845e9..c2a3f718e2 100644 --- a/codex-rs/tui/src/history_cell.rs +++ b/codex-rs/tui/src/history_cell.rs @@ -37,6 +37,7 @@ use std::io::Cursor; use std::path::PathBuf; use std::time::Duration; use tracing::error; +use uuid::Uuid; #[derive(Clone)] pub(crate) struct CommandOutput { @@ -560,7 +561,11 @@ impl HistoryCell { } } - pub(crate) fn new_status_output(config: &Config, usage: &TokenUsage) -> Self { + pub(crate) fn new_status_output( + config: &Config, + usage: &TokenUsage, + session_id: &Option, + ) -> Self { let mut lines: Vec> = Vec::new(); lines.push(Line::from("/status".magenta())); @@ -597,6 +602,12 @@ impl HistoryCell { " • Sandbox: ".into(), sandbox_name.into(), ])); + if let Some(session_id) = session_id { + lines.push(Line::from(vec![ + " • Session ID: ".into(), + session_id.to_string().into(), + ])); + } lines.push(Line::from(""));