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

@@ -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.