Skip to content

feat(library): unified library_get_section command#40

Merged
pythoninthegrass merged 9 commits intomainfrom
pythoninthegrass/lib-section-cmd
Apr 13, 2026
Merged

feat(library): unified library_get_section command#40
pythoninthegrass merged 9 commits intomainfrom
pythoninthegrass/lib-section-cmd

Conversation

@pythoninthegrass
Copy link
Copy Markdown
Collaborator

Summary

  • Add library_get_section Tauri command that returns tracks + authoritative stats (total_tracks, total_duration) in a single SQLite transaction, replacing separate library_get_count + library_get_all calls that could read from different DB states
  • Add library_revision table with monotonic counter bumped on every library mutation (add/delete/favorite/playlist), enabling revision-based cache invalidation on the frontend
  • Add stats query functions for all section types: favorites, top25, recently played, recently added, and playlists
  • Simplify frontend store to use the unified endpoint, preferring backend-owned totals over JS-computed values
  • 14 Rust tests and 10 Vitest tests covering the new command, stats queries, revision tracking, and frontend integration

Test plan

  • cargo nextest run — 712/712 Rust tests pass
  • npx vitest run — 441/442 frontend tests pass (1 pre-existing failure)
  • Manual: switch between all/liked/recent/added/top25/playlist sections, verify track counts and durations
  • Manual: add/remove a favorite, verify section stats update correctly
  • Manual: verify pagination in "all" section still works

🤖 Generated with Claude Code

pythoninthegrass and others added 9 commits April 13, 2026 00:56
Replace separate library_get_count + library_get_all calls with a single
library_get_section Tauri command that returns tracks + authoritative stats
(total_tracks, total_duration) in one SQLite transaction.

- Add library_revision table with monotonic counter for cache invalidation
- Add stats query functions for favorites, top25, recent, added, playlists
- Bump revision on all library mutation paths (add/delete/favorite/playlist)
- Add getSection() API method on frontend
- Simplify store section loaders to use unified endpoint
- Prefer backend-owned total_tracks/total_duration over JS computation
- Add 14 Rust tests and 10 Vitest tests for the new command

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- library-operations.js: keep unified endpoint code, adopt main's
  totalTracks/totalDuration reset during loading
- acl-manifests.json: take main's version (includes play_context command);
  library_get_section will be regenerated on next build

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…oint

- Remove unused favorites and playlists imports from library store
  (unified endpoint handles all sections via library.getSection)
- Update FOUC regression tests to mock library.getSection instead of
  library.getCount + store._fetchPage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The getSection method only had a Tauri invoke path and threw a 501 in
non-Tauri environments. Playwright E2E tests run without a Tauri backend,
so all accessibility tests timed out waiting for tracks to load.

Add an HTTP fallback that composes existing /library + /library/count
endpoints into the unified response shape.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The HTTP fallback for getSection always called /library + /library/count
regardless of section type. Playlist sections (playlist-{id}) need to
call /playlists/:id instead, matching the pre-existing REST endpoint
that E2E mock fixtures provide.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the hard throw in browser mode with a REST POST to
/queue/play-context. Add corresponding Playwright route mock that
builds queue items from library state, rotates to the start track,
and returns the expected response shape.

Fixes 10 pre-existing E2E failures where double-click-to-play
timed out because playContext was unavailable without Tauri IPC.
handleDoubleClickPlay bypassed player.playTrack() (which contains
the missing track modal check) by going directly to playContext.
Add track.missing to the guard clause so missing tracks fall through
to playTrack, which shows the missing track modal as expected.
When using the unified library_get_section backend command, the returned
tracks are already authoritative for the requested section. Filtering
them against the 'all' section's filteredTracks (via _filterByLibrary)
incorrectly drops all tracks when the 'all' section hasn't been loaded
or only has a partial first page.

Skip the filter in both loadSection and backgroundRefreshSection when
useUnified is true.
@pythoninthegrass pythoninthegrass merged commit d42139e into main Apr 13, 2026
9 checks passed
@pythoninthegrass pythoninthegrass deleted the pythoninthegrass/lib-section-cmd branch April 13, 2026 16:19
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