From 2d581656514cf4d87a43e20f3a8be4a0a2696025 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Thu, 19 Nov 2026 00:44:04 +0000 Subject: [PATCH] Expose custom status lines in `/experimental` (#62387) ## Why Custom status lines previously depended on a feature flag in the TUI client's configuration. When the TUI connects to a separate app server, that flag can differ from the setting in the server's active profile. ## What changed Add **Custom status line** to `/experimental` as an opt-in feature. Save the toggle on the connected app server, restart the TUI, then use `/statusline` to choose a provider. Read `tui_extensions_statusline` from the app server's effective configuration at startup. Keep that value when switching conversations or reloading local status line preferences, so toggling the feature takes effect on the next TUI launch. ## Testing Add a menu snapshot and regression coverage for saving the toggle in a server profile while preserving the active provider across a thread change. GitOrigin-RevId: 4025c9771e560d6d7b1e6bd97236bffc44201556 --- ...sline_mention_loads_the_bundled_skill.snap | 2 +- codex-rs/features/src/lib.rs | 6 +- .../assets/samples/create-statusline/SKILL.md | 2 +- codex-rs/tui/src/app/event_dispatch.rs | 2 +- .../src/app/experimental_features_tests.rs | 102 +++++++++++++++-- codex-rs/tui/src/app/session_lifecycle.rs | 1 + codex-rs/tui/src/app/startup.rs | 106 +++++++++++------- .../tui/src/app/status_line_settings_tests.rs | 8 +- codex-rs/tui/src/app/statusline_picker.rs | 22 +--- .../tui/src/app/statusline_picker_tests.rs | 7 +- codex-rs/tui/src/app/tests.rs | 3 +- .../tui/src/app/tests/new_session_tests.rs | 6 +- .../tui/src/app/tests/projectless_tests.rs | 10 +- .../app/tests/session_lifecycle_requests.rs | 3 +- .../src/app/tests/startup_defaults_tests.rs | 27 ++++- .../experimental_features_view_tests.rs | 1 + ...al_features_tui_extensions_statusline.snap | 14 +++ codex-rs/tui/src/chatwidget.rs | 1 + codex-rs/tui/src/chatwidget/constructor.rs | 1 + codex-rs/tui/src/chatwidget/session_flow.rs | 4 + .../tui/src/chatwidget/status_controls.rs | 6 +- .../tui/src/chatwidget/statusline_reader.rs | 6 +- .../src/chatwidget/statusline_reader_tests.rs | 7 +- .../tests/status_surface_previews.rs | 4 +- codex-rs/tui/src/config_update.rs | 10 +- codex-rs/tui/src/statusline_metrics.rs | 7 +- 26 files changed, 246 insertions(+), 122 deletions(-) create mode 100644 codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__experimental_features_view__tests__experimental_features_tui_extensions_statusline.snap diff --git a/codex-rs/core/tests/suite/snapshots/all__suite__scenarios__statusline_authoring__explicit_statusline_mention_loads_the_bundled_skill.snap b/codex-rs/core/tests/suite/snapshots/all__suite__scenarios__statusline_authoring__explicit_statusline_mention_loads_the_bundled_skill.snap index 087f9b8180..765784d052 100644 --- a/codex-rs/core/tests/suite/snapshots/all__suite__scenarios__statusline_authoring__explicit_statusline_mention_loads_the_bundled_skill.snap +++ b/codex-rs/core/tests/suite/snapshots/all__suite__scenarios__statusline_authoring__explicit_statusline_mention_loads_the_bundled_skill.snap @@ -48,7 +48,7 @@ Scenario: A user requests the bundled statusline skill by name. ### Enable and verify - Install the provider through an installed plugin or register the stdio command on the connected app-serv...guration and restart the TUI if you changed the flag. [hash=42c056811162cca2] + Install the provider through an installed plugin or register the stdio command on the connected app-serv...l` on the connected app server, then restart the TUI. [hash=e0f5170a5aeda287] Exercise `tools/list` and `resources/read` with a representative snapshot. After adding the server, star... file, restart its stdio process to load the changes. [hash=4d64fb913d86fc64] diff --git a/codex-rs/features/src/lib.rs b/codex-rs/features/src/lib.rs index d4eca54182..da27366a59 100644 --- a/codex-rs/features/src/lib.rs +++ b/codex-rs/features/src/lib.rs @@ -1177,7 +1177,11 @@ pub const FEATURES: &[FeatureSpec] = &[ FeatureSpec { id: Feature::TuiExtensionsStatusLine, key: "tui_extensions_statusline", - stage: Stage::UnderDevelopment, + stage: Stage::Experimental { + name: "Custom status line", + menu_description: "Restart the TUI, then use /statusline.", + announcement: "", + }, default_enabled: false, }, FeatureSpec { diff --git a/codex-rs/skills/src/assets/samples/create-statusline/SKILL.md b/codex-rs/skills/src/assets/samples/create-statusline/SKILL.md index 3e49690838..1c4f8e2fc3 100644 --- a/codex-rs/skills/src/assets/samples/create-statusline/SKILL.md +++ b/codex-rs/skills/src/assets/samples/create-statusline/SKILL.md @@ -15,6 +15,6 @@ Use a `row` with an explicit whole-number `gap` to group items. Use named theme ### Enable and verify -Install the provider through an installed plugin or register the stdio command on the connected app-server host. For example, run `codex mcp add my-statusline -- python3 -u /absolute/path/to/statusline.py` there, using a path and interpreter the host can access. If the workspace is on a separate executor, give the user the provider file to copy to the host and the command to run there. Set `tui_extensions_statusline = true` under `[features]` in the TUI client's configuration and restart the TUI if you changed the flag. +Install the provider through an installed plugin or register the stdio command on the connected app-server host. For example, run `codex mcp add my-statusline -- python3 -u /absolute/path/to/statusline.py` there, using a path and interpreter the host can access. If the workspace is on a separate executor, give the user the provider file to copy to the host and the command to run there. Enable **Custom status line** in `/experimental` on the connected app server, then restart the TUI. Exercise `tools/list` and `resources/read` with a representative snapshot. After adding the server, start a new conversation in its workspace to connect to it. Open `/statusline`, choose **Choose a status line provider**, and select the provider. Verify that changing threads changes the displayed inputs. F2 shows the failed attempt if the footer falls back. After editing the Python file, restart its stdio process to load the changes. diff --git a/codex-rs/tui/src/app/event_dispatch.rs b/codex-rs/tui/src/app/event_dispatch.rs index fd948d1746..b5e5cd1d68 100644 --- a/codex-rs/tui/src/app/event_dispatch.rs +++ b/codex-rs/tui/src/app/event_dispatch.rs @@ -502,7 +502,7 @@ impl App { AppEvent::ChooseStatuslineProvider { scan, id, key } => self.choose_statusline_provider(scan, id, key, app_server).await, AppEvent::CreateCustomStatusline { backend, thread_id, key } => { if app_server.thread_params_mode() != crate::ThreadParamsMode::Cloud - && self.config.features.enabled(Feature::TuiExtensionsStatusLine) + && self.chat_widget.custom_statusline_enabled() && self.chat_widget.active_view_is(crate::bottom_pane::StatusLineSetupView::VIEW_ID) && self.chat_widget.model_catalog().backend == backend && backend.is_none_or(|id| id == app_server.backend_id()) diff --git a/codex-rs/tui/src/app/experimental_features_tests.rs b/codex-rs/tui/src/app/experimental_features_tests.rs index 7df4235f4d..7103c5383a 100644 --- a/codex-rs/tui/src/app/experimental_features_tests.rs +++ b/codex-rs/tui/src/app/experimental_features_tests.rs @@ -1,26 +1,24 @@ use super::*; +use crate::app::session_lifecycle::ThreadAttachPresentation; +use crate::app::startup::statusline_enabled; use crate::app::tests::make_test_app_with_channels; use codex_app_server_client::AppServerClient; use pretty_assertions::assert_eq; -#[tokio::test] -async fn experimental_features_use_selected_server_profile_and_preserve_task_settings() -> Result<()> -{ - let home = tempfile::tempdir()?; - let selected = AbsolutePathBuf::from_absolute_path(home.path().join("work.config.toml"))?; - let managed = home.path().join("managed.toml"); - std::fs::write(home.path().join("config.toml"), "# unselected\n")?; - std::fs::write(&selected, "[features]\nnetwork_proxy = true\n")?; - std::fs::write(&managed, "")?; +async fn start_feature_server( + home: &Path, + selected: &AbsolutePathBuf, + managed: &Path, +) -> Result<(AppServerSession, AppServerStartedThread)> { let loader = LoaderOverrides { user_config_path: Some(selected.clone()), user_config_profile: Some("work".parse()?), - managed_config_path: Some(managed.clone()), + managed_config_path: Some(managed.to_path_buf()), ignore_project_config: true, ..LoaderOverrides::without_managed_config_for_tests() }; let config = ConfigBuilder::default() - .codex_home(home.path().to_path_buf()) + .codex_home(home.to_path_buf()) .loader_overrides(loader.clone()) .build() .await?; @@ -43,7 +41,21 @@ async fn experimental_features_use_selected_server_profile_and_preserve_task_set AppServerClient::InProcess(client), crate::app_server_session::ThreadParamsMode::Remote, ); - let thread = server.start_thread(&config).await?.session.thread_id; + let started = server.start_thread(&config).await?; + Ok((server, started)) +} + +#[tokio::test] +async fn experimental_features_use_selected_server_profile_and_preserve_task_settings() -> Result<()> +{ + let home = tempfile::tempdir()?; + let selected = AbsolutePathBuf::from_absolute_path(home.path().join("work.config.toml"))?; + let managed = home.path().join("managed.toml"); + std::fs::write(home.path().join("config.toml"), "# unselected\n")?; + std::fs::write(&selected, "[features]\nnetwork_proxy = true\n")?; + std::fs::write(&managed, "")?; + let (server, started) = start_feature_server(home.path(), &selected, &managed).await?; + let thread = started.session.thread_id; let (mut app, mut events, _ops) = make_test_app_with_channels().await; let before = (app.config.clone(), app.chat_widget.config_ref().clone()); let updates = vec![ @@ -138,3 +150,69 @@ async fn experimental_features_use_selected_server_profile_and_preserve_task_set server.shutdown().await?; Ok(()) } + +#[tokio::test] +async fn statusline_uses_the_startup_flag_until_restart() -> Result<()> { + let home = tempfile::tempdir()?; + let selected = AbsolutePathBuf::from_absolute_path(home.path().join("work.config.toml"))?; + let managed = home.path().join("managed.toml"); + std::fs::write(&selected, "[features]\ntui_extensions_statusline = true\n")?; + std::fs::write(&managed, "")?; + let (mut server, started) = start_feature_server(home.path(), &selected, &managed).await?; + let thread = started.session.thread_id; + let (mut app, _events, _ops) = make_test_app_with_channels().await; + let cwd = app.config.cwd.display().to_string(); + let read_flag = async |server: &AppServerSession| -> Result { + let defaults = crate::config_update::read_effective_config_with_layers( + &server.request_handle(), + cwd.clone(), + ) + .await?; + Ok(statusline_enabled(&defaults.config)) + }; + app.chat_widget.statusline_feature_enabled = read_flag(&server).await?; + assert!(app.chat_widget.statusline_feature_enabled); + let mut tui = crate::tui::test_support::make_test_tui()?; + std::fs::write( + &app.local_settings.user_config_path, + "[tui]\nstatus_line_provider = { server = 'fixture', tool = 'line' }\n", + )?; + app.refresh_in_memory_config_from_disk().await?; + app.replace_chat_widget_with_app_server_thread( + &mut tui, + started, + ThreadAttachPresentation::Fresh, + /*initial_user_message*/ None, + ) + .await?; + let provider = app + .chat_widget + .selected_statusline_provider() + .unwrap() + .clone(); + + let key = Feature::TuiExtensionsStatusLine.key(); + let (tx, rx) = oneshot::channel(); + app.save_experimental_features(&server, thread, vec![(key.into(), false)], tx); + assert!(rx.await?.expect("server save").warning.is_none()); + assert_eq!( + app.chat_widget.selected_statusline_provider(), + Some(&provider) + ); + + let next = server.start_thread(&app.config).await?; + app.replace_chat_widget_with_app_server_thread( + &mut tui, + next, + ThreadAttachPresentation::Fresh, + /*initial_user_message*/ None, + ) + .await?; + assert_eq!( + app.chat_widget.selected_statusline_provider(), + Some(&provider) + ); + assert!(!read_flag(&server).await?); + server.shutdown().await?; + Ok(()) +} diff --git a/codex-rs/tui/src/app/session_lifecycle.rs b/codex-rs/tui/src/app/session_lifecycle.rs index d56a192ba0..f3c9709580 100644 --- a/codex-rs/tui/src/app/session_lifecycle.rs +++ b/codex-rs/tui/src/app/session_lifecycle.rs @@ -630,6 +630,7 @@ impl App { chat_widget.config_panel_tui = self.chat_widget.config_panel_tui.clone(); chat_widget.config_panel_tui.mouse_scroll_speed = chat_widget.local_settings.tui.mouse_scroll_speed; + chat_widget.statusline_feature_enabled = self.chat_widget.statusline_feature_enabled; chat_widget.remote_connection = self.chat_widget.remote_connection.clone(); chat_widget.snapshot_local_images = self.app_server_target.uses_remote_workspace(); chat_widget.thread_params_mode = self.chat_widget.thread_params_mode; diff --git a/codex-rs/tui/src/app/startup.rs b/codex-rs/tui/src/app/startup.rs index 8cea2f977e..d1fb8e0ac1 100644 --- a/codex-rs/tui/src/app/startup.rs +++ b/codex-rs/tui/src/app/startup.rs @@ -52,25 +52,36 @@ fn spawn_startup_thread_start( }); } -pub(super) async fn prepare_fresh_startup_config( - config: &mut Config, - app_server: &AppServerSession, +pub(super) fn startup_config_cwd<'a>( + config: &'a Config, + app_server: &'a AppServerSession, app_server_target: &AppServerTarget, - cli_kv_overrides: &[(String, TomlValue)], - harness_overrides: &ConfigOverrides, - environments: &EnvironmentManager, -) -> Result { - let defaults_cwd = match app_server_target { +) -> &'a Path { + match app_server_target { AppServerTarget::Embedded | AppServerTarget::LocalDaemon { .. } => config.cwd.as_path(), AppServerTarget::Remote { .. } | AppServerTarget::Cloud => { app_server.remote_cwd_override().unwrap_or(Path::new(".")) } - }; - let defaults = crate::config_update::read_effective_config_with_layers( - &app_server.request_handle(), - defaults_cwd.display().to_string(), - ) - .await?; + } +} + +pub(super) fn statusline_enabled(config: &codex_app_server_protocol::Config) -> bool { + config + .additional + .get("features") + .and_then(|features| features.get(Feature::TuiExtensionsStatusLine.key())) + .and_then(serde_json::Value::as_bool) + .unwrap_or(false) +} + +pub(super) fn prepare_fresh_startup_config( + config: &mut Config, + app_server: &AppServerSession, + defaults: &crate::config_update::EffectiveConfig, + cli_kv_overrides: &[(String, TomlValue)], + harness_overrides: &ConfigOverrides, + environments: &EnvironmentManager, +) -> crate::projectless::AppliedDefaults { super::new_session::overlay_new_session_defaults( config, &defaults.config, @@ -82,7 +93,7 @@ pub(super) async fn prepare_fresh_startup_config( harness_overrides, app_server, environments, - &defaults, + defaults, ); apply_managed_new_thread_defaults( config, @@ -90,7 +101,7 @@ pub(super) async fn prepare_fresh_startup_config( cli_kv_overrides, harness_overrides, ); - Ok(projectless) + projectless } pub(super) fn startup_model( @@ -384,31 +395,47 @@ impl App { config.model_reasoning_effort = None; } } - let startup_defaults = if fresh_start { - match startup_draft - .run_until( - tui, - prepare_fresh_startup_config( - &mut config, - &app_server, - &app_server_target, - &cli_kv_overrides, - &harness_overrides, - &environment_manager, - ), - ) - .await - { - Ok(Ok(defaults)) => defaults, - Ok(Err(err)) => { - return shutdown_on_startup_error(app_server, &mut other_backends, err).await; - } - Err(err) => { - return shutdown_on_startup_error(app_server, &mut other_backends, err).await; + let cwd = startup_config_cwd(&config, &app_server, &app_server_target) + .display() + .to_string(); + let startup_config = match startup_draft + .run_until(tui, async { + let request_handle = app_server.request_handle(); + let read_config = crate::config_update::read_effective_config_with_optional_layers( + &request_handle, + cwd, + /*include_layers*/ fresh_start, + ); + if fresh_start { + read_config.await + } else { + tokio::time::timeout(Duration::from_secs(/*secs*/ 2), read_config).await? } + }) + .await + { + Ok(Ok(config)) => Some(config), + Ok(Err(_)) if !fresh_start => None, + Ok(Err(err)) => { + return shutdown_on_startup_error(app_server, &mut other_backends, err).await; } - } else { - crate::projectless::AppliedDefaults::default() + Err(err) => { + return shutdown_on_startup_error(app_server, &mut other_backends, err).await; + } + }; + let statusline_feature_enabled = startup_config + .as_ref() + .is_some_and(|response| statusline_enabled(&response.config)); + let startup_defaults = match startup_config.as_ref() { + Some(defaults) if fresh_start => prepare_fresh_startup_config( + &mut config, + &app_server, + defaults, + &cli_kv_overrides, + &harness_overrides, + &environment_manager, + ), + _ => crate::projectless::AppliedDefaults::default(), }; let mut launch_choices = crate::app_server_session::StartupLaunchChoices::from_launch( &cli_kv_overrides, @@ -937,6 +964,7 @@ impl App { .borrow_mut() .continue_from(&mut startup_draft.blossom.borrow_mut()); } + chat_widget.statusline_feature_enabled = statusline_feature_enabled; chat_widget.remote_connection = remote_connection; chat_widget.snapshot_local_images = app_server_target.uses_remote_workspace(); chat_widget.thread_params_mode = app_server.thread_params_mode(); diff --git a/codex-rs/tui/src/app/status_line_settings_tests.rs b/codex-rs/tui/src/app/status_line_settings_tests.rs index 9c7af0dd77..d0b6969649 100644 --- a/codex-rs/tui/src/app/status_line_settings_tests.rs +++ b/codex-rs/tui/src/app/status_line_settings_tests.rs @@ -142,7 +142,7 @@ async fn failed_write_preserves_the_file_and_the_live_selection() -> anyhow::Res } #[tokio::test] -async fn reloading_the_effective_feature_gate_and_reselecting_an_unchanged_preference() { +async fn reloading_the_local_provider_preserves_the_server_feature_gate() { let mut app = make_test_app().await; let path = app.local_settings.user_config_path.clone(); let configured = "[features]\ntui_extensions_statusline = true\n[tui]\nstatus_line = []\nstatus_line_provider = { tool='line', server='fixture' } # local formatting\n"; @@ -156,6 +156,9 @@ async fn reloading_the_effective_feature_gate_and_reselecting_an_unchanged_prefe .into(), )]; app.refresh_in_memory_config_from_disk().await.unwrap(); + assert!(!render_bottom_popup(&app.chat_widget, /*width*/ 80).contains("Initializing…")); + app.chat_widget.statusline_feature_enabled = true; + app.chat_widget.refresh_status_line(); assert!(render_bottom_popup(&app.chat_widget, /*width*/ 80).contains("Initializing…")); let selected = app @@ -176,8 +179,5 @@ async fn reloading_the_effective_feature_gate_and_reselecting_an_unchanged_prefe ); std::fs::write(&path, configured.replace("= true", "= false")).unwrap(); app.refresh_in_memory_config_from_disk().await.unwrap(); - assert!(!render_bottom_popup(&app.chat_widget, /*width*/ 80).contains("Initializing…")); - std::fs::write(&path, configured).unwrap(); - app.refresh_in_memory_config_from_disk().await.unwrap(); assert!(render_bottom_popup(&app.chat_widget, /*width*/ 80).contains("Initializing…")); } diff --git a/codex-rs/tui/src/app/statusline_picker.rs b/codex-rs/tui/src/app/statusline_picker.rs index 7573d896d9..5f92a3136c 100644 --- a/codex-rs/tui/src/app/statusline_picker.rs +++ b/codex-rs/tui/src/app/statusline_picker.rs @@ -161,13 +161,8 @@ impl StatuslinePicker { } } - fn applies_to( - &mut self, - thread: Option, - backend: BackendId, - config: &Config, - ) -> bool { - if self.backend != backend || !config.features.enabled(Feature::TuiExtensionsStatusLine) { + fn applies_to(&mut self, thread: Option, backend: BackendId) -> bool { + if self.backend != backend { return false; } // The picker may open before the displayed thread receives its ID. @@ -178,11 +173,7 @@ impl StatuslinePicker { impl App { pub(super) fn open_statusline_picker(&mut self, owner: &AppServerSession) { - if !self - .config - .features - .enabled(Feature::TuiExtensionsStatusLine) - { + if !self.chat_widget.custom_statusline_enabled() { return; } self.statusline_metrics @@ -230,11 +221,8 @@ impl App { .chat_widget .selected_index_for_present_view(PICKER) .is_none() - || !picker.applies_to( - self.chat_widget.thread_id(), - owner.backend_id(), - &self.config, - ) + || !self.chat_widget.custom_statusline_enabled() + || !picker.applies_to(self.chat_widget.thread_id(), owner.backend_id()) { self.statusline_picker = None; return None; diff --git a/codex-rs/tui/src/app/statusline_picker_tests.rs b/codex-rs/tui/src/app/statusline_picker_tests.rs index 61a5936c7b..6f5b49a502 100644 --- a/codex-rs/tui/src/app/statusline_picker_tests.rs +++ b/codex-rs/tui/src/app/statusline_picker_tests.rs @@ -25,11 +25,7 @@ async fn picker() -> anyhow::Result<( mpsc::UnboundedReceiver, )> { let (mut app, events, _) = make_test_app_with_channels().await; - app.config - .features - .enable(Feature::TuiExtensionsStatusLine)?; - app.chat_widget - .set_feature_enabled(Feature::TuiExtensionsStatusLine, /*enabled*/ true); + app.chat_widget.statusline_feature_enabled = true; app.chat_widget.thread_params_mode = ThreadParamsMode::Cloud; let (client, commands, _) = CloudClient::channel(/*capacity*/ 8); let owner = AppServerSession::new( @@ -231,6 +227,7 @@ async fn discovery_only_starts_a_reader_on_explicit_selection() -> anyhow::Resul let cwd = app.config.cwd.to_path_buf(); app.chat_widget .handle_thread_session(test_thread_session(thread, cwd)); + app.chat_widget.statusline_feature_enabled = true; let provider = advertised("work", "calendar", "ui://work/day"); for (uri, expected) in [ diff --git a/codex-rs/tui/src/app/tests.rs b/codex-rs/tui/src/app/tests.rs index 97381a7f05..f4082a8c61 100644 --- a/codex-rs/tui/src/app/tests.rs +++ b/codex-rs/tui/src/app/tests.rs @@ -2244,8 +2244,7 @@ async fn token_usage_update_refreshes_status_line_with_runtime_context_window() (false, 900_000, "900K window · 8 used"), ] { let before = render_bottom_popup(&app.chat_widget, /*width*/ 60); - app.chat_widget - .set_feature_enabled(Feature::TuiExtensionsStatusLine, extensions); + app.chat_widget.statusline_feature_enabled = extensions; app.refresh_status_line(); assert_eq!(render_bottom_popup(&app.chat_widget, /*width*/ 60), before); app.handle_thread_event_now(ThreadBufferedEvent::Notification(Box::new( diff --git a/codex-rs/tui/src/app/tests/new_session_tests.rs b/codex-rs/tui/src/app/tests/new_session_tests.rs index 193f61e019..7d5ae52085 100644 --- a/codex-rs/tui/src/app/tests/new_session_tests.rs +++ b/codex-rs/tui/src/app/tests/new_session_tests.rs @@ -1854,11 +1854,6 @@ async fn fresh_session_saves_input_restored_by_a_late_interrupt() -> Result<()> #[tokio::test] async fn create_statusline_keeps_the_draft_editable() -> Result<()> { let (mut app, mut events, mut ops) = make_test_app_with_channels().await; - app.config - .features - .enable(Feature::TuiExtensionsStatusLine)?; - app.chat_widget - .set_feature_enabled(Feature::TuiExtensionsStatusLine, /*enabled*/ true); let cwd = app.config.codex_home.to_path_buf(); let user_skill = cwd.join("skills/create-statusline"); std::fs::create_dir_all(&user_skill)?; @@ -1869,6 +1864,7 @@ async fn create_statusline_keeps_the_draft_editable() -> Result<()> { let source = ThreadId::new(); app.enqueue_primary_thread_session(test_thread_session(source, cwd), Vec::new()) .await?; + app.chat_widget.statusline_feature_enabled = true; app.chat_widget.handle_server_notification( turn_started_notification(source, "running"), /*replay_kind*/ None, diff --git a/codex-rs/tui/src/app/tests/projectless_tests.rs b/codex-rs/tui/src/app/tests/projectless_tests.rs index 476b0f5106..5d100cead5 100644 --- a/codex-rs/tui/src/app/tests/projectless_tests.rs +++ b/codex-rs/tui/src/app/tests/projectless_tests.rs @@ -332,15 +332,19 @@ async fn local_projectless_defaults_respect_trust_scope_and_explicit_settings() LoaderOverrides::without_managed_config_for_tests(), ) .await?; + let defaults = crate::config_update::read_effective_config_with_layers( + &server.request_handle(), + config.cwd.display().to_string(), + ) + .await?; let startup = crate::app::startup::prepare_fresh_startup_config( &mut config, &server, - &AppServerTarget::Embedded, + &defaults, &[], &overrides, &EnvironmentManager::default_for_tests(), - ) - .await?; + ); if expected_approval.is_some() { assert_eq!(startup.approval_policy, None); } diff --git a/codex-rs/tui/src/app/tests/session_lifecycle_requests.rs b/codex-rs/tui/src/app/tests/session_lifecycle_requests.rs index d966072300..544e52fa74 100644 --- a/codex-rs/tui/src/app/tests/session_lifecycle_requests.rs +++ b/codex-rs/tui/src/app/tests/session_lifecycle_requests.rs @@ -2030,8 +2030,7 @@ async fn first_prompt_counts_once_before_and_after_resume() -> Result<()> { ) .await?; drain_app_events(&mut app, &mut tui, &mut server, &mut events).await?; - app.chat_widget - .set_feature_enabled(Feature::TuiExtensionsStatusLine, mode == "builtin"); + app.chat_widget.statusline_feature_enabled = mode == "builtin"; for text in ["first prompt", "follow-up"] { let sent = responses::mount_sse_once(&model, responses::sse_completed("ok")).await; app.chat_widget.apply_external_edit(text.into()); diff --git a/codex-rs/tui/src/app/tests/startup_defaults_tests.rs b/codex-rs/tui/src/app/tests/startup_defaults_tests.rs index 94a804b595..d1c34af4b4 100644 --- a/codex-rs/tui/src/app/tests/startup_defaults_tests.rs +++ b/codex-rs/tui/src/app/tests/startup_defaults_tests.rs @@ -3,7 +3,9 @@ use super::*; use crate::app::backend_sessions::InitialBackendSessions; use crate::app::startup::prepare_fresh_startup_config; +use crate::app::startup::startup_config_cwd; use crate::app::startup::startup_model; +use crate::app::startup::statusline_enabled; use crate::app::startup_bootstrap::bootstrap_server_owned_start; use pretty_assertions::assert_eq; @@ -461,15 +463,21 @@ requires_openai_auth = false if !server_owned { server.bootstrap(&config).await?; } + let defaults = crate::config_update::read_effective_config_with_layers( + &server.request_handle(), + startup_config_cwd(&config, &server, &target) + .display() + .to_string(), + ) + .await?; prepare_fresh_startup_config( &mut config, &server, - &target, + &defaults, &cli_kv_overrides, &harness_overrides, &EnvironmentManager::default_for_tests(), - ) - .await?; + ); if server_owned { bootstrap_server_owned_start( &mut server, @@ -677,15 +685,22 @@ async fn fresh_startup_reads_destination_and_cleared_model_uses_catalog() -> Res bootstrap.default_model.as_deref(), Some("stale-client-model") ); + let defaults = crate::config_update::read_effective_config_with_layers( + &server.request_handle(), + startup_config_cwd(&config, &server, &target) + .display() + .to_string(), + ) + .await?; + assert!(!statusline_enabled(&defaults.config)); let defaults_read = prepare_fresh_startup_config( &mut config, &server, - &target, + &defaults, &[], &ConfigOverrides::default(), &EnvironmentManager::default_for_tests(), - ) - .await?; + ); assert!(!defaults_read.prompt_windows_sandbox); assert_eq!(config.model, None); let selected_model = diff --git a/codex-rs/tui/src/bottom_pane/experimental_features_view_tests.rs b/codex-rs/tui/src/bottom_pane/experimental_features_view_tests.rs index c90e919ffd..95a7584b4f 100644 --- a/codex-rs/tui/src/bottom_pane/experimental_features_view_tests.rs +++ b/codex-rs/tui/src/bottom_pane/experimental_features_view_tests.rs @@ -54,6 +54,7 @@ fn experimental_features_display_metadata() { Feature::AnalyticsPlanHistory, Feature::LoginShellPackagePath, Feature::RespectSystemProxy, + Feature::TuiExtensionsStatusLine, ] { let stage = feature.stage(); let (app_tx, _app_rx) = tokio::sync::mpsc::unbounded_channel(); diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__experimental_features_view__tests__experimental_features_tui_extensions_statusline.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__experimental_features_view__tests__experimental_features_tui_extensions_statusline.snap new file mode 100644 index 0000000000..5d0d8485d0 --- /dev/null +++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__experimental_features_view__tests__experimental_features_tui_extensions_statusline.snap @@ -0,0 +1,14 @@ +--- +source: tui/src/bottom_pane/experimental_features_view_tests.rs +expression: buffer_text(&buffer) +--- + + Experimental features + Checked features are configured on. Some experimental features take effect + only in new tasks or after restarting the Codex server. + + +› [ ] Custom status line Restart the TUI, then use /statusline. + + + space toggle · enter save · esc cancel diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index 0378a15d2b..bbc8ca19fd 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -577,6 +577,7 @@ pub(crate) struct ChatWidget { status_account_display: Option, pub(crate) remote_connection: Option, pub(crate) app_server_path_convention: Option, + pub(crate) statusline_feature_enabled: bool, statusline_read: Option, pub(crate) statusline_disconnected: bool, /// Remote app servers cannot read image paths on the TUI host. diff --git a/codex-rs/tui/src/chatwidget/constructor.rs b/codex-rs/tui/src/chatwidget/constructor.rs index c341254251..1e4a4cd4ab 100644 --- a/codex-rs/tui/src/chatwidget/constructor.rs +++ b/codex-rs/tui/src/chatwidget/constructor.rs @@ -154,6 +154,7 @@ impl ChatWidget { status_account_display, remote_connection: None, app_server_path_convention: None, + statusline_feature_enabled: false, statusline_read: None, statusline_disconnected: false, snapshot_local_images: false, diff --git a/codex-rs/tui/src/chatwidget/session_flow.rs b/codex-rs/tui/src/chatwidget/session_flow.rs index 01c5f3c949..56b7140ec6 100644 --- a/codex-rs/tui/src/chatwidget/session_flow.rs +++ b/codex-rs/tui/src/chatwidget/session_flow.rs @@ -65,6 +65,10 @@ impl ChatWidget { } } + pub(crate) fn custom_statusline_enabled(&self) -> bool { + self.statusline_feature_enabled + } + fn on_session_configured_with_display_and_fork_parent_title( &mut self, session: ThreadSessionState, diff --git a/codex-rs/tui/src/chatwidget/status_controls.rs b/codex-rs/tui/src/chatwidget/status_controls.rs index c761194d62..f3f869ee9c 100644 --- a/codex-rs/tui/src/chatwidget/status_controls.rs +++ b/codex-rs/tui/src/chatwidget/status_controls.rs @@ -332,11 +332,7 @@ impl ChatWidget { use crate::bottom_pane::StatuslineProviderActions; let configured_status_line_items = self.configured_status_line_items(); - let providers = if !self - .config - .features - .enabled(codex_features::Feature::TuiExtensionsStatusLine) - { + let providers = if !self.custom_statusline_enabled() { StatuslineProviderActions::Hidden } else if self.thread_params_mode == crate::ThreadParamsMode::Cloud { StatuslineProviderActions::Choose diff --git a/codex-rs/tui/src/chatwidget/statusline_reader.rs b/codex-rs/tui/src/chatwidget/statusline_reader.rs index 8f8595107c..e47bc10449 100644 --- a/codex-rs/tui/src/chatwidget/statusline_reader.rs +++ b/codex-rs/tui/src/chatwidget/statusline_reader.rs @@ -23,7 +23,6 @@ use crate::ui_tree::UiNode; use crate::ui_tree::UiTree; use codex_config::types::StatusLineProviderId; use codex_config::types::StatusLineSelection; -use codex_features::Feature; use codex_protocol::ThreadId; use codex_utils_path_uri::PathUri; use std::time::Duration; @@ -80,10 +79,7 @@ impl ChatWidget { .app_event_tx .voice_only .load(std::sync::atomic::Ordering::Relaxed) - || !self - .config - .features - .enabled(Feature::TuiExtensionsStatusLine) + || !self.custom_statusline_enabled() { return None; } diff --git a/codex-rs/tui/src/chatwidget/statusline_reader_tests.rs b/codex-rs/tui/src/chatwidget/statusline_reader_tests.rs index f83e64bb0d..237b58820e 100644 --- a/codex-rs/tui/src/chatwidget/statusline_reader_tests.rs +++ b/codex-rs/tui/src/chatwidget/statusline_reader_tests.rs @@ -86,7 +86,7 @@ async fn custom_statusline_requests_headline_and_billing_with_no_native_items() server: "fixture".into(), tool: "line".into(), }))); - chat.set_feature_enabled(Feature::TuiExtensionsStatusLine, /*enabled*/ true); + chat.statusline_feature_enabled = true; chat.refresh_status_line(); let events: Vec<_> = std::iter::from_fn(|| rx.try_recv().ok()).collect(); @@ -111,14 +111,13 @@ async fn statusline_reader_waits_for_the_displayed_thread_and_keeps_its_result() chat.local_settings.tui.status_line = Some(Vec::new()); chat.thread_id = Some(ThreadId::new()); chat.local_settings.tui.status_line_provider = Some(selected.clone()); - chat.set_feature_enabled(Feature::TuiExtensionsStatusLine, /*enabled*/ false); chat.refresh_status_line(); assert!(read_events(&mut rx).is_empty()); chat.local_settings.tui.status_line_provider = Some(Box::new(StatusLineSelection::Builtin( BuiltinStatusLine::Default, ))); - chat.set_feature_enabled(Feature::TuiExtensionsStatusLine, /*enabled*/ true); + chat.statusline_feature_enabled = true; chat.refresh_status_line(); assert!(read_events(&mut rx).is_empty()); chat.thread_id = None; @@ -224,7 +223,7 @@ impl Reader { ThreadParamsMode::Cloud, ); chat.thread_id = Some(ThreadId::new()); - chat.set_feature_enabled(Feature::TuiExtensionsStatusLine, /*enabled*/ true); + chat.statusline_feature_enabled = true; chat.local_settings.tui.status_line_provider = Some(Box::new(StatusLineSelection::Mcp(StatusLineProviderId { server: "fixture".into(), diff --git a/codex-rs/tui/src/chatwidget/tests/status_surface_previews.rs b/codex-rs/tui/src/chatwidget/tests/status_surface_previews.rs index 21dbc0d032..0d976f6473 100644 --- a/codex-rs/tui/src/chatwidget/tests/status_surface_previews.rs +++ b/codex-rs/tui/src/chatwidget/tests/status_surface_previews.rs @@ -154,7 +154,7 @@ async fn status_surface_preview_lines_live_only_snapshot() { #[tokio::test] async fn status_line_setup_popup_live_only_snapshot() { let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await; - chat.set_feature_enabled(Feature::TuiExtensionsStatusLine, /*enabled*/ true); + chat.statusline_feature_enabled = true; cache_project_root(&mut chat, "preview-live-root"); chat.status_line_branch = Some("feature/live-preview-branch".to_string()); chat.thread_name = Some("Live preview thread".to_string()); @@ -173,7 +173,7 @@ async fn status_line_setup_popup_live_only_snapshot() { #[tokio::test] async fn status_line_setup_popup_cloud_hides_create() { let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await; - chat.set_feature_enabled(Feature::TuiExtensionsStatusLine, /*enabled*/ true); + chat.statusline_feature_enabled = true; chat.thread_params_mode = crate::ThreadParamsMode::Cloud; assert_chatwidget_snapshot!( "status_line_setup_popup_native_cloud", diff --git a/codex-rs/tui/src/config_update.rs b/codex-rs/tui/src/config_update.rs index 25e35f1425..d2916dc1ce 100644 --- a/codex-rs/tui/src/config_update.rs +++ b/codex-rs/tui/src/config_update.rs @@ -441,12 +441,20 @@ pub(crate) struct EffectiveConfig { pub(crate) async fn read_effective_config_with_layers( request_handle: &AppServerRequestHandle, cwd: String, +) -> Result { + read_effective_config_with_optional_layers(request_handle, cwd, /*include_layers*/ true).await +} + +pub(crate) async fn read_effective_config_with_optional_layers( + request_handle: &AppServerRequestHandle, + cwd: String, + include_layers: bool, ) -> Result { request_handle .request_typed(ClientRequest::ConfigRead { request_id: RequestId::String(format!("tui-config-read-{}", Uuid::new_v4())), params: ConfigReadParams { - include_layers: true, + include_layers, cwd: Some(cwd), }, }) diff --git a/codex-rs/tui/src/statusline_metrics.rs b/codex-rs/tui/src/statusline_metrics.rs index 29670257b5..5e5e787d2c 100644 --- a/codex-rs/tui/src/statusline_metrics.rs +++ b/codex-rs/tui/src/statusline_metrics.rs @@ -4,7 +4,6 @@ use crate::chatwidget::ChatWidget; use crate::legacy_core::config::Config; use codex_config::types::DEFAULT_OTEL_ENVIRONMENT; use codex_config::types::OtelExporterKind; -use codex_features::Feature; use codex_otel::MetricsClient; #[derive(Default)] @@ -59,11 +58,7 @@ impl StatuslineMetrics { return; } self.first_prompt_recorded = true; - let mode = if !chat - .config_ref() - .features - .enabled(Feature::TuiExtensionsStatusLine) - { + let mode = if !chat.custom_statusline_enabled() { "feature_off" } else if chat.selected_statusline_provider().is_some() { "custom"