Skip to content

feat(clock,system): PixelArt sprites for clock_derived + system_monitor_{battery,cpu} - #262

Merged
unhappychoice merged 5 commits into
mainfrom
feat/pixel-art-fetcher-expansion
Jun 6, 2026
Merged

unhappychoice merged 5 commits into
mainfrom
feat/pixel-art-fetcher-expansion

Conversation

@unhappychoice

@unhappychoice unhappychoice commented Jun 6, 2026 •

Copy link
Copy Markdown
Owner

Implements #261. Stacks on top of #260 (feat/pixel-art-shape) — merge that first.

Summary

Extends three existing fetchers with the PixelArt shape now that the renderer is in place:

  • clock_derived — eight 16×16 moon-phase sprites (new → waxing crescent → first quarter → waxing gibbous → full → waning gibbous → last quarter → waning crescent) and four season sprites (spring cherry blossom, summer sun, autumn maple, winter snowflake — hemisphere-aware). Unsupported kinds (zodiac, iso_week, day_of_year, …) fall back to a 1×1 placeholder labelled with the kind name so the misconfiguration is visible.
  • system_monitor_battery — horizontal battery silhouette with terminal cap and an inner ratio bar that grows + colour-shifts (red → orange → yellow → lime → green) across the 5 buckets. AC hosts render the full-tier sprite labelled "AC".
  • system_monitor_cpu — chip silhouette with four symmetric pins (cols 3, 6, 9, 12) above and below the package and a 6×4 core whose colour tracks load (blue → lime → yellow → orange → red).

Sprites live in src/fetcher/{clock,system}/sprites.rs, authored as ASCII grids + palette decoded once via OnceLock. Same pattern as weather/sprites.rs.

After merge: tick the relevant rows on #62 (System / clock fetchers); the renderer roadmap (#61) already gets ticked by #260.

Out of scope

  • kind = "zodiac" (12 sprites) and kind = "chinese_zodiac" (12 sprites) — animal / constellation art deserves a dedicated PR's worth of drawing time.

clock_derived reference (mirror of /reference/fetchers/clock/clock_derived/)

A single value derived from today's date, picked by kind. New shape entry:

Shape Behaviour
pixel_art Returns a 16×16 sprite when kind = "moon_phase" or kind = "season"; other kinds fall back to a 1×1 placeholder labelled with the kind name.

Compatible renderer: media_pixel.

system_monitor_battery reference

Shape Behaviour
pixel_art Five buckets at 20% steps, label format "42% · Discharging". AC hosts render the full-tier sprite labelled "AC".

system_monitor_cpu reference

Shape Behaviour
pixel_art Five buckets at 20% steps (sleepy → relaxed → normal → busy → overheating), label is the formatted percent.

Test plan

  • cargo test --lib — 3264 pass, 0 fail
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo fmt --all -- --check — clean
  • Smoke test: basic_read_store widget reads 16 of the 22 generated sprites over a 4×4 grid (moon × 4, season × 4, battery × 4, cpu × 4). All buckets render with the expected colour transitions and labels.

Summary by CodeRabbit

  • New Features
    • Clock widget now supports PixelArt display showing moon phases with animated sprites based on the lunar cycle.
    • System monitor widgets (CPU and battery) now support PixelArt visualization for enhanced visual feedback.

unhappychoice and others added 4 commits June 6, 2026 20:20
Adds eight 16x16 moon-phase sprites and four season sprites under
`src/fetcher/clock/sprites.rs`, mirroring the authoring pattern from
weather: ASCII grids + palette decoded once via `OnceLock`.

`clock_derived` learns `Shape::PixelArt`. When the user picks
`kind = "moon_phase"` or `kind = "season"`, `compute()` emits the
matching sprite (hemisphere-aware for seasons). Other kinds (numeric /
textual: iso_week, day_of_year, julian_day, unix_epoch, time_of_day,
rokuyou, jp_season, zodiac, chinese_zodiac) fall back to a 1x1
placeholder labelled with the kind name so the misconfiguration is
visible rather than silent.

`moon_phase` is refactored to share its phase index with the sprite
catalog through a new `pub(crate) moon_phase_index()`, keeping the text
label and the sprite in lockstep.

Refs #261.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Introduces `src/fetcher/system/sprites.rs` housing five battery sprites
(horizontal cell + terminal + inner ratio bar, colour shifting red →
orange → yellow → lime → green) and five CPU sprites (chip silhouette
with four symmetric pins (cols 3, 6, 9, 12) above and below the
package, a 6×4 core that shifts blue → lime → yellow → orange → red
with load). A shared `bucket_index()` maps a 0..=1 ratio into five
20-percent buckets used by both `battery_sprite()` and `cpu_sprite()`.

The module registration is the only system/mod.rs change in this
commit; the battery and cpu fetchers gain their PixelArt branches in
the next two commits so the sprite library landing stays independently
reviewable and bisect-clean.

Refs #261.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Extends `system_monitor_battery` with `Shape::PixelArt`. The battery
ratio routes through `sprites::battery_sprite()`, picking one of five
buckets and labelling it with the formatted percent + state
(`"42% · Discharging"`). Hosts without a battery render the AC-power
case as the full-tier sprite labelled `"AC"`.

