Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Normalize whitespace-only lines in agent messages (#34772)

Eric Trautc00e2e851cd8
diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__tests__required_stream_reflow_during_capped_initial_replay.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__tests__required_stream_reflow_during_capped_initial_replay.snap
index acd26d1b97..5555aed2a8 100644
--- a/codex-rs/tui/src/app/snapshots/codex_tui__app__tests__required_stream_reflow_during_capped_initial_replay.snap
+++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__tests__required_stream_reflow_during_capped_initial_replay.snap
@@ -5,7 +5,7 @@ expression: "rendered.lines.iter().map(rendered_line_text).collect::<Vec<_>>().j
latest user question
• Final answer:
-
+
Pattern Outcome
━━━━━━━━━━━━ ━━━━━━━━━━━
Table tail Preserved
diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__tests__required_stream_reflow_during_capped_initial_replay_survives_transcript_overlay.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__tests__required_stream_reflow_during_capped_initial_replay_survives_transcript_overlay.snap
index acd26d1b97..5555aed2a8 100644
--- a/codex-rs/tui/src/app/snapshots/codex_tui__app__tests__required_stream_reflow_during_capped_initial_replay_survives_transcript_overlay.snap
+++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__tests__required_stream_reflow_during_capped_initial_replay_survives_transcript_overlay.snap
@@ -5,7 +5,7 @@ expression: "rendered.lines.iter().map(rendered_line_text).collect::<Vec<_>>().j
latest user question
• Final answer:
-
+
Pattern Outcome
━━━━━━━━━━━━ ━━━━━━━━━━━
Table tail Preserved
diff --git a/codex-rs/tui/src/history_cell/messages.rs b/codex-rs/tui/src/history_cell/messages.rs
index 58892e4261..f8fe26e7ad 100644
--- a/codex-rs/tui/src/history_cell/messages.rs
+++ b/codex-rs/tui/src/history_cell/messages.rs
@@ -407,6 +407,21 @@ impl AgentMarkdownCell {
}
}
+fn normalize_whitespace_only_hyperlink_lines(mut lines: Vec<HyperlinkLine>) -> Vec<HyperlinkLine> {
+ for line in &mut lines {
+ if line
+ .line
+ .spans
+ .iter()
+ .all(|span| span.content.chars().all(char::is_whitespace))
+ {
+ line.line = Line::default().style(line.line.style);
+ line.hyperlinks.clear();
+ }
+ }
+ lines
+}
+
impl HistoryCell for AgentMarkdownCell {
fn display_lines(&self, width: u16) -> Vec<Line<'static>> {
visible_lines(self.display_hyperlink_lines(width))
@@ -432,7 +447,11 @@ impl HistoryCell for AgentMarkdownCell {
Some(self.cwd.as_path()),
self.inline_visualization_context.as_ref(),
);
- prefix_hyperlink_lines(lines, "• ".dim(), " ".into())
+ normalize_whitespace_only_hyperlink_lines(prefix_hyperlink_lines(
+ lines,
+ "• ".dim(),
+ " ".into(),
+ ))
};
if let Some(rendered_lines) = &self.rendered_lines {
@@ -487,7 +506,7 @@ impl HistoryCell for StreamingAgentTailCell {
fn display_hyperlink_lines(&self, _width: u16) -> Vec<HyperlinkLine> {
// Tail lines are already rendered at the controller's current stream width.
// Re-wrapping them here can split table borders and produce malformed in-flight rows.
- let mut lines = prefix_hyperlink_lines(
+ normalize_whitespace_only_hyperlink_lines(prefix_hyperlink_lines(
self.lines.clone(),
if self.is_first_line {
"• ".dim()
@@ -495,19 +514,7 @@ impl HistoryCell for StreamingAgentTailCell {
" ".into()
},
" ".into(),
- );
- for line in &mut lines {
- if line
- .line
- .spans
- .iter()
- .all(|span| span.content.chars().all(char::is_whitespace))
- {
- line.line = Line::default().style(line.line.style);
- line.hyperlinks.clear();
- }
- }
- lines
+ ))
}
fn transcript_hyperlink_lines(&self, width: u16) -> Vec<HyperlinkLine> {
diff --git a/codex-rs/tui/src/history_cell/snapshots/codex_tui__history_cell__tests__raw_mode_toggle_transcript.snap b/codex-rs/tui/src/history_cell/snapshots/codex_tui__history_cell__tests__raw_mode_toggle_transcript.snap
index f1c04cec85..e2c378fff6 100644
--- a/codex-rs/tui/src/history_cell/snapshots/codex_tui__history_cell__tests__raw_mode_toggle_transcript.snap
+++ b/codex-rs/tui/src/history_cell/snapshots/codex_tui__history_cell__tests__raw_mode_toggle_transcript.snap
@@ -9,11 +9,11 @@ rich before:
• - first item
- second item
-
+
Col Value
━━━━━━ ━━━━━━━
code x = 1
-
+
copy me
• Called
└ workspace.inspect({"path":"README.md
@@ -45,11 +45,11 @@ rich after:
• - first item
- second item
-
+
Col Value
━━━━━━ ━━━━━━━
code x = 1
-
+
copy me
• Called
└ workspace.inspect({"path":"README.md
diff --git a/codex-rs/tui/src/snapshots/codex_tui__inline_visualization__tests__agent_code_blocks_preserve_visualization_directive_literals.snap b/codex-rs/tui/src/snapshots/codex_tui__inline_visualization__tests__agent_code_blocks_preserve_visualization_directive_literals.snap
index 5f212bc63a..88a75a2b37 100644
--- a/codex-rs/tui/src/snapshots/codex_tui__inline_visualization__tests__agent_code_blocks_preserve_visualization_directive_literals.snap
+++ b/codex-rs/tui/src/snapshots/codex_tui__inline_visualization__tests__agent_code_blocks_preserve_visualization_directive_literals.snap
@@ -3,9 +3,9 @@ source: tui/src/inline_visualization_tests.rs
expression: text
---
• Fenced:
-
+
::codex-inline-vis{file="chart.html"}
-
+
Indented:
-
+
::codex-inline-vis{file="chart.html"}
diff --git a/codex-rs/tui/src/snapshots/codex_tui__inline_visualization__tests__finalized_agent_cell_visualization_link.snap b/codex-rs/tui/src/snapshots/codex_tui__inline_visualization__tests__finalized_agent_cell_visualization_link.snap
index 4ece4e88c0..c0b1eda053 100644
--- a/codex-rs/tui/src/snapshots/codex_tui__inline_visualization__tests__finalized_agent_cell_visualization_link.snap
+++ b/codex-rs/tui/src/snapshots/codex_tui__inline_visualization__tests__finalized_agent_cell_visualization_link.snap
@@ -3,8 +3,8 @@ source: tui/src/inline_visualization_tests.rs
expression: snapshot_text
---
• Before
-
+
Open chart visualization in the browser
file://<viewer-path>
-
+
After