of-the-day: font-aware word wrapping with auto-fit for long definitions - #260
Conversation
Long definitions and subtitles previously wrapped against hardcoded line counts (10 body / 3 subtitle) and any lines past the panel bottom were silently dropped, so long content was cut off mid-sentence — and picking a larger font via the customization UI made it worse. Wrapping is now fully font-aware: the number of lines is computed from the real font height and the space below the underline, and line breaks are measured with the actual font. When the wrapped text still needs more lines than fit, scalable fonts are retried at progressively smaller sizes (down to 5px) and the largest size that fits the whole text wins. When no size fits everything — or the font is a non-scalable bitmap font — the configured font is kept and the text is cut with a visible '...' instead of being clipped silently. Also clamps the dynamic spacing spread so rounding can no longer push the last wrapped line one row past the panel and drop it. New advanced config key auto_fit_text (default true) disables the auto-shrink; wrapping stays font-aware regardless. Consolidates the repeated text-width/font-height fallback code into helpers, adds test_text_fitting.py regression tests, and regenerates the 64x32 golden (the subtitle there was previously clipped mid-sentence; it now shows an ellipsis). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRMQBB431aTK2mq6GGmEgk
|
Warning Review limit reached
Next review available in: 55 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. 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. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe Of The Day plugin adds the enabled-by-default ChangesOf The Day text fitting
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Configuration
participant OfTheDayManager
participant TextFitting
participant DisplayManager
Configuration->>OfTheDayManager: Load auto_fit_text
OfTheDayManager->>TextFitting: Fit title, subtitle, or description
TextFitting->>DisplayManager: Measure font and text dimensions
TextFitting-->>OfTheDayManager: Return fitted text
OfTheDayManager->>DisplayManager: Render fitted text
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 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 | 24 |
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.
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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.
Inline comments:
In `@plugins/of-the-day/manager.py`:
- Around line 477-481: Update the candidate-acceptance logic in the font-sizing
method around _wrap_text so a candidate is returned only when the wrapped output
preserves every input token without ellipsizing or truncating an oversized word;
otherwise continue evaluating smaller scalable-font candidates. Add a regression
test covering a word wider than max_width where a smaller candidate preserves
the complete word.
In `@plugins/of-the-day/manifest.json`:
- Line 28: Correct the auto_fit_text description in the manifest notes so it
states that disabling the setting prevents auto-shrinking, while the
default-enabled setting enables it.
- Line 27: Replace the deprecated ledmatrix_min field in the new release record
with ledmatrix_min_version, preserving the existing version value.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 492c6ea0-e65c-4863-aef4-52c4c32d86bf
⛔ Files ignored due to path filters (1)
plugins/of-the-day/test/golden/64x32/of_the_day.pngis excluded by!**/*.png
📒 Files selected for processing (6)
plugins.jsonplugins/of-the-day/README.mdplugins/of-the-day/config_schema.jsonplugins/of-the-day/manager.pyplugins/of-the-day/manifest.jsonplugins/of-the-day/test_text_fitting.py
- Use ledmatrix_min_version (not the deprecated ledmatrix_min) in the new 1.4.0 manifest release record; the core's store manifest validation flags the old spelling. - Fix the 1.4.0 release note, which described auto_fit_text backwards. - Don't accept a font size as fitting when _wrap_text had to truncate a word wider than the panel: keep trying smaller sizes that can hold the word whole, with a regression test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRMQBB431aTK2mq6GGmEgk
|
CI status note: the collisions check keeps failing due to a GitHub Actions infrastructure outage — the runner can't download its actions ( Generated by Claude Code |
Pull Request
Summary
Makes the of-the-day plugin's word wrapping fully font-aware: long definitions and subtitles now wrap into as many lines as actually fit the panel (computed from the real font height and available space, not hardcoded line counts), and when the configured font can't fit the whole text, scalable fonts auto-shrink to the largest size that fits everything. Text that can't fit even at the smallest size is cut with a visible
...instead of being silently clipped mid-sentence at the panel bottom.Type of change
Plugin(s) affected
of-the-day
Related issues
N/A
Test plan
(
EMULATOR=true python3 run.py)scripts/check_plugin.pyacross all 8 supported sizes: all PASS, with only the 64x32 golden changing (its subtitle was previously clipped mid-sentence with no indication; it now ends with an ellipsis). Also rendered long-definition and font-size-override scenarios and visually inspected the PNGs.auto_fit_textkey hastype,default,description, and is markedx-advancedAdditionally: added
test_text_fitting.py(11 new tests covering wrap correctness, auto-shrink, ellipsize fallback, and the auto-fit-off path) and re-ran the existingtest_element_styles.py— all 20 tests pass, confirming untouched configs still render byte-identically on the styling paths.Required for plugin changes
versioninplugins/<id>/manifest.json(1.3.2 → 1.4.0)class_nameinmanifest.jsonmatches the actual class inmanager.pyexactly (case-sensitive, no spaces)entry_pointmatches the real file (or is omitted to use themanager.pydefault)README.mdif config keys changed — documentedauto_fit_textconfig_schema.jsonis the source of truth for the web UI form — any new option is in the schema with adefault,description, and constraintsplugins.json) —update_registry.pyrun manually;plugins.jsonnow lists 1.4.0SUBMISSION checklist (new plugins only)
N/A — existing plugin.
Checklist
CONTRIBUTING.mdCONTRIBUTING.mdandCODE_OF_CONDUCT.mdNotes for reviewer
MIN_AUTO_FONT_SIZE = 5bounds the shrink.freetype.Face, PIL default) can't be resized, so they skip the shrink and go straight to wrap + ellipsize.Generated by Claude Code
Summary by CodeRabbit
New Features
auto_fit_textsetting, enabled by default, to control this behavior.Bug Fixes
Documentation
Chores