mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Dim conversation recaps in the TUI (#46332)
## What changed Apply dim styling to all rendered recap lines and remove the cyan color from `Next:`, preserving italics and bold labels. ## Testing Update recap style assertions and add a rendered-buffer snapshot covering dimmed text, label styling, line breaks, and next-action wrapping. GitOrigin-RevId: 2dfef4753fa5da4e1fae32b5cdb03a881482f91b
This commit is contained in:
1 parent
ad70cbdd96
commit
3cd255a4ee
3 files changed
+55
-25
No files matched your search
@@ -28,8 +28,12 @@ use codex_app_server_protocol::Turn;
|
|||||||
use codex_app_server_protocol::TurnStatus;
|
use codex_app_server_protocol::TurnStatus;
|
||||||
use codex_protocol::ThreadId;
|
use codex_protocol::ThreadId;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
use ratatui::buffer::Buffer;
|
||||||
|
use ratatui::layout::Rect;
|
||||||
use ratatui::style::Modifier;
|
use ratatui::style::Modifier;
|
||||||
use ratatui::style::Stylize;
|
use ratatui::style::Stylize;
|
||||||
|
use ratatui::widgets::Paragraph;
|
||||||
|
use ratatui::widgets::Widget;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@@ -653,11 +657,11 @@ fn recap_history_cell_uses_hanging_indent_and_right_padding() {
|
|||||||
let cell =
|
let cell =
|
||||||
ThreadRecapHistoryCell::new("Automatic recaps stay compact on wide terminals.".to_string());
|
ThreadRecapHistoryCell::new("Automatic recaps stay compact on wide terminals.".to_string());
|
||||||
let lines = cell.display_lines(/*width*/ 56);
|
let lines = cell.display_lines(/*width*/ 56);
|
||||||
assert!(
|
assert!(lines.iter().all(|line| {
|
||||||
lines
|
line.style
|
||||||
.iter()
|
.add_modifier
|
||||||
.all(|line| line.style.add_modifier.contains(Modifier::ITALIC))
|
.contains(Modifier::ITALIC | Modifier::DIM)
|
||||||
);
|
}));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&lines[0].spans[..3],
|
&lines[0].spans[..3],
|
||||||
&[" ".into(), "↳ ".dim(), "Recap: ".bold()],
|
&[" ".into(), "↳ ".dim(), "Recap: ".bold()],
|
||||||
@@ -726,11 +730,11 @@ fn recap_history_cell_wraps_long_urls_in_narrow_terminals() {
|
|||||||
.skip(/*n*/ 1)
|
.skip(/*n*/ 1)
|
||||||
.all(|line| line.to_string().starts_with(" "))
|
.all(|line| line.to_string().starts_with(" "))
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(lines.iter().all(|line| {
|
||||||
lines
|
line.style
|
||||||
.iter()
|
.add_modifier
|
||||||
.all(|line| line.style.add_modifier.contains(Modifier::ITALIC))
|
.contains(Modifier::ITALIC | Modifier::DIM)
|
||||||
);
|
}));
|
||||||
let rendered = lines
|
let rendered = lines
|
||||||
.iter()
|
.iter()
|
||||||
.map(ToString::to_string)
|
.map(ToString::to_string)
|
||||||
@@ -827,7 +831,7 @@ fn recap_history_cell_wraps_next_action_urls_in_narrow_terminals() {
|
|||||||
.iter()
|
.iter()
|
||||||
.flat_map(|line| &line.spans)
|
.flat_map(|line| &line.spans)
|
||||||
.find(|span| span.content == "Next: "),
|
.find(|span| span.content == "Next: "),
|
||||||
Some(&"Next: ".bold().cyan().italic()),
|
Some(&"Next: ".bold().italic()),
|
||||||
);
|
);
|
||||||
let rendered = lines
|
let rendered = lines
|
||||||
.iter()
|
.iter()
|
||||||
@@ -856,13 +860,16 @@ fn recap_history_cell_preserves_line_breaks_and_optional_next() {
|
|||||||
.iter()
|
.iter()
|
||||||
.flat_map(|line| &line.spans)
|
.flat_map(|line| &line.spans)
|
||||||
.find(|span| span.content == "Next: "),
|
.find(|span| span.content == "Next: "),
|
||||||
Some(&"Next: ".bold().cyan().italic()),
|
Some(&"Next: ".bold().italic()),
|
||||||
);
|
);
|
||||||
let displayed = lines
|
let area = Rect::new(
|
||||||
.iter()
|
/*x*/ 0,
|
||||||
.map(ToString::to_string)
|
/*y*/ 0,
|
||||||
.collect::<Vec<_>>()
|
/*width*/ 48,
|
||||||
.join("\n");
|
lines.len() as u16,
|
||||||
|
);
|
||||||
|
let mut buffer = Buffer::empty(area);
|
||||||
|
Paragraph::new(lines).render(area, &mut buffer);
|
||||||
let raw = cell
|
let raw = cell
|
||||||
.raw_lines()
|
.raw_lines()
|
||||||
.iter()
|
.iter()
|
||||||
@@ -870,12 +877,7 @@ fn recap_history_cell_preserves_line_breaks_and_optional_next() {
|
|||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
insta::assert_snapshot!(displayed, @r"
|
insta::assert_snapshot!("recap_dimmed", format!("{buffer:?}"));
|
||||||
↳ Recap: Finished the parser.
|
|
||||||
Twelve tests pass.
|
|
||||||
Next: Run focused tests and check
|
|
||||||
the empty-input case.
|
|
||||||
");
|
|
||||||
insta::assert_snapshot!(raw, @r"
|
insta::assert_snapshot!(raw, @r"
|
||||||
Conversation recap
|
Conversation recap
|
||||||
Finished the parser.
|
Finished the parser.
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
source: tui/src/app/recap_tests.rs
|
||||||
|
assertion_line: 875
|
||||||
|
expression: "format!(\"{buffer:?}\")"
|
||||||
|
---
|
||||||
|
Buffer {
|
||||||
|
area: Rect { x: 0, y: 0, width: 48, height: 4 },
|
||||||
|
content: [
|
||||||
|
" ↳ Recap: Finished the parser. ",
|
||||||
|
" Twelve tests pass. ",
|
||||||
|
" Next: Run focused tests and check ",
|
||||||
|
" the empty-input case. ",
|
||||||
|
],
|
||||||
|
styles: [
|
||||||
|
x: 0, y: 0, fg: Reset, bg: Reset, underline: Reset, modifier: DIM | ITALIC,
|
||||||
|
x: 4, y: 0, fg: Reset, bg: Reset, underline: Reset, modifier: BOLD | DIM | ITALIC,
|
||||||
|
x: 11, y: 0, fg: Reset, bg: Reset, underline: Reset, modifier: DIM | ITALIC,
|
||||||
|
x: 31, y: 0, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
|
||||||
|
x: 0, y: 1, fg: Reset, bg: Reset, underline: Reset, modifier: DIM | ITALIC,
|
||||||
|
x: 29, y: 1, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
|
||||||
|
x: 0, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM | ITALIC,
|
||||||
|
x: 11, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: BOLD | DIM | ITALIC,
|
||||||
|
x: 17, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM | ITALIC,
|
||||||
|
x: 44, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
|
||||||
|
x: 0, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: DIM | ITALIC,
|
||||||
|
x: 32, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -347,7 +347,7 @@ impl HistoryCell for ThreadRecapHistoryCell {
|
|||||||
if let Some(action) = &self.next_action {
|
if let Some(action) = &self.next_action {
|
||||||
body.extend(prefix_lines(
|
body.extend(prefix_lines(
|
||||||
raw_lines_from_source(action),
|
raw_lines_from_source(action),
|
||||||
"Next: ".bold().cyan(),
|
"Next: ".bold(),
|
||||||
"".into(),
|
"".into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -380,7 +380,7 @@ impl HistoryCell for ThreadRecapHistoryCell {
|
|||||||
push_owned_lines(&wrapped, &mut lines);
|
push_owned_lines(&wrapped, &mut lines);
|
||||||
options.initial_indent = options.subsequent_indent.clone();
|
options.initial_indent = options.subsequent_indent.clone();
|
||||||
}
|
}
|
||||||
lines
|
lines.into_iter().map(Line::dim).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn raw_lines(&self) -> Vec<Line<'static>> {
|
fn raw_lines(&self) -> Vec<Line<'static>> {
|
||||||
|
|||||||
Reference in new issue
Block a user