Skip to content

fix(ledmatrix-music): scroll long now-playing text instead of overflowing (+ GPL-3.0)#179

Merged
ChuckBuilds merged 6 commits into
mainfrom
claude/plugin-audit-music-scroll-fix
Jul 10, 2026
Merged

fix(ledmatrix-music): scroll long now-playing text instead of overflowing (+ GPL-3.0)#179
ChuckBuilds merged 6 commits into
mainfrom
claude/plugin-audit-music-scroll-fix

Conversation

@ChuckBuilds

@ChuckBuilds ChuckBuilds commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the now-playing text overflowing the right edge on narrow (64px-wide) panels, and completes the repo-wide MIT→GPL-3.0 pass (music was the one plugin deferred because of this bug).

The issue

Album art is a square of the panel height, so on a 64×32 panel it's 32px wide and the text area is only ~29px (x 34–63). The title/artist/album marquee builds a rotated string (text[pos:] + sep + text[:pos]) and draws the whole thing at the text-area x with no right-edge clip. The character-based scroll changes which characters lead, but the drawn string is still full-length, so long text always runs off the right edge (and during the initial "pause" it draws the untrimmed title). The safety harness caught this as now_playing overflow bbox=(64,…) at 64×32 and 64×64.

The fix

Add _clip_text_to_width(text, font, max_width) and apply it to all four text draws (title, artist, album-fits, album-scroll). It trims trailing characters until the rendered text fits the text-area width, so the marquee stays inside its viewport. Long text still scrolls — the char-based rotation is unchanged; it's just clipped on the right instead of drawing past the panel edge. No behavior change on wide panels where text already fit.

Plugin(s) affected

ledmatrix-music (1.0.6 → 1.0.7)

Type of change

  • Bug fix in an existing plugin (render overflow on narrow panels)
  • Documentation / metadata (relicense MIT → GPL-3.0: LICENSE + manifest + README)

Test plan

  • Local: python -c "import ast; ast.parse(...)" (parses), update_registry.py (1.0.6→1.0.7), check_module_collisions.py (clean), JSON validity.
  • CI renders ledmatrix-music at all sizes — this is the authoritative check for the overflow fix (the harness is what caught it; I can't run it locally). If any size still overflows I'll iterate.

Context

Part of the maintainer-requested "no MIT, all GPL-3.0" pass. With this merged, every plugin is GPL-3.0. (Companion license PRs: #173, #175, #177.)

🤖 Generated with Claude Code

https://claude.ai/code/session_01F9Saiat9CQmNi3DeDdvacB


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Updated the ledmatrix-music plugin to version 1.0.7.
    • Improved text handling so now-playing details stay within the display area on narrow panels.
  • Bug Fixes

    • Prevented song title, artist, and album text from overflowing the screen.
    • Avoided drawing the progress bar when there isn’t enough horizontal space.
  • Documentation

    • Updated the plugin’s license information to GPLv3 in the plugin details and README.

…low) + GPL-3.0

The now-playing title/artist/album marquee drew the full (rotated) string at
the text-area x with no right-edge clip, so long text ran past the panel's
right edge. The safety harness flagged this as an overflow on the 64px-wide
panels (64x32 / 64x64), where the text area is only ~29px wide.

Add _clip_text_to_width() and apply it to all four text draws so the marquee
stays inside its viewport: long text still scrolls (the char-based rotation is
unchanged) — it's just clipped on the right instead of overflowing the panel.

Also relicense to GPL-3.0 (LICENSE + manifest + README). music was the plugin
deferred from the repo-wide MIT -> GPL-3.0 pass because of this overflow.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F9Saiat9CQmNi3DeDdvacB
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@ChuckBuilds, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 8 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d7473033-28ed-4701-9c10-a81fc538d728

📥 Commits

Reviewing files that changed from the base of the PR and between cb35c60 and 579f9f1.

📒 Files selected for processing (3)
  • plugins.json
  • plugins/ledmatrix-music/manager.py
  • plugins/ledmatrix-music/manifest.json
📝 Walkthrough

Walkthrough

This PR adds a text-clipping helper to the ledmatrix-music plugin's display() method to prevent title, artist, and album text from overflowing the drawable width, tightens the progress-bar render guard, and changes the plugin's license from MIT to GPLv3 with corresponding manifest, README, LICENSE, and registry metadata updates.

Changes

Display Clipping and License Update

Layer / File(s) Summary
Text clipping helper and rendering integration
plugins/ledmatrix-music/manager.py
Adds _clip_text_to_width helper that trims text to fit available pixel width, applies it to title, artist, and album rendering (both fit and scrolling branches), and requires text_area_width > 0 alongside duration_ms > 0 before drawing the progress bar.
License change and version metadata
plugins/ledmatrix-music/LICENSE, plugins/ledmatrix-music/README.md, plugins/ledmatrix-music/manifest.json, plugins.json
Replaces MIT license text with GPLv3 in LICENSE and README, bumps manifest version to 1.0.7, changes license to GPL-3.0, adds a 1.0.7 release entry with notes, updates last_updated, and refreshes plugins.json registry timestamps and latest_version.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Display as display()
  participant Clip as _clip_text_to_width
  participant DM as display_manager

  Display->>Clip: clip title/artist/album text, text_area_width
  Clip->>DM: get_text_width(text, font)
  DM-->>Clip: measured text width
  Clip-->>Display: clipped text (or empty string)
  Display->>Display: draw clipped text within bounds
  Display->>Display: check text_area_width > 0 before drawing progress bar
Loading

Possibly related PRs

  • ChuckBuilds/ledmatrix-plugins#67: Both PRs modify plugins/ledmatrix-music/manager.py's display() rendering and progress-bar logic, overlapping in the same display code paths.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main fix for overflowing now-playing text and also reflects the GPL-3.0 license update.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/plugin-audit-music-scroll-fix

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

codacy-production Bot commented Jul 9, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 13 complexity

Metric Results
Complexity 13

View in Codacy

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.

claude added 2 commits July 9, 2026 19:00
…quare panels)

