Skip to content

refactor(c7): migrate recently-played to domain CursorPaged<TrackInfo>#319

Merged
LargeModGames merged 1 commit into
multi-sourcefrom
worktree-agent-a1b70ba352bc49aea
Jun 22, 2026
Merged

refactor(c7): migrate recently-played to domain CursorPaged<TrackInfo>#319
LargeModGames merged 1 commit into
multi-sourcefrom
worktree-agent-a1b70ba352bc49aea

Conversation

@LargeModGames

Copy link
Copy Markdown
Owner

Summary

  • Removes rspotify::model::PlayHistory from app.recently_played in src/core/app.rs; field now holds SpotifyResultAndSelectedIndex<Option<CursorPaged<TrackInfo>>> using the Wave 0 domain pagination type
  • Conversion from CursorBasedPage<PlayHistory> to CursorPaged<TrackInfo> happens at the infra boundary in get_recently_played (src/infra/network/user.rs) via the foundation map_cursor_page helper
  • draw_recently_played_table (src/tui/ui/tables.rs) reads TrackInfo fields directly (id, name, artists.join(", "), duration_ms)
  • Handler (src/tui/handlers/recently_played.rs) re-parses stored String ids to TrackId/PlayableId at dispatch sites as per architecture spec

Bug fix included

The Key::Enter handler previously built a track_uris vec with filter_map (dropping tracks with None ids, e.g. local files common in the recently-played API response) but passed the raw app.recently_played.index as the playback offset into the now-shorter vec. This caused the wrong track to start playing when any local file appeared before the cursor position. The fix remaps the offset to the compressed uri list position using enumerate.

Test plan

  • cargo clippy --no-default-features --features telemetry -- -D warnings passes clean
  • cargo test --no-default-features --features telemetry 261 tests pass
  • cargo build (full) compiles
  • cargo fmt --all applied

…Info>

Remove rspotify PlayHistory from App state. The recently-played field now
holds CursorPaged<TrackInfo> (source-agnostic domain type). Conversion from
CursorBasedPage<PlayHistory> happens at the infra boundary in
get_recently_played via map_cursor_page. UI and handler code read TrackInfo
fields directly.

Also fix a latent index-misalignment bug in the Key::Enter handler: the old
code mapped all items (typed TrackId, infallible), but the new code must
re-parse String ids and filter_map drops tracks without valid ids (local
files). The playback offset now tracks the remapped position in the filtered
uri list rather than passing the raw cursor index unchanged.
@LargeModGames LargeModGames merged commit 11e84e2 into multi-source Jun 22, 2026
5 checks passed
@LargeModGames LargeModGames deleted the worktree-agent-a1b70ba352bc49aea branch June 22, 2026 12:37
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