Skip to content

feat(fetcher): add steam_* family (player_summary, recently_played, owned_games, charts) - #249

Merged
unhappychoice merged 5 commits into
mainfrom
feat/steam-family
May 20, 2026
Merged

unhappychoice merged 5 commits into
mainfrom
feat/steam-family

Conversation

@unhappychoice

@unhappychoice unhappychoice commented May 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds the steam_* fetcher family — Steam Web API readouts, mirroring the lastfm_* family layout (shared client.rs + common.rs + games.rs, one file per fetcher).

Fetcher Source Auth Shapes
steam_player_summary GetPlayerSummaries + GetSteamLevel STEAM_API_KEY + steam_id 8
steam_recently_played GetRecentlyPlayedGames STEAM_API_KEY + steam_id 11
steam_owned_games GetOwnedGames STEAM_API_KEY + steam_id 11
steam_charts GetMostPlayedGames + store appdetails none (public) 10

All four are Safety::Safe — api.steampowered.com / store.steampowered.com are hardcoded, config only picks which resource is queried. STEAM_API_KEY goes in $HOME/.splashboard/secrets.toml; STEAM_ID resolves from a per-fetcher option or the STEAM_ID env var (same precedence as the steamfetch CLI).

Renderer infra change

Bar gains an optional value_label: Option<String> field. list_ranking previously printed Bar.value as a raw u64, so fetchers could not control the value column's unit. Now:

  • text-first renderers (list_ranking) print value_label when present; visual renderers (chart_bar / chart_pie) keep ignoring it.
  • list_ranking preserves the fetcher's bar order instead of re-sorting by value — sort is the fetcher's responsibility, matching the other Bars renderers. max_items truncates from the head.
  • lastfm_top_* / lastfm_charts bars now carry their pluralised play-count unit, so list_ranking shows 1.5k plays instead of 1500.

Notable decisions:

  • steam_recently_played's Text shape sums playtime_2weeks into an "Xh across N games this week" headline, covering the catalog's steam_playtime_week candidate 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 so chart_bar heights remain comparable.
  • steam_charts reports peak_in_game (24h peak concurrent) — GetMostPlayedGames does not expose the live "right now" count — labelled ... peak to stay honest. appid → name is an N+1 over the store appdetails endpoint, fanned out with a 4-permit semaphore; per-app failures fall back to an app/<id> placeholder.

Test plan

  • cargo test — 2893 lib + 12 integration tests green (62 new under fetcher::steam + render::list_ranking value_label / order coverage).
  • cargo clippy --all-targets -- -D warnings — clean.
  • cargo fmt --all -- --check — clean.
  • Smoke-tested via a local .splashboard/dashboard.toml (splashboard watch): all four fetchers across chart_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 into steam_recently_played's Text shape), steam_charts. steam_player_summary / steam_owned_games are family siblings added alongside.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added Steam integration with four new fetchers: top charts, player summary, recently played games, and owned games library.
    • Bar charts now support optional value labels for enhanced display formatting.
  • Improvements

    • Bar ranking display now preserves data order instead of automatically sorting by value.

Review Change Stack

unhappychoice and others added 5 commits May 20, 2026 12:24
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]>
@coderabbitai

coderabbitai Bot commented May 20, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR adds an optional value_label field to the Bar payload struct, refactors ListRankingRenderer to preserve fetcher order and render preformatted display strings, introduces a complete Steam fetcher family with shared client/helper infrastructure, and updates all existing fetchers to populate the new field.

Changes

Bar Schema Expansion & Steam Fetcher Implementation

