Discover TUI experimental features from the server (#42425)

## What changed

- Load the `/experimental` catalog from the running server for the active thread, with loading, empty, and failure states in the popup.
- Show beta features in server order and preserve server-reported names, descriptions, and configured values. Mark features as read-only when the local config writer cannot safely update them.
- Persist only changed, writable feature flags. Bound discovery with page-size and page-count limits, repeated-cursor detection, deduplication, cancellation, and a timeout.

## Testing

- Cover paginated discovery, malformed or unresponsive servers, popup cancellation, read-only controls, selective writes, and the new popup states.

GitOrigin-RevId: 1f49eb961c8ab220a466e15f032c1dc61ed86d38
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-03 02:49:36 +00:00
1 parent 38ba8cdceb
commit cac96cd7b1
20 files changed
+630 -71

No files matched your search

+14 -15
View File
@@ -87,22 +87,21 @@ impl ChatWidget {
}
pub(crate) fn open_experimental_popup(&mut self) {
let features: Vec<ExperimentalFeatureItem> = FEATURES
.iter()
.filter_map(|spec| {
let name = spec.stage.experimental_menu_name()?;
let description = spec.stage.experimental_menu_description()?;
Some(ExperimentalFeatureItem {
feature: spec.id,
name: name.to_string(),
description: description.to_string(),
enabled: self.config.features.enabled(spec.id),
})
})
.collect();
let Some(thread_id) = self.thread_id() else {
self.add_info_message(
"Experimental features are unavailable until startup completes.".to_string(),
/*hint*/ None,
);
return;
};
let (response_tx, response_rx) = tokio::sync::oneshot::channel();
self.app_event_tx.send(AppEvent::FetchExperimentalFeatures {
thread_id,
response_tx,
});
let view = ExperimentalFeaturesView::new(
features,
Vec::new(),
Some(response_rx),
self.app_event_tx.clone(),
self.bottom_pane.list_keymap(),
);
@@ -0,0 +1,12 @@
---
source: tui/src/chatwidget/tests/popups_and_settings.rs
expression: "render_bottom_popup(&chat, 80)"
---
Experimental features
Checked features are configured on. Some experimental features take effect
only in new tasks or after restarting the Codex server.
Loading server experiments…
Press space to select or enter to save
@@ -3,11 +3,12 @@ source: tui/src/chatwidget/tests/popups_and_settings.rs
expression: popup
---
Experimental features
Toggle experimental features. Changes are saved to config.toml.
Checked features are configured on. Some experimental features take effect
only in new tasks or after restarting the Codex server.
› [ ] JavaScript REPL Enable a persistent Node-backed JavaScript REPL for
interactive website debugging and other inline
JavaScript execution capabilities.
[x] Shell tool Allow the model to run shell commands.
Press space to select or enter to save for next conversation
Press space to select or enter to save
@@ -3,8 +3,9 @@ source: tui/src/chatwidget/tests/popups_and_settings.rs
expression: popup
---
Experimental features
Toggle experimental features. Changes are saved to config.toml.
Checked features are configured on. Some experimental features take effect
only in new tasks or after restarting the Codex server.
› [x] Shell tool Allow the model to run shell commands.
Press space to select or ctrl + x enter to save for next conversation
Press space to select or ctrl + x enter to save
-1
View File
@@ -122,7 +122,6 @@ pub(super) use codex_config::types::ApprovalsReviewer;
pub(super) use codex_config::types::Notifications;
pub(super) use codex_config::types::WindowsSandboxModeToml;
pub(super) use codex_core_plugins::OPENAI_CURATED_MARKETPLACE_NAME;
pub(super) use codex_features::FEATURES;
pub(super) use codex_features::Feature;
pub(super) use codex_git_utils::CommitLogEntry;
pub(super) use codex_models_manager::test_support::construct_model_info_offline_for_tests;
@@ -1,5 +1,6 @@
use super::*;
use crate::app_event::ConnectorsSnapshot;
use crate::bottom_pane::ExperimentalFeatureItem;
use crate::chatwidget::connectors::ConnectorsCacheState;
use codex_app_server_protocol::HookErrorInfo;
use codex_app_server_protocol::HooksListEntry;
@@ -11,7 +12,6 @@ use codex_app_server_protocol::PluginShareContext;
use codex_app_server_protocol::PluginShareDiscoverability;
use codex_app_server_protocol::PluginSource;
use codex_connectors::AppInfo;
use codex_features::Stage;
use pretty_assertions::assert_eq;
#[tokio::test]
@@ -3000,13 +3000,13 @@ async fn experimental_features_popup_snapshot() {
let features = vec![
ExperimentalFeatureItem {
feature: Feature::JsRepl,
feature: Some(Feature::JsRepl),
name: "JavaScript REPL".to_string(),
description: "Enable a persistent Node-backed JavaScript REPL for interactive website debugging and other inline JavaScript execution capabilities.".to_string(),
enabled: false,
},
ExperimentalFeatureItem {
feature: Feature::ShellTool,
feature: Some(Feature::ShellTool),
name: "Shell tool".to_string(),
description: "Allow the model to run shell commands.".to_string(),
enabled: true,
@@ -3014,6 +3014,7 @@ async fn experimental_features_popup_snapshot() {
];
let view = ExperimentalFeaturesView::new(
features,
/*catalog_rx*/ None,
chat.app_event_tx.clone(),
crate::keymap::RuntimeKeymap::defaults().list,
);
@@ -3030,11 +3031,12 @@ async fn experimental_features_popup_snapshot() {
.expect("valid experimental-feature chord");
let view = ExperimentalFeaturesView::new(
vec![ExperimentalFeatureItem {
feature: Feature::ShellTool,
feature: Some(Feature::ShellTool),
name: "Shell tool".to_string(),
description: "Allow the model to run shell commands.".to_string(),
enabled: true,
}],
/*catalog_rx*/ None,
chat.app_event_tx.clone(),
keymap.list,
);
@@ -3050,11 +3052,12 @@ async fn experimental_features_toggle_saves_on_exit() {
let expected_feature = Feature::JsRepl;
let view = ExperimentalFeaturesView::new(
vec![ExperimentalFeatureItem {
feature: expected_feature,
feature: Some(expected_feature),
name: "JavaScript REPL".to_string(),
description: "Enable a persistent Node-backed JavaScript REPL for interactive website debugging and other inline JavaScript execution capabilities.".to_string(),
enabled: false,
}],
/*catalog_rx*/ None,
chat.app_event_tx.clone(),
crate::keymap::RuntimeKeymap::defaults().list,
);
@@ -3085,23 +3088,29 @@ async fn experimental_features_toggle_saves_on_exit() {
}
#[tokio::test]
async fn experimental_popup_omits_stable_guardian_approval() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
let guardian_stage = FEATURES
.iter()
.find(|spec| spec.id == Feature::GuardianApproval)
.map(|spec| spec.stage)
.expect("expected guardian approval feature metadata");
assert_eq!(guardian_stage, Stage::Stable);
async fn experimental_popup_loading_snapshot() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
chat.open_experimental_popup();
let popup = render_bottom_popup(&chat, /*width*/ 120);
assert!(
!popup.contains("Auto-review"),
"expected stable auto-review feature to be omitted from experimental popup, got:\n{popup}"
assert!(!chat.has_active_view());
let cell = assert_matches!(rx.try_recv(), Ok(AppEvent::InsertHistoryCell(cell)) => cell);
insta::assert_snapshot!(
"experimental_features_startup",
lines_to_single_string(&cell.display_lines(/*width*/ 80))
);
assert!(rx.try_recv().is_err());
chat.thread_id = Some(ThreadId::new());
chat.open_experimental_popup();
let AppEvent::FetchExperimentalFeatures { response_tx, .. } = rx.try_recv().unwrap() else {
panic!("expected experimental discovery request");
};
assert_chatwidget_snapshot!(
"experimental_features_loading",
render_bottom_popup(&chat, /*width*/ 80)
);
chat.handle_key_event(KeyEvent::new(KeyCode::Esc, KeyModifiers::NONE));
assert!(response_tx.send(Ok(Vec::new())).is_err());
assert!(!chat.has_active_view());
assert!(rx.try_recv().is_err());
}
#[tokio::test]
@@ -0,0 +1,5 @@
---
source: tui/src/chatwidget/tests/popups_and_settings.rs
expression: lines_to_single_string(&cell.display_lines(80))
---
• Experimental features are unavailable until startup completes.