fix: escape Rich markup with official helper#750
Conversation
|
Hey @nanookclaw thanks for your contribuitions. Could you post a video showing that the fix works? thanks for your help |
Signed-off-by: Nanook <nanookclaw@users.noreply.github.com>
b47c85b to
b993c18
Compare
|
Rebased onto current Short demo GIF showing the repro class and current behavior: Validation after the rebase:
|
|
@nanookclaw Thanks, but a gif is not what we are asking for. You should run the CLI yourself, and record the screen, with the relevant grep with backlash-escaped characters, then post the video. Can you do that? |
|
Uploaded an MP4 terminal demo here: It shows the CLI version, the relevant Validation shown in the video:
|
|
😅 but @nanookclaw , your video shows you ran the relevant "grep with backtick-escapes" in the terminal shell directly, it was not in the OpenHands CLI interactive run. |
|
You're right — the previous video ran the grep in the shell outside the OpenHands CLI session. I recorded a corrected MP4 here: This one shows the OpenHands CLI TUI conversation executing the terminal tool action itself. The visible action line is:
The conversation event log from that run recorded the terminal observation with output |

Why
Issue #749 reports
MissingStylewhen a terminal command title already contains backslash-escaped brackets, for examplegrep "#\[cfg(test)\]" .... The current helper escapes[by blindly prefixing another backslash, which can leave Rich parsing the text as a malformed style tag.Summary
This replaces the hand-rolled title/content escaping helper with
rich.markup.escape, Rich's official markup escaper. That preserves the existing protection for ordinary bracketed text while correctly round-tripping commands that already contain backslashes.I also updated the focused visualizer tests to assert round-trip behavior through Rich markup parsing and added regression coverage for terminal titles containing the reported
#\[cfg(test)\]-style command.Issue Number
Fixes #749
How to Test
uv run pytest tests/tui/widgets/test_richlog_visualizer.py -quv run ruff check openhands_cli/tui/widgets/richlog_visualizer.py tests/tui/widgets/test_richlog_visualizer.pygit diff --checkType