Add a reasoning summary picker to /config (#62905)

## What changed

Choose Auto, Concise, Detailed, or None under Sessions in `/config`.
The picker saves `model_reasoning_summary` through the connected app server
for new chats. The panel shows the effective value and reports when a config
or launch setting overrides the saved choice.

## Testing

Add coverage for the picker and for saving Auto explicitly when the setting
was previously unset. Verify that the active chat keeps its setting and
that the panel reflects a profile override.

GitOrigin-RevId: cd027a6b16879a656b8d8b21488f0588c98f9077
This commit is contained in:
Eric Traut
2026-11-21 05:56:42 +00:00
committed by copyberry
parent 553c7f8ea6
commit f63f8b9bc6
15 changed files with 312 additions and 2 deletions
+93
View File
@@ -6,8 +6,101 @@ use crate::config_panel::ConfigToggle;
use crate::config_update::format_config_error;
use crate::legacy_core::config::load_config_toml_with_layer_stack;
use crate::local_settings::LocalSettings;
use codex_app_server_protocol::RequestId;
use serde::de::IgnoredAny;
impl App {
pub(super) async fn update_reasoning_summary(
&mut self,
server: &AppServerSession,
requested: Option<codex_protocol::config_types::ReasoningSummary>,
) {
let result = tokio::time::timeout(std::time::Duration::from_secs(5), async {
if self.reconnect.offline {
color_eyre::eyre::bail!(
"Reconnect to the app server to change reasoning summaries"
);
}
let handle = server.request_handle();
if let Some(summary) = requested {
handle
.request_typed::<IgnoredAny>(ClientRequest::ConfigBatchWrite {
request_id: RequestId::String(Uuid::new_v4().to_string()),
params: ConfigBatchWriteParams {
edits: vec![crate::config_update::replace_config_value(
"model_reasoning_summary",
serde_json::json!(summary),
)],
file_path: None,
expected_version: None,
reload_user_config: false,
},
})
.await?;
}
let cwd = super::startup::startup_config_cwd(
self.chat_widget.config_ref(),
server,
&self.app_server_target,
);
let effective = crate::config_update::read_effective_config_if_supported(handle, cwd)
.await?
.ok_or_else(|| {
color_eyre::eyre::eyre!(
"Update the connected app server to change reasoning summaries"
)
})?;
let mut summary = effective.config.model_reasoning_summary;
if matches!(
&self.app_server_target,
crate::AppServerTarget::Remote { .. } | crate::AppServerTarget::LocalDaemon { .. }
) {
let config = self
.rebuild_config_for_cwd(self.chat_widget.config_ref().cwd.to_path_buf())
.await
.unwrap_or_else(|_| self.config.clone());
if super::new_session::has_launch_setting(
&config,
&self.cli_kv_overrides,
"model_reasoning_summary",
) {
summary = config.model_reasoning_summary;
}
}
Ok::<_, color_eyre::Report>(summary)
})
.await
.map_err(|_| color_eyre::eyre::eyre!("server timed out"))
.and_then(std::convert::identity);
match result {
Ok(effective) => {
self.chat_widget.config_panel_reasoning_summary =
Some((server.backend_id(), effective));
let notice = requested.map(|summary| {
if effective == Some(summary) {
"Saved · applies to new chats".into()
} else {
"Saved · overridden by config or launch setting".into()
}
});
self.chat_widget.refresh_config_panel(notice);
}
Err(error) => {
let error = format!(
"Could not confirm reasoning summary setting: {}",
format_config_error(&error)
);
self.chat_widget.config_panel_reasoning_summary = None;
let updated = self
.chat_widget
.refresh_config_panel(requested.map(|_| error.clone()));
if requested.is_some() && !updated {
self.chat_widget.add_error_message(error);
}
}
}
}
pub(super) async fn save_config_preference(
&mut self,
tui: &mut tui::Tui,
@@ -25,6 +25,66 @@ fn open_effects_editor(app: &mut App) {
);
}
#[tokio::test]
async fn reasoning_summary_saves_explicit_auto_for_new_chats() -> Result<()> {
use codex_protocol::config_types::ReasoningSummary;
let mut app = Box::pin(make_test_app()).await;
let profile = tempfile::tempdir()?;
let path = profile.path().join("work.config.toml");
std::fs::write(&path, "")?;
app.loader_overrides.user_config_path = Some(path.clone().abs());
app.loader_overrides.user_config_profile = Some("work".parse()?);
app.app_server_target = AppServerTarget::LocalDaemon {
allow_embedded_fallback: true,
endpoint: crate::RemoteAppServerEndpoint::UnixSocket {
socket_path: profile.path().join("daemon.sock").abs(),
},
};
app.config = app
.rebuild_config_for_cwd(app.config.cwd.to_path_buf())
.await?;
let server = Box::pin(crate::start_embedded_app_server_for_picker(&app.config)).await?;
let current = app.chat_widget.config_ref().model_reasoning_summary;
app.chat_widget.open_config_panel();
app.update_reasoning_summary(&server, /*requested*/ None)
.await;
assert_eq!(
app.chat_widget.config_panel_reasoning_summary,
Some((server.backend_id(), None))
);
assert!(
!std::fs::read_to_string(&app.local_settings.user_config_path)
.unwrap_or_default()
.contains("model_reasoning_summary")
);
app.update_reasoning_summary(&server, Some(ReasoningSummary::Auto))
.await;
let saved: toml::Value = toml::from_str(&std::fs::read_to_string(
&app.local_settings.user_config_path,
)?)?;
assert_eq!(saved["model_reasoning_summary"].as_str(), Some("auto"));
assert_eq!(
app.chat_widget.config_ref().model_reasoning_summary,
current
);
assert_eq!(
app.chat_widget.config_panel_reasoning_summary,
Some((server.backend_id(), Some(ReasoningSummary::Auto)))
);
std::fs::write(&path, "model_reasoning_summary = 'detailed'\n")?;
app.update_reasoning_summary(&server, Some(ReasoningSummary::Concise))
.await;
assert_eq!(
app.chat_widget.config_panel_reasoning_summary,
Some((server.backend_id(), Some(ReasoningSummary::Detailed)))
);
server.shutdown().await?;
Ok(())
}
fn next_config_preference(rx: &mut UnboundedReceiver<AppEvent>) -> Result<ConfigPreference> {
let AppEvent::SaveConfigPreference(preference) = rx.try_recv()? else {
panic!("expected config preference save");
+12
View File
@@ -94,6 +94,8 @@ impl App {
| AppEvent::TestConfigNotification
| AppEvent::SendConfigTestNotification { .. }
| AppEvent::SaveConfigPreference(_)
| AppEvent::SaveReasoningSummary { .. }
| AppEvent::RefreshConfigReasoningSummary
| AppEvent::CopyWarning(_)
| AppEvent::UpdateWarnings { .. }
| AppEvent::CopySelection { .. }
@@ -4138,6 +4140,16 @@ impl App {
AppEvent::SaveConfigPreference(preference) => {
self.save_config_preference(tui, preference).await;
}
AppEvent::SaveReasoningSummary { backend, summary } => {
if backend == app_server.backend_id() {
self.update_reasoning_summary(app_server, Some(summary)).await;
}
tui.frame_requester().schedule_frame();
}
AppEvent::RefreshConfigReasoningSummary => {
self.update_reasoning_summary(app_server, /*requested*/ None).await;
tui.frame_requester().schedule_frame();
}
AppEvent::PersistAgentsOverviewGrouping(grouping) => {
self.persist_agents_overview_grouping(grouping).await;
}
+6
View File
@@ -254,6 +254,8 @@ impl App {
pane.opening = None;
}
self.reconnect.offline = true;
self.chat_widget.config_panel_reasoning_summary = None;
self.chat_widget.refresh_config_panel(/*notice*/ None);
self.account_email_request_id = None;
// Cached blank sessions are usable only while this connection owns a subscription.
self.agents_overview.blank_sessions.retain(|id, _| {
@@ -669,6 +671,10 @@ impl App {
server.reconnect(app_server.request_handle(), self.app_event_tx.clone());
}
self.reconnect.offline = false;
if self.chat_widget.refresh_config_panel(/*notice*/ None) {
self.app_event_tx
.send(AppEvent::RefreshConfigReasoningSummary);
}
if self.reconnect.presentation == ReconnectPresentation::Overview {
self.refresh_agents_overview_threads(app_server);
}
@@ -308,6 +308,8 @@ async fn disconnected_config_panel_keeps_input() -> Result<()> {
app.handle_tui_event(&mut tui, &mut session, TuiEvent::Key(KeyCode::Enter.into()))
.await?;
let refresh = events.try_recv()?;
assert!(matches!(refresh, AppEvent::RefreshConfigReasoningSummary));
assert!(app.chat_widget.has_active_view());
app.app_server_target = AppServerTarget::Remote {
endpoint: crate::resolve_remote_addr("ws://127.0.0.1:9")?,
+9
View File
@@ -1971,6 +1971,15 @@ pub(crate) enum AppEvent {
/// Requests saving a local `/config` preference and refreshing its effective value.
SaveConfigPreference(crate::config_panel::ConfigPreference),
/// Save the connected server's reasoning-summary default for new chats.
SaveReasoningSummary {
backend: BackendId,
summary: codex_protocol::config_types::ReasoningSummary,
},
/// Refresh the connected server's reasoning-summary default without writing config.
RefreshConfigReasoningSummary,
/// Save the transcript renderer preference for the next launch only.
FullscreenTranscriptSelected {
enabled: bool,
+3
View File
@@ -47,6 +47,7 @@ use crate::app_event::HistoryLookupResponse;
use crate::app_server_approval_conversions::file_update_changes_to_display;
use crate::approval_events::ApplyPatchApprovalRequestEvent;
use crate::approval_events::ExecApprovalRequestEvent;
use crate::backend_id::BackendId;
use crate::bottom_pane::StatusLineItem;
use crate::bottom_pane::StatusLineSetupView;
use crate::bottom_pane::StatusSurfacePreviewData;
@@ -137,6 +138,7 @@ use codex_protocol::approvals::GuardianAssessmentStatus;
use codex_protocol::config_types::CollaborationMode;
use codex_protocol::config_types::CollaborationModeMask;
use codex_protocol::config_types::ModeKind;
use codex_protocol::config_types::ReasoningSummary;
use codex_protocol::config_types::Settings;
#[cfg(target_os = "windows")]
use codex_protocol::config_types::WindowsSandboxLevel;
@@ -543,6 +545,7 @@ pub(crate) struct ChatWidget {
config: Config,
pub(crate) local_settings: crate::local_settings::LocalSettings,
pub(crate) config_panel_tui: codex_config::types::Tui,
pub(crate) config_panel_reasoning_summary: Option<(BackendId, Option<ReasoningSummary>)>,
raw_output_mode: bool,
/// Runtime value resolved by core. `config.service_tier` remains the explicit user choice.
effective_service_tier: Option<String>,
@@ -33,6 +33,17 @@ impl ChatWidget {
self.app_event_tx
.send(crate::app_event::AppEvent::Provider(event));
}
ConfigEditor::ReasoningSummary => {
let Some((backend, summary)) = self.config_panel_reasoning_summary else {
self.config_editor_open_failed("Reasoning summary is unavailable.".into());
return;
};
let keymap = self.bottom_pane.list_keymap();
self.bottom_pane
.show_selection_view(crate::config_panel::reasoning_summary(
summary, backend, &keymap,
));
}
ConfigEditor::Theme => self.open_theme_picker(),
ConfigEditor::Effects => {
let keymap = self.bottom_pane.list_keymap();
@@ -220,6 +231,10 @@ impl ChatWidget {
self.local_settings.transcript_mode,
),
custom_notification_filters: self.local_settings.custom_notification_filters,
reasoning_summary: self
.config_panel_reasoning_summary
.map(|(_, summary)| summary)
.ok_or("Reconnect or update the connected server to change this setting"),
}
}
@@ -129,6 +129,7 @@ impl ChatWidget {
config,
local_settings,
config_panel_tui,
config_panel_reasoning_summary: None,
effective_service_tier,
skills_all: Vec::new(),
skills_initial_state: None,
@@ -587,7 +587,10 @@ impl ChatWidget {
self.open_status_line_setup();
}
SlashCommand::Config => {
self.config_panel_reasoning_summary = None;
self.open_config_panel();
self.app_event_tx
.send(AppEvent::RefreshConfigReasoningSummary);
}
SlashCommand::Theme => {
self.open_theme_picker();
@@ -28,6 +28,7 @@ const STATUS: ConfigPanelStatus = ConfigPanelStatus {
copy_on_select: true,
right_click_paste: Ok(false),
custom_notification_filters: false,
reasoning_summary: Ok(None),
};
fn panel() -> (ConfigPanel, UnboundedReceiver<AppEvent>) {
@@ -327,6 +328,29 @@ fn session_picker_layout_uses_editor_handoff_and_saves_choice() {
));
}
#[test]
fn reasoning_summary_picker_saves_explicit_auto() {
use codex_protocol::config_types::ReasoningSummary;
let (tx, mut rx) = unbounded_channel();
let keymap = RuntimeKeymap::defaults().list;
let backend = crate::backend_id::BackendId::new();
let mut picker = ListSelectionView::new(
reasoning_summary(/*configured*/ None, backend, &keymap),
AppEventSender::new(tx),
keymap,
);
insta::assert_snapshot!(
"config_reasoning_summary_choice",
render(&picker, /*width*/ 100)
);
picker.handle_key_event(KeyCode::Enter.into());
assert!(matches!(
rx.try_recv().expect("save choice event"),
AppEvent::SaveReasoningSummary { backend: saved_backend, summary: ReasoningSummary::Auto } if saved_backend == backend
));
}
#[test]
fn mouse_scroll_speed_picker_preserves_a_custom_value_and_saves_a_preset() {
let (mut panel, mut rx) = panel();
+25
View File
@@ -12,6 +12,7 @@ pub(crate) use render::effects;
pub(crate) use render::effects_with_toggle_states;
pub(crate) use render::mouse_scroll_speed;
pub(crate) use render::notification_condition;
pub(crate) use render::reasoning_summary;
pub(crate) use render::resume_directory;
pub(crate) use render::right_click_paste;
pub(crate) use render::session_picker_layout;
@@ -31,6 +32,7 @@ use codex_config::types::NotificationCondition;
use codex_config::types::Notifications;
use codex_config::types::RightClickPaste;
use codex_config::types::Tui;
use codex_protocol::config_types::ReasoningSummary;
use std::sync::Arc;
use std::sync::Mutex;
use std::time::Instant;
@@ -60,6 +62,7 @@ pub(crate) enum ConfigEditor {
TerminalTitle,
Keyboard,
ModelProviders,
ReasoningSummary,
MouseScrollSpeed,
SessionPickerLayout,
ResumeDirectory,
@@ -74,6 +77,16 @@ pub(crate) enum ResumeCurrentAvailability {
RequiresCwdOverride,
}
fn reasoning_summary_label(summary: Option<ReasoningSummary>) -> &'static str {
match summary {
None => "Auto (default)",
Some(ReasoningSummary::Auto) => "Auto",
Some(ReasoningSummary::Concise) => "Concise",
Some(ReasoningSummary::Detailed) => "Detailed",
Some(ReasoningSummary::None) => "None",
}
}
/// Effective state the panel cannot derive from the `Tui` preferences alone.
#[derive(Clone, Copy)]
pub(crate) struct ConfigPanelStatus {
@@ -81,6 +94,7 @@ pub(crate) struct ConfigPanelStatus {
pub(crate) copy_on_select: bool,
pub(crate) right_click_paste: Result<bool, &'static str>,
pub(crate) custom_notification_filters: bool,
pub(crate) reasoning_summary: Result<Option<ReasoningSummary>, &'static str>,
}
/// State shared by the panel that queued an editor and the event that will open it.
@@ -143,6 +157,10 @@ impl ConfigEditor {
fn value(self, tui: &Tui, status: ConfigPanelStatus) -> ConfigSettingValue {
let label = match self {
Self::ModelProviders => "Choose".to_string(),
Self::ReasoningSummary => match status.reasoning_summary {
Ok(summary) => reasoning_summary_label(summary).into(),
Err(reason) => return ConfigSettingValue::Unavailable { reason },
},
Self::Theme => tui.theme.clone().unwrap_or_else(|| "Automatic".to_string()),
Self::MouseScrollSpeed => format!("{}×", tui.mouse_scroll_speed.unwrap_or(1.0)),
Self::SessionPickerLayout => match tui.session_picker_view.unwrap_or_default() {
@@ -427,6 +445,13 @@ fn settings(tui: &Tui, status: ConfigPanelStatus) -> Vec<ConfigSetting> {
keywords: "provider gateway endpoint model default",
value: ConfigEditor::ModelProviders.value(tui, status),
},
ConfigSetting {
section: ConfigSection::Sessions,
label: "Reasoning summary",
description: "Choose the reasoning summary style for new chats on the connected server",
keywords: "model thinking concise detailed none auto",
value: ConfigEditor::ReasoningSummary.value(tui, status),
},
ConfigSetting {
section: ConfigSection::TextSelection,
label: "Copy on select",
+44
View File
@@ -40,6 +40,50 @@ use unicode_width::UnicodeWidthStr;
pub(crate) const EFFECTS_VIEW_ID: &str = "config-effects";
pub(crate) fn reasoning_summary(
configured: Option<codex_protocol::config_types::ReasoningSummary>,
backend: crate::backend_id::BackendId,
keymap: &ListKeymap,
) -> SelectionViewParams {
use codex_protocol::config_types::ReasoningSummary;
let current = configured.unwrap_or(ReasoningSummary::Auto);
let choices = [
ReasoningSummary::Auto,
ReasoningSummary::Concise,
ReasoningSummary::Detailed,
ReasoningSummary::None,
];
SelectionViewParams {
title: Some("Reasoning summary".into()),
subtitle: Some("Choose the reasoning summary style for new chats".into()),
footer_hint: Some(picker_hint_line_for_keymap(keymap)),
initial_selected_idx: choices.iter().position(|choice| *choice == current),
allow_input_when_disconnected: true,
items: choices
.into_iter()
.map(|choice| SelectionItem {
name: super::reasoning_summary_label(if choice == current {
configured
} else {
Some(choice)
})
.into(),
is_current: choice == current,
actions: vec![Box::new(move |tx| {
tx.send(AppEvent::SaveReasoningSummary {
backend,
summary: choice,
});
})],
dismiss_on_select: true,
..Default::default()
})
.collect(),
..SelectionViewParams::picker()
}
}
pub(crate) fn effects(tui: &codex_config::types::Tui, keymap: &ListKeymap) -> SelectionViewParams {
effects_with_toggle_states(tui, keymap, &[])
}
@@ -2,7 +2,6 @@
source: tui/src/config_panel/config_panel_tests.rs
expression: "render(&panel, 140)"
---
Configuration
Changes save automatically
@@ -12,7 +11,7 @@ expression: "render(&panel, 140)"
Session picker layout Dense › Choose tighter rows or a roomier list when resuming and forking conversations
Resume directory Ask › Choose which working directory to use when the current directory and saved session differ
Model providers Choose › Choose the default provider for new chats on the connected server
Reasoning summary Auto (default) › Choose the reasoning summary style for new chats on the connected server
Collapse turn details [ ] Off Summarize tool calls in the conversation
left/right group · / search · enter toggle · esc clear search/close
@@ -0,0 +1,14 @@
---
source: tui/src/config_panel/config_panel_tests.rs
expression: "render(&picker, 100)"
---
Reasoning summary
Choose the reasoning summary style for new chats
› 1. Auto (default) (current)
2. Concise
3. Detailed
4. None
enter select · esc back