Repository navigation
feat(fetcher): add steam_* family (player_summary, recently_played, owned_games, charts) - #249
Conversation
list_ranking printed Bar.value as a raw u64, so fetchers could not control the value column's unit. Add an optional value_label field to Bar: text-first renderers prefer it, visual renderers (chart_bar / chart_pie) keep ignoring it and consume only the numeric value. list_ranking now renders value_label when present and preserves the fetcher's bar order instead of re-sorting by value descending — sort is the fetcher's responsibility, matching chart_bar / chart_pie. max_items truncates from the head. All existing Bar call sites pass value_label: None (no behavior change); the lastfm_top_* / lastfm_charts bars carry their pluralised play-count unit so list_ranking shows "1.5k plays" instead of "1500". Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
First member of the steam_* family. Reads ISteamUser/GetPlayerSummaries and IPlayerService/GetSteamLevel in parallel and reshapes the single profile snapshot into 8 shapes (TextBlock / Text / MarkdownTextBlock / LinkedTextBlock / ImageLinkedList / Entries / Badge / Image): persona name, Steam level, online status, currently-playing game, last logoff. Ships the shared steam/client.rs — fixed host api.steampowered.com so Safety::Safe, STEAM_API_KEY auth, STEAM_ID resolved from option or env. Catalog: #68 (Life & Ambient — Gaming). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Games the configured Steam user launched in the last two weeks, with per-game minutes from playtime_2weeks. 11 shapes (Bars / Entries / TextBlock / MarkdownTextBlock / LinkedTextBlock / ImageLinkedList / Text / Ratio / NumberSeries / Image / Badge). The Text shape sums the window into an "Xh across N games this week" headline, covering the catalog's steam_playtime_week candidate without a second read. Ships the shared steam/common.rs (appid-derived URLs, playtime / count formatting) and steam/games.rs (game-list shape builders reused by the recently_played / owned_games / charts siblings). Catalog: #68 (steam_recently_played, steam_playtime_week). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The configured Steam user's library ranked by total playtime
(sort = "playtime", default) or most-recently launched (sort =
"recent"). Complement to steam_recently_played over the all-time window.
11 shapes via the shared games.rs builders.
Recent-sort rows label the value column with a relative pill
("today" / "3d ago" / "2w ago", ISO date past 30 days) so list_ranking
reads as "when" rather than raw playtime minutes; the bar value stays
in minutes so chart_bar heights remain comparable.
Catalog: #68 (steam_owned_games).
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Global most-played games on Steam right now, ranked by 24-hour peak concurrent count. Reads the public ISteamChartsService/GetMostPlayedGames endpoint (no auth) and resolves appid -> game name via parallel store.steampowered.com/api/appdetails calls (the chart endpoint returns appid only); a failed lookup falls back to an "app/<id>" placeholder so a single 404 does not sink the chart. 10 shapes via the shared games.rs builders. The Steam slot in the *_trending family alongside crypto_trending / huggingface_trending / lastfm_charts. Catalog: #68 (steam_charts). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthroughThis PR adds an optional ChangesBar Schema Expansion & Steam Fetcher Implementation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #249 +/- ##
==========================================
- Coverage 94.80% 94.26% -0.55%
==========================================
Files 231 239 +8
Lines 60883 62321 +1438
==========================================
+ Hits 57722 58745 +1023
- Misses 3161 3576 +415
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/fetcher/code/comments.rs (1)
258-267:⚠️ Potential issue | 🟠 Major | ⚡ Quick winPopulate
value_labelfor Bars to avoid misleading values inlist_ranking.For
unit = percent,valueis scaled (20.0%becomes200), so rendering withoutvalue_labelshows incorrect-looking numbers in text-first ranking output.Suggested diff
Shape::Bars => Body::Bars(BarsData { bars: totals .by_language .iter() .take(limit) .map(|(name, stat)| Bar { label: name.clone(), value: bar_value(stat, unit), - value_label: None, + value_label: Some(format_value(stat, unit)), }) .collect(), }),🤖 Prompt for 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. In `@src/fetcher/code/comments.rs` around lines 258 - 267, The Bars mapping in Shape::Bars (constructing Body::Bars with BarsData and Bar) leaves Bar.value_label None which causes list_ranking to show misleading numbers because bar_value scales percent units; populate value_label by formatting the original stat with the intended unit (e.g., call or add a helper like format_stat_label(stat, unit) or use existing formatting logic) and set value_label = Some(formatted_label) for each Bar so percent values render as "20.0%" (or appropriate unit) while non-percent units get their human-readable labels.src/render/list_ranking.rs (1)
17-24:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUpdate
max_itemsschema description to match current behavior.
max_itemsno longer keeps “top N by value”; it truncates from the head of fetcher-provided order. The schema help text should reflect that to avoid config confusion.Suggested diff
OptionSchema { name: "max_items", type_hint: "positive integer", required: false, default: Some("all bars"), - description: "Cap on rendered ranks. Keeps the top N by value when the input has more bars than the cap.", + description: "Cap on rendered ranks. Truncates from the head of fetcher-provided order when the input has more bars than the cap.", },🤖 Prompt for 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. In `@src/render/list_ranking.rs` around lines 17 - 24, The OptionSchema entry named "max_items" in OPTION_SCHEMAS currently says it "Keeps the top N by value" but behavior actually truncates the list from the head of the fetcher-provided order; update the description of the OptionSchema with name "max_items" to state that it caps rendered ranks by truncating the fetcher-provided order from the head to the first N items (mention it does not reorder by value), leaving the other fields (type_hint, required, default) unchanged.
🤖 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 `@src/fetcher/steam/client.rs`:
- Around line 121-131: The parse_json function currently calls res.bytes().await
and only then checks bytes.len(), which allows oversized bodies to be fully
buffered; change parse_json to first inspect res.content_length() and return
FetchError::Failed if content_length > MAX_BYTES, and if absent or acceptable,
consume the response body as a stream (using res.bytes_stream() or similar)
accumulating chunks into a buffer but aborting and returning FetchError::Failed
as soon as the running total exceeds MAX_BYTES; finally deserialize the
accumulated buffer into T. Keep references to parse_json, MAX_BYTES, and
FetchError so the checks and early exit point are easy to find.
In `@src/fetcher/steam/owned_games.rs`:
- Around line 236-241: The current summation uses .sum() which can wrap on u32
overflow; replace it with a saturating fold to cap instead of wrapping. Change
the total calculation (the line using games.iter().map(|g|
g.playtime_forever).sum()) to use games.iter().fold(0u32, |acc, g|
acc.saturating_add(g.playtime_forever)) so total remains a u32 but uses
saturating_add to prevent overflow before calling format_minutes and
constructing the Body::Text.
In `@src/fetcher/steam/player_summary.rs`:
- Around line 314-327: When building the entries in entries_body, avoid pushing
the "last seen" Entry when the player is currently playing; change the logic so
that if snap.current_game is Some(...) you push the "playing" Entry and skip
adding the "last seen" Entry, otherwise (when current_game is None) push the
"last seen" Entry from snap.last_logoff (formatted with format_last_logoff).
Update the block that currently checks snap.current_game and snap.last_logoff so
that the snap.last_logoff push is guarded by snap.current_game.is_none(),
mirroring the mutually-exclusive behavior used by lines().
---
Outside diff comments:
In `@src/fetcher/code/comments.rs`:
- Around line 258-267: The Bars mapping in Shape::Bars (constructing Body::Bars
with BarsData and Bar) leaves Bar.value_label None which causes list_ranking to
show misleading numbers because bar_value scales percent units; populate
value_label by formatting the original stat with the intended unit (e.g., call
or add a helper like format_stat_label(stat, unit) or use existing formatting
logic) and set value_label = Some(formatted_label) for each Bar so percent
values render as "20.0%" (or appropriate unit) while non-percent units get their
human-readable labels.
In `@src/render/list_ranking.rs`:
- Around line 17-24: The OptionSchema entry named "max_items" in OPTION_SCHEMAS
currently says it "Keeps the top N by value" but behavior actually truncates the
list from the head of the fetcher-provided order; update the description of the
OptionSchema with name "max_items" to state that it caps rendered ranks by
truncating the fetcher-provided order from the head to the first N items
(mention it does not reorder by value), leaving the other fields (type_hint,
required, default) unchanged.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3dd01eee-36f7-4b11-948c-51146b640621
📒 Files selected for processing (47)
src/fetcher/basic/bars.rssrc/fetcher/code/comments.rssrc/fetcher/code/files.rssrc/fetcher/code/largest_files.rssrc/fetcher/code/loc.rssrc/fetcher/code/todos.rssrc/fetcher/crypto_trending.rssrc/fetcher/crypto_watchlist.rssrc/fetcher/deal/common.rssrc/fetcher/forge_items.rssrc/fetcher/git/age.rssrc/fetcher/git/churn.rssrc/fetcher/git/contributors.rssrc/fetcher/github/action_history.rssrc/fetcher/github/contributors_monthly.rssrc/fetcher/github/languages.rssrc/fetcher/github/repo_stars.rssrc/fetcher/gitlab/repo_stars.rssrc/fetcher/huggingface_trending.rssrc/fetcher/lastfm/top.rssrc/fetcher/linear/cycle.rssrc/fetcher/linear/issues.rssrc/fetcher/linear/notifications.rssrc/fetcher/lobsters/top.rssrc/fetcher/mod.rssrc/fetcher/net/interfaces.rssrc/fetcher/net/speedtest.rssrc/fetcher/read_store.rssrc/fetcher/reddit/trending.rssrc/fetcher/steam/charts.rssrc/fetcher/steam/client.rssrc/fetcher/steam/common.rssrc/fetcher/steam/games.rssrc/fetcher/steam/mod.rssrc/fetcher/steam/owned_games.rssrc/fetcher/steam/player_summary.rssrc/fetcher/steam/recently_played.rssrc/fetcher/stock_watchlist.rssrc/fetcher/system/mod.rssrc/fetcher/weather/forecast.rssrc/fetcher/weather/now.rssrc/fetcher/wikipedia/trending.rssrc/payload.rssrc/render/chart_bar.rssrc/render/chart_pie.rssrc/render/list_ranking.rssrc/samples.rs
| async fn parse_json<T: DeserializeOwned>(res: reqwest::Response) -> Result<T, FetchError> { | ||
| let status = res.status(); | ||
| let bytes = res | ||
| .bytes() | ||
| .await | ||
| .map_err(|e| FetchError::Failed(format!("steam read body: {e}")))?; | ||
| if bytes.len() > MAX_BYTES { | ||
| return Err(FetchError::Failed(format!( | ||
| "steam response too large ({} bytes, cap {MAX_BYTES})", | ||
| bytes.len() | ||
| ))); |
There was a problem hiding this comment.
Enforce response-size limits before full buffering.
The 5MB cap is currently checked only after res.bytes().await, so a much larger body can still be fully loaded into memory first. This weakens the protection against oversized responses.
Suggested mitigation
async fn parse_json<T: DeserializeOwned>(res: reqwest::Response) -> Result<T, FetchError> {
let status = res.status();
+ if let Some(len) = res.content_length() {
+ if len > MAX_BYTES as u64 {
+ return Err(FetchError::Failed(format!(
+ "steam response too large ({len} bytes, cap {MAX_BYTES})"
+ )));
+ }
+ }
let bytes = res
.bytes()
.await
.map_err(|e| FetchError::Failed(format!("steam read body: {e}")))?;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| async fn parse_json<T: DeserializeOwned>(res: reqwest::Response) -> Result<T, FetchError> { | |
| let status = res.status(); | |
| let bytes = res | |
| .bytes() | |
| .await | |
| .map_err(|e| FetchError::Failed(format!("steam read body: {e}")))?; | |
| if bytes.len() > MAX_BYTES { | |
| return Err(FetchError::Failed(format!( | |
| "steam response too large ({} bytes, cap {MAX_BYTES})", | |
| bytes.len() | |
| ))); | |
| async fn parse_json<T: DeserializeOwned>(res: reqwest::Response) -> Result<T, FetchError> { | |
| let status = res.status(); | |
| if let Some(len) = res.content_length() { | |
| if len > MAX_BYTES as u64 { | |
| return Err(FetchError::Failed(format!( | |
| "steam response too large ({len} bytes, cap {MAX_BYTES})" | |
| ))); | |
| } | |
| } | |
| let bytes = res | |
| .bytes() | |
| .await | |
| .map_err(|e| FetchError::Failed(format!("steam read body: {e}")))?; | |
| if bytes.len() > MAX_BYTES { | |
| return Err(FetchError::Failed(format!( | |
| "steam response too large ({} bytes, cap {MAX_BYTES})", | |
| bytes.len() | |
| ))); |
🤖 Prompt for 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.
In `@src/fetcher/steam/client.rs` around lines 121 - 131, The parse_json function
currently calls res.bytes().await and only then checks bytes.len(), which allows
oversized bodies to be fully buffered; change parse_json to first inspect
res.content_length() and return FetchError::Failed if content_length >
MAX_BYTES, and if absent or acceptable, consume the response body as a stream
(using res.bytes_stream() or similar) accumulating chunks into a buffer but
aborting and returning FetchError::Failed as soon as the running total exceeds
MAX_BYTES; finally deserialize the accumulated buffer into T. Keep references to
parse_json, MAX_BYTES, and FetchError so the checks and early exit point are
easy to find.
| let total: u32 = games.iter().map(|g| g.playtime_forever).sum(); | ||
| Body::Text(crate::payload::TextData { | ||
| value: format!( | ||
| "{} across {} owned games", | ||
| format_minutes(total), | ||
| games.len() |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n src/fetcher/steam/owned_games.rs | head -250Repository: unhappychoice/splashboard
Length of output: 10159
🏁 Script executed:
# Check the GameRow and game data structures to understand playtime_forever type
rg "playtime_forever" -A 2 -B 2Repository: unhappychoice/splashboard
Length of output: 3360
🏁 Script executed:
# Search for how this data is sourced and what realistic values might be
rg "playtime" src/fetcher/steam/ -B 2 -A 2Repository: unhappychoice/splashboard
Length of output: 12426
Use saturating_add to prevent overflow when aggregating playtime across large libraries.
Line 236 sums all playtime_forever values (each u32) into a u32 total. A user with a large library (1000+ games) can realistically exceed u32::MAX (≈4.3B minutes ≈ 8,173 years), causing silent overflow. Replace with saturating addition to gracefully cap the total instead of wrapping.
Proposed fix
- let total: u32 = games.iter().map(|g| g.playtime_forever).sum();
+ let total = games
+ .iter()
+ .fold(0_u32, |acc, g| acc.saturating_add(g.playtime_forever));📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let total: u32 = games.iter().map(|g| g.playtime_forever).sum(); | |
| Body::Text(crate::payload::TextData { | |
| value: format!( | |
| "{} across {} owned games", | |
| format_minutes(total), | |
| games.len() | |
| let total = games | |
| .iter() | |
| .fold(0_u32, |acc, g| acc.saturating_add(g.playtime_forever)); | |
| Body::Text(crate::payload::TextData { | |
| value: format!( | |
| "{} across {} owned games", | |
| format_minutes(total), | |
| games.len() |
🤖 Prompt for 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.
In `@src/fetcher/steam/owned_games.rs` around lines 236 - 241, The current
summation uses .sum() which can wrap on u32 overflow; replace it with a
saturating fold to cap instead of wrapping. Change the total calculation (the
line using games.iter().map(|g| g.playtime_forever).sum()) to use
games.iter().fold(0u32, |acc, g| acc.saturating_add(g.playtime_forever)) so
total remains a u32 but uses saturating_add to prevent overflow before calling
format_minutes and constructing the Body::Text.
| if let Some(game) = &snap.current_game { | ||
| items.push(Entry { | ||
| key: "playing".into(), | ||
| value: Some(game.clone()), | ||
| status: None, | ||
| }); | ||
| } | ||
| if let Some(ts) = snap.last_logoff { | ||
| items.push(Entry { | ||
| key: "last seen".into(), | ||
| value: Some(format_last_logoff(ts)), | ||
| status: None, | ||
| }); | ||
| } |
There was a problem hiding this comment.
Avoid showing last seen while a game is actively shown as playing.
entries_body can emit both rows at once, which is inconsistent. Use the same mutually-exclusive behavior as lines().
Suggested fix
- if let Some(game) = &snap.current_game {
+ if let Some(game) = &snap.current_game {
items.push(Entry {
key: "playing".into(),
value: Some(game.clone()),
status: None,
});
- }
- if let Some(ts) = snap.last_logoff {
+ } else if let Some(ts) = snap.last_logoff {
items.push(Entry {
key: "last seen".into(),
value: Some(format_last_logoff(ts)),
status: None,
});
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if let Some(game) = &snap.current_game { | |
| items.push(Entry { | |
| key: "playing".into(), | |
| value: Some(game.clone()), | |
| status: None, | |
| }); | |
| } | |
| if let Some(ts) = snap.last_logoff { | |
| items.push(Entry { | |
| key: "last seen".into(), | |
| value: Some(format_last_logoff(ts)), | |
| status: None, | |
| }); | |
| } | |
| if let Some(game) = &snap.current_game { | |
| items.push(Entry { | |
| key: "playing".into(), | |
| value: Some(game.clone()), | |
| status: None, | |
| }); | |
| } else if let Some(ts) = snap.last_logoff { | |
| items.push(Entry { | |
| key: "last seen".into(), | |
| value: Some(format_last_logoff(ts)), | |
| status: None, | |
| }); | |
| } |
🤖 Prompt for 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.
In `@src/fetcher/steam/player_summary.rs` around lines 314 - 327, When building
the entries in entries_body, avoid pushing the "last seen" Entry when the player
is currently playing; change the logic so that if snap.current_game is Some(...)
you push the "playing" Entry and skip adding the "last seen" Entry, otherwise
(when current_game is None) push the "last seen" Entry from snap.last_logoff
(formatted with format_last_logoff). Update the block that currently checks
snap.current_game and snap.last_logoff so that the snap.last_logoff push is
guarded by snap.current_game.is_none(), mirroring the mutually-exclusive
behavior used by lines().
Summary
Adds the
steam_*fetcher family — Steam Web API readouts, mirroring thelastfm_*family layout (sharedclient.rs+common.rs+games.rs, one file per fetcher).steam_player_summaryGetPlayerSummaries+GetSteamLevelSTEAM_API_KEY+steam_idsteam_recently_playedGetRecentlyPlayedGamesSTEAM_API_KEY+steam_idsteam_owned_gamesGetOwnedGamesSTEAM_API_KEY+steam_idsteam_chartsGetMostPlayedGames+ storeappdetailsAll four are
Safety::Safe—api.steampowered.com/store.steampowered.comare hardcoded, config only picks which resource is queried.STEAM_API_KEYgoes in$HOME/.splashboard/secrets.toml;STEAM_IDresolves from a per-fetcher option or theSTEAM_IDenv var (same precedence as thesteamfetchCLI).Renderer infra change
Bargains an optionalvalue_label: Option<String>field.list_rankingpreviously printedBar.valueas a rawu64, so fetchers could not control the value column's unit. Now:list_ranking) printvalue_labelwhen present; visual renderers (chart_bar/chart_pie) keep ignoring it.list_rankingpreserves the fetcher's bar order instead of re-sorting by value — sort is the fetcher's responsibility, matching the other Bars renderers.max_itemstruncates from the head.lastfm_top_*/lastfm_chartsbars now carry their pluralised play-count unit, solist_rankingshows1.5k playsinstead of1500.Notable decisions:
steam_recently_played'sTextshape sumsplaytime_2weeksinto an "Xh across N games this week" headline, covering the catalog'ssteam_playtime_weekcandidate without a second read.steam_owned_games sort = "recent"labels the value column with a relative pill (today/3d ago/2w ago, ISO date past 30 days); the bar value stays in minutes sochart_barheights remain comparable.steam_chartsreportspeak_in_game(24h peak concurrent) —GetMostPlayedGamesdoes not expose the live "right now" count — labelled... peakto stay honest. appid → name is an N+1 over the storeappdetailsendpoint, fanned out with a 4-permit semaphore; per-app failures fall back to anapp/<id>placeholder.Test plan
cargo test— 2893 lib + 12 integration tests green (62 new underfetcher::steam+render::list_rankingvalue_label / order coverage).cargo clippy --all-targets -- -D warnings— clean.cargo fmt --all -- --check— clean..splashboard/dashboard.toml(splashboard watch): all four fetchers acrosschart_bar/list_ranking/grid_table/list_cards/status_badge/text_ascii, confirmed value columns, ordering, peak labels, and relative dates render correctly.Catalog
Ticks
#68(Life & Ambient — Gaming):steam_recently_played,steam_playtime_week(absorbed intosteam_recently_played's Text shape),steam_charts.steam_player_summary/steam_owned_gamesare family siblings added alongside.🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Improvements