Fix/Strip ANSI from TUI text before footer/sidebar rendering#2485
Closed
idling11 wants to merge 2 commits into
Closed
Fix/Strip ANSI from TUI text before footer/sidebar rendering#2485idling11 wants to merge 2 commits into
idling11 wants to merge 2 commits into
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 codesfirst. Result: raw fragments like
06;174;242;48;2;10leaked intothe footer status line and sidebar activity panel.
Fix
All three paths now call
strip_ansi_intobefore processing:footer_ui.rsone_line_summaryui_text.rsnormalize_shell_textsidebar.rsnormalize_activity_textFiles Changed
crates/tui/src/tui/footer_ui.rscrates/tui/src/tui/ui_text.rscrates/tui/src/tui/sidebar.rsTests
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, andui_text.rs::normalize_shell_texteach now callstrip_ansi_intointo a fresh buffer before collapsing whitespace.strip_ansi_intohelper (inosc8.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
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 labelReviews (1): Last reviewed commit: "fix: also strip ANSI in sidebar normaliz..." | Re-trigger Greptile