mirror of
https://github.com/openai/codex.git
synced 2026-11-18 23:02:23 +00:00
Show action required in terminal title (#18372)
Implements #18162 This updates the TUI terminal title to show an explicit action-required state when Codex is blocked on user approval or input. The terminal title now uses the activity title item to cover both active work and blocked-on-user states, while still accepting the legacy spinner config value. Changes - Rename the terminal title item from `spinner` to `activity` while preserving legacy config compatibility - Show `[ ! ] Action Required `while approval or input overlays are active, with a blinking `[ . ]` alternate state - Suppress the normal working spinner while Codex is blocked on user action - Add targeted coverage for action-required title behavior and legacy title-item parsing Testing - Trigger an approval or input modal and confirm the tab title alternates between `[ ! ] Action Required` and `[ . ] Action Required` - Disable the activity title item and confirm the action-required title does not appear - Resolve the prompt and confirm the title returns to the normal spinning/idel state https://github.com/user-attachments/assets/e9ecc530-a6be-4fd7-b9a6-d550a790eb2c
This commit is contained in:
1 parent
e903d000b0
commit
e64c765673
20 files changed
+450
-68
No files matched your search
@@ -18,8 +18,10 @@ use strum_macros::EnumString;
|
||||
|
||||
use crate::app_event::AppEvent;
|
||||
use crate::app_event_sender::AppEventSender;
|
||||
use crate::bottom_pane::ACTION_REQUIRED_PREVIEW_PREFIX;
|
||||
use crate::bottom_pane::CancellationEvent;
|
||||
use crate::bottom_pane::bottom_pane_view::BottomPaneView;
|
||||
use crate::bottom_pane::build_action_required_title_text;
|
||||
use crate::bottom_pane::multi_select_picker::MultiSelectItem;
|
||||
use crate::bottom_pane::multi_select_picker::MultiSelectPicker;
|
||||
use crate::bottom_pane::status_surface_preview::StatusSurfacePreviewData;
|
||||
@@ -41,7 +43,8 @@ pub(crate) enum TerminalTitleItem {
|
||||
Project,
|
||||
/// Current working directory path.
|
||||
CurrentDir,
|
||||
/// Animated task spinner while active.
|
||||
/// Terminal-title activity indicator while active.
|
||||
#[strum(to_string = "activity", serialize = "spinner")]
|
||||
Spinner,
|
||||
/// Compact runtime run-state text.
|
||||
#[strum(to_string = "run-state", serialize = "status")]
|
||||
@@ -88,7 +91,7 @@ impl TerminalTitleItem {
|
||||
TerminalTitleItem::Project => "Project name (falls back to current directory name)",
|
||||
TerminalTitleItem::CurrentDir => "Current working directory",
|
||||
TerminalTitleItem::Spinner => {
|
||||
"Animated task spinner (omitted while idle or when animations are off)"
|
||||
"Spinner while working, action-required message while blocked."
|
||||
}
|
||||
TerminalTitleItem::Status => {
|
||||
"Compact session run-state text (Ready, Working, Thinking)"
|
||||
@@ -154,8 +157,8 @@ impl TerminalTitleItem {
|
||||
|
||||
/// Returns the separator to place before this item in a rendered title.
|
||||
///
|
||||
/// The spinner gets a plain space on either side so it reads as
|
||||
/// `my-project <spinner> Working` rather than `my-project | <spinner> | Working`.
|
||||
/// The activity indicator gets a plain space on either side so it reads as
|
||||
/// `my-project <activity> Working` rather than `my-project | <activity> | Working`.
|
||||
/// All other adjacent items are joined with ` | `.
|
||||
pub(crate) fn separator_from_previous(self, previous: Option<Self>) -> &'static str {
|
||||
match previous {
|
||||
@@ -174,17 +177,25 @@ pub(crate) fn preview_line_for_title_items(
|
||||
items: &[TerminalTitleItem],
|
||||
preview_data: &StatusSurfacePreviewData,
|
||||
) -> Option<Line<'static>> {
|
||||
if items.contains(&TerminalTitleItem::Spinner) {
|
||||
let preview = build_action_required_title_text(
|
||||
ACTION_REQUIRED_PREVIEW_PREFIX,
|
||||
items.iter().copied(),
|
||||
&[],
|
||||
|item| {
|
||||
item.preview_item()
|
||||
.and_then(|preview_item| preview_data.value_for(preview_item))
|
||||
.map(str::to_owned)
|
||||
},
|
||||
);
|
||||
return Some(Line::from(preview));
|
||||
}
|
||||
|
||||
let mut previous = None;
|
||||
let preview = items
|
||||
.iter()
|
||||
.copied()
|
||||
.fold(String::new(), |mut preview, item| {
|
||||
if item == TerminalTitleItem::Spinner {
|
||||
preview.push_str(item.separator_from_previous(previous));
|
||||
preview.push('⠋');
|
||||
previous = Some(item);
|
||||
return preview;
|
||||
}
|
||||
let Some(value) = item
|
||||
.preview_item()
|
||||
.and_then(|preview_item| preview_data.value_for(preview_item))
|
||||
@@ -369,7 +380,7 @@ mod tests {
|
||||
let tx = AppEventSender::new(tx_raw);
|
||||
let selected = [
|
||||
"project-name".to_string(),
|
||||
"spinner".to_string(),
|
||||
"activity".to_string(),
|
||||
"run-state".to_string(),
|
||||
"thread-title".to_string(),
|
||||
];
|
||||
@@ -384,7 +395,7 @@ mod tests {
|
||||
#[test]
|
||||
fn parse_terminal_title_items_preserves_order() {
|
||||
let items = parse_terminal_title_items(
|
||||
["project-name", "spinner", "run-state", "thread-title"].into_iter(),
|
||||
["project-name", "activity", "run-state", "thread-title"].into_iter(),
|
||||
);
|
||||
assert_eq!(
|
||||
items,
|
||||
@@ -403,6 +414,19 @@ mod tests {
|
||||
assert_eq!(items, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn activity_is_canonical_and_accepts_spinner_legacy_id() {
|
||||
assert_eq!(TerminalTitleItem::Spinner.to_string(), "activity");
|
||||
assert_eq!(
|
||||
"activity".parse::<TerminalTitleItem>(),
|
||||
Ok(TerminalTitleItem::Spinner)
|
||||
);
|
||||
assert_eq!(
|
||||
"spinner".parse::<TerminalTitleItem>(),
|
||||
Ok(TerminalTitleItem::Spinner)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_name_is_canonical_and_accepts_project_legacy_id() {
|
||||
assert_eq!(TerminalTitleItem::Project.to_string(), "project-name");
|
||||
@@ -476,7 +500,7 @@ mod tests {
|
||||
"context-used",
|
||||
"five-hour-limit",
|
||||
"git-branch",
|
||||
"spinner",
|
||||
"activity",
|
||||
"current-dir",
|
||||
"project-name",
|
||||
"model",
|
||||
|
||||
Reference in new issue
Block a user