Follow-up to the viewport clip: on square panels (e.g. 64x64) the album art
is sized to the panel height, so it fills the full width and text_area_width
goes negative. The clip helper's `max_width <= 0` guard returned the text
UNCLIPPED, so it was still drawn off-panel (overflow bbox=(64,28,91,36) at
64x64). Now return an empty string when there's no room, and skip the progress
bar too. Album art fills the panel; no text is drawn rather than overflowing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F9Saiat9CQmNi3DeDdvacB
…width

That was the real overflow the harness caught (CI has no auth -> no track ->
the "Nothing Playing" idle screen renders). The text is centered via
x = (width - text_width)//2, which goes negative when the text is wider than
the panel (64px), spilling off both edges — matching the failing bbox exactly
(y = height//2 - 4 = 12 at 64x32, 28 at 64x64). Clip the text to the panel
width and clamp x to >= 0. (The earlier marquee viewport clip is still correct
for the now-playing view with a real track.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F9Saiat9CQmNi3DeDdvacB

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
plugins/ledmatrix-music/manager.py (1)

1068-1072: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

"..." truncation indicator may be clipped away in the scrolling-disabled path.

The rough truncation title[:text_area_width // 6] + "..." produces a string that is typically wider than text_area_width, so _clip_text_to_width (applied at line 1081) will trim further—often removing the "..." entirely. The same pattern exists for artist (line 1125) and album (line 1199). Users who explicitly disable scrolling lose the visual cue that text was truncated.

Consider either dropping the rough truncation and relying solely on _clip_text_to_width, or clipping first and appending "..." only if clipping actually occurred.

💡 Suggested approach
 elif title_width > text_area_width and not title_config['enabled']:
-    # Scrolling disabled - truncate text
-    current_title_display_text = title[:text_area_width // 6] + "..."  # Rough truncation
+    # Scrolling disabled - clip to viewport, add ellipsis if truncated
+    clipped = self._clip_text_to_width(title, font_title, text_area_width)
+    current_title_display_text = clipped + ("..." if clipped != title else "")
     self.scroll_position_title = 0
     self.title_scroll_tick = 0
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugins/ledmatrix-music/manager.py` around lines 1068 - 1072, The
scrolling-disabled truncation paths in the title, artist, and album display
logic are appending "..." before width clipping, which can cause the indicator
to be clipped away. Update the display flow in the title/artist/album handling
blocks so that truncation is handled either entirely by _clip_text_to_width or
by appending "..." only after confirming the text was actually clipped, and
preserve the indicator when scrolling is disabled.
🧹 Nitpick comments (1)
plugins/ledmatrix-music/manager.py (1)

736-757: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

_clip_text_to_width logic is correct and well-documented.

The helper handles all edge cases properly: max_width <= 0 returns "", falsy text is returned as-is, already-fitting text is returned unchanged, and the trim loop correctly degenerates to "" when even a single character exceeds max_width.

One minor performance note: the while-loop calls get_text_width once per removed character, making it O(n²) in the worst case for the underlying font measurement. For typical music titles on small panels this is fine, but a binary search on the trim length would reduce it to O(n log n) if profiling ever shows hot spots.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugins/ledmatrix-music/manager.py` around lines 736 - 757, The
`_clip_text_to_width` helper in `manager.py` is correct but the trimming loop is
O(n²) because it measures text width after removing one character at a time.
Update `_clip_text_to_width` to use a more efficient search strategy, such as
binary search on the clipped length with
`self.display_manager.get_text_width(...)`, while preserving the existing edge
cases for empty text and non-positive `max_width`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@plugins/ledmatrix-music/manager.py`:
- Around line 1068-1072: The scrolling-disabled truncation paths in the title,
artist, and album display logic are appending "..." before width clipping, which
can cause the indicator to be clipped away. Update the display flow in the
title/artist/album handling blocks so that truncation is handled either entirely
by _clip_text_to_width or by appending "..." only after confirming the text was
actually clipped, and preserve the indicator when scrolling is disabled.

---

Nitpick comments:
In `@plugins/ledmatrix-music/manager.py`:
- Around line 736-757: The `_clip_text_to_width` helper in `manager.py` is
correct but the trimming loop is O(n²) because it measures text width after
removing one character at a time. Update `_clip_text_to_width` to use a more
efficient search strategy, such as binary search on the clipped length with
`self.display_manager.get_text_width(...)`, while preserving the existing edge
cases for empty text and non-positive `max_width`.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 858a4e64-b2ce-48c9-b79a-868356d7db8e

📥 Commits

Reviewing files that changed from the base of the PR and between 4e5de3c and cb35c60.

📒 Files selected for processing (5)
  • plugins.json
  • plugins/ledmatrix-music/LICENSE
  • plugins/ledmatrix-music/README.md
  • plugins/ledmatrix-music/manager.py
  • plugins/ledmatrix-music/manifest.json

claude added 3 commits July 9, 2026 19:10
… text

When scrolling is disabled, the title/artist/album were truncated with a
rough char-count estimate (`text[:width//6] + "..."`) and then passed
through the draw-time viewport clip, which could trim the trailing "..."
back off — leaving no truncation indicator. Add
`_truncate_text_with_ellipsis`, which reserves room for the ellipsis
before clipping so the "..." always survives and the result fits the
text-area viewport.

Bumps ledmatrix-music to 1.0.8.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F9Saiat9CQmNi3DeDdvacB
Follows the maintainer's correction on #175: the core's manifest
validator flags `ledmatrix_min` as deprecated and expects
`ledmatrix_min_version`. Switch the music versions[] entries (1.0.8,
1.0.7, 1.0.6) to `ledmatrix_min_version` so device installs don't log a
deprecated-field warning. Also merges the latest main (#174, #175) and
regenerates plugins.json.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F9Saiat9CQmNi3DeDdvacB
@ChuckBuilds ChuckBuilds merged commit 993c5a3 into main Jul 10, 2026
3 checks passed
@ChuckBuilds ChuckBuilds deleted the claude/plugin-audit-music-scroll-fix branch July 10, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants