Add session-only arguments to /title and /statusline (#54387)

## What changed

Allow inline item selection, such as `/title model reasoning` and `/statusline current-dir --no-colors`, without changing saved defaults. Support `--clear` for both commands and `--colors` or `--no-colors` for `/statusline`, including color-only updates that preserve the current items.

Carry overrides with per-thread input state across navigation and reconnects, and allow these local commands in parent-owned subagent threads. Reject invalid or conflicting arguments before applying changes. Saved editor selections supersede the corresponding overrides.

## Testing

Add coverage for argument parsing, atomic updates, rate-limit item aliases and ambiguity, thread-state restoration, saved-setting interactions, and local command submission in parent-owned threads.

GitOrigin-RevId: 909cc2ede026fbf5c7f9cd52c8cf2ae835084f14
This commit is contained in:
Felipe Coury
2026-10-15 19:11:32 +00:00
committed by copyberry
parent 36803b180a
commit 141bf7680d
20 changed files with 527 additions and 24 deletions
@@ -157,8 +157,8 @@
//! Parent-owned subagent threads keep the draft editable while blocking agent-directed submission.
//! On the `Enter` and `Tab` submission paths, normal prompts, disallowed slash commands, and `!`
//! shell commands return `ParentOwnedInputBlocked` without clearing the draft. Bare local and
//! navigation slash commands remain available so users can leave or manage the view. Transcript
//! exports also remain available, including an explicit destination filename.
//! navigation slash commands remain available so users can leave or manage the view.
//! Exports and local display commands (`/title` and `/statusline`) also accept arguments.
//!
//! During reconnection, `handle_restricted_key` edits the draft directly without popup dispatch,
//! composer shortcuts, or submission; `?` becomes literal input. Enter and Tab leave the draft
@@ -489,7 +489,10 @@ pub enum InputResult {
}
fn parent_owned_command_is_allowed(command: SlashCommand, args: &str) -> bool {
if command == SlashCommand::Export {
if matches!(
command,
SlashCommand::Export | SlashCommand::Title | SlashCommand::Statusline
) {
return true;
}
@@ -527,8 +530,6 @@ fn parent_owned_command_is_allowed(command: SlashCommand, args: &str) -> bool {
| SlashCommand::Usage
| SlashCommand::Ide
| SlashCommand::DebugConfig
| SlashCommand::Title
| SlashCommand::Statusline
| SlashCommand::Theme
| SlashCommand::Pets
| SlashCommand::Ps
@@ -6,7 +6,7 @@ use assert_matches::assert_matches;
use pretty_assertions::assert_eq;
#[test]
fn parent_owned_thread_allows_bare_navigation_commands() {
fn parent_owned_thread_allows_local_commands() {
for (command, expected) in [
("/agents", SlashCommand::Agents),
("/subagents", SlashCommand::MultiAgents),
@@ -25,6 +25,21 @@ fn parent_owned_thread_allows_bare_navigation_commands() {
InputResult::Command(expected)
);
}
for (command, args) in [
(SlashCommand::Title, "model"),
(SlashCommand::Statusline, "model --no-colors"),
] {
let (mut composer, _rx) = new_test_composer();
composer.set_parent_owned_thread();
let name = command.command();
composer.set_text_content(format!("/{name} {args}"), Vec::new(), Vec::new());
assert_eq!(
composer.handle_key_event(KeyCode::Enter.into()).0,
InputResult::CommandWithArgs(command, args.into(), Vec::new())
);
}
}
#[test]
+4
View File
@@ -390,7 +390,9 @@ use self::status_state::StatusIndicatorState;
use self::status_state::StatusState;
use self::status_state::TerminalTitleStatusKind;
mod status_controls;
mod status_surface_commands;
mod status_surfaces;
use self::status_surface_commands::StatusSurfaceOverrides;
mod streaming;
use self::status_surfaces::CachedProjectRootName;
mod thread_title_status;
@@ -750,6 +752,8 @@ pub(crate) struct ChatWidget {
// On cancel or persist-failure the inner value is restored to config;
// on confirm the outer is set to `None` to end the session.
terminal_title_setup_original_items: Option<Option<Vec<String>>>,
// Explicit per-thread layout choices made through `/title` and `/statusline`.
status_surface_overrides: StatusSurfaceOverrides,
// Baseline instant used to animate spinner-prefixed title statuses.
terminal_title_animation_origin: Instant,
// The foreground loop refreshes the title at this deadline without drawing a frame.
+3 -1
View File
@@ -99,11 +99,13 @@ impl ChatWidget {
ConfigToggle::PasteDetection => self.bottom_pane.set_disable_paste_burst(
/*disabled*/ tui.disable_paste_burst.unwrap_or(/*default*/ false),
),
ConfigToggle::StatusLineColors => {
self.status_surface_overrides.status_line_use_colors = None;
}
ConfigToggle::AutomaticRecaps
| ConfigToggle::CopyOnSelectClearSelection
| ConfigToggle::Notifications
| ConfigToggle::StartInVimMode
| ConfigToggle::StatusLineColors
| ConfigToggle::Tips => {}
}
if setting == ConfigToggle::Animations
@@ -270,6 +270,7 @@ impl ChatWidget {
last_terminal_title: None,
last_terminal_title_requires_action: false,
terminal_title_setup_original_items: None,
status_surface_overrides: StatusSurfaceOverrides::default(),
terminal_title_animation_origin: Instant::now(),
terminal_title_next_refresh: None,
status_line_project_root_name_cache: None,
@@ -598,6 +598,7 @@ impl ChatWidget {
current_collaboration_mode: self.current_collaboration_mode.clone(),
active_collaboration_mask: self.active_collaboration_mask.clone(),
plan_mode_reasoning_effort: self.config.plan_mode_reasoning_effort.clone(),
status_surface_overrides: self.status_surface_overrides.clone(),
task_running: self.bottom_pane.is_task_running(),
agent_turn_running: self.turn_lifecycle.agent_turn_running,
})
@@ -617,6 +618,7 @@ impl ChatWidget {
self.current_collaboration_mode = input_state.current_collaboration_mode;
self.active_collaboration_mask = input_state.active_collaboration_mask;
self.config.plan_mode_reasoning_effort = input_state.plan_mode_reasoning_effort;
self.restore_status_surface_overrides(input_state.status_surface_overrides);
self.safety_buffering_prompt = input_state.safety_buffering_prompt;
self.safety_buffering_source = input_state.safety_buffering_source;
self.turn_lifecycle.restore_running(
+1 -1
View File
@@ -21,7 +21,7 @@ struct ModelCommand {
}
fn parse_model_command_args(args: &str) -> Result<ModelCommandArgs, String> {
let parsed = slash_command_args::parse(args, &["--reasoning", "--speed"], &[])?;
let parsed = slash_command_args::parse(args, &["--reasoning", "--speed"], &[], &[])?;
if let Some(unexpected) = parsed.positionals.get(1) {
return Err(format!(
"Unexpected argument '{unexpected}'. Use '--reasoning=<level>' or '--speed=<tier>'."
@@ -41,7 +41,7 @@ fn parse_reviewer(value: &str) -> Result<ApprovalsReviewer, String> {
}
fn parse_permission_profile_args(args: &str) -> Result<PermissionProfileArgs, String> {
let parsed = slash_command_args::parse(args, &["--approval-policy", "--reviewer"], &[])?;
let parsed = slash_command_args::parse(args, &["--approval-policy", "--reviewer"], &[], &[])?;
let profile_id = parsed.positionals.first().cloned().ok_or_else(|| {
"Usage: /permissions <profile-id> [--approval-policy=<policy>] [--reviewer=user|auto_review]"
.to_string()
@@ -1,7 +1,8 @@
//! Shared tokenization for slash commands with positional arguments and named settings.
//!
//! Values may follow their setting or use `=`, while switches never consume a value. A bare `--`
//! leaves all remaining tokens positional.
//! Values may follow their setting or use `=`, switches never consume a value, and boolean
//! settings accept both `--name` and `--no-name`. A bare `--` leaves all remaining tokens
//! positional.
#[derive(Debug, Default, PartialEq, Eq)]
pub(super) struct ParsedCommandArgs {
@@ -12,7 +13,14 @@ pub(super) struct ParsedCommandArgs {
#[derive(Debug, PartialEq, Eq)]
struct NamedArgument {
name: String,
value: Option<String>,
value: NamedArgumentValue,
}
#[derive(Debug, PartialEq, Eq)]
enum NamedArgumentValue {
Value(String),
Switch,
Boolean { value: bool },
}
impl ParsedCommandArgs {
@@ -20,7 +28,26 @@ impl ParsedCommandArgs {
self.named
.iter()
.find(|argument| argument.name == name)
.and_then(|argument| argument.value.as_deref())
.and_then(|argument| match &argument.value {
NamedArgumentValue::Value(value) => Some(value.as_str()),
NamedArgumentValue::Switch | NamedArgumentValue::Boolean { .. } => None,
})
}
pub(super) fn has_switch(&self, name: &str) -> bool {
self.named
.iter()
.any(|argument| argument.name == name && argument.value == NamedArgumentValue::Switch)
}
pub(super) fn boolean(&self, name: &str) -> Option<bool> {
let name = format!("--{name}");
self.named
.iter()
.find(|argument| argument.name == name)
.and_then(|argument| match &argument.value {
NamedArgumentValue::Boolean { value } => Some(*value),
NamedArgumentValue::Value(_) | NamedArgumentValue::Switch => None,
})
}
}
@@ -28,6 +55,7 @@ pub(super) fn parse(
args: &str,
value_settings: &[&str],
switches: &[&str],
boolean_settings: &[&str],
) -> Result<ParsedCommandArgs, String> {
let mut words = shlex::split(args)
.ok_or_else(|| "Invalid command arguments. Check the quoting.".to_string())?
@@ -39,12 +67,29 @@ pub(super) fn parse(
if parse_settings && word == "--" {
parse_settings = false;
} else if parse_settings && word.starts_with("--") {
let argument = parse_named_argument(&word, &mut words, value_settings, switches)?;
if parsed
let argument = parse_named_argument(
&word,
&mut words,
value_settings,
switches,
boolean_settings,
)?;
if let Some(existing) = parsed
.named
.iter()
.any(|existing| existing.name == argument.name)
.find(|existing| existing.name == argument.name)
{
if let (
NamedArgumentValue::Boolean {
value: existing_value,
},
NamedArgumentValue::Boolean { value },
) = (&existing.value, &argument.value)
&& existing_value != value
{
let name = argument.name.trim_start_matches("--");
return Err(format!("Specify only one of --{name} or --no-{name}."));
}
return Err(format!(
"Command setting `{}` was provided more than once.",
argument.name
@@ -63,6 +108,7 @@ fn parse_named_argument(
words: &mut std::iter::Peekable<std::vec::IntoIter<String>>,
value_settings: &[&str],
switches: &[&str],
boolean_settings: &[&str],
) -> Result<NamedArgument, String> {
let (name, inline_value) = word
.split_once('=')
@@ -75,7 +121,7 @@ fn parse_named_argument(
.ok_or_else(|| format!("Command setting `{name}` requires a value."))?;
return Ok(NamedArgument {
name: name.to_string(),
value: Some(value),
value: NamedArgumentValue::Value(value),
});
}
if switches.contains(&name) {
@@ -84,9 +130,24 @@ fn parse_named_argument(
}
return Ok(NamedArgument {
name: name.to_string(),
value: None,
value: NamedArgumentValue::Switch,
});
}
for setting in boolean_settings {
let positive = format!("--{setting}");
let negative = format!("--no-{setting}");
if name == positive || name == negative {
if inline_value.is_some() {
return Err(format!("Command setting `{name}` does not take a value."));
}
return Ok(NamedArgument {
name: positive,
value: NamedArgumentValue::Boolean {
value: name != negative,
},
});
}
}
Err(format!("Unknown command setting `{name}`."))
}
@@ -4,9 +4,10 @@ use pretty_assertions::assert_eq;
#[test]
fn parses_positional_values_switches_and_quoted_arguments() {
let parsed = parse(
"'team review' item --reviewer user --speed=fast --clear -- --literal",
"'team review' item --reviewer user --speed=fast --clear --no-colors -- --literal",
&["--reviewer", "--speed"],
&["--clear"],
&["colors"],
)
.expect("valid command arguments");
@@ -17,20 +18,26 @@ fn parses_positional_values_switches_and_quoted_arguments() {
named: vec![
NamedArgument {
name: "--reviewer".into(),
value: Some("user".into()),
value: NamedArgumentValue::Value("user".into()),
},
NamedArgument {
name: "--speed".into(),
value: Some("fast".into()),
value: NamedArgumentValue::Value("fast".into()),
},
NamedArgument {
name: "--clear".into(),
value: None,
value: NamedArgumentValue::Switch,
},
NamedArgument {
name: "--colors".into(),
value: NamedArgumentValue::Boolean { value: false },
},
],
}
);
assert_eq!(parsed.value("--reviewer"), Some("user"));
assert!(parsed.has_switch("--clear"));
assert_eq!(parsed.boolean("colors"), Some(false));
}
#[test]
@@ -48,6 +55,10 @@ fn rejects_invalid_named_arguments() {
"--clear --clear",
"Command setting `--clear` was provided more than once.",
),
(
"--colors --no-colors",
"Specify only one of --colors or --no-colors.",
),
("--unknown", "Unknown command setting `--unknown`."),
(
"'unfinished",
@@ -55,7 +66,7 @@ fn rejects_invalid_named_arguments() {
),
] {
assert_eq!(
parse(args, &["--reviewer"], &["--clear"]),
parse(args, &["--reviewer"], &["--clear"], &["colors"]),
Err(expected.to_string())
);
}
@@ -815,6 +815,14 @@ impl ChatWidget {
self.handle_model_command_args(trimmed);
self.app_event_tx.send(AppEvent::SettingsSelectionClosed);
}
SlashCommand::Title => {
self.handle_terminal_title_command_args(trimmed);
self.app_event_tx.send(AppEvent::SettingsSelectionClosed);
}
SlashCommand::Statusline => {
self.handle_status_line_command_args(trimmed);
self.app_event_tx.send(AppEvent::SettingsSelectionClosed);
}
SlashCommand::Permissions
if self.windows_sandbox_local_server
&& self.windows_sandbox_host != WindowsSandboxHost::Remote
@@ -133,6 +133,8 @@ impl ChatWidget {
self.config_panel_tui.status_line_use_colors = use_theme_colors;
self.local_settings.tui.status_line = Some(ids);
self.local_settings.tui.status_line_use_colors = use_theme_colors;
self.status_surface_overrides.status_line = None;
self.status_surface_overrides.status_line_use_colors = None;
self.refresh_status_line();
}
@@ -175,6 +177,7 @@ impl ChatWidget {
self.terminal_title_setup_original_items = None;
self.config_panel_tui.terminal_title = Some(ids.clone());
self.local_settings.tui.terminal_title = Some(ids);
self.status_surface_overrides.terminal_title = None;
self.refresh_terminal_title();
}
@@ -0,0 +1,160 @@
//! Session-only `/title` and `/statusline` command handling.
//!
//! The command handlers update the live widget without changing saved defaults. Explicit
//! overrides are carried with the existing per-thread input state so navigation and reconnects
//! retain the selected layout.
use super::slash_command_args;
use super::*;
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub(super) struct StatusSurfaceOverrides {
pub(super) terminal_title: Option<Vec<String>>,
pub(super) status_line: Option<Vec<String>>,
pub(super) status_line_use_colors: Option<bool>,
}
#[derive(Debug, PartialEq, Eq)]
struct StatusLineCommand {
items: Option<Vec<StatusLineItem>>,
use_theme_colors: Option<bool>,
}
impl ChatWidget {
pub(super) fn handle_terminal_title_command_args(&mut self, args: &str) {
let preview_data = self.terminal_title_preview_data();
match parse_terminal_title_command(args, &preview_data) {
Ok(items) => {
let ids = items.iter().map(ToString::to_string).collect::<Vec<_>>();
self.status_surface_overrides.terminal_title = Some(ids.clone());
self.local_settings.tui.terminal_title = Some(ids);
self.refresh_terminal_title();
self.request_redraw();
}
Err(error) => self.add_error_message(error),
}
}
pub(super) fn handle_status_line_command_args(&mut self, args: &str) {
let preview_data = self.status_surface_preview_data();
match parse_status_line_command(args, &preview_data) {
Ok(command) => {
if let Some(items) = command.items {
let ids = items.iter().map(ToString::to_string).collect::<Vec<_>>();
self.status_surface_overrides.status_line = Some(ids.clone());
self.local_settings.tui.status_line = Some(ids);
}
if let Some(use_theme_colors) = command.use_theme_colors {
self.status_surface_overrides.status_line_use_colors = Some(use_theme_colors);
self.local_settings.tui.status_line_use_colors = use_theme_colors;
}
self.refresh_status_line();
self.request_redraw();
}
Err(error) => self.add_error_message(error),
}
}
pub(super) fn restore_status_surface_overrides(&mut self, overrides: StatusSurfaceOverrides) {
if let Some(items) = &overrides.terminal_title {
self.local_settings.tui.terminal_title = Some(items.clone());
}
if let Some(items) = &overrides.status_line {
self.local_settings.tui.status_line = Some(items.clone());
}
if let Some(use_theme_colors) = overrides.status_line_use_colors {
self.local_settings.tui.status_line_use_colors = use_theme_colors;
}
self.status_surface_overrides = overrides;
self.refresh_status_surfaces();
}
}
fn parse_terminal_title_command(
args: &str,
preview_data: &StatusSurfacePreviewData,
) -> Result<Vec<TerminalTitleItem>, String> {
let args = slash_command_args::parse(args, &[], &["--clear"], &[])?;
let items = args
.positionals
.iter()
.map(|item| parse_item(item, "terminal-title", "/title", preview_data))
.collect::<Result<Vec<_>, _>>()?;
let clear = args.has_switch("--clear");
if clear && !items.is_empty() {
return Err("Cannot combine --clear with terminal-title items.".into());
}
Ok(if clear { Vec::new() } else { items })
}
fn parse_status_line_command(
args: &str,
preview_data: &StatusSurfacePreviewData,
) -> Result<StatusLineCommand, String> {
let args = slash_command_args::parse(args, &[], &["--clear"], &["colors"])?;
let items = args
.positionals
.iter()
.map(|item| parse_item(item, "status-line", "/statusline", preview_data))
.collect::<Result<Vec<_>, _>>()?;
Ok(StatusLineCommand {
items: status_line_items(items, args.has_switch("--clear"))?,
use_theme_colors: args.boolean("colors"),
})
}
fn status_line_items(
items: Vec<StatusLineItem>,
clear: bool,
) -> Result<Option<Vec<StatusLineItem>>, String> {
if clear && !items.is_empty() {
return Err("Cannot combine --clear with status-line items.".into());
}
Ok(if clear {
Some(Vec::new())
} else if items.is_empty() {
None
} else {
Some(items)
})
}
fn parse_item<T>(
token: &str,
surface: &str,
command: &str,
preview_data: &StatusSurfacePreviewData,
) -> Result<T, String>
where
T: std::str::FromStr,
{
if let Ok(item) = token.parse() {
return Ok(item);
}
let five_hour_id = "five-hour-limit";
let weekly_id = "weekly-limit";
let five_hour_matches = preview_data
.rate_limit_item_name(StatusSurfacePreviewItem::FiveHourLimit, five_hour_id)
== token;
let weekly_matches = preview_data
.rate_limit_item_name(StatusSurfacePreviewItem::WeeklyLimit, weekly_id)
== token;
let id = match (five_hour_matches, weekly_matches) {
(true, false) => five_hour_id,
(false, true) => weekly_id,
(true, true) => {
return Err(format!(
"Ambiguous {surface} item '{token}'. Use '{five_hour_id}' or '{weekly_id}'."
));
}
(false, false) => {
return Err(format!(
"Unknown {surface} item '{token}'. Use {command} to see available items."
));
}
};
id.parse().map_err(|_| {
format!("Unknown {surface} item '{token}'. Use {command} to see available items.")
})
}
+2
View File
@@ -296,6 +296,8 @@ mod sparkle_submission_tests;
mod startup_submission_tests;
mod status_and_layout;
mod status_command_tests;
#[path = "tests/status_surface_command_tests.rs"]
mod status_surface_command_tests;
mod status_surface_previews;
#[path = "tests/subagent_activity_tests.rs"]
mod subagent_activity;
@@ -1895,6 +1895,7 @@ async fn restore_thread_input_state_applies_running_state_policy() {
current_collaboration_mode: chat.current_collaboration_mode.clone(),
active_collaboration_mask: chat.active_collaboration_mask.clone(),
plan_mode_reasoning_effort: chat.config.plan_mode_reasoning_effort.clone(),
status_surface_overrides: StatusSurfaceOverrides::default(),
task_running: true,
agent_turn_running: true,
};
@@ -435,6 +435,7 @@ async fn restore_thread_input_state_restores_pending_steers_without_downgrading_
current_collaboration_mode: chat.current_collaboration_mode.clone(),
active_collaboration_mask: chat.active_collaboration_mask.clone(),
plan_mode_reasoning_effort: chat.config.plan_mode_reasoning_effort.clone(),
status_surface_overrides: StatusSurfaceOverrides::default(),
task_running: false,
agent_turn_running: false,
}),
@@ -0,0 +1,227 @@
use super::*;
use crate::config_panel::ConfigPreference;
use crate::config_panel::ConfigToggle;
use pretty_assertions::assert_eq;
fn dispatch_inline(
chat: &mut ChatWidget,
events: &mut tokio::sync::mpsc::UnboundedReceiver<AppEvent>,
command: SlashCommand,
args: &str,
) -> Vec<AppEvent> {
chat.dispatch_command_with_args(command, args.to_string(), Vec::new());
std::iter::from_fn(|| events.try_recv().ok()).collect()
}
fn rendered_history(events: Vec<AppEvent>) -> String {
events
.into_iter()
.filter_map(|event| match event {
AppEvent::InsertHistoryCell(cell) => {
Some(lines_to_single_string(&cell.display_lines(/*width*/ 80)))
}
_ => None,
})
.collect()
}
#[tokio::test]
async fn inline_status_surface_commands_are_session_only_and_atomic() {
let (mut chat, mut events, _ops) = make_chatwidget_manual(Some("gpt-5.5")).await;
let saved_tui = chat.config_panel_tui.clone();
super::status_surface_previews::cache_rate_limit_snapshot(&mut chat);
let title_events = dispatch_inline(
&mut chat,
&mut events,
SlashCommand::Title,
"model-name monthly-limit",
);
assert_eq!(
chat.local_settings.tui.terminal_title,
Some(vec!["model".into(), "five-hour-limit".into()])
);
assert!(matches!(
title_events.as_slice(),
[AppEvent::SettingsSelectionClosed]
));
let status_events = dispatch_inline(
&mut chat,
&mut events,
SlashCommand::Statusline,
"monthly-limit weekly-limit --no-colors",
);
assert_eq!(
(
chat.local_settings.tui.status_line.clone(),
chat.local_settings.tui.status_line_use_colors,
),
(
Some(vec!["five-hour-limit".into(), "weekly-limit".into()]),
false,
)
);
assert!(matches!(
status_events.as_slice(),
[AppEvent::SettingsSelectionClosed]
));
assert_eq!(chat.config_panel_tui, saved_tui);
chat.rate_limit_snapshots_by_limit_id
.get_mut("codex")
.and_then(|snapshot| snapshot.secondary.as_mut())
.expect("secondary usage limit")
.window_minutes = Some(30 * 24 * 60);
let before_ambiguous = chat.status_surface_overrides.clone();
let ambiguous_events = dispatch_inline(
&mut chat,
&mut events,
SlashCommand::Statusline,
"monthly-limit",
);
assert_eq!(chat.status_surface_overrides, before_ambiguous);
let rendered = rendered_history(ambiguous_events);
insta::assert_snapshot!(rendered, @"■ Ambiguous status-line item 'monthly-limit'. Use 'five-hour-limit' or 'weekly-limit'.\n");
dispatch_inline(
&mut chat,
&mut events,
SlashCommand::Statusline,
"model reasoning",
);
assert!(!chat.local_settings.tui.status_line_use_colors);
let before_invalid = chat.status_surface_overrides.clone();
let invalid_events = dispatch_inline(
&mut chat,
&mut events,
SlashCommand::Statusline,
"current-dir --colors --no-colors",
);
assert_eq!(chat.status_surface_overrides, before_invalid);
assert!(
invalid_events
.iter()
.any(|event| matches!(event, AppEvent::SettingsSelectionClosed))
);
let rendered = rendered_history(invalid_events);
insta::assert_snapshot!(rendered, @"■ Specify only one of --colors or --no-colors.\n");
dispatch_inline(&mut chat, &mut events, SlashCommand::Statusline, "--colors");
assert_eq!(
(
chat.local_settings.tui.status_line.clone(),
chat.local_settings.tui.status_line_use_colors,
),
(Some(vec!["model".into(), "reasoning".into()]), true)
);
dispatch_inline(&mut chat, &mut events, SlashCommand::Title, "--clear");
dispatch_inline(
&mut chat,
&mut events,
SlashCommand::Statusline,
"--clear --no-colors",
);
assert_eq!(
(
chat.local_settings.tui.terminal_title.clone(),
chat.local_settings.tui.status_line.clone(),
chat.local_settings.tui.status_line_use_colors,
),
(Some(Vec::new()), Some(Vec::new()), false)
);
}
#[tokio::test]
async fn session_status_surface_overrides_follow_thread_state_and_editor_saves() {
let (mut chat, mut events, _ops) = make_chatwidget_manual(Some("gpt-5.5")).await;
dispatch_inline(
&mut chat,
&mut events,
SlashCommand::Title,
"model reasoning",
);
dispatch_inline(
&mut chat,
&mut events,
SlashCommand::Statusline,
"current-dir --no-colors",
);
chat.preview_terminal_title(vec![TerminalTitleItem::AppName]);
let state = chat
.capture_thread_input_state()
.expect("thread input state");
chat.cancel_terminal_title_setup();
assert_eq!(
chat.local_settings.tui.terminal_title,
Some(vec!["model".into(), "reasoning".into()])
);
let (mut restored, mut restored_events, _ops) = make_chatwidget_manual(Some("gpt-5.5")).await;
restored.local_settings.tui.terminal_title = Some(vec!["app-name".into()]);
restored.local_settings.tui.status_line = Some(vec!["codex-version".into()]);
restored.restore_thread_input_state(
Some(state),
ThreadInputStateRestoreMode {
preserve_in_flight_turn: false,
},
);
assert_eq!(
(
restored.local_settings.tui.terminal_title.clone(),
restored.local_settings.tui.status_line.clone(),
restored.local_settings.tui.status_line_use_colors,
),
(
Some(vec!["model".into(), "reasoning".into()]),
Some(vec!["current-dir".into()]),
false,
)
);
restored.restore_thread_input_state(
/*input_state*/ None,
ThreadInputStateRestoreMode {
preserve_in_flight_turn: false,
},
);
assert_eq!(
restored.local_settings.tui.terminal_title,
Some(vec!["model".into(), "reasoning".into()])
);
restored.setup_terminal_title(vec![TerminalTitleItem::Project]);
restored.setup_status_line(
vec![StatusLineItem::ModelName],
/*use_theme_colors*/ true,
);
assert_eq!(
restored.status_surface_overrides,
StatusSurfaceOverrides::default()
);
dispatch_inline(
&mut restored,
&mut restored_events,
SlashCommand::Statusline,
"reasoning --no-colors",
);
let mut saved_tui = restored.local_settings.tui.clone();
saved_tui.status_line_use_colors = true;
restored.apply_config_preference(
ConfigPreference::Toggle {
setting: ConfigToggle::StatusLineColors,
enabled: true,
},
&saved_tui,
);
assert_eq!(
restored.status_surface_overrides,
StatusSurfaceOverrides {
status_line: Some(vec!["reasoning".into()]),
..Default::default()
}
);
}
@@ -100,7 +100,7 @@ fn cache_project_root(chat: &mut ChatWidget, root_name: &str) {
});
}
fn cache_rate_limit_snapshot(chat: &mut ChatWidget) {
pub(super) fn cache_rate_limit_snapshot(chat: &mut ChatWidget) {
chat.on_rate_limit_snapshot(Some(RateLimitSnapshot {
limit_id: None,
limit_name: None,
@@ -27,6 +27,7 @@ use codex_utils_plugins::mention_syntax::PLUGIN_TEXT_MENTION_SIGIL;
use codex_utils_plugins::mention_syntax::TOOL_MENTION_SIGIL;
use super::ChatWidget;
use super::StatusSurfaceOverrides;
#[derive(Debug, Clone, PartialEq)]
pub(crate) struct UserMessage {
@@ -162,6 +163,7 @@ pub(crate) struct ThreadInputState {
pub(super) current_collaboration_mode: CollaborationMode,
pub(super) active_collaboration_mask: Option<CollaborationModeMask>,
pub(super) plan_mode_reasoning_effort: Option<ReasoningEffortConfig>,
pub(super) status_surface_overrides: StatusSurfaceOverrides,
pub(super) task_running: bool,
pub(super) agent_turn_running: bool,
}
+2
View File
@@ -175,6 +175,8 @@ impl SlashCommand {
SlashCommand::Review
| SlashCommand::Model
| SlashCommand::Permissions
| SlashCommand::Title
| SlashCommand::Statusline
| SlashCommand::Rename
| SlashCommand::New
| SlashCommand::Clear