Layer / File(s) Summary
Bar struct expansion and test fixture updates
src/payload.rs, src/render/chart_*.rs, src/samples.rs
Bar gains optional value_label: Option<String> field with serde defaults and omission when None. Test fixtures updated to construct bars with the new field.
ListRankingRenderer order preservation and value_label rendering
src/render/list_ranking.rs
Renderer now preserves input fetcher order instead of sorting by value, uses preformatted Bar.value_label when present (falling back to stringified numeric value), and updates width/line composition logic. Tests cover order preservation and value_label override behavior.
Steam HTTP client and formatting helpers
src/fetcher/steam/client.rs, src/fetcher/steam/common.rs
Singleton reqwest::Client with configurable timeout/user-agent, environment-based STEAM_API_KEY/STEAM_ID resolution, three JSON fetching patterns (authenticated/unauthenticated/store), and format helpers for URLs, durations, counts, and pluralization.
Steam GameRow body renderers
src/fetcher/steam/games.rs
Normalized GameRow struct with 12 public body renderers (text, markdown, linked, image-linked, entries, ratio, series, bars, badge, image) handling empty states and concurrent thumbnail downloads. Full unit test coverage.
Steam module registration and entry point
src/fetcher/mod.rs, src/fetcher/steam/mod.rs
New steam module declared and registered in fetcher registry. fetchers() entry point returns all four Steam fetchers with unit test validating naming and presence.
Individual Steam fetchers
src/fetcher/steam/charts.rs, src/fetcher/steam/player_summary.rs, src/fetcher/steam/recently_played.rs, src/fetcher/steam/owned_games.rs
Four Steam fetchers: charts (top-played games with concurrent name resolution), player_summary (profile with persona/level/avatar), recently_played (2-week history with text summary), owned_games (full library with playtime/recency sorting). Each includes configuration options, multi-shape rendering, and comprehensive tests.
Bulk value_label population in existing fetchers
src/fetcher/{basic,code,git,github,gitlab,crypto,deal,forge,lastfm,linear,lobsters,net,reddit,stock,system,weather,wikipedia}/*.rs
~40 fetchers updated to explicitly populate value_label field on Bar items (set to None except lastfm/top.rs which uses pluralized play-count label), ensuring consistent bar struct initialization.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • unhappychoice/splashboard#248: Introduces Last.fm's top.rs rendering layer; main PR updates that same bars_body to explicitly populate Bar.value_label with play-count labels.
  • unhappychoice/splashboard#240: Adds deal-fetcher shared rendering pipeline; main PR updates deal's bars_body to explicitly set Bar.value_label = None.
  • unhappychoice/splashboard#125: Likely introduces list_ranking renderer; main PR refactors that renderer to use value_label for display and preserve fetcher order instead of sorting.

Poem

🐰 A rabbit hops through Steam's great hall,
Charts and profiles, names and all,
Each bar now labeled, none left bare,
From fetch to render—order is fair! 🎮

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.58% 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 title clearly and specifically describes the main change: adding a family of four Steam-related fetchers with explicit names (player_summary, recently_played, owned_games, charts).
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/steam-family

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 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.58470% with 416 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.26%. Comparing base (1768208) to head (81f14d7).

Files with missing lines Patch % Lines
src/fetcher/steam/player_summary.rs 65.30% 119 Missing ⚠️
src/fetcher/steam/charts.rs 49.33% 76 Missing ⚠️
src/fetcher/steam/client.rs 55.19% 69 Missing ⚠️
src/fetcher/steam/games.rs 74.89% 59 Missing ⚠️
src/fetcher/steam/owned_games.rs 75.00% 51 Missing ⚠️
src/fetcher/steam/recently_played.rs 71.91% 41 Missing ⚠️
src/render/list_ranking.rs 98.59% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
src/fetcher/basic/bars.rs 97.08% <100.00%> (+0.08%) ⬆️
src/fetcher/code/comments.rs 100.00% <100.00%> (ø)
src/fetcher/code/files.rs 100.00% <100.00%> (ø)
src/fetcher/code/largest_files.rs 99.60% <100.00%> (+<0.01%) ⬆️
src/fetcher/code/loc.rs 96.67% <100.00%> (+<0.01%) ⬆️
src/fetcher/code/todos.rs 96.98% <100.00%> (+0.03%) ⬆️
src/fetcher/crypto_trending.rs 85.65% <100.00%> (+0.03%) ⬆️
src/fetcher/crypto_watchlist.rs 93.93% <100.00%> (+<0.01%) ⬆️
src/fetcher/deal/common.rs 79.13% <100.00%> (+0.09%) ⬆️
src/fetcher/forge_items.rs 91.11% <100.00%> (+0.02%) ⬆️
... and 37 more

... 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Populate value_label for Bars to avoid misleading values in list_ranking.

For unit = percent, value is scaled (20.0% becomes 200), so rendering without value_label shows 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 win

Update max_items schema description to match current behavior.

max_items no 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1768208 and 81f14d7.

📒 Files selected for processing (47)
  • src/fetcher/basic/bars.rs
  • src/fetcher/code/comments.rs
  • src/fetcher/code/files.rs
  • src/fetcher/code/largest_files.rs
  • src/fetcher/code/loc.rs
  • src/fetcher/code/todos.rs
  • src/fetcher/crypto_trending.rs
  • src/fetcher/crypto_watchlist.rs
  • src/fetcher/deal/common.rs
  • src/fetcher/forge_items.rs
  • src/fetcher/git/age.rs
  • src/fetcher/git/churn.rs
  • src/fetcher/git/contributors.rs
  • src/fetcher/github/action_history.rs
  • src/fetcher/github/contributors_monthly.rs
  • src/fetcher/github/languages.rs
  • src/fetcher/github/repo_stars.rs
  • src/fetcher/gitlab/repo_stars.rs
  • src/fetcher/huggingface_trending.rs
  • src/fetcher/lastfm/top.rs
  • src/fetcher/linear/cycle.rs
  • src/fetcher/linear/issues.rs
  • src/fetcher/linear/notifications.rs
  • src/fetcher/lobsters/top.rs
  • src/fetcher/mod.rs
  • src/fetcher/net/interfaces.rs
  • src/fetcher/net/speedtest.rs
  • src/fetcher/read_store.rs
  • src/fetcher/reddit/trending.rs
  • src/fetcher/steam/charts.rs
  • src/fetcher/steam/client.rs
  • src/fetcher/steam/common.rs
  • src/fetcher/steam/games.rs
  • src/fetcher/steam/mod.rs
  • src/fetcher/steam/owned_games.rs
  • src/fetcher/steam/player_summary.rs
  • src/fetcher/steam/recently_played.rs
  • src/fetcher/stock_watchlist.rs
  • src/fetcher/system/mod.rs
  • src/fetcher/weather/forecast.rs
  • src/fetcher/weather/now.rs
  • src/fetcher/wikipedia/trending.rs
  • src/payload.rs
  • src/render/chart_bar.rs
  • src/render/chart_pie.rs
  • src/render/list_ranking.rs
  • src/samples.rs

Comment on lines +121 to +131
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()
)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

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.

Suggested change
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.

Comment on lines +236 to +241
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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

cat -n src/fetcher/steam/owned_games.rs | head -250

Repository: 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 2

Repository: 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 2

Repository: 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.

Suggested change
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.

Comment on lines +314 to +327
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,
});
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

Suggested change
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().

@unhappychoice
unhappychoice merged commit ea29935 into main May 20, 2026
7 checks passed
@unhappychoice
unhappychoice deleted the feat/steam-family branch May 20, 2026 11:01
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