Persist server-advertised experimental features from the TUI (#42674)

## What changed

- Save writable `/experimental` selections through `config/batchWrite`, including features that are not known to the local client.
- Refresh configured values after writes and surface timeouts, failures, and higher-priority overrides without changing the active task's settings.
- Serialize saves and discovery, let accepted writes finish after the popup closes, and retain uncertain selections for explicit retry.

## Testing

- Cover new server feature keys, server defaults, overrides, write and readback failures, timeouts, selected config profiles, and popup retry behavior.

GitOrigin-RevId: acee4e10cbb8c2fce9211e8fadd3cd67fa0eb1a5
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-04 04:55:40 +00:00
1 parent b995d06050
commit 048a936a23
18 files changed
+647 -81

No files matched your search

@@ -3001,13 +3001,15 @@ async fn experimental_features_popup_snapshot() {
let worktrees = Feature::Worktrees.stage();
let features = vec![
ExperimentalFeatureItem {
feature: Some(Feature::JsRepl),
key: Feature::JsRepl.key().to_string(),
writable: true,
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: Some(Feature::ShellTool),
key: Feature::ShellTool.key().to_string(),
writable: true,
name: "Shell tool".to_string(),
description: "Allow the model to run shell commands.".to_string(),
enabled: true,
@@ -3021,6 +3023,7 @@ async fn experimental_features_popup_snapshot() {
];
let view = ExperimentalFeaturesView::new(
features,
ThreadId::new(),
/*catalog_rx*/ None,
chat.app_event_tx.clone(),
crate::keymap::RuntimeKeymap::defaults().list,
@@ -3038,11 +3041,13 @@ async fn experimental_features_popup_snapshot() {
.expect("valid experimental-feature chord");
let view = ExperimentalFeaturesView::new(
vec![ExperimentalFeatureItem {
feature: Some(Feature::ShellTool),
key: Feature::ShellTool.key().to_string(),
writable: true,
name: "Shell tool".to_string(),
description: "Allow the model to run shell commands.".to_string(),
enabled: true,
}],
ThreadId::new(),
/*catalog_rx*/ None,
chat.app_event_tx.clone(),
keymap.list,
@@ -3056,17 +3061,21 @@ async fn experimental_features_popup_snapshot() {
async fn experimental_features_toggle_saves_on_exit() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
let mut keymap = crate::keymap::RuntimeKeymap::defaults().list;
keymap.cancel = vec![crate::key_hint::plain(KeyCode::F(2))];
let expected_feature = Feature::JsRepl;
let view = ExperimentalFeaturesView::new(
vec![ExperimentalFeatureItem {
feature: Some(expected_feature),
key: expected_feature.key().to_string(),
writable: true,
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,
}],
ThreadId::new(),
/*catalog_rx*/ None,
chat.app_event_tx.clone(),
crate::keymap::RuntimeKeymap::defaults().list,
keymap,
);
chat.bottom_pane.show_view(Box::new(view));
@@ -3077,12 +3086,17 @@ async fn experimental_features_toggle_saves_on_exit() {
"expected no updates until saving the popup"
);
chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
chat.handle_key_event(KeyEvent::new(KeyCode::F(2), KeyModifiers::NONE));
assert!(
!chat.has_active_view(),
"remapped cancel must save and close"
);
let mut updates = None;
while let Ok(event) = rx.try_recv() {
if let AppEvent::UpdateFeatureFlags {
if let AppEvent::SaveExperimentalFeatures {
updates: event_updates,
..
} = event
{
updates = Some(event_updates);
@@ -3090,8 +3104,8 @@ async fn experimental_features_toggle_saves_on_exit() {
}
}
let updates = updates.expect("expected UpdateFeatureFlags event");
assert_eq!(updates, vec![(expected_feature, true)]);
let updates = updates.expect("expected SaveExperimentalFeatures event");
assert_eq!(updates, vec![(expected_feature.key().to_string(), true)]);
}
#[tokio::test]