refactor(shared): extract text truncation utilities to shared/text_utils.py#753
refactor(shared): extract text truncation utilities to shared/text_utils.py#753github-actions[bot] wants to merge 2 commits into
Conversation
…ils.py Extract the duplicated text truncation functions from history_side_panel.py and richlog_visualizer.py into a new shared/text_utils.py module. The new truncate_text() function consolidates: - _truncate() from history_side_panel.py (simple truncation) - _truncate_for_display() from richlog_visualizer.py (with from_start option) Features of the consolidated function: - Supports truncation from start (default) or end (for paths) - Optional whitespace collapsing (newlines/carriage returns to spaces) - ELLIPSIS constant exported for consistent usage Addresses item from code quality report. Closes #751 Co-authored-by: openhands <openhands@all-hands.dev>
|
@OpenHands make an empty commit to kick off CI and /iterate to green and approved by the AI reviewer from pr-review workflow. |
|
I'm on it! enyst can track my progress at all-hands.dev |
Co-authored-by: openhands <openhands@all-hands.dev>
Coverage Report •
|
|||||||||||||||||||||||||||||||||||||||||||||
all-hands-bot
left a comment
There was a problem hiding this comment.
🟢 Good taste - Clean refactoring that eliminates code duplication without changing behavior.
The consolidated truncate_text() function is well-designed:
- Clear parameters with sensible defaults
- Correctly preserves behavior from both original implementations
- The
collapse_whitespaceflag properly handles the difference between direct truncation and clean-then-truncate flows
[RISK ASSESSMENT]
🟢 LOW - Pure refactoring with no user-facing changes. Existing tests continue to pass and validate the preserved behavior.
VERDICT:
✅ Worth merging - Solid refactoring that improves code maintainability.
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/26402228478
|
Since the last summary, there were no additional changes or actions.
|
Summary
Extract the duplicated text truncation functions from
history_side_panel.pyandrichlog_visualizer.pyinto a newshared/text_utils.pymodule.Changes
openhands_cli/shared/text_utils.pywith thetruncate_text()function_truncate()fromhistory_side_panel.py(simple truncation)_truncate_for_display()fromrichlog_visualizer.py(withfrom_startoption)ELLIPSISconstant exported for consistent usageopenhands_cli/shared/__init__.pyto exporttruncate_texttests/tui/widgets/test_richlog_visualizer.pyto importELLIPSISfrom the shared moduleRelated Issue
Addresses findings from #751
Testing
make lint)make test- 1353 tests)This PR was automatically generated by the Code Quality Report workflow.
🚀 Try this PR