Add custom status line authoring to /statusline (#62037)

## What changed

- Add “Create a custom status line” when `tui_extensions_statusline` is enabled outside cloud mode. Open a new conversation with an editable draft bound to the bundled `create-statusline` skill when available, falling back to a plain request otherwise.
- Preserve the previous thread’s draft and queued input, including input restored by a late interrupt, while switching conversations.
- Guard against stale create actions and held Enter submitting the new draft. Rename the provider action to “Choose a status line provider”.

## Testing

Add regression coverage for draft editing, bundled skill binding, input preservation, activation-key handling, dismissed setup actions, and hiding the create action in cloud mode.

GitOrigin-RevId: d40dd12914cf38968e605987f67d1ddee5ba7dd1
This commit is contained in:
Joe Savona
2026-11-17 12:24:05 +00:00
committed by copyberry
parent b47df356af
commit e20ccdfa80
17 changed files with 450 additions and 42 deletions
@@ -50,7 +50,7 @@ Scenario: A user requests the bundled statusline skill by name.
Install the provider through an installed plugin or register the stdio command on the connected app-serv...guration and restart the TUI if you changed the flag. [hash=42c056811162cca2]
Exercise `tools/list` and `resources/read` with a representative snapshot. After adding the server, star... file, restart its stdio process to load the changes. [hash=0c36ed73eb177796]
Exercise `tools/list` and `resources/read` with a representative snapshot. After adding the server, star... file, restart its stdio process to load the changes. [hash=4d64fb913d86fc64]
</skill>
08:configuration_update:reasoning={"effort":"low"}
@@ -17,4 +17,4 @@ Use a `row` with an explicit whole-number `gap` to group items. Use named theme
Install the provider through an installed plugin or register the stdio command on the connected app-server host. For example, run `codex mcp add my-statusline -- python3 -u /absolute/path/to/statusline.py` there, using a path and interpreter the host can access. If the workspace is on a separate executor, give the user the provider file to copy to the host and the command to run there. Set `tui_extensions_statusline = true` under `[features]` in the TUI client's configuration and restart the TUI if you changed the flag.
Exercise `tools/list` and `resources/read` with a representative snapshot. After adding the server, start a new conversation in its workspace to connect to it. Open `/statusline`, choose **Choose a statusline plugin**, and select the provider. Verify that changing threads changes the displayed inputs. F2 shows the failed attempt if the footer falls back. After editing the Python file, restart its stdio process to load the changes.
Exercise `tools/list` and `resources/read` with a representative snapshot. After adding the server, start a new conversation in its workspace to connect to it. Open `/statusline`, choose **Choose a status line provider**, and select the provider. Verify that changing threads changes the displayed inputs. F2 shows the failed attempt if the footer falls back. After editing the Python file, restart its stdio process to load the changes.
+1
View File
@@ -14,6 +14,7 @@ const LEGACY_REPEAT_GUARD: Duration = Duration::from_secs(/*secs*/ 1);
pub(crate) enum ActivationKeySuppression {
ViewTransition,
ReportedRepeats,
PressOnlyFallback,
}
#[derive(Clone, Copy)]
+19
View File
@@ -67,6 +67,7 @@ impl App {
| AppEvent::OpenStatuslinePicker(_)
| AppEvent::CloseStatuslinePicker(_)
| AppEvent::ChooseStatuslineProvider { .. }
| AppEvent::CreateCustomStatusline { .. }
| AppEvent::StatuslinePicker { .. }
| AppEvent::StatusLineSetupCancelled
| AppEvent::TerminalTitleSetup { .. }
@@ -496,6 +497,24 @@ impl App {
}
}
AppEvent::ChooseStatuslineProvider { scan, id, key } => self.choose_statusline_provider(scan, id, key, app_server).await,
AppEvent::CreateCustomStatusline { backend, thread_id, key } => {
if app_server.thread_params_mode() != crate::ThreadParamsMode::Cloud
&& self.config.features.enabled(Feature::TuiExtensionsStatusLine)
&& self.chat_widget.active_view_is(crate::bottom_pane::StatusLineSetupView::VIEW_ID)
&& self.chat_widget.model_catalog().backend == backend
&& backend.is_none_or(|id| id == app_server.backend_id())
&& self.current_displayed_thread_id() == thread_id
{
crate::boxed_future!(self.start_statusline_authoring(tui, app_server)).await;
if self.current_displayed_thread_id() != thread_id {
self.chat_widget.suppress_current_view_key_until_release(
key,
Instant::now(),
crate::activation_key_guard::ActivationKeySuppression::PressOnlyFallback,
);
}
}
}
AppEvent::StatuslinePicker { scan, updates } => self.finish_statusline_discovery(scan, updates, app_server),
AppEvent::StatuslineRead(event) => {
self.chat_widget.handle_statusline_read(event, app_server);
+88 -14
View File
@@ -18,9 +18,12 @@ use crate::app_server_session::SideChatStorage;
use crate::app_server_session::is_server_shutting_down_error;
use crate::app_server_session::source_agent_path;
use crate::app_server_session::thread_blocks_direct_input;
use crate::bottom_pane::MentionBinding;
use crate::chatwidget::ThreadInputStateRestoreMode;
use crate::chatwidget::UserMessage;
use crate::startup_draft::StartupDraftPump;
use crate::streaming::commit_tick::CommitTickScope;
use codex_app_server_protocol::SkillScope;
use codex_app_server_protocol::ThreadPrepareApprovedPlanParams;
use codex_model_provider_info::OPENAI_PROVIDER_ID;
use std::collections::HashSet;
@@ -1343,14 +1346,14 @@ impl App {
} else {
ThreadAttachPresentation::Fresh
};
self.adopt_fresh_session(
crate::boxed_future!(self.adopt_fresh_session(
tui,
app_server,
prepared,
presentation,
initial_user_message,
new_thread_name,
)
))
.await;
}
Err(err) => {
@@ -1370,6 +1373,65 @@ impl App {
}
}
pub(super) async fn start_statusline_authoring(
&mut self,
tui: &mut tui::Tui,
app_server: &mut AppServerSession,
) {
if self.reconnect.offline {
self.chat_widget.add_error_message(
"Reconnect to the app server to create a custom statusline.".into(),
);
return;
}
let previous_thread_id = self.chat_widget.thread_id();
self.start_fresh_session(
tui,
app_server,
FreshSessionStart::NewConversation,
/*initial_user_message*/ None,
/*new_thread_name*/ None,
)
.await;
let thread_id = self.chat_widget.thread_id();
if thread_id.is_none() || thread_id == previous_thread_id {
return;
}
let cwd = self.chat_widget.config_ref().cwd.to_path_buf();
let mut draft = UserMessage::from("Help me build and enable a custom statusline.");
if let Ok(skills) = app_server
.skills_list(SkillsListParams {
cwds: vec![cwd.clone()],
force_reload: false,
})
.await
{
if let Some(skill) = skills
.data
.iter()
.find(|entry| entry.cwd == cwd)
.into_iter()
.flat_map(|entry| &entry.skills)
.find(|skill| {
skill.enabled
&& skill.scope == SkillScope::System
&& skill.name == "create-statusline"
})
{
draft.text =
"Use $create-statusline to help me build and enable a custom statusline."
.into();
draft.mention_bindings.push(MentionBinding {
sigil: '$',
mention: skill.name.clone(),
path: skill.path.as_str().to_owned(),
});
}
self.handle_skills_list_response(skills);
}
self.chat_widget.restore_user_message_to_composer(draft);
}
async fn prepare_fresh_session(
&mut self,
app_server: &mut AppServerSession,
@@ -1483,17 +1545,15 @@ impl App {
self.chat_widget.add_error_message(error.to_string());
return;
}
if let Some(thread_id) = self.current_displayed_thread_id()
// A completed turn can release queued input while draining the outgoing thread.
let handoff = self.chat_widget.pause_input_for_resume_handoff();
let source_thread = self.current_displayed_thread_id();
if let Some(thread_id) = source_thread
&& let Some(blank) = self.agents_overview.blank_sessions.get_mut(&thread_id)
&& let Some(channel) = self.thread_event_channels.get(&thread_id)
&& let Some(session) = channel.store.lock().await.session.as_ref()
{
if let Some(channel) = self.thread_event_channels.get(&thread_id)
&& let Some(session) = channel.store.lock().await.session.as_ref()
{
blank.session = session.clone();
}
if let Some(input) = self.chat_widget.capture_thread_input_state() {
self.agents_overview.input_states.insert(thread_id, input);
}
blank.session = session.clone();
}
self.detach_current_thread_for_navigation(app_server, Some(started.session.thread_id))
.await;
@@ -1532,16 +1592,21 @@ impl App {
.blank_sessions
.insert(thread_id, started.clone());
}
if let Err(err) = self
let attached = self
.replace_chat_widget_with_account(
tui,
started,
presentation,
initial_user_message,
account,
source_thread,
)
.await
{
.await;
drop(handoff);
if let Err(err) = attached {
if self.current_displayed_thread_id() == source_thread {
self.chat_widget.maybe_send_next_queued_input();
}
self.agents_overview.blank_sessions.remove(&thread_id);
self.chat_widget.add_error_message(format!(
"Failed to attach to fresh app-server thread: {err}"
@@ -1571,6 +1636,7 @@ impl App {
presentation,
initial_user_message,
/*account*/ None,
/*source_thread*/ None,
)
.await
}
@@ -1606,6 +1672,7 @@ impl App {
presentation: ThreadAttachPresentation,
initial_user_message: Option<crate::chatwidget::UserMessage>,
account: Option<SessionAccount>,
source_thread: Option<ThreadId>,
) -> Result<()> {
// Initial messages are for freshly attached primary threads only. Thread switches and
// resume/fork flows pass `None` so they cannot replay old history and then auto-submit a new
@@ -1616,6 +1683,13 @@ impl App {
) {
self.drain_outgoing_thread_events().await;
}
if let Some(thread_id) = source_thread
&& (self.agents_overview.blank_sessions.contains_key(&thread_id)
|| self.chat_widget.has_unsent_input())
&& let Some(input) = self.chat_widget.capture_thread_input_state()
{
self.agents_overview.input_states.insert(thread_id, input);
}
self.store_active_thread_receiver().await;
self.refresh_transcript_document_links();
self.reset_transcript_state_after_clear();
@@ -29,6 +29,7 @@ async fn picker() -> anyhow::Result<(
.enable(Feature::TuiExtensionsStatusLine)?;
app.chat_widget
.set_feature_enabled(Feature::TuiExtensionsStatusLine, /*enabled*/ true);
app.chat_widget.thread_params_mode = ThreadParamsMode::Cloud;
let (client, commands, _) = CloudClient::channel(/*capacity*/ 8);
let owner = AppServerSession::new(
BackendId::new(),
@@ -39,8 +40,9 @@ async fn picker() -> anyhow::Result<(
}
#[tokio::test(start_paused = true)]
async fn holding_enter_opens_the_statusline_picker_without_selecting() -> anyhow::Result<()> {
async fn quick_second_enter_opens_the_statusline_picker_without_selecting() -> anyhow::Result<()> {
let (mut app, mut owner, _commands, mut events) = picker().await?;
app.chat_widget.thread_params_mode = ThreadParamsMode::Embedded;
let mut tui = make_test_tui()?;
app.chat_widget
.restore_user_message_to_composer("/statusline".into());
@@ -83,6 +85,33 @@ async fn holding_enter_opens_the_statusline_picker_without_selecting() -> anyhow
Ok(())
}
#[tokio::test]
async fn statusline_create_is_ignored_after_dismissing_setup() -> anyhow::Result<()> {
let (mut app, _, _, mut events) = picker().await?;
app.chat_widget.thread_params_mode = ThreadParamsMode::Embedded;
app.chat_widget
.dispatch_command(crate::slash_command::SlashCommand::Statusline);
app.chat_widget.handle_key_event(KeyCode::Down.into());
app.chat_widget.handle_key_event(KeyCode::Enter.into());
let create = std::iter::from_fn(|| events.try_recv().ok())
.find(|event| matches!(event, AppEvent::CreateCustomStatusline { .. }))
.expect("Create selected");
app.chat_widget.handle_key_event(KeyCode::Esc.into());
let (client, mut requests, _) = CloudClient::channel(/*capacity*/ 1);
let mut server = AppServerSession::new(
BackendId::new(),
AppServerClient::Cloud(client),
ThreadParamsMode::Remote,
);
let mut tui = make_test_tui()?;
tokio::select! {
result = app.handle_event(&mut tui, &mut server, create) => { result.unwrap(); }
_ = requests.recv() => panic!("dismissed Create contacted the server"),
}
Ok(())
}
#[tokio::test(start_paused = true)]
async fn statusline_picker_disconnect_leaves_the_item_editor_open() -> anyhow::Result<()> {
let (mut app, owner, mut commands, mut events) = picker().await?;
@@ -1692,6 +1692,184 @@ async fn replacement_preserves_remote_launch_paths_and_older_servers() -> Result
Ok(())
}
#[tokio::test]
async fn fresh_session_saves_input_restored_by_a_late_interrupt() -> Result<()> {
use crate::app::session_lifecycle::PreparedFreshSession;
use crate::app::session_lifecycle::ThreadAttachPresentation;
use codex_app_server_client::AppServerClient;
use codex_app_server_client::CloudClient;
use codex_app_server_client::CloudOperation;
let (mut app, _, _) = make_test_app_with_channels().await;
let source = ThreadId::new();
let cwd = app.config.cwd.to_path_buf();
app.enqueue_primary_thread_session(test_thread_session(source, cwd.clone()), Vec::new())
.await?;
app.chat_widget.handle_server_notification(
turn_started_notification(source, "running"),
/*replay_kind*/ None,
);
app.chat_widget
.apply_external_edit("queued follow-up".into());
app.chat_widget.handle_key_event(KeyCode::Tab.into());
app.chat_widget.apply_external_edit("source draft".into());
let events = app.ensure_thread_channel(source).sender.clone();
let mut session = test_thread_session(ThreadId::new(), cwd);
session.model_provider_id = app.chat_widget.quota_provider_id().to_owned();
let prepared = PreparedFreshSession {
started: AppServerStartedThread {
session,
turns: Vec::new(),
blocks_direct_input: false,
task_tools_available: false,
},
config: app.config.clone(),
local_settings: app.local_settings.clone(),
};
let (client, mut commands, _) = CloudClient::channel(/*capacity*/ 1);
let mut server = AppServerSession::new(
crate::backend_id::BackendId::new(),
AppServerClient::Cloud(client),
crate::app_server_session::ThreadParamsMode::Remote,
);
let mut tui = crate::tui::test_support::make_test_tui()?;
tokio::join!(
crate::boxed_future!(app.adopt_fresh_session(
&mut tui,
&mut server,
prepared,
ThreadAttachPresentation::Fresh,
/*initial_user_message*/ None,
/*new_thread_name*/ None,
)),
async {
let command = commands.recv().await.unwrap();
assert!(
matches!(command.operation, CloudOperation::Request(request) if matches!(
request.as_ref(),
ClientRequest::ThreadUnsubscribe { params, .. } if params.thread_id == source.to_string()
))
);
events
.send(ThreadBufferedEvent::Notification(Box::new(
turn_completed_notification(source, "running", TurnStatus::Interrupted),
)))
.await
.unwrap();
command
.response
.send(Ok(Ok(serde_json::json!({
"status": "unsubscribed"
}))))
.unwrap();
}
);
let input = app.agents_overview.input_states.remove(&source).unwrap();
app.chat_widget.restore_thread_input_state(
Some(input),
crate::chatwidget::ThreadInputStateRestoreMode {
preserve_in_flight_turn: false,
},
);
assert_eq!(
app.chat_widget.composer_text_with_pending(),
"queued follow-up\nsource draft"
);
assert!(app.chat_widget.queued_user_message_texts().is_empty());
Ok(())
}
#[tokio::test]
async fn create_statusline_keeps_the_draft_editable() -> Result<()> {
let (mut app, mut events, mut ops) = make_test_app_with_channels().await;
app.config
.features
.enable(Feature::TuiExtensionsStatusLine)?;
app.chat_widget
.set_feature_enabled(Feature::TuiExtensionsStatusLine, /*enabled*/ true);
let cwd = app.config.codex_home.to_path_buf();
let user_skill = cwd.join("skills/create-statusline");
std::fs::create_dir_all(&user_skill)?;
std::fs::write(
user_skill.join("SKILL.md"),
"---\nname: create-statusline\ndescription: A user skill with the same name.\n---\nUser skill.\n",
)?;
let source = ThreadId::new();
app.enqueue_primary_thread_session(test_thread_session(source, cwd), Vec::new())
.await?;
app.chat_widget.handle_server_notification(
turn_started_notification(source, "running"),
/*replay_kind*/ None,
);
app.chat_widget
.apply_external_edit("queued follow-up".into());
app.chat_widget.handle_key_event(KeyCode::Tab.into());
app.chat_widget
.apply_external_edit("Keep this draft".into());
app.chat_widget
.dispatch_command(crate::slash_command::SlashCommand::Statusline);
app.chat_widget.handle_key_event(KeyCode::Down.into());
app.chat_widget.handle_key_event(KeyCode::Enter.into());
let create = std::iter::from_fn(|| events.try_recv().ok())
.find(|event| matches!(event, AppEvent::CreateCustomStatusline { .. }))
.expect("Create selected");
app.enqueue_thread_notification(
source,
turn_completed_notification(source, "running", TurnStatus::Completed),
)
.await?;
let mut tui = crate::tui::test_support::make_test_tui()?;
tui.pause_events();
let mut server = crate::start_embedded_app_server_for_picker(&app.config).await?;
app.handle_event(&mut tui, &mut server, create).await?;
assert_ne!(app.chat_widget.thread_id(), Some(source));
let draft = app.chat_widget.composer_draft_snapshot();
assert!(draft.text.contains("$create-statusline"));
let home = app.config.codex_home.canonicalize()?.abs();
let bundled_skill =
codex_skills::system_cache_root_dir(&home).join("create-statusline/SKILL.md");
let [binding] = draft.mention_bindings.as_slice() else {
panic!("expected one skill binding");
};
assert_eq!(binding.path, bundled_skill.to_string_lossy());
// Press-only terminals report a held Enter as another press.
app.chat_widget.handle_key_event(KeyCode::Enter.into());
assert_eq!(app.chat_widget.composer_draft_snapshot(), draft);
assert!(
!std::iter::from_fn(|| ops.try_recv().ok()).any(|op| matches!(op, Op::UserTurn { .. }))
);
assert!(
!std::iter::from_fn(|| events.try_recv().ok())
.any(|event| matches!(event, AppEvent::CodexOp(Op::UserTurn { .. })))
);
app.chat_widget
.handle_key_event(KeyEvent::new(KeyCode::Char('u'), KeyModifiers::CONTROL));
let edited = app.chat_widget.composer_draft_snapshot();
assert!(!edited.text.contains("$create-statusline"));
assert!(edited.mention_bindings.is_empty());
let input = app.agents_overview.input_states.remove(&source).unwrap();
app.chat_widget.restore_thread_input_state(
Some(input),
crate::chatwidget::ThreadInputStateRestoreMode {
preserve_in_flight_turn: false,
},
);
assert_eq!(
app.chat_widget.composer_text_with_pending(),
"Keep this draft"
);
assert_eq!(
app.chat_widget.queued_user_message_texts(),
["queued follow-up"]
);
server.shutdown().await?;
Ok(())
}
#[tokio::test]
async fn provider_continuation_starts_current_provider_and_drafts_saved_reference() -> Result<()> {
use crate::app_server_session::ThreadParamsMode;
+5
View File
@@ -1910,6 +1910,11 @@ pub(crate) enum AppEvent {
id: Option<crate::statusline_provider::ProviderId>,
key: crate::key_hint::KeyBinding,
},
CreateCustomStatusline {
backend: Option<crate::backend_id::BackendId>,
thread_id: Option<ThreadId>,
key: crate::key_hint::KeyBinding,
},
StatuslinePicker {
scan: uuid::Uuid,
updates: Vec<crate::statusline_provider::discovery::DiscoveryUpdate>,
+20 -3
View File
@@ -209,6 +209,7 @@ pub(crate) use skills_toggle_view::SkillsToggleItem;
pub(crate) use skills_toggle_view::SkillsToggleView;
pub(crate) use status_line_setup::StatusLineItem;
pub(crate) use status_line_setup::StatusLineSetupView;
pub(crate) use status_line_setup::StatuslineProviderActions;
pub(crate) use status_surface_preview::StatusSurfacePreviewData;
pub(crate) use status_surface_preview::StatusSurfacePreviewItem;
pub(crate) use title_setup::TerminalTitleItem;
@@ -2059,8 +2060,13 @@ impl BottomPane {
activated_at: Instant,
suppression: ActivationKeySuppression,
) {
let reported_repeats_only = self.enhanced_keys_supported
|| matches!(suppression, ActivationKeySuppression::ReportedRepeats);
let reported_repeats_only = match suppression {
ActivationKeySuppression::ViewTransition => self.enhanced_keys_supported,
ActivationKeySuppression::ReportedRepeats => true,
ActivationKeySuppression::PressOnlyFallback => {
self.enhanced_keys_supported && crate::tui::reports_key_releases()
}
};
self.view_transition_key_guard = Some(ActivationKeyGuard::new_at(
key,
activated_at,
@@ -3025,7 +3031,7 @@ mod tests {
fn view_transition_key_guard_survives_an_intervening_modal() {
let (tx_raw, _rx) = unbounded_channel::<AppEvent>();
let mut pane = test_pane(AppEventSender::new(tx_raw));
let activation_key = crate::key_hint::plain(KeyCode::Enter);
let activation_key = crate::key_hint::plain(KeyCode::F(11));
pane.suppress_current_view_key_until_release(
activation_key,
Instant::now(),
@@ -3033,9 +3039,20 @@ mod tests {
);
pane.push_view(Box::new(DismissibleView::default()));
// Press-only terminals report repeats as presses.
assert!(pane.consume_view_transition_key(activation_key, KeyEventKind::Press));
assert!(pane.consume_view_transition_key(activation_key, KeyEventKind::Repeat));
assert!(pane.consume_view_transition_key(activation_key, KeyEventKind::Release));
assert!(!pane.consume_view_transition_key(activation_key, KeyEventKind::Press));
// Enhanced picker transitions allow another intentional press without a release.
pane.enhanced_keys_supported = true;
pane.suppress_current_view_key_until_release(
activation_key,
Instant::now(),
ActivationKeySuppression::ViewTransition,
);
assert!(!pane.consume_view_transition_key(activation_key, KeyEventKind::Press));
}
#[test]
@@ -110,6 +110,9 @@ pub type ConfirmCallback = Box<dyn Fn(&[String], &AppEventSender) + Send + Sync>
/// Callback invoked when the user cancels the picker (presses Escape).
pub type CancelCallback = Box<dyn Fn(&AppEventSender) + Send + Sync>;
/// Action dispatched from a picker row with the key that activated it.
type ActionCallback = Box<dyn Fn(&AppEventSender, KeyBinding) + Send + Sync>;
/// Callback to generate an optional preview line based on current item states.
/// Returns `None` to hide the preview area.
type PreviewCallback = Box<dyn Fn(&[MultiSelectItem]) -> Option<StatusLine> + Send + Sync>;
@@ -137,7 +140,7 @@ pub(crate) struct MultiSelectItem {
/// Whether to draw a divider after this item when another visible item follows.
pub section_break_after: bool,
/// An action row opens its child on Enter and has no checkbox.
pub on_activate: Option<fn(&AppEventSender, KeyBinding)>,
pub on_activate: Option<ActionCallback>,
}
impl Default for MultiSelectItem {
@@ -406,7 +409,7 @@ impl MultiSelectPicker {
.state
.selected_idx
.and_then(|index| self.filtered_indices.get(index))
.and_then(|index| self.items[*index].on_activate)
.and_then(|index| self.items[*index].on_activate.as_deref())
{
action(&self.app_event_tx, activation_key);
return;
@@ -31,6 +31,7 @@ use strum_macros::EnumString;
use crate::app_event::AppEvent;
use crate::app_event_sender::AppEventSender;
use crate::backend_id::BackendId;
use crate::bottom_pane::CancellationEvent;
use crate::bottom_pane::bottom_pane_view::BottomPaneView;
use crate::bottom_pane::multi_select_picker::MultiSelectItem;
@@ -281,6 +282,15 @@ impl StatusLineItem {
}
}
pub(crate) enum StatuslineProviderActions {
Hidden,
Choose,
CreateAndChoose {
backend: Option<BackendId>,
thread_id: Option<codex_protocol::ThreadId>,
},
}
/// Interactive view for configuring which items appear in the status line.
///
/// Wraps a [`MultiSelectPicker`] with status-line-specific behavior:
@@ -311,19 +321,36 @@ impl StatusLineSetupView {
pub(crate) fn new(
status_line_items: Option<&[String]>,
use_theme_colors: bool,
provider_actions: bool,
providers: StatuslineProviderActions,
preview_data: StatusSurfacePreviewData,
app_event_tx: AppEventSender,
list_keymap: ListKeymap,
) -> Self {
let mut used_ids = HashSet::new();
let mut items = Vec::new();
if provider_actions {
if !matches!(providers, StatuslineProviderActions::Hidden) {
items.push(MultiSelectItem {
name: "Choose a statusline plugin".into(),
name: "Choose a status line provider".into(),
orderable: false,
section_break_after: matches!(providers, StatuslineProviderActions::Choose),
on_activate: Some(Box::new(|tx, key| {
tx.send(AppEvent::OpenStatuslinePicker(key))
})),
..Default::default()
});
}
if let StatuslineProviderActions::CreateAndChoose { backend, thread_id } = providers {
items.push(MultiSelectItem {
name: "Create a custom status line".into(),
orderable: false,
section_break_after: true,
on_activate: Some(|tx, key| tx.send(AppEvent::OpenStatuslinePicker(key))),
on_activate: Some(Box::new(move |tx, key| {
tx.send(AppEvent::CreateCustomStatusline {
backend,
thread_id,
key,
})
})),
..Default::default()
});
}
@@ -754,7 +781,7 @@ mod tests {
let mut view = StatusLineSetupView::new(
Some(&[StatusLineItem::PullRequestNumber.to_string()]),
use_theme_colors,
/*provider_actions*/ false,
StatuslineProviderActions::Hidden,
preview,
AppEventSender::new(tx),
crate::keymap::RuntimeKeymap::defaults().list,
@@ -779,7 +806,7 @@ mod tests {
StatusLineItem::GitBranch.to_string(),
]),
/*use_theme_colors*/ true,
/*provider_actions*/ false,
StatuslineProviderActions::Hidden,
StatusSurfacePreviewData::from_iter([
(
StatusLineItem::ModelName.preview_item(),
@@ -814,7 +841,7 @@ mod tests {
StatusLineItem::EstimatedThreadCost.to_string(),
]),
/*use_theme_colors*/ true,
/*provider_actions*/ false,
StatuslineProviderActions::Hidden,
StatusSurfacePreviewData::from_iter([
(
StatusLineItem::ThreadCredits.preview_item(),
@@ -841,7 +868,7 @@ mod tests {
StatusLineItem::CurrentDir.to_string(),
]),
/*use_theme_colors*/ true,
/*provider_actions*/ false,
StatuslineProviderActions::Hidden,
StatusSurfacePreviewData::from_iter([
(
StatusLineItem::Hostname.preview_item(),
@@ -7,14 +7,14 @@ expression: status_line_popup_snapshot(&mut chat)
Type to search
› Choose a statusline plugin
› Choose a status line provider
Create a custom status line
───────────────────────
[x] Use theme colors Apply colors from the active /theme
[x] Use theme colors Apply colors from the active /theme
───────────────────────
[x] project-name Project name (omitted when unavailable)
[x] git-branch Current Git branch (omitted when unavailable)
[x] thread-title Current thread title, or thread identifier when unnamed
[ ] model Current model name
[x] project-name Project name (omitted when unavailable)
[x] git-branch Current Git branch (omitted when unavailable)
[x] thread-title Current thread title, or thread identifier when unnamed
↓
preview-live-root · feature/live-preview-branch · Live preview thread
enter select · esc back
@@ -0,0 +1,20 @@
---
source: tui/src/chatwidget/tests/status_surface_previews.rs
expression: status_line_popup_snapshot(&mut chat)
---
Configure Status Line
Select which items to display in the status line.
Type to search
› Choose a status line provider
───────────────────────
[x] Use theme colors Apply colors from the active /theme
───────────────────────
[x] model-with-reasoning Current model name with reasoning level
[x] current-dir Current working directory
[x] thread-name Current thread name (omitted when unnamed)
[ ] model Current model name
↓
GPT-5.6-Sol default · /tmp/project · thread name
enter select · esc back
+17 -3
View File
@@ -328,13 +328,27 @@ impl ChatWidget {
}
pub(super) fn open_status_line_setup(&mut self) {
use crate::bottom_pane::StatuslineProviderActions;
let configured_status_line_items = self.configured_status_line_items();
let providers = if !self
.config
.features
.enabled(codex_features::Feature::TuiExtensionsStatusLine)
{
StatuslineProviderActions::Hidden
} else if self.thread_params_mode == crate::ThreadParamsMode::Cloud {
StatuslineProviderActions::Choose
} else {
StatuslineProviderActions::CreateAndChoose {
backend: self.model_catalog.backend,
thread_id: self.thread_id(),
}
};
let view = StatusLineSetupView::new(
Some(configured_status_line_items.as_slice()),
self.local_settings.tui.status_line_use_colors,
self.config
.features
.enabled(codex_features::Feature::TuiExtensionsStatusLine),
providers,
self.status_surface_preview_data(),
self.app_event_tx.clone(),
self.bottom_pane.list_keymap(),
@@ -25,6 +25,18 @@ fn rendered_history(events: Vec<AppEvent>) -> String {
.collect()
}
#[tokio::test]
async fn built_in_statusline_accepts_a_second_enter() {
let (mut chat, mut events, _ops) = make_chatwidget_manual(/*model_override*/ None).await;
chat.restore_user_message_to_composer("/statusline".into());
chat.handle_key_event(KeyCode::Enter.into());
chat.handle_key_event(KeyCode::Enter.into());
assert!(
std::iter::from_fn(|| events.try_recv().ok())
.any(|event| matches!(event, AppEvent::StatusLineSetup { .. }))
);
}
#[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;
@@ -170,6 +170,17 @@ async fn status_line_setup_popup_live_only_snapshot() {
);
}
#[tokio::test]
async fn status_line_setup_popup_cloud_hides_create() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
chat.set_feature_enabled(Feature::TuiExtensionsStatusLine, /*enabled*/ true);
chat.thread_params_mode = crate::ThreadParamsMode::Cloud;
assert_chatwidget_snapshot!(
"status_line_setup_popup_native_cloud",
status_line_popup_snapshot(&mut chat)
);
}
#[tokio::test]
async fn status_surface_preview_lines_hardcoded_only_snapshot() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
@@ -133,9 +133,7 @@ async fn statusline_reads_the_selected_stdio_resource_on_the_displayed_thread()
terminal.wait_for_screen("Raw output mode off")?;
terminal.wait_for_screen(&format!("Provider thread {thread} (standard)"))?;
terminal.write_input(b"/statusline\r")?;
terminal.wait_for_screen("Choose a statusline plugin")?;
// This PTY reports presses only. Navigate back to the action before pressing Enter again.
terminal.write_input(b"\x1b[B\x1b[A")?;
terminal.wait_for_screen("Choose a status line provider")?;
for row in ["Default status line", "fixture / sandbox_meta"] {
terminal.write_input(b"\r")?;
terminal.wait_for_screen(row)?;