Save subagent and memory opt-ins through the app server (#43113)

## What changed

Route the TUI's subagent and memory enable prompts through server config writes for new threads, leaving the current thread unchanged. Report success, configuration overrides, or failures after the write completes, and clarify the scope in the prompts.

Write both `features.memories` and the legacy `features.memory_tool` key for compatibility with older app servers.

## Testing

Extend tests to cover writes to the selected server config, preservation of current settings, legacy memory key updates, and managed configuration overrides. Update prompt snapshots and verify that confirmation emits the new save event.

GitOrigin-RevId: ec331db675b38102851899a4aa878d6fe8e9606e
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-05 22:16:26 +00:00
1 parent a31c18ab7a
commit fc748ab8d5
14 files changed
+184 -149

No files matched your search

@@ -1,11 +1,12 @@
---
source: tui/src/chatwidget/tests/popups_and_settings.rs
expression: popup
expression: "render_bottom_popup(&chat, 80)"
---
Enable memories?
Memories are currently disabled in your config.
Memories are disabled in this TUI session.
› 1. Yes, enable Save the setting now. You will need a new session to use it.
› 1. Yes, enable Save on the server for new threads. This thread is
unchanged.
2. Not now Keep memories disabled.
Learn more: https://developers.openai.com/codex/memories
@@ -1,11 +1,12 @@
---
source: tui/src/chatwidget/tests/popups_and_settings.rs
expression: popup
expression: "render_bottom_popup(&chat, 80)"
---
Enable subagents?
Subagents are currently disabled in your config.
Subagents are disabled in this TUI session.
› 1. Yes, enable Save the setting now. You will need a new session to use it.
› 1. Yes, enable Save on the server for new threads. This thread is
unchanged.
2. Not now Keep subagents disabled.
Press enter to confirm or esc to go back
@@ -3177,61 +3177,33 @@ async fn experimental_popup_loading_snapshot() {
}
#[tokio::test]
async fn multi_agent_enable_prompt_snapshot() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
chat.open_multi_agent_enable_prompt();
let popup = render_bottom_popup(&chat, /*width*/ 80);
assert_chatwidget_snapshot!("multi_agent_enable_prompt", popup);
}
#[tokio::test]
async fn multi_agent_enable_prompt_updates_feature_and_emits_notice() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
chat.open_multi_agent_enable_prompt();
chat.handle_key_event(KeyEvent::from(KeyCode::Enter));
assert_matches!(
rx.try_recv(),
Ok(AppEvent::UpdateFeatureFlags { updates }) if updates == vec![(Feature::Collab, true)]
);
let cell = match rx.try_recv() {
Ok(AppEvent::InsertHistoryCell(cell)) => cell,
other => panic!("expected InsertHistoryCell event, got {other:?}"),
};
let rendered = lines_to_single_string(&cell.display_lines(/*width*/ 120));
assert!(rendered.contains("Subagents will be enabled in the next session."));
}
#[tokio::test]
async fn memories_enable_prompt_snapshot() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
chat.set_feature_enabled(Feature::MemoryTool, /*enabled*/ false);
chat.open_memories_popup();
let popup = render_bottom_popup(&chat, /*width*/ 80);
assert_chatwidget_snapshot!("memories_enable_prompt", popup);
}
#[tokio::test]
async fn memories_enable_prompt_updates_feature_without_notice() {
async fn feature_enable_prompts_snapshot() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
chat.set_feature_enabled(Feature::MemoryTool, /*enabled*/ false);
chat.open_memories_popup();
chat.open_feature_enable_prompt(Feature::Collab);
assert_chatwidget_snapshot!(
"multi_agent_enable_prompt",
render_bottom_popup(&chat, /*width*/ 80)
);
chat.handle_key_event(KeyEvent::from(KeyCode::Enter));
assert_matches!(
rx.try_recv(),
Ok(AppEvent::UpdateFeatureFlags { updates }) if updates == vec![(Feature::MemoryTool, true)]
Ok(AppEvent::EnableFeatureForNewThreads(Feature::Collab))
);
assert!(
rx.try_recv().is_err(),
"memory enable prompt should not emit the success notice before persistence succeeds"
chat.open_memories_popup();
assert_chatwidget_snapshot!(
"memories_enable_prompt",
render_bottom_popup(&chat, /*width*/ 80)
);
chat.handle_key_event(KeyEvent::from(KeyCode::Enter));
assert_matches!(
rx.try_recv(),
Ok(AppEvent::EnableFeatureForNewThreads(Feature::MemoryTool))
);
assert!(rx.try_recv().is_err());
assert!(!chat.has_active_view());
}
#[tokio::test]