Skip to content

Fix/Strip ANSI from TUI text before footer/sidebar rendering#2485

Closed
idling11 wants to merge 2 commits into
Hmbown:mainfrom
idling11:fix/footer-ansi-leak
Closed

Fix/Strip ANSI from TUI text before footer/sidebar rendering#2485
idling11 wants to merge 2 commits into
Hmbown:mainfrom
idling11:fix/footer-ansi-leak

Conversation

@idling11

@idling11 idling11 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Prevent raw ANSI/SGR escape codes from leaking into the TUI footer
and sidebar during tool execution by stripping ANSI sequences from
every split_whitespace().join(" ") text-normalization path.

Closes: #2481

Problem

Three text-normalization helpers passed raw text (potentially
containing embedded ANSI sequences from tool output / shell commands)
through split_whitespace().join(" ") without stripping escape codes
first. Result: raw fragments like 06;174;242;48;2;10 leaked into
the footer status line and sidebar activity panel.

Fix

All three paths now call strip_ansi_into before processing:

File Function Rendered in
footer_ui.rs one_line_summary Footer tool status label
ui_text.rs normalize_shell_text Concise shell command label
sidebar.rs normalize_activity_text Sidebar activity panel

Files Changed

File Change
crates/tui/src/tui/footer_ui.rs +3/-1
crates/tui/src/tui/ui_text.rs +3/-1
crates/tui/src/tui/sidebar.rs +3/-1

Tests

Full suite: 3789 passed, 6 pre-existing failures

Greptile Summary

This PR strips ANSI/SGR escape codes before the split_whitespace().join(\" \") normalization step in three TUI text-rendering helpers, preventing raw terminal escape sequences from leaking into the footer status line, the sidebar activity panel, and the shell command label.

  • footer_ui.rs::one_line_summary, sidebar.rs::normalize_activity_text, and ui_text.rs::normalize_shell_text each now call strip_ansi_into into a fresh buffer before collapsing whitespace.
  • The reused strip_ansi_into helper (in osc8.rs) already covers CSI, OSC, DCS, SOS, PM, and APC sequences and has comprehensive unit tests including multi-byte UTF-8 correctness.

Confidence Score: 4/5

Safe to merge; the three changed functions each receive a minimal, focused addition of strip_ansi_into before whitespace normalization, with no behavioural change for ANSI-free input.

The three targeted fixes are correct and the underlying strip_ansi_into helper is well-tested. The only open question is whether normalize_header_summary in history.rs — an untouched fourth helper with the identical pattern — also receives tool output that can carry ANSI codes, which would leave that rendering path unaddressed.

crates/tui/src/tui/history.rs — normalize_header_summary uses the same pattern on tool summary text but was not updated in this PR.

Important Files Changed

Filename Overview
crates/tui/src/tui/footer_ui.rs Adds strip_ansi_into call before whitespace normalization in one_line_summary; minimal and correct.
crates/tui/src/tui/sidebar.rs Adds strip_ansi_into call before whitespace normalization in normalize_activity_text; minimal and correct.
crates/tui/src/tui/ui_text.rs Adds strip_ansi_into call before whitespace normalization in normalize_shell_text; minimal and correct.

Sequence Diagram

sequenceDiagram
    participant Tool as Tool Output
    participant NL as Normalizer
    participant ANSI as strip_ansi_into
    participant WS as split_whitespace join
    participant UI as TUI Render

    Note over Tool,UI: Before this PR
    Tool->>NL: text with embedded ESC codes
    NL->>WS: raw text passed directly
    WS->>UI: ANSI fragments leak into footer and sidebar

    Note over Tool,UI: After this PR
    Tool->>NL: text with embedded ESC codes
    NL->>ANSI: strip CSI and OSC sequences
    ANSI->>WS: clean visible text only
    WS->>UI: correctly formatted label
Loading

Reviews (1): Last reviewed commit: "fix: also strip ANSI in sidebar normaliz..." | Re-trigger Greptile

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@Hmbown

Hmbown commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Thanks @idling11 — harvested this ANSI cleanup into main for v0.8.49 in 599b599 and 87b5c78, with extra footer/sidebar/command-label regressions in dde8654. Closing this PR as integrated and credited in the changelog.

@Hmbown Hmbown closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TUI footer leaks raw ANSI escape codes during tool execution

2 participants