Skip to content

refactor(shared): extract escape_rich_markup to shared/rich_utils.py#752

Merged
enyst merged 3 commits into
mainfrom
fix/code-quality/extract-rich-utils
May 25, 2026
Merged

refactor(shared): extract escape_rich_markup to shared/rich_utils.py#752
enyst merged 3 commits into
mainfrom
fix/code-quality/extract-rich-utils

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 25, 2026

Summary

Extract the duplicated _escape_rich_markup function from history_side_panel.py and richlog_visualizer.py into a new shared/rich_utils.py module.

Changes

  • Created openhands_cli/shared/rich_utils.py with the escape_rich_markup() function
  • Updated openhands_cli/shared/__init__.py to export the new function
  • Replaced local _escape_rich_markup function in tui/panels/history_side_panel.py with import from shared module
  • Replaced method _escape_rich_markup in tui/widgets/richlog_visualizer.py with import from shared module
  • Updated tests in tests/tui/widgets/test_richlog_visualizer.py to use the shared function

Related Issue

Addresses findings from #751

Testing

  • Linting passes (make lint)
  • Tests pass (make test - 1353 tests)

This PR was automatically generated by the Code Quality Report workflow.


🚀 Try this PR

uvx --python 3.12 git+https://github.com/OpenHands/OpenHands-CLI.git@fix/code-quality/extract-rich-utils

github-actions Bot and others added 2 commits May 25, 2026 10:54
Extract the duplicated _escape_rich_markup function from history_side_panel.py
and richlog_visualizer.py into a new shared/rich_utils.py module.

This eliminates code duplication by consolidating the Rich markup escaping
utility that was previously defined in two separate TUI files with identical
implementations.

Addresses item from code quality report.

Closes #751

Co-authored-by: openhands <openhands@all-hands.dev>
@enyst
Copy link
Copy Markdown
Member

enyst commented May 25, 2026

@OpenHands /iterate to green and approved by the AI reviewer from pr-review workflow. If approved, merge it and make sure you comment tagging me.

@openhands-ai
Copy link
Copy Markdown

openhands-ai Bot commented May 25, 2026

I'm on it! enyst can track my progress at all-hands.dev

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented May 25, 2026

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands_cli/shared
   __init__.py40100% 
   rich_utils.py20100% 
openhands_cli/tui/panels
   history_side_panel.py2051791%212, 247–248, 252, 319, 325, 358, 371, 442, 447–449, 451–452, 454, 456, 466
openhands_cli/tui/widgets
   richlog_visualizer.py3477378%76, 83–86, 88, 176, 183–184, 196, 291, 373, 423–426, 439, 442–444, 447–449, 452, 454, 457, 491–495, 499, 506–509, 513, 525, 556, 561–562, 565–567, 570, 576–579, 581, 588, 602–603, 605, 611, 630–631, 634, 687, 690–691, 695, 718–720, 736, 754–755, 757, 777, 781, 802, 805
TOTAL7063101185% 

Co-authored-by: openhands <openhands@all-hands.dev>
@enyst enyst requested a review from all-hands-bot May 25, 2026 13:31
@enyst enyst added the review-this label May 25, 2026 — with OpenHands AI
Copy link
Copy Markdown
Collaborator

@all-hands-bot all-hands-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Good taste - Clean refactoring that eliminates code duplication by extracting escape_rich_markup to a shared module. The function logic is unchanged, tests are updated appropriately, and the new location is logical.

VERDICT:Worth merging - Textbook example of a DRY refactoring

[RISK ASSESSMENT]

  • [Overall PR] ⚠️ Risk Assessment: 🟢 LOW
    Pure refactoring with no behavior change. Function logic is identical, just moved to a shared location. Tests pass and cover the function thoroughly.

Was this automated review useful? React with 👍 or 👎 to this review to help us measure review quality.
Workflow run: https://github.com/OpenHands/OpenHands-CLI/actions/runs/26403061166

@enyst enyst merged commit 61d9eb6 into main May 25, 2026
14 of 15 checks passed
@enyst enyst deleted the fix/code-quality/extract-rich-utils branch May 25, 2026 13:42
Copy link
Copy Markdown
Member

enyst commented May 25, 2026

@enyst PR #752 is green, approved by the AI reviewer, and merged.

Local verification I ran before pushing the final fix:

  • uv run pre-commit run --all-files
  • uv run pytest tests/tui/widgets/test_richlog_visualizer.py -q

Reminder: this comment was created by an AI agent (OpenHands) on your behalf.

@openhands-ai
Copy link
Copy Markdown

openhands-ai Bot commented May 25, 2026

Since my last summary, there were no additional code or repository changes.

Final status:

  • ✅ The request was fully addressed: PR refactor(shared): extract escape_rich_markup to shared/rich_utils.py #752 was driven to green, approved by the AI reviewer, merged, and @enyst was tagged in a follow-up PR comment.
  • ✅ Instructions were followed faithfully, including using GitHub tooling/API, verifying CI/review status, merging only after approval, and including AI disclosure in the human-facing PR comment.
  • ✅ Changes remained concise: the only pushed change was the minimal Ruff formatting fix needed to clear CI; no extraneous changes were introduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants