Skip to content

feat(fetcher): add system_battery realtime fetcher - #123

Merged
unhappychoice merged 1 commit into
mainfrom
feat/system-battery-fetcher
Apr 26, 2026
Merged

unhappychoice merged 1 commit into
mainfrom
feat/system-battery-fetcher

Conversation

@unhappychoice

Copy link
Copy Markdown
Owner

Summary

  • Adds system_battery realtime fetcher backed by starship-battery. Pairs with the existing gauge_battery renderer family.
  • Three shapes: Ratio (charge 0..=1, default), Text (formatted via kind option), Entries (charge / state / time_left / cycles / health).
  • Hosts without a battery (desktops, servers) render as a "full AC" stand-in (Ratio = 1.0, Text = "AC", single power = AC entry) so the widget doesn't silently disappear.

Ticks the system_battery box on #62.


  • Kind: realtime
  • Safety: Safe
  • Shapes: ratio, text, entries

Options

Option Type Required Default Description
kind "summary" | "percent" | "status" | "time_remaining" no "summary" Selects the format of the Text shape. Ignored by Ratio / Entries.
index integer no 0 Index of the battery to read on multi-battery systems.

Compatible renderers

Shape Renderers
ratio animated_boot, animated_postfx, animated_scanlines, animated_splitflap, animated_wave, gauge_battery, gauge_circle, gauge_line, gauge_segment
text animated_boot, animated_figlet_morph, animated_postfx, animated_scanlines, animated_splitflap, animated_typewriter, animated_wave, text_ascii, text_plain
entries animated_boot, animated_postfx, animated_scanlines, animated_splitflap, animated_wave, grid_table

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test (28 system tests pass — kind branches, shape branches, no-battery fallback, options error)
  • Smoke-tested via cargo run --bin splashboard with all four gauge renderers + three Text kind variants + grid_table

Follow-up

While testing the smoke fixture I noticed unknown fetcher names silently drop widgets from the layout instead of rendering an in-band error like unknown renderers do — filed as #121.

🤖 Generated with Claude Code

Reads laptop battery state via starship-battery and emits Ratio (pairs
with gauge_battery / gauge_circle / gauge_segment / gauge_line), Text
(summary / percent / status / time_remaining via the kind option), or
Entries (charge / state / time_left / cycles / health). Hosts without a
battery (desktops, servers) render as a "full AC" stand-in so the widget
slot stays visible instead of silently disappearing.

Ticks the system_battery box on #62.

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

coderabbitai Bot commented Apr 26, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@unhappychoice has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 57 minutes and 16 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 57 minutes and 16 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fd8520f7-b190-461e-9ea8-63857e014e00

📥 Commits

Reviewing files that changed from the base of the PR and between 7e6d795 and c57408a.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • Cargo.toml
  • src/fetcher/system.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/system-battery-fetcher

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.

@codecov

codecov Bot commented Apr 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.69565% with 72 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.25%. Comparing base (14ee8a4) to head (c57408a).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
src/fetcher/system.rs 68.69% 72 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #123      +/-   ##
==========================================
- Coverage   78.41%   78.25%   -0.16%     
==========================================
  Files          95       95              
  Lines       17304    17542     +238     
==========================================
+ Hits        13569    13728     +159     
- Misses       3735     3814      +79     
Files with missing lines Coverage Δ
src/fetcher/system.rs 74.27% <68.69%> (-2.15%) ⬇️

... and 2 files with indirect coverage changes

🚀 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 54a481f into main Apr 26, 2026
7 checks passed
@unhappychoice
unhappychoice deleted the feat/system-battery-fetcher branch April 26, 2026 00:33
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