fix(tui): strip ANSI escape sequences from generic tool output#16369
Open
chiranjeevi-max wants to merge 1 commit intoanomalyco:devfrom
Open
fix(tui): strip ANSI escape sequences from generic tool output#16369chiranjeevi-max wants to merge 1 commit intoanomalyco:devfrom
chiranjeevi-max wants to merge 1 commit intoanomalyco:devfrom
Conversation
Generic tool output was rendered raw in the TUI, causing display corruption when output contained ANSI escape codes. The Bash tool component already strips ANSI via stripAnsi() — this applies the same treatment to GenericTool. Fixes anomalyco#16193
kiennq
added a commit
to kiennq/opencode
that referenced
this pull request
Mar 6, 2026
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.
Generic tool output was rendered raw in the TUI, causing display corruption when output contained ANSI escape codes.
The Bash tool component already strips ANSI via
stripAnsi()- this applies the same treatment toGenericTool.Issue for this PR
Closes #16193
Type of change
What does this PR do?
When the "Show generic tool output" option is enabled, tool outputs containing ANSI escape sequences (colors, cursor movements, etc.) were being rendered directly to the terminal, causing display corruption.
The Problem:
The
GenericToolcomponent was renderingprops.outputdirectly without sanitization, while theBashtool component was already properly handling this by wrapping output withstripAnsi().The Solution:
Applied the same
stripAnsi()treatment toGenericTooloutput, matching the existing pattern used in theBashcomponent. This ensures ANSI escape codes are removed before rendering to the TUI.How did you verify your code works?
Bashtool implementation (line 1762)strip-ansi(v7.1.2) is already a project dependency and properly imported at line 72Screenshots / recordings
_No screenshots. The issue reporter's screenshot in #16193 demonstrates the problem this fix addresses.
Checklist
If you do not follow this template your PR will be automatically rejected.