fix(tui): Preserve Rich Text styling in collapsible content for diff highlighting#661
Open
sjathin wants to merge 4 commits into
Open
fix(tui): Preserve Rich Text styling in collapsible content for diff highlighting#661sjathin wants to merge 4 commits into
sjathin wants to merge 4 commits into
Conversation
Collaborator
all-hands-bot
left a comment
There was a problem hiding this comment.
🟢 Good taste — Elegant simplification that preserves Rich Text styling.
Key insight: This change eliminates lossy string conversion and lets Rich Text objects flow through the rendering pipeline intact, preserving diff colors and other styling that the SDK already generates.
Risk Assessment: 🟢 LOW — Additive change (accepts str | Text instead of just str), all 74 tests pass, and Static widgets already support both types.
Co-authored-by: OpenHands Bot <contact@all-hands.dev>
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.
Why
The TUI was stripping Rich Text styling from SDK event visualizations by converting
Textobjects to plain strings viastr(). The SDK'sFileEditorObservation.visualizealready generates colored diff output (red for removals, green for additions) through itsvisualize_diff()function, but this styling was lost before reaching the user. All collapsible content rendered as unstyled plain text.Summary
event.visualizeTextobject directly from_build_observation_content()instead ofstr(event.visualize), preserving Rich styling (colors, bold, dim)Textobjects through_create_titled_collapsibleand_create_event_collapsibleinstead of escaping and stringifying_update_widget_in_uisignature to acceptstr | TextTextobjects and style spans are preserved through the rendering pipelineIssue Number
Closes #308
Video/Screenshots
Before
After
Type
Notes
_escape_rich_markupmethod is still used and correct for title strings (which use Rich markup syntax). It was only incorrectly applied to collapsible content (which usesStatic(markup=False)and rendersTextobjects directly).