fix(masters): fix startup errors, display timing, and hole card layout#80
fix(masters): fix startup errors, display timing, and hole card layout#80ChuckBuilds merged 4 commits intomainfrom
Conversation
Fixes three issues preventing the Masters plugin from running and improves the display experience: Startup fixes: - Replace self.plugin_dir (not set by BasePlugin) with os.path.dirname(__file__) for MastersLogoLoader initialization - Replace self.display_manager.draw_image() (doesn't exist) with self.display_manager.image.paste() matching other plugins Display timing: - Hole cards (course_tour, featured_holes) now hold each hole for hole_display_duration (default 15s) instead of switching every 1s - Paginated modes (past_champions, tournament_stats, course_overview, schedule, leaderboard) hold each page for page_display_duration (default 15s) via new _advance_page() timer - Fun facts scroll steps advance every 2s instead of every 1s - Both durations are user-configurable Visual improvements: - Countdown: Masters logo has black glow outline for visibility - Hole cards: redesigned layout with left info panel (hole #, name, par, yardage) and right side dedicated to hole image at full height - Zone badge (AMEN CORNER, FEATURED) moved to bottom-right corner to avoid overlapping left panel text Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdds time-gated rotation for pages, holes, and fun-facts; resets timers on config changes; fixes MastersLogoLoader path; switches image rendering to paste; adds RGBA-aware logo glow; and reworks hole card to a left info panel plus right image panel. Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
plugins/masters-tournament/manager.py (1)
538-544:⚠️ Potential issue | 🟠 MajorHot config reload never applies the new rotation durations.
hole_display_durationandpage_display_durationare only read in__init__, so changing them at runtime has no effect until the plugin restarts. Update the cached intervals inon_config_change()and reset the related last-advance state so the new cadence applies immediately.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/masters-tournament/manager.py` around lines 538 - 544, on_config_change currently updates _update_interval and display_duration but does not refresh the cached rotation durations read in __init__ (hole_display_duration and page_display_duration) nor reset the per-rotation timers, so hot reloads don't take effect; update hole_display_duration and page_display_duration from new_config inside on_config_change and reset any last-advance state variables (e.g., _last_hole_advance, _last_page_advance or similar) so the new cadence is applied immediately, keeping the existing call to super().on_config_change(new_config) and _build_enabled_modes().
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@plugins/masters-tournament/manager.py`:
- Around line 114-120: Both hole-rotation modes (_display_course_tour and
_display_featured_holes) currently share a single _last_hole_switch timestamp so
they throttle each other and advance immediately on first render; change this to
a per-rotation-key timestamp (similar to _last_page_advance) — replace
_last_hole_switch with a dict (e.g., _last_hole_switch = {}) keyed by mode or
rotation id, consult _hole_switch_interval as before, and in the rotation logic
initialize the key on first render (do not advance when the key is missing or
zero) so the first shown hole holds for the full interval; apply the same
pattern where hole rotation is used (also around the region referenced 405-429)
and keep _advance_page behavior unchanged.
In `@plugins/masters-tournament/masters_renderer_enhanced.py`:
- Around line 214-241: The name block and par/yard lines overlap on the "small"
tier because par_y is a hardcoded value and wrapping only splits by word count
without measuring widths/heights; update the rendering in the method that draws
the left panel (references: self.tier, name_text, self._text_width,
self.font_detail, left_w, par_y, hole_info) to: measure the rendered height of
the name lines using self._text_width and font metrics, compute
name_block_height and set par_y = self.height - 20 (or a configurable bottom
padding) minus the measured par/yard height so the par/yard never overlap the
name; for wrapping, implement width-aware line breaking by building lines that
fit left_w - 4 using self._text_width and, if self.tier == "small", fall back to
truncating the second line with an ellipsis when it exceeds the available
width/height; ensure all centering uses measured line widths when positioning
text.
---
Outside diff comments:
In `@plugins/masters-tournament/manager.py`:
- Around line 538-544: on_config_change currently updates _update_interval and
display_duration but does not refresh the cached rotation durations read in
__init__ (hole_display_duration and page_display_duration) nor reset the
per-rotation timers, so hot reloads don't take effect; update
hole_display_duration and page_display_duration from new_config inside
on_config_change and reset any last-advance state variables (e.g.,
_last_hole_advance, _last_page_advance or similar) so the new cadence is applied
immediately, keeping the existing call to super().on_config_change(new_config)
and _build_enabled_modes().
🪄 Autofix (Beta)
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
Run ID: 45f56cdd-d5bd-4b43-a0f8-9647be60325c
📒 Files selected for processing (3)
plugins/masters-tournament/manager.pyplugins/masters-tournament/masters_renderer.pyplugins/masters-tournament/masters_renderer_enhanced.py
- Replace shared _last_hole_switch with per-mode _last_hole_advance dict so course_tour and featured_holes don't throttle each other, and first hole holds for the full interval before advancing - Fix name/par text overlap on small displays: use width-aware line wrapping with measured heights, and anchor par/yardage below the name block with a minimum gap - Update on_config_change to refresh hole_display_duration and page_display_duration and reset timer state so hot reloads take effect Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move the Masters logo from a small centered-top position (48x20 max) to a large left-side position (55% width, nearly full height) with black glow. Stack the countdown info (label, number, unit) vertically centered in the right panel using smaller font. The logo now dominates the display while keeping all countdown information visible. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@plugins/masters-tournament/masters_renderer.py`:
- Around line 815-816: The split-layout that places the countdown to the right
(using right_x = lx + logo.width + 6 and computing the right panel width as
self.width - logo.width - 12) must be gated to avoid clipping on tiny/small
tiers; update the rendering branch around those lines (where logo_max_w,
logo_max_h, right_x are used and the countdown is split) to only use the
two-column layout when the display is large enough — e.g., either if self.tier
in ("large","xlarge") or if (self.width - logo.width - 12) >= MIN_RIGHT_WIDTH
(choose a MIN_RIGHT_WIDTH equal to the minimum label+value width you need);
otherwise fall back to the compact single-column countdown path (the existing
"UNTIL THE MASTERS"/"TO MASTERS" + count/unit layout) so the count and unit
remain visible.
🪄 Autofix (Beta)
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
Run ID: 3845f6d9-53f7-4955-a3f1-136b6d8c29f9
📒 Files selected for processing (1)
plugins/masters-tournament/masters_renderer.py
The two-column countdown layout (large logo left, text right) clips on tiny/small displays where the right panel is too narrow for text. Gate the split layout to tier=="large" (width > 64) with a minimum right panel width check (40px). Fall back to the compact centered layout (logo top, countdown below) for smaller displays. Also extract _draw_logo_with_glow() helper to deduplicate the black glow rendering between both layout paths. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
plugins/masters-tournament/masters_renderer.py (1)
877-899:⚠️ Potential issue | 🔴 CriticalCompact countdown fallback still clips on
smallandtinypanels.Line 898 draws the unit at
mid_y + 16, which lands aty == 32on the documented 64x32smalltier andy == 24on the 32x16tinytier, so that line never renders there. Ontiny, Line 893 also pushes the count into the bottom edge. This fallback needs to stack fromlogo.heightand measured text heights instead of fixed offsets, and it should drop the logo or unit when the remaining height is too small.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/masters-tournament/masters_renderer.py` around lines 877 - 899, The compact-layout drawing uses fixed offsets (mid_y + 4 / +16) which clip on small/tiny panels; change the layout in the rendering method that calls logo_loader.get_masters_logo and _draw_logo_with_glow to compute positions from the actual occupied heights instead of hard-coded mid_y offsets: measure logo height (logo.height) if present and measure text heights via the font metrics (use draw.textbbox/textsize with font_detail and font_score) to compute a stacked y offset (logo_top -> until_text -> count_text -> unit_text) and center each line horizontally using _text_width; if total required height exceeds self.height, drop the logo first, then the unit_text as needed, and ensure count_text never overflows the bottom by reducing spacing or font (or hiding optional elements) so all rendered text fits inside self.height.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@plugins/masters-tournament/masters_renderer.py`:
- Around line 877-899: The compact-layout drawing uses fixed offsets (mid_y + 4
/ +16) which clip on small/tiny panels; change the layout in the rendering
method that calls logo_loader.get_masters_logo and _draw_logo_with_glow to
compute positions from the actual occupied heights instead of hard-coded mid_y
offsets: measure logo height (logo.height) if present and measure text heights
via the font metrics (use draw.textbbox/textsize with font_detail and
font_score) to compute a stacked y offset (logo_top -> until_text -> count_text
-> unit_text) and center each line horizontally using _text_width; if total
required height exceeds self.height, drop the logo first, then the unit_text as
needed, and ensure count_text never overflows the bottom by reducing spacing or
font (or hiding optional elements) so all rendered text fits inside self.height.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 03de0c85-3fde-4be4-a404-0f080de7097e
📒 Files selected for processing (1)
plugins/masters-tournament/masters_renderer.py
Summary
self.plugin_dirAttributeError anddraw_imagemissing on DisplayManagerTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Style
New Features
Bug Fixes