Refs #261.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Extends `system_monitor_cpu` with `Shape::PixelArt`. The CPU usage
ratio routes through `sprites::cpu_sprite()`, picking one of five
buckets (sleepy → relaxed → normal → busy → overheating) and labelling
it with the formatted percent (`"42%"`).

Refs #261.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The pull request adds pixel-art sprite rendering support to two clock and system fetcher families. Clock-derived sprites render moon phases and seasons from ASCII grids; system sprites render battery charge and CPU load from ratio-bucketed variants. Each fetcher declares PixelArt as a supported shape and branches compute/sample_body logic accordingly.

Changes

Clock PixelArt Support

Layer / File(s) Summary
Clock sprites module with moon and season catalogs
src/fetcher/clock/mod.rs, src/fetcher/clock/sprites.rs
New sprites.rs module exports moon_sprite, season_sprite, and placeholder functions backed by OnceLock-cached ASCII sprite grids (8 moon phases and 4 seasons with hemisphere variants). Sprite decoding maps palette characters to pixel colors with transparent fallback. Full test coverage for grid dimensions, label handling, palette completeness, and season fallback behavior.
Clock derived fetcher PixelArt integration
src/fetcher/clock/derived.rs
ClockDerivedFetcher declares Shape::PixelArt, adds PixelArt branching in compute() and sample_body(). Moon-phase computation refactored into moon_phase_index() used by both text and sprite label selection. New sprite_for_kind() dispatcher selects moon, season, or placeholder sprites; kind_label() maps unsupported kinds to fallback labels. Tests validate PixelArt rendering for all kind/hemisphere combinations, placeholder behavior, and phase index consistency.

System PixelArt Support

Layer / File(s) Summary
System sprites module with battery and CPU catalogs
src/fetcher/system/mod.rs, src/fetcher/system/sprites.rs
New sprites.rs module exports battery_sprite and cpu_sprite functions that map input ratios to 5 bucket indices (0–4) and return OnceLock-cached ASCII sprites. Shared palette, bucket thresholds (0.2 increments), and ASCII grids for battery states (critical/low/mid/good/full) and CPU load (sleepy/relaxed/normal/busy/overheating). Tests validate bucket boundaries, label round-tripping, grid dimensions, and palette coverage.
System battery monitor PixelArt rendering
src/fetcher/system/monitor_battery.rs
SystemMonitorBattery declares and renders Shape::PixelArt, selecting sprite via charge ratio and including battery state in label (e.g., "75% · Charging"). No-battery fallback renders full AC sprite. Tests verify sample label and pixel count, plus AC fallback behavior.
System CPU monitor PixelArt rendering
src/fetcher/system/monitor_cpu.rs
SystemMonitorCpu declares and renders Shape::PixelArt, selecting sprite via CPU ratio and including percentage label. Tests verify PixelArt output and sample_body coverage across all supported shapes (Ratio, Text, PixelArt, returning None for unsupported Shape::Entries).
System fetcher contract test updates
src/fetcher/system/mod.rs
Module-level contract tests updated to expect Shape::PixelArt as declared supported shape for both system_monitor_cpu and system_monitor_battery fetchers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🎨✨ Sprites dance in pixels eight-by-eight,
From luna's phases to the load's great weight—
Moon glows, batteries charge, and CPUs hum,
Each shape's a canvas where the art's begun! 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 56.92% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately and concisely summarizes the main change: adding PixelArt sprite support to three fetchers (clock_derived, system_monitor_battery, and system_monitor_cpu).
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/pixel-art-fetcher-expansion

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 and usage tips.

Base automatically changed from feat/pixel-art-shape to main June 6, 2026 15:31
@codecov

codecov Bot commented Jun 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.24838% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.62%. Comparing base (030a6be) to head (6467c3a).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
src/fetcher/clock/derived.rs 84.94% 14 Missing ⚠️
src/fetcher/system/monitor_battery.rs 76.00% 6 Missing ⚠️
src/fetcher/system/monitor_cpu.rs 91.30% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #262      +/-   ##
==========================================
- Coverage   95.62%   95.62%   -0.01%     
==========================================
  Files         250      252       +2     
  Lines       68372    68815     +443     
==========================================
+ Hits        65382    65803     +421     
- Misses       2990     3012      +22     
Files with missing lines Coverage Δ
src/fetcher/clock/mod.rs 94.19% <ø> (ø)
src/fetcher/clock/sprites.rs 100.00% <100.00%> (ø)
src/fetcher/system/mod.rs 86.56% <100.00%> (+0.09%) ⬆️
src/fetcher/system/sprites.rs 100.00% <100.00%> (ø)
src/fetcher/system/monitor_cpu.rs 97.22% <91.30%> (-2.78%) ⬇️
src/fetcher/system/monitor_battery.rs 85.75% <76.00%> (-0.85%) ⬇️
src/fetcher/clock/derived.rs 95.53% <84.94%> (-3.48%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@unhappychoice
unhappychoice merged commit d56d49d into main Jun 6, 2026
7 checks passed
@unhappychoice
unhappychoice deleted the feat/pixel-art-fetcher-expansion branch June 6, 2026 15:42
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.

1 participant