Skip to content

feat(fetcher): add weather_forecast + fix chart bg - #215

Merged
unhappychoice merged 2 commits into
mainfrom
feat/weather-forecast
May 11, 2026
Merged

unhappychoice merged 2 commits into
mainfrom
feat/weather-forecast

Conversation

@unhappychoice

Copy link
Copy Markdown
Owner

Summary

  • New weather_forecast fetcher — Open-Meteo daily multi-day forecast (default 3 days, range 1..=7) for a fixed (latitude, longitude). Sibling of weather (now). 9 shapes covering everything from a one-liner headline to a Timeline of per-day events.
  • weather.rs split into src/fetcher/weather/{mod,common,now,forecast}.rs mirroring the github/ family layout. weather's registered name / behaviour / tests are unchanged.
  • Drive-by bg fix for chart_line / chart_scatter — ratatui's Chart / Canvas were painting Color::Reset across the plot area, erasing the panel theme.bg. Anchored both to theme.bg.

Refs #41 — ticks the weather_forecast box on #68.

weather_forecast reference

Kind Safety Shapes
cached Safe text_block (default), text, entries, ratio, number_series, point_series, bars, badge, timeline

Options

Option Type Required Default Description
latitude float (degrees) yes — Latitude of the location to query (e.g., 35.68 for Tokyo).
longitude float (degrees) yes — Longitude of the location to query.
units "metric" | "imperial" no "metric" Metric renders °C; imperial renders °F and reports precipitation in inches.
days int (1..=7) no 3 Forecast window. Open-Meteo serves longer windows but accuracy drops past a week.

Compatible renderers (per shape)

Shape Default renderers
text_block list_plain
text text_plain, text_ascii
entries grid_table
ratio gauge_battery, gauge_circle, gauge_line, gauge_segment, gauge_thermometer
number_series chart_histogram, chart_sparkline
point_series chart_line, chart_scatter
bars chart_bar, chart_pie, list_ranking
badge status_badge
timeline list_timeline

Theme tokens

Bars carries per-day precipitation probability (%), not rainfall amount, so chart_bar stays informative in dry forecasts. NumberSeries keeps the rainfall amount in tenths-of-mm/inch for sparkline / histogram consumers. Textual shapes append precipitation amount only when > 0 (Tue 🌧 18°/13°C 💧80% 8.4mm).

chart_line / chart_scatter bg fix

ratatui 0.29's Chart widget seeds its internal Canvas with self.style.bg.unwrap_or(Color::Reset) (chart.rs:1023); Canvas::default() defaults background_color to Color::Reset (canvas.rs:639). Either path painted the terminal default across the plot area and erased the panel surface (theme.bg or bg = "subtle").

  • chart_line: Chart::new(...).style(Style::default().bg(theme.bg)) propagates the bg into the inner Canvas.
  • chart_scatter: Canvas::default().background_color(theme.bg).

theme::BG added to each renderer's COLOR_KEYS so the docs / catalog surface the theme dependency. Regression tests assert rendered cells carry Theme::default().bg.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test --all-targets (2054 lib + 28 + 12 integration, all green; 12 live-network tests #[ignore]d)
  • cargo run --bin splashboard -- catalog fetcher weather_forecast shows 9 shapes + 4 options + every compatible renderer
  • Hand-rolled .splashboard/dashboard.toml smoke-tested locally across 8 panels (TextBlock / Entries / PointSeries chart_line / Bars chart_bar / Ratio gauge_battery / Badge / Timeline / Text centered)
  • Verify chart_line panel bg matches sibling panels under both theme.bg and bg = "subtle" layouts in production
  • Catalog checkbox at meta: fetcher roadmap - Life & Ambient #68 → flip weather_forecast to [x] after merge

unhappychoice and others added 2 commits May 12, 2026 03:37
Open-Meteo daily multi-day forecast fetcher for a fixed (latitude,
longitude). Sibling of the existing `weather` (now) widget.

Refactor: `src/fetcher/weather.rs` is split into `src/fetcher/weather/`
with `common.rs` (Units / weather_description / weather_badge / http /
parse_options), `now.rs` (existing logic, unchanged registered name and
public behaviour), and `forecast.rs` (new). Mirrors the `github/` family
layout.

9 shapes: `TextBlock` (default), `Text`, `Entries`, `Ratio`,
`NumberSeries`, `PointSeries`, `Bars`, `Badge`, `Timeline`. `Image` /
`Calendar` / `Heatmap` rejected (no natural mapping).

`Bars` carries per-day precipitation **probability** (%) rather than
rainfall amount so chart_bar stays informative in dry forecasts where
`precipitation_sum` is all zero. `NumberSeries` keeps the rainfall
amount in tenths-of-mm/inch for sparkline / histogram consumers.

Textual shapes (`TextBlock` / `Entries` / `Timeline` detail) append
precipitation amount when > 0 (`Tue  🌧 18°/13°C  💧80% 8.4mm`).

Options: `latitude` / `longitude` (required), `units` (metric default),
`days` (default 3, range 1..=7).

Refs #41 (#68: weather_forecast).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ratatui 0.29's `Chart` widget seeds its internal `Canvas` with
`self.style.bg.unwrap_or(Color::Reset)` (`chart.rs:1023`), and
`Canvas::default()` itself defaults `background_color` to `Color::Reset`
(`canvas.rs:639`). Either path paints the terminal default background
across the entire plot area, overwriting the panel surface (`theme.bg`
or `bg = "subtle"`) the layout already painted.

Anchor both renderers to `theme.bg`:

- `chart_line`: `Chart::new(...).style(Style::default().bg(theme.bg))`
  propagates the background into the inner Canvas.
- `chart_scatter`: `Canvas::default().background_color(theme.bg)` sets
  the bg directly.

Add `theme::BG` to each renderer's `COLOR_KEYS` so the catalog surfaces
the theme dependency. Regression test in each renderer asserts the
rendered cells carry `Theme::default().bg` rather than `Color::Reset`.

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

coderabbitai Bot commented May 11, 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 38 minutes and 27 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ 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: b19596d3-90c1-4544-93e7-11436a360725

📥 Commits

Reviewing files that changed from the base of the PR and between 5c57d44 and 911ed4f.

📒 Files selected for processing (7)
  • src/fetcher/mod.rs
  • src/fetcher/weather/common.rs
  • src/fetcher/weather/forecast.rs
  • src/fetcher/weather/mod.rs
  • src/fetcher/weather/now.rs
  • src/render/chart_line.rs
  • src/render/chart_scatter.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/weather-forecast

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 May 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.75339% with 83 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.97%. Comparing base (5c57d44) to head (911ed4f).

Files with missing lines Patch % Lines
src/fetcher/weather/forecast.rs 90.18% 58 Missing ⚠️
src/fetcher/weather/common.rs 72.61% 23 Missing ⚠️
src/fetcher/weather/now.rs 89.47% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #215      +/-   ##
==========================================
- Coverage   96.10%   95.97%   -0.13%     
==========================================
  Files         151      154       +3     
  Lines       44778    45421     +643     
==========================================
+ Hits        43032    43593     +561     
- Misses       1746     1828      +82     
Files with missing lines Coverage Δ
src/fetcher/mod.rs 99.09% <100.00%> (+<0.01%) ⬆️
src/fetcher/weather/mod.rs 100.00% <100.00%> (ø)
src/render/chart_line.rs 100.00% <100.00%> (ø)
src/render/chart_scatter.rs 100.00% <100.00%> (ø)
src/fetcher/weather/now.rs 91.00% <89.47%> (ø)
src/fetcher/weather/common.rs 72.61% <72.61%> (ø)
src/fetcher/weather/forecast.rs 90.18% <90.18%> (ø)

... and 1 file 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 b4947f9 into main May 11, 2026
7 checks passed
@unhappychoice
unhappychoice deleted the feat/weather-forecast branch May 11, 2026 18:51
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