Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

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

Felipe Coury141bf7680d77
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs
index 970234f5be..49b13b5360 100644
--- a/codex-rs/tui/src/bottom_pane/chat_composer.rs
+++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs
@@ -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
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/agents_navigation_tests.rs b/codex-rs/tui/src/bottom_pane/chat_composer/agents_navigation_tests.rs
index b96020995a..83c68ab9f2 100644
--- a/codex-rs/tui/src/bottom_pane/chat_composer/agents_navigation_tests.rs
+++ b/codex-rs/tui/src/bottom_pane/chat_composer/agents_navigation_tests.rs
@@ -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]
diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs
index 0652fbd4f2..da3d310f27 100644
--- a/codex-rs/tui/src/chatwidget.rs
+++ b/codex-rs/tui/src/chatwidget.rs
@@ -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.
diff --git a/codex-rs/tui/src/chatwidget/config_panel.rs b/codex-rs/tui/src/chatwidget/config_panel.rs
index ea8cd8c7a5..444b2a7106 100644
--- a/codex-rs/tui/src/chatwidget/config_panel.rs
+++ b/codex-rs/tui/src/chatwidget/config_panel.rs
@@ -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
diff --git a/codex-rs/tui/src/chatwidget/constructor.rs b/codex-rs/tui/src/chatwidget/constructor.rs
index b0a12a3d26..8ef50403dd 100644
--- a/codex-rs/tui/src/chatwidget/constructor.rs
+++ b/codex-rs/tui/src/chatwidget/constructor.rs
@@ -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,
diff --git a/codex-rs/tui/src/chatwidget/input_restore.rs b/codex-rs/tui/src/chatwidget/input_restore.rs
index 086aa4ac1e..1f21ca9a7a 100644
--- a/codex-rs/tui/src/chatwidget/input_restore.rs
+++ b/codex-rs/tui/src/chatwidget/input_restore.rs
@@ -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(
diff --git a/codex-rs/tui/src/chatwidget/model_command.rs b/codex-rs/tui/src/chatwidget/model_command.rs
index 0c7992b229..bde9ce72ee 100644
--- a/codex-rs/tui/src/chatwidget/model_command.rs
+++ b/codex-rs/tui/src/chatwidget/model_command.rs
@@ -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>'."
diff --git a/codex-rs/tui/src/chatwidget/permission_discovery.rs b/codex-rs/tui/src/chatwidget/permission_discovery.rs
index 01e964e7fb..343186d0af 100644
--- a/codex-rs/tui/src/chatwidget/permission_discovery.rs
+++ b/codex-rs/tui/src/chatwidget/permission_discovery.rs
@@ -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()
diff --git a/codex-rs/tui/src/chatwidget/slash_command_args.rs b/codex-rs/tui/src/chatwidget/slash_command_args.rs
index fa4ac26df6..e73048d92c 100644
--- a/codex-rs/tui/src/chatwidget/slash_command_args.rs
+++ b/codex-rs/tui/src/chatwidget/slash_command_args.rs
@@ -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}`."))
}
diff --git a/codex-rs/tui/src/chatwidget/slash_command_args_tests.rs b/codex-rs/tui/src/chatwidget/slash_command_args_tests.rs
index f413bba636..f856d5b83a 100644
--- a/codex-rs/tui/src/chatwidget/slash_command_args_tests.rs
+++ b/codex-rs/tui/src/chatwidget/slash_command_args_tests.rs
@@ -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())
);
}
diff --git a/codex-rs/tui/src/chatwidget/slash_dispatch.rs b/codex-rs/tui/src/chatwidget/slash_dispatch.rs
index 8977c41642..fd56394f6b 100644
--- a/codex-rs/tui/src/chatwidget/slash_dispatch.rs
+++ b/codex-rs/tui/src/chatwidget/slash_dispatch.rs
@@ -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
diff --git a/codex-rs/tui/src/chatwidget/status_controls.rs b/codex-rs/tui/src/chatwidget/status_controls.rs
index 692eba105a..a5d020c749 100644
--- a/codex-rs/tui/src/chatwidget/status_controls.rs
+++ b/codex-rs/tui/src/chatwidget/status_controls.rs
@@ -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();
}
diff --git a/codex-rs/tui/src/chatwidget/status_surface_commands.rs b/codex-rs/tui/src/chatwidget/status_surface_commands.rs
new file mode 100644
index 0000000000..caf0ab1cb2
--- /dev/null
+++ b/codex-rs/tui/src/chatwidget/status_surface_commands.rs
@@ -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.")
+ })
+}
diff --git a/codex-rs/tui/src/chatwidget/tests.rs b/codex-rs/tui/src/chatwidget/tests.rs
index 1e5dade887..1cc51a1646 100644
--- a/codex-rs/tui/src/chatwidget/tests.rs
+++ b/codex-rs/tui/src/chatwidget/tests.rs
@@ -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;
diff --git a/codex-rs/tui/src/chatwidget/tests/composer_submission.rs b/codex-rs/tui/src/chatwidget/tests/composer_submission.rs
index 6ef2db01fb..5443074228 100644
--- a/codex-rs/tui/src/chatwidget/tests/composer_submission.rs
+++ b/codex-rs/tui/src/chatwidget/tests/composer_submission.rs
@@ -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,
};
diff --git a/codex-rs/tui/src/chatwidget/tests/review_mode.rs b/codex-rs/tui/src/chatwidget/tests/review_mode.rs
index dd8214d013..c996f604a9 100644
--- a/codex-rs/tui/src/chatwidget/tests/review_mode.rs
+++ b/codex-rs/tui/src/chatwidget/tests/review_mode.rs
@@ -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,
}),
diff --git a/codex-rs/tui/src/chatwidget/tests/status_surface_command_tests.rs b/codex-rs/tui/src/chatwidget/tests/status_surface_command_tests.rs
new file mode 100644
index 0000000000..8574c4fe39
--- /dev/null
+++ b/codex-rs/tui/src/chatwidget/tests/status_surface_command_tests.rs
@@ -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()
+ }
+ );
+}
diff --git a/codex-rs/tui/src/chatwidget/tests/status_surface_previews.rs b/codex-rs/tui/src/chatwidget/tests/status_surface_previews.rs
index 085d51619e..de9eaaab56 100644
--- a/codex-rs/tui/src/chatwidget/tests/status_surface_previews.rs
+++ b/codex-rs/tui/src/chatwidget/tests/status_surface_previews.rs
@@ -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,
diff --git a/codex-rs/tui/src/chatwidget/user_messages.rs b/codex-rs/tui/src/chatwidget/user_messages.rs
index ed997253bc..a05f041bac 100644
--- a/codex-rs/tui/src/chatwidget/user_messages.rs
+++ b/codex-rs/tui/src/chatwidget/user_messages.rs
@@ -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,
}
diff --git a/codex-rs/tui/src/slash_command.rs b/codex-rs/tui/src/slash_command.rs
index 223bd3048b..dfd05384f7 100644
--- a/codex-rs/tui/src/slash_command.rs
+++ b/codex-rs/tui/src/slash_command.rs
@@ -175,6 +175,8 @@ impl SlashCommand {
SlashCommand::Review
| SlashCommand::Model
| SlashCommand::Permissions
+ | SlashCommand::Title
+ | SlashCommand::Statusline
| SlashCommand::Rename
| SlashCommand::New
| SlashCommand::Clear