mirror of
https://github.com/openai/codex.git
synced 2026-12-03 07:47:10 +00:00
tui: clarify pending steer follow-ups (#13841)
## Summary - split the pending input preview into labeled pending-steer and queued follow-up sections - explain that pending steers submit after the next tool call and that Esc can interrupt and send them immediately - treat Esc as an interrupt-plus-resubmit path when pending steers exist, with updated TUI snapshots and tests Queues and steers: <img width="1038" height="263" alt="Screenshot 2026-03-07 at 10 17 17 PM" src="https://github.com/user-attachments/assets/4ef433ef-27a3-4b7c-ad69-2046f6eb89e6" /> After pressing Esc: <img width="1046" height="320" alt="Screenshot 2026-03-07 at 10 17 21 PM" src="https://github.com/user-attachments/assets/0f4d89e0-b6b9-486a-9f04-b6021f169ba7" /> ## Codex author `codex resume 019cc6f4-2cca-7803-b717-8264526dbd97` --------- Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
1 parent
f41b1638c9
commit
4ad3b59de3
17 files changed
+406
-136
No files matched your search
@@ -12,11 +12,13 @@ use crate::wrapping::adaptive_wrap_lines;
|
||||
|
||||
/// Widget that displays pending steers plus user messages queued while a turn is in progress.
|
||||
///
|
||||
/// The widget shows pending steers first, then queued user messages. It only
|
||||
/// shows the edit hint at the bottom (e.g. "⌥ + ↑ edit") when there are actual
|
||||
/// queued user messages to pop back into the composer. Because some terminals
|
||||
/// intercept certain modifier-key combinations, the displayed binding is
|
||||
/// configurable via [`set_edit_binding`](Self::set_edit_binding).
|
||||
/// The widget renders pending steers first, then queued user messages, as two
|
||||
/// labeled sections. Pending steers explain that they will be submitted after
|
||||
/// the next tool/result boundary unless the user presses Esc to interrupt and
|
||||
/// send them immediately. The edit hint at the bottom only appears when there
|
||||
/// are actual queued user messages to pop back into the composer. Because some
|
||||
/// terminals intercept certain modifier-key combinations, the displayed
|
||||
/// binding is configurable via [`set_edit_binding`](Self::set_edit_binding).
|
||||
pub(crate) struct PendingInputPreview {
|
||||
pub pending_steers: Vec<String>,
|
||||
pub queued_messages: Vec<String>,
|
||||
@@ -55,6 +57,15 @@ impl PendingInputPreview {
|
||||
}
|
||||
}
|
||||
|
||||
fn push_section_header(lines: &mut Vec<Line<'static>>, width: u16, header: Line<'static>) {
|
||||
let mut spans = vec!["• ".dim()];
|
||||
spans.extend(header.spans);
|
||||
lines.extend(adaptive_wrap_lines(
|
||||
std::iter::once(Line::from(spans)),
|
||||
RtOptions::new(width as usize).subsequent_indent(Line::from(" ".dim())),
|
||||
));
|
||||
}
|
||||
|
||||
fn as_renderable(&self, width: u16) -> Box<dyn Renderable> {
|
||||
if (self.pending_steers.is_empty() && self.queued_messages.is_empty()) || width < 4 {
|
||||
return Box::new(());
|
||||
@@ -62,28 +73,48 @@ impl PendingInputPreview {
|
||||
|
||||
let mut lines = vec![];
|
||||
|
||||
for steer in &self.pending_steers {
|
||||
let wrapped = adaptive_wrap_lines(
|
||||
steer.lines().map(|line| Line::from(line.dim())),
|
||||
RtOptions::new(width as usize)
|
||||
.initial_indent(Line::from(" ! pending steer: ".dim()))
|
||||
.subsequent_indent(Line::from(" ")),
|
||||
if !self.pending_steers.is_empty() {
|
||||
Self::push_section_header(
|
||||
&mut lines,
|
||||
width,
|
||||
Line::from(vec![
|
||||
"Messages to be submitted after next tool call".into(),
|
||||
" (press ".dim(),
|
||||
key_hint::plain(KeyCode::Esc).into(),
|
||||
" to interrupt and send immediately)".dim(),
|
||||
]),
|
||||
);
|
||||
Self::push_truncated_preview_lines(&mut lines, wrapped, Line::from(" …".dim()));
|
||||
|
||||
for steer in &self.pending_steers {
|
||||
let wrapped = adaptive_wrap_lines(
|
||||
steer.lines().map(|line| Line::from(line.dim())),
|
||||
RtOptions::new(width as usize)
|
||||
.initial_indent(Line::from(" ↳ ".dim()))
|
||||
.subsequent_indent(Line::from(" ")),
|
||||
);
|
||||
Self::push_truncated_preview_lines(&mut lines, wrapped, Line::from(" …".dim()));
|
||||
}
|
||||
}
|
||||
|
||||
for message in &self.queued_messages {
|
||||
let wrapped = adaptive_wrap_lines(
|
||||
message.lines().map(|line| Line::from(line.dim().italic())),
|
||||
RtOptions::new(width as usize)
|
||||
.initial_indent(Line::from(" ↳ ".dim()))
|
||||
.subsequent_indent(Line::from(" ")),
|
||||
);
|
||||
Self::push_truncated_preview_lines(
|
||||
&mut lines,
|
||||
wrapped,
|
||||
Line::from(" …".dim().italic()),
|
||||
);
|
||||
if !self.queued_messages.is_empty() {
|
||||
if !lines.is_empty() {
|
||||
lines.push(Line::from(""));
|
||||
}
|
||||
Self::push_section_header(&mut lines, width, "Queued follow-up messages".into());
|
||||
|
||||
for message in &self.queued_messages {
|
||||
let wrapped = adaptive_wrap_lines(
|
||||
message.lines().map(|line| Line::from(line.dim().italic())),
|
||||
RtOptions::new(width as usize)
|
||||
.initial_indent(Line::from(" ↳ ".dim()))
|
||||
.subsequent_indent(Line::from(" ")),
|
||||
);
|
||||
Self::push_truncated_preview_lines(
|
||||
&mut lines,
|
||||
wrapped,
|
||||
Line::from(" …".dim().italic()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if !self.queued_messages.is_empty() {
|
||||
@@ -91,7 +122,7 @@ impl PendingInputPreview {
|
||||
Line::from(vec![
|
||||
" ".into(),
|
||||
self.edit_binding.into(),
|
||||
" edit".into(),
|
||||
" edit last queued message".into(),
|
||||
])
|
||||
.dim(),
|
||||
);
|
||||
@@ -131,7 +162,7 @@ mod tests {
|
||||
fn desired_height_one_message() {
|
||||
let mut queue = PendingInputPreview::new();
|
||||
queue.queued_messages.push("Hello, world!".to_string());
|
||||
assert_eq!(queue.desired_height(40), 2);
|
||||
assert_eq!(queue.desired_height(40), 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -219,8 +250,8 @@ mod tests {
|
||||
let width = 36;
|
||||
let height = queue.desired_height(width);
|
||||
assert_eq!(
|
||||
height, 2,
|
||||
"expected one message row plus hint row for URL-like token"
|
||||
height, 3,
|
||||
"expected header, one message row, and hint row for URL-like token"
|
||||
);
|
||||
|
||||
let mut buf = Buffer::empty(Rect::new(0, 0, width, height));
|
||||
|
||||
Reference in new issue
Block a user