From a734a13ad77c759c927fc1ff86d4f7d31e53e997 Mon Sep 17 00:00:00 2001 From: Benjamin Carlsson Date: Wed, 18 Nov 2026 05:52:49 +0000 Subject: [PATCH] Omit unknown server versions from `/status` (#62202) ## Why `/status` appends `(unknown)` to the server label when a cloud or remote server does not report a version. ## What changed Show the cloud label or remote address on its own when the version is unavailable. When a version is reported, use the same `v` prefix for cloud and remote servers. The daemon menu still displays `unknown` for a running local daemon whose version is unavailable. ## Testing Add `/status` snapshots for cloud connections with and without a reported version and for a remote WebSocket connection without a reported version. GitOrigin-RevId: 113d2502fc7de6af37da3b3029ee28923af29e6f --- codex-rs/tui/src/app/daemon_menu.rs | 7 ++- codex-rs/tui/src/app/daemon_menu_tests.rs | 4 +- codex-rs/tui/src/app/server_version_notice.rs | 3 +- codex-rs/tui/src/app/tests/startup.rs | 5 +- .../tui/src/chatwidget/tests/app_server.rs | 2 +- .../chatwidget/tests/status_command_tests.rs | 2 +- codex-rs/tui/src/status/card.rs | 11 ++--- codex-rs/tui/src/status/remote_connection.rs | 46 ++++++++----------- ...__tests__status_snapshot_cloud_server.snap | 21 +++++++++ ...us_snapshot_cloud_server_with_version.snap | 21 +++++++++ ...napshot_remote_server_without_version.snap | 21 +++++++++ codex-rs/tui/src/status/tests.rs | 33 +++++++++++-- 12 files changed, 131 insertions(+), 45 deletions(-) create mode 100644 codex-rs/tui/src/status/snapshots/codex_tui__status__tests__status_snapshot_cloud_server.snap create mode 100644 codex-rs/tui/src/status/snapshots/codex_tui__status__tests__status_snapshot_cloud_server_with_version.snap create mode 100644 codex-rs/tui/src/status/snapshots/codex_tui__status__tests__status_snapshot_remote_server_without_version.snap diff --git a/codex-rs/tui/src/app/daemon_menu.rs b/codex-rs/tui/src/app/daemon_menu.rs index 920f1485e2..66026d7440 100644 --- a/codex-rs/tui/src/app/daemon_menu.rs +++ b/codex-rs/tui/src/app/daemon_menu.rs @@ -47,7 +47,12 @@ impl App { .remote_connection .as_ref() .filter(|_| matches!(self.app_server_target, AppServerTarget::LocalDaemon { .. })) - .map(|connection| format!("Running daemon: {}", connection.version)) + .map(|connection| { + format!( + "Running daemon: {}", + connection.version.as_deref().unwrap_or("unknown") + ) + }) .unwrap_or_else(|| "Not connected to the local background server.".to_string()); let mut header = vec![Line::from("Daemon".bold()), Line::from(status.dim())]; let unavailable = if matches!( diff --git a/codex-rs/tui/src/app/daemon_menu_tests.rs b/codex-rs/tui/src/app/daemon_menu_tests.rs index 0498495092..473d52b663 100644 --- a/codex-rs/tui/src/app/daemon_menu_tests.rs +++ b/codex-rs/tui/src/app/daemon_menu_tests.rs @@ -81,7 +81,7 @@ async fn daemon_menu_is_read_only_and_confirmation_can_cancel_or_handoff() { }; app.chat_widget.remote_connection = Some(RemoteConnectionStatus { address: "local".into(), - version: "v0.153.0".into(), + version: Some("v0.153.0".into()), is_local_daemon: true, is_managed_daemon: true, }); @@ -308,7 +308,7 @@ async fn unavailable_daemon_menu_offers_guidance_without_update_actions() { }; app.chat_widget.remote_connection = Some(RemoteConnectionStatus { address: "ws://example.test:1234".into(), - version: "v0.153.0".into(), + version: Some("v0.153.0".into()), is_local_daemon: false, is_managed_daemon: false, }); diff --git a/codex-rs/tui/src/app/server_version_notice.rs b/codex-rs/tui/src/app/server_version_notice.rs index bca03e34f7..aee7069977 100644 --- a/codex-rs/tui/src/app/server_version_notice.rs +++ b/codex-rs/tui/src/app/server_version_notice.rs @@ -13,7 +13,8 @@ impl App { .chat_widget .remote_connection .as_ref() - .and_then(|connection| connection.version.strip_prefix('v')) + .and_then(|connection| connection.version.as_deref()) + .and_then(|version| version.strip_prefix('v')) .map(str::to_owned); let _ = self.initialize_server_version_notice(client_version, server_version.as_deref()); } diff --git a/codex-rs/tui/src/app/tests/startup.rs b/codex-rs/tui/src/app/tests/startup.rs index 8e1017eadf..0b37763914 100644 --- a/codex-rs/tui/src/app/tests/startup.rs +++ b/codex-rs/tui/src/app/tests/startup.rs @@ -1509,8 +1509,9 @@ async fn remote_overview_startup_hides_disabled_older_server_notice() -> Result< .remote_connection .as_ref() .expect("remote status") - .version, - "v2.0.0" + .version + .as_deref(), + Some("v2.0.0") ); app.local_settings.tui.show_server_version_notice = true; app.refresh_server_version_overview_notice("2.1.0"); diff --git a/codex-rs/tui/src/chatwidget/tests/app_server.rs b/codex-rs/tui/src/chatwidget/tests/app_server.rs index c2e6164232..a4ceff486e 100644 --- a/codex-rs/tui/src/chatwidget/tests/app_server.rs +++ b/codex-rs/tui/src/chatwidget/tests/app_server.rs @@ -1306,7 +1306,7 @@ async fn startup_config_warning_is_not_repeated_by_thread() { chat.remote_connection = Some(crate::status::remote_connection::RemoteConnectionStatus { address: "local".into(), - version: "v0.153.0".into(), + version: Some("v0.153.0".into()), is_local_daemon: true, is_managed_daemon: managed_daemon, }); diff --git a/codex-rs/tui/src/chatwidget/tests/status_command_tests.rs b/codex-rs/tui/src/chatwidget/tests/status_command_tests.rs index b6daf7a335..12ccac09e8 100644 --- a/codex-rs/tui/src/chatwidget/tests/status_command_tests.rs +++ b/codex-rs/tui/src/chatwidget/tests/status_command_tests.rs @@ -535,7 +535,7 @@ async fn status_command_requests_thread_usage_for_remote_connection_metadata() { ); chat.remote_connection = Some(crate::status::remote_connection::RemoteConnectionStatus { address: "wss://remote.example.com".to_string(), - version: "v1.0.0".to_string(), + version: Some("v1.0.0".to_string()), is_local_daemon: false, is_managed_daemon: false, }); diff --git a/codex-rs/tui/src/status/card.rs b/codex-rs/tui/src/status/card.rs index d18a3059fe..706eeb89ae 100644 --- a/codex-rs/tui/src/status/card.rs +++ b/codex-rs/tui/src/status/card.rs @@ -830,12 +830,11 @@ impl StatusHistoryCell { let value = if remote_connection.is_local_daemon { Line::from("Local background server") } else { - Line::from(vec![ - Span::from(remote_connection.address.clone()), - Span::from(" (").dim(), - Span::from(remote_connection.version.clone()).dim(), - Span::from(")").dim(), - ]) + let mut spans = vec![remote_connection.address.clone().into()]; + if let Some(version) = &remote_connection.version { + spans.push(format!(" ({version})").dim()); + } + Line::from(spans) }; let wrapped_remote = word_wrap_lines([value], RtOptions::new(value_width.max(1))); let mut wrapped_remote = wrapped_remote.into_iter(); diff --git a/codex-rs/tui/src/status/remote_connection.rs b/codex-rs/tui/src/status/remote_connection.rs index a08b3b760c..b31c45e280 100644 --- a/codex-rs/tui/src/status/remote_connection.rs +++ b/codex-rs/tui/src/status/remote_connection.rs @@ -1,3 +1,5 @@ +//! Formats connection metadata and notices, preserving unavailable server versions as absent. + use crate::AppServerTarget; use crate::RemoteAppServerEndpoint; use crate::update_versions::ServerVersionNoticeKind; @@ -8,7 +10,7 @@ use url::Url; #[derive(Clone, Debug, PartialEq, Eq)] pub(crate) struct RemoteConnectionStatus { pub(crate) address: String, - pub(crate) version: String, + pub(crate) version: Option, pub(crate) is_local_daemon: bool, pub(crate) is_managed_daemon: bool, } @@ -23,33 +25,23 @@ pub(crate) fn remote_connection_status_value( app_server_target: &AppServerTarget, server_version: Option<&str>, ) -> Option { - let endpoint = match app_server_target { + let address = match app_server_target { AppServerTarget::Embedded => return None, - AppServerTarget::Cloud => { - return Some(RemoteConnectionStatus { - address: "Cloud".into(), - version: server_version.unwrap_or("unknown").into(), - is_local_daemon: false, - is_managed_daemon: false, - }); - } + AppServerTarget::Cloud => "Cloud".to_string(), AppServerTarget::LocalDaemon { endpoint, .. } | AppServerTarget::Remote { endpoint } => { - endpoint + match endpoint { + RemoteAppServerEndpoint::WebSocket { websocket_url, .. } => { + sanitized_websocket_url(websocket_url) + .map(|url| url.to_string()) + .unwrap_or_else(|| "".to_string()) + } + RemoteAppServerEndpoint::UnixSocket { socket_path } => { + format!("unix://{}", socket_path.display()) + } + } } }; - let address = match endpoint { - RemoteAppServerEndpoint::WebSocket { websocket_url, .. } => { - sanitized_websocket_url(websocket_url) - .map(|url| url.to_string()) - .unwrap_or_else(|| "".to_string()) - } - RemoteAppServerEndpoint::UnixSocket { socket_path } => { - format!("unix://{}", socket_path.display()) - } - }; - let version = server_version - .map(|version| format!("v{version}")) - .unwrap_or_else(|| "unknown".to_string()); + let version = server_version.map(|version| format!("v{version}")); Some(RemoteConnectionStatus { address, version, @@ -201,7 +193,7 @@ mod tests { remote_connection_status_value(&websocket_target, Some("1.2.3")), Some(RemoteConnectionStatus { address: "ws://127.0.0.1:4500/".to_string(), - version: "v1.2.3".to_string(), + version: Some("v1.2.3".to_string()), is_local_daemon: false, is_managed_daemon: false, }) @@ -218,7 +210,7 @@ mod tests { remote_connection_status_value(&daemon_target, /*server_version*/ None), Some(RemoteConnectionStatus { address: format!("unix://{}", socket_path.display()), - version: "unknown".to_string(), + version: None, is_local_daemon: true, is_managed_daemon: false, }) @@ -232,7 +224,7 @@ mod tests { remote_connection_status_value(&remote_socket_target, Some("1.2.3")), Some(RemoteConnectionStatus { address: format!("unix://{}", socket_path.display()), - version: "v1.2.3".to_string(), + version: Some("v1.2.3".to_string()), is_local_daemon: false, is_managed_daemon: false, }) diff --git a/codex-rs/tui/src/status/snapshots/codex_tui__status__tests__status_snapshot_cloud_server.snap b/codex-rs/tui/src/status/snapshots/codex_tui__status__tests__status_snapshot_cloud_server.snap new file mode 100644 index 0000000000..ce1efb6969 --- /dev/null +++ b/codex-rs/tui/src/status/snapshots/codex_tui__status__tests__status_snapshot_cloud_server.snap @@ -0,0 +1,21 @@ +--- +source: tui/src/status/tests.rs +expression: sanitized +--- +/status + + >_ OpenAI Codex (v0.0.0) + + Visit https://chatgpt.com/settings/usage for up-to-date + information on rate limits and credits + + Server: Cloud + + Model: gpt-5.1-codex-max (reasoning medium) + Directory: [[workspace]] + Permissions: Custom (workspace with network access, Ask for approval) + Agents.md: + + Token usage: 750 total (500 input + 250 output) + Context window: 100% left (750 used / 272K) + Limits: data not available yet diff --git a/codex-rs/tui/src/status/snapshots/codex_tui__status__tests__status_snapshot_cloud_server_with_version.snap b/codex-rs/tui/src/status/snapshots/codex_tui__status__tests__status_snapshot_cloud_server_with_version.snap new file mode 100644 index 0000000000..8a3f71505d --- /dev/null +++ b/codex-rs/tui/src/status/snapshots/codex_tui__status__tests__status_snapshot_cloud_server_with_version.snap @@ -0,0 +1,21 @@ +--- +source: tui/src/status/tests.rs +expression: sanitized +--- +/status + + >_ OpenAI Codex (v0.0.0) + + Visit https://chatgpt.com/settings/usage for up-to-date + information on rate limits and credits + + Server: Cloud (v0.133.0) + + Model: gpt-5.1-codex-max (reasoning medium) + Directory: [[workspace]] + Permissions: Custom (workspace with network access, Ask for approval) + Agents.md: + + Token usage: 750 total (500 input + 250 output) + Context window: 100% left (750 used / 272K) + Limits: data not available yet diff --git a/codex-rs/tui/src/status/snapshots/codex_tui__status__tests__status_snapshot_remote_server_without_version.snap b/codex-rs/tui/src/status/snapshots/codex_tui__status__tests__status_snapshot_remote_server_without_version.snap new file mode 100644 index 0000000000..832b4ce6a9 --- /dev/null +++ b/codex-rs/tui/src/status/snapshots/codex_tui__status__tests__status_snapshot_remote_server_without_version.snap @@ -0,0 +1,21 @@ +--- +source: tui/src/status/tests.rs +expression: sanitized +--- +/status + + >_ OpenAI Codex (v0.0.0) + + Visit https://chatgpt.com/settings/usage for up-to-date + information on rate limits and credits + + Server: ws://devbox.example.com:4500/ + + Model: gpt-5.1-codex-max (reasoning medium) + Directory: [[workspace]] + Permissions: Custom (workspace with network access, Ask for approval) + Agents.md: + + Token usage: 750 total (500 input + 250 output) + Context window: 100% left (750 used / 272K) + Limits: data not available yet diff --git a/codex-rs/tui/src/status/tests.rs b/codex-rs/tui/src/status/tests.rs index 967a8928fa..b803b99f96 100644 --- a/codex-rs/tui/src/status/tests.rs +++ b/codex-rs/tui/src/status/tests.rs @@ -17,6 +17,7 @@ use crate::legacy_core::config::PermissionProfileSnapshot; use crate::pager_overlay::TranscriptOverlay; use crate::status::StatusAccountDisplay; use crate::status::remote_connection::RemoteConnectionStatus; +use crate::status::remote_connection::remote_connection_status_value; use crate::test_support::PathBufExt; use crate::test_support::test_path_buf; use crate::token_usage::TokenUsage; @@ -1744,22 +1745,46 @@ async fn status_snapshot_uses_default_reasoning_when_config_empty() { .with_ymd_and_hms(2024, 2, 3, 4, 5, 6) .single() .expect("timestamp"); - for (is_local_daemon, snapshot) in [ + let connections = [ ( None, "status_snapshot_uses_default_reasoning_when_config_empty", ), (Some(false), "status_snapshot_remote_server"), (Some(true), "status_snapshot_local_background_server"), - ] { + ] + .map(|(is_local_daemon, snapshot)| { let remote_connection = is_local_daemon.map(|is_local_daemon| RemoteConnectionStatus { address: "unix:///tmp/codex-home/app-server-control/app-server-control.sock" .to_string(), - version: "v0.133.0".to_string(), + version: Some("v0.133.0".to_string()), is_local_daemon, is_managed_daemon: is_local_daemon, }); - + (remote_connection, snapshot) + }); + for (remote_connection, snapshot) in connections.into_iter().chain([ + ( + remote_connection_status_value( + &crate::AppServerTarget::Cloud, + /*server_version*/ None, + ), + "status_snapshot_cloud_server", + ), + ( + remote_connection_status_value(&crate::AppServerTarget::Cloud, Some("0.133.0")), + "status_snapshot_cloud_server_with_version", + ), + ( + remote_connection_status_value( + &crate::AppServerTarget::Remote { + endpoint: crate::resolve_remote_addr("ws://devbox.example.com:4500").unwrap(), + }, + /*server_version*/ None, + ), + "status_snapshot_remote_server_without_version", + ), + ]) { let model_slug = get_model_offline_for_tests(config.model.as_deref()); let token_info = token_info_for(&model_slug, &config, &usage); let (composite, _) = new_status_output_with_rate_limits_handle(