fix(ledmatrix-music): size the progress bar to the text, not the whole panel - #230
Conversation
…e panel The progress bar was drawn at the full width of the text area regardless of how much of that area the text actually filled. With a short track title on a wide panel that left a bar stretching right across the display under a few characters. Trimming cannot help here: the bar is ink, so there is nothing to reclaim — it has to be drawn narrower in the first place. It is now sized to the widest of the title, artist and album lines, with a 24px floor so a very short title still leaves something recognisable as a progress indicator. A line long enough to scroll measures wider than the area and so pins the bar to full width, which is correct — that line really does fill it. The album line is only counted when there is height to draw it. Font measurement failures fall back to the full-width bar rather than losing the bar entirely. Set progress_bar_match_text false to restore the previous behaviour. Note the safety harness cannot cover this: its mock track has no duration, so the bar is never drawn and the rendered extent is byte-identical with and without the change (verified by running the harness against both). Hence the focused unit tests in test_progress_bar_width.py, which exercise the sizing rule directly. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KEZK1P1Q1fu5pcuVrkrCFZ
|
Warning Review limit reached
Next review available in: 36 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. 📝 WalkthroughWalkthroughThe Music Player plugin now sizes its progress bar to visible text by default, preserves full-width behavior through a configuration option, updates version 1.2.0 metadata, and adds focused width-calculation tests. ChangesMusic Player progress-bar sizing
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant display as display()
participant width as _progress_bar_width()
participant font as Font measurement
display->>width: pass title, artist, and album lines
width->>font: measure visible text
font-->>width: return text widths
width-->>display: return bounded progress-bar width
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
⚔️ Resolve merge conflicts 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 27 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Replaces Cls.__new__(Cls) with a no-op-__init__ subclass for building the test shell. The __new__ form is valid Python but Codacy's Pylint reports it as a missing-cls call; the subclass reads better and states the intent — bypass the real __init__, which starts polling threads and API clients the sizing logic does not need. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KEZK1P1Q1fu5pcuVrkrCFZ
|
@coderabbitai review |
✅ Action performedReview finished.
|
Problem
The progress bar was drawn at the full width of the text area regardless of how much of that area the text actually filled:
With a short track title on a wide panel, that leaves a bar stretching right across the display under a few characters. It's especially visible in Vegas scroll mode, where a full-width element reads as sparse.
Trimming can't help here — the bar is ink, so there is nothing blank to reclaim. It has to be drawn narrower in the first place.
Fix
The bar is now sized to the widest of the title, artist and album lines, with a 24px floor so a very short title still leaves something recognisable as a progress indicator.
Three details worth noting:
Set
progress_bar_match_textto false to restore the previous behaviour.Testing
The safety harness cannot cover this, which is worth flagging. Its mock track has no duration, so
duration_ms > 0is false and the bar is never drawn — I ran the harness against both the old and new code and the reported extents are byte-identical (256x32 … extent 46%x25%either way). Relying on it here would have given false confidence.So this ships with focused unit tests in
test_progress_bar_width.py(17 cases) that exercise the sizing rule directly: widest-line selection, the floor, the full-area clamp, the scrolling case, hidden album, empty strings, the config toggle, and measurement failure.check_module_collisions.py: OK across 41 plugins.Context
Part of a set of Vegas scroll mode changes. The core-side companion is ChuckBuilds/LEDMatrix#423, which adds the ability to render plugins at a fraction of the panel width so their layouts compact rather than being cropped — this fix handles the one element that narrowing alone can't, since the bar scales to whatever width it's given.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KEZK1P1Q1fu5pcuVrkrCFZ
Summary by CodeRabbit
New Features
Documentation
Tests