Commit Graph
100 Commits
Author SHA1 Message Date
vicrodh c09213a0ee docs(release-1.2.8): Mixtapes & Collections tag notes
Release notes for 1.2.8 explaining Mixtape vs Collection vs Playlist in
user-facing terms: playlists are Qobuz-hosted track lists, Mixtapes are
private ordered cross-source listening sessions, Collections are
private themed album shelves. Covers the Discography Builder, the
Add to Mixtape picker kind rules, custom covers, duplicate-handling
dialog, and the under-the-hood notes for upgraders (new tables, new
v2_* command surface, Plex queue resolver branch).

cc
2026-04-20 17:49:27 -06:00
vicrodh 68e76a203e fix(ui): wire per-album play + session source restore + NowPlayingBar artwork + My QBZ titlebar
Consolidates the +page.svelte side of several independent fixes/features
whose non-+page pieces landed in the preceding commits.

- handleMixtapeItemAction: was calling v2_set_queue with { trackIds }
  but the command expects { tracks, startIndex } — Tauri rejected the
  call so per-album Play from a Collection did nothing. Now routes
  Qobuz items through the existing fast path (with blacklist filter +
  artwork fallbacks) and local/Plex items through the new
  v2_enqueue_collection_item backend command, then resolves the queue
  via playQueueIndex(0) + playQueueTrack(trk) so audio actually starts
  (v2_play_queue_index only moves the cursor; it doesn't tell the
  player to load bytes).
- Session save (saveSessionBeforeClose): includes source on each
  PersistedQueueTrack. Without it, a LocalLibrary queue came back as
  is_local=true / source=undefined and the auto-advance path routed
  local row-ids to v2_play_track (Qobuz).
- Session restore: map session.queue_tracks with a source fallback
  (trk.source ?? (trk.is_local ? 'local' : undefined)) so older saved
  sessions (pre-source-field) still route correctly. setCurrentTrack
  default for source is now 'local' when is_local is true, not
  hardcoded 'qobuz'.
- playQueueTrack: artwork goes through resolveQueueTrackArtwork so a
  raw Plex /library/... thumb path or a bare local filesystem path
  becomes a valid src for NowPlayingBar instead of a 404.
- Title bar: isMyQbzInTitlebar state + showMyQbz prop passed to
  TitleBarNav so the new My QBZ entry can be toggled from Settings.

cc
2026-04-20 17:49:17 -06:00
vicrodh 260f147621 feat(titlebar): add My QBZ to title bar nav
Mirrors the Discover / Library / Local Library / Purchases title-bar
entries. Button opens a hover dropdown with Mixtapes and Collections;
label comes from myQbzNavStore so a sidebar rename propagates.

- titlebarNavStore: new myQbz flag with getter/setter/migration.
  isTitlebarNavEnabled() includes it in the enabled-any check.
- TitleBarNav: new showMyQbz prop + CassetteTape button with a
  dropdown menu (Mixtapes / Collections); shared open/close mechanics
  with the other nav dropdowns so only one is open at a time.
- SettingsView: new Toggle between Library and Purchases, disabled
  when the title bar is hidden or the system title bar is active
  (matches the other toggles in the section).

Wiring in +page.svelte ships with the next commit.

cc
2026-04-20 17:48:59 -06:00
vicrodh 739d5b0f7e feat(collections): index toolbar (search/sort/filter/view) + i18n
Root Collections and Mixtapes pages had only a title + New button + a
grid of cards. Added the same .list-controls vocabulary the detail view
uses so users see a consistent control surface across the feature.

- Search: matches name + description.
- Sort dropdown with asc/desc toggle on re-click: Position (manual),
  Name, Items, Recently updated.
- Kind filter on CollectionsView only (All / Collections / Artist
  Collections). MixtapesView omits it — one kind means the dropdown
  would be noise.
- View-mode segmented toggle (list / grid). Grid keeps the existing
  208px cards; list is a dense row with 48px mosaic cover + name +
  kind label + count.
- Empty-results state when search/filter returns zero.
- Preferences persisted globally (per user) under
  collections-index-prefs / mixtapes-index-prefs — viewMode, sortBy,
  sortDir, kindFilter round-trip across sessions. searchQuery stays
  transient per-session.

i18n (en / es-MX / de / fr / pt):
- collections.searchPlaceholder / sortByItems / sortByUpdated /
  kindFilterAll / kindFilterCollection / kindFilterArtistCollection
- mixtapes.searchPlaceholder
- nav.myQbz (used by the upcoming title bar entry)

cc
2026-04-20 17:48:49 -06:00
vicrodh 62355f8b64 perf(mixtape+playlist): virtualize + unified sticky headers + small artwork
Collection / Mixtape detail, Playlist detail, and Playlist manager all
got sluggish with 50+ items — too many <img> tags, full 600px Qobuz
covers decoded for tiny tiles, and two-tier sticky headers with visible
gaps between them. Straightened all of it with patterns we already had
in the codebase; no new deps.

MixtapeCollectionDetailView:
- Fixed-height windowed virtualization for list/grid modes (LIST_ROW_HEIGHT 56,
  GRID_ROW_HEIGHT 240). Top/bottom spacer divs reserve scroll height.
- Row height forced to 56px (was variable 52-60), so the scrollbar's
  scrollHeight matches the actual end of the content and the user can
  reach the last row without stutter.
- The scroll-reset effect now reads listAnchorOffsetTop via untrack so
  mid-scroll ResizeObserver ticks don't re-fire the reset and snap
  scroll back; RO no longer observes the list anchor itself (its size
  changes every scroll tick and is irrelevant to its offsetTop).
- Expanded-mode auto-fetch is gated to visible items — no more 60
  concurrent backend calls on mode switch.
- Sticky toolbar wraps search + sort + filter + select + view-mode as
  ONE block; box-shadow -8px/+8px extends the opaque background over
  the scroller's 8px padding-top gap and any next-element margin seam.
- Qobuz artwork URLs downsized (_50 / _150) for list/grid thumbnails
  instead of the stored _600.

PlaylistDetailView:
- Track controls + batch-controls + column header wrapped in one
  .tracks-sticky-header inside .track-list. Single sticky instead of
  two at top:0 and top:56 with a visible row peeking through the gap;
  containing block is .track-list (tall as virtual content) so the
  toolbar no longer disappears when scrolled past the .view-transition
  wrapper's height: 100%.
- Cover <img> routed through use:cachedSrc + loading=lazy / decoding=async.

PlaylistManagerView:
- .controls sticky with box-shadow -8px/+12px to cover the padding-top
  gap and bottom margin; folder-icon <img> tags (grid / list / tree)
  now use:cachedSrc with convertFileSrc + lazy/async.

Shared components:
- QualityBadgeStatic: new component, visually 1:1 with QualityBadge's
  full mode but no hardware-status polling, no downgrade arrow, no
  plughw tooltip — used in list rows where every item advertises its
  own stored quality and shouldn't react to now-playing state.
- CollectionMosaic + PlaylistCollage: size-aware Qobuz URL picker
  (50/150/300/600 based on rendered tile size) and use:cachedSrc +
  lazy/async on every cell. 20 mosaics × 4 cells at 140px used to
  pull 80 × 600px JPEGs; now they pull 80 × 150px JPEGs through the
  shared image cache.

cc
2026-04-20 17:48:31 -06:00
vicrodh ec52997c02 feat(library): album multi-select + bulk ops + root-view padding
- AddToMixtapeModal: accepts an array of items (was single), gains a
  duplicate pre-check panel with Add anyway / Skip duplicates / Cancel,
  hides the + Collection button for non-album items (Collection shelves
  can't hold a bare track or nested playlist).
- AlbumCard: selectable / selected / onToggleSelect props — corner
  checkbox overlay that replaces the click-to-open behavior when
  selection mode is on. Same pattern ArtistDetailView already used for
  popular tracks.
- VirtualizedAlbumList: pass-through for the select-mode props +
  forwards albumId / year / trackCount so cards render consistently in
  the grid.
- LocalLibraryView: new SquareCheckBig toggle in the Albums tab; bulk
  handlers (PlayNext / PlayLater / AddToMixtape / AddToPlaylist) route
  each selected album through fetchAlbumTracks so local + Plex items
  resolve correctly. BulkActionBar mounted at the bottom of the albums
  grid.
- ArtistDetailView + LocalLibraryView: root-view padding now
  'padding: 8px 8px 100px 18px' and .back-btn margin-top 8px to match
  the AlbumDetailView / FavoritesView standard.

cc
2026-04-20 17:48:04 -06:00
vicrodh 4b6d8173af fix(queue): preserve source on session save/restore + resolve queue artwork
Two fixes that together clear the LocalLibrary auto-advance desync:
audio played a different track than the NowPlayingBar showed, and the
cover showed a '?' placeholder for local/Plex tracks.

- sessionService.ts: PersistedQueueTrack gains an optional source
  field so qobuz | local | plex round-trips through session_store.
  Without this, the restore path rebuilt the queue with is_local=true
  but source=undefined, and downstream callers that defaulted
  undefined-source to 'qobuz' routed v2_next_track results to
  v2_play_track — Qobuz then resolved library row ids to whatever
  random track shared the id.
- queueArtwork.ts: new resolveQueueTrackArtwork() turns a CoreQueueTrack
  artwork_url (http, file://, bare Plex /library/... path, or bare
  filesystem path) into something the WebView can actually fetch.
  Previously a raw Plex thumb path hit localhost:1420 and 404'd;
  local paths tried to load as if relative URLs.
- playbackService.ts: both auto-skip fallback paths now resolve next
  track artwork through the helper before handing off to playTrack.

cc
2026-04-20 17:47:51 -06:00
vicrodh 23f56b178a feat(mixtape): v2_enqueue_collection_item + Plex branch + repo hydration
Backend:
- New v2_enqueue_collection_item(collectionId, position, mode) routes a
  single collection item through the existing ProdItemResolver — same
  path v2_enqueue_collection uses, scoped to one position. Supports
  replace / play_next / append modes. Unlocks per-album Play for local
  and Plex items from the Collection detail view (previously only Qobuz
  had a working fast-path there).
- enqueue.rs: resolve_local_album now detects plex: prefixes and routes
  to plex_cache_get_album_tracks instead of querying local_tracks, so
  Collections with Plex albums actually enqueue end-to-end.
- repo.rs: list_collections now hydrates items for every collection so
  the item count in CollectionsView / MixtapesView is real, not 0.
- mixtapeCollectionsStore.ts: bindings updated for new + changed
  commands (add_item with allow_duplicate, item_exists, custom cover
  upload/remove).

cc
2026-04-20 17:47:38 -06:00
vicrodh 93eef97b4b feat(mixtape): Collection/Mixtape detail view rewrite
Full rework of MixtapeCollectionDetailView. Groups of changes:

Play + UX correctness
  - Play / Shuffle actually start audio: after enqueueCollection fires,
    fetch the first queue track via playQueueIndex(0) and hand off to
    playTrack() so the audio pipeline kicks in (bridge.play_index alone
    only updates queue state, never triggers playback).
  - Loading spinner swaps Play / Shuffle icons for LoaderCircle while
    the enqueue + track load is in flight — covers the noticeable
    delay on large collections.
  - Canonical scroll pattern (width/height/overflow-y auto).
  - Detail-view header Play / Shuffle / More buttons now use the
    global .action-btn-circle family instead of bespoke pill styles.

Item row chrome
  - Source indicators: canonical monochrome mask pattern
    (plex-mono.svg / hdd.svg / qobuz-logo.svg) tinted --accent-primary.
  - Quality column uses the full QualityBadge component.
  - Live-resolve per item: fetch v2_library_get_albums +
    v2_plex_cache_get_albums once on load so each row knows its true
    kind (plex vs qobuz_download vs qobuz_purchase vs user) and can
    show Plex album art via buildPlexArtworkUrl.
  - Qobuz items fetch v2_get_album in parallel to populate quality
    data (Qobuz-streaming items don't persist bit-depth / sample-rate
    at add-time).
  - Clickable title → onOpenItem; clickable artist subtitle (Qobuz
    only) → onOpenArtist runtime-resolves via search.
  - Row hover reveals a play overlay on the artwork.

Row context menu (⋯)
  - Play / Play Next / Add to queue entries.
  - Change release type → nested submenu with Album / EP / Single /
    Live / Compilation and "Use auto-detected" reset. Uses the
    shared releaseTypeOverridesStore so the override also shows in
    DiscographyBuilder and vice-versa.
  - Type column shows the effective release type for album items.

Controls row
  - Search (album title / subtitle + track titles when expanded).
  - Sort (Position / Name / Year / Tracks, asc/desc toggle).
  - Filter with Type + Source sections (multi-select Source).
  - Reset clears every filter + sort.
  - Select mode toggle (SquareCheckBig).
  - View-mode segmented group (List / Grid / Expanded).

View modes
  - List: canonical row listing (no chevron, no inline tracks).
  - Grid: AlbumCard-like tiles with corner-checkbox selection.
  - Expanded: auto-loads every album's tracks via v2_get_album
    (Qobuz), v2_library_get_album_tracks (local — with title+artist
    re-resolve fallback for re-indexed libraries) or
    v2_plex_cache_get_album_tracks (Plex album_key prefix). Tracks
    render as real TrackRow instances.

Selection + BulkActionBar
  - Selected positions tracked separately from view-mode.
  - BulkActionBar below the list with Play Next, Add to Queue, Add
    to Playlist, Add to Mixtape/Collection, Remove from Collection.

Custom cover + header actions
  - Hero mosaic + grid tiles honor the user-uploaded cover.
  - Header ⋯ menu: Upload cover / Clear custom cover.

i18n
  - collectionDetail.* keys across all 5 locales: itemActions,
    changeReleaseType, removeItem, cover{Uploaded,UploadFailed,
    Removed,RemoveFailed}, selectItem, sort, filter, sortBy*,
    filterAll, viewMode, view{List,Grid,Expanded}, searchPlaceholder.

cc
2026-04-19 22:47:05 -06:00
vicrodh 921d5b455c feat(mixtape): wire Mixtape/Collection + DiscographyBuilder navigation
Handlers + callback wiring in the root view layer:

DiscographyBuilder
  - onOpenAlbum → handleAlbumClick (Qobuz) or selectLocalAlbum (local)
    so clicking a candidate album navigates to its detail.

Mixtape / Collection detail
  - onOpenItem for album / track / playlist rows.
  - onOpenArtist runs handleOpenArtistByName: v2_search_artists(name)
    and navigates to the top match — collection items only store an
    artist name, not an id.
  - onPlayItem / onPlayItemNext / onAddItemToQueueLater wired to a
    new handleMixtapeItemAction that fetches the item's tracks
    (Qobuz album path) and sets / appends the queue. Non-Qobuz
    item types toast a "not available yet" message.
  - Bulk variants (onBulkPlayNext / onBulkPlayLater /
    onBulkAddToPlaylist) iterate through selected items.
  - onPlayTrackFromItem (expanded-view TrackRow Play): fetches the
    parent album and jumps to the picked track's index.
  - onPlayTrackNext / onPlayTrackLater: fetch via v2_get_track and
    call v2_add_tracks_to_queue_next / v2_add_tracks_to_queue for a
    single Qobuz track.

Adds selectLocalAlbum + MixtapeCollectionItem to the existing
imports.

cc
2026-04-19 22:45:16 -06:00
vicrodh 4e618dd5b7 fix(ui): back-to-top z-index + AddToMixtapeModal items prop
- back-to-top-global button z-index 50 → 200 so no view's sticky
  footer (Collection detail BulkActionBar, DiscographyBuilder footer,
  etc.) can park on top of it.
- AddToMixtapeModal now receives items={} (array) instead of
  item={} (single) after the store + modal signature moved to the
  bulk-capable shape.

cc
2026-04-19 22:36:15 -06:00
vicrodh 7d2340a978 fix(queue): clear stale now-playing after Clear + natural end
Two related UX fixes in handleClearQueue + the setOnTrackEnded branch:

- handleClearQueue now passes includeCurrent=!isPlaying. When the
  user hits Clear while nothing is actively playing, the call flows
  down to v2_clear_queue, which stops + wipes the current slot too —
  no more stale track lingering in NOW PLAYING across restarts.
- setOnTrackEnded's "queue ran out + no repeat" branch now also
  calls clearQueue({includeCurrent: true}) after stopPlayback(). The
  track that just finished is already off; wiping the current index
  stops it from being re-parked by any subsequent queue snapshot.

cc
2026-04-19 22:35:00 -06:00
vicrodh 578a934c20 i18n: DiscographyBuilder column labels + release types + track count
Keys added to all 5 locales (en/es/de/fr/pt):
- discographyBuilder.col{Year,Type,Album,Tracks,Source,Quality}
- discographyBuilder.releaseType.{album,ep,single,live,compilation}
- discographyBuilder.{checkAll,uncheckAll,typeOverrideHint,typeOverrideReset}
- common.trackCount (reused across DiscographyBuilder + Collection
  detail tracks column tooltip)

Mexican Spanish convention for es.json.

cc
2026-04-19 22:31:24 -06:00
vicrodh 0c49f7153f feat(library): expose Add to Mixtape for albums in LocalLibrary
Both AlbumCard call sites (artist-albums column + VirtualizedAlbumList)
were rendering AlbumCard without albumId, so its built-in
handleAddToMixtape never fired and AlbumMenu never rendered the entry.
Pass albumId (+ year + trackCount for modal metadata).

Album detail hero gains an Add to Mixtape/Collection action-btn-circle
(CassetteTape icon) next to Play / Shuffle / Select, firing
openAddToMixtape for the selected album.

cc
2026-04-19 22:23:40 -06:00
vicrodh 5974276bea feat(mixtape): bulk Add to Mixtape + kind restriction in picker
BulkActionBar gains onAddToMixtape + onRemoveFromCollection props
(CassetteTape + Trash2 icons, reusing existing common.* i18n keys).

AddToMixtapeModal now takes items: AddToMixtapeItem[] instead of a
single item. Single-item callers pass a 1-element array; bulk callers
(BulkActionBar in the Collection detail) pass many. Modal loops
over all items on pick and shows a bulk-count toast when more than
one was added.

Track / playlist items can only be added to Mixtapes, not Collections
(Collections hold whole albums by design). When any incoming item is
a track or playlist, the picker filters the visible target list to
mixtapes only AND hides the + Collection footer button so the user
can't land in an invalid destination.

cc
2026-04-19 22:23:28 -06:00
vicrodh 40fa372611 feat(collections): CollectionMosaic honors user-uploaded covers
New customCoverUrl prop — when set, renders a single full-size image
instead of the 2x2/3x3 collage. CollectionsView + MixtapesView
compute it via convertFileSrc(col.custom_artwork_path) so the grid
tiles show the user's uploaded cover in the list as well as in the
detail view.

cc
2026-04-19 22:23:14 -06:00
vicrodh 1a223c2a85 feat(mixtape): custom-cover upload + remove commands
Lets users pick any image (png/jpg/jpeg/webp) as a Mixtape's or
Collection's cover. Mirrors v2_library_set_custom_album_cover:
source → artwork cache dir → resize to 1000x1000 via image crate →
store path in mixtape_collections.custom_artwork_path.

- v2_mixtape_upload_custom_cover(id, source_path): validates extension,
  copies + resizes, stamps the resulting path, deletes the previous
  cover file after the DB write succeeds.
- v2_mixtape_remove_custom_cover(id): nulls the column + deletes the
  on-disk file.
- Both registered in lib.rs.
- Frontend store: uploadCustomCover / removeCustomCover wrappers that
  also patch collectionsStore optimistically so UIs update without a
  full reload.

Uses mixtape::repo::get_custom_artwork (added in the previous commit)
to find the previous path before overwriting.

cc
2026-04-19 22:22:14 -06:00
vicrodh 32e4eff504 feat(discography): builder overhaul — scroll, columns, selection, type override
Major rework of the Discography Builder:

- Local library tracks finally show up: fix camelCase args for
  v2_library_get_albums (includeHidden / excludeNetworkFolders) and
  serialize the Qobuz fetch before the local one so artistName is
  populated before filtering.
- Include Plex-cache albums too (v2_plex_cache_get_albums with a
  2-second retry after cold-cache) so Plex collections show in the
  candidate list.
- Album titles + artist subtitles are now clickable (onOpenAlbum
  callback routes Qobuz→handleAlbumClick, local→selectLocalAlbum).
- New Tracks + Type columns; Type shows Album / EP / Single / Live /
  Compilation (color-tinted). Classifier uses Qobuz release_type +
  group_type when present, falls back to track-count heuristic.
- User can override the release type per row via a popover on the
  Type cell; overrides persist in per-user localStorage via the new
  releaseTypeOverridesStore (sidecar — never written to Qobuz or
  the library DB).
- Canonical source indicators (plex-mono.svg / hdd.svg / qobuz-logo.svg
  as CSS masks tinted with --accent-primary).
- Full QualityBadge component (bit-depth + sample-rate + format),
  dropping the compact + overrides experiment.
- Header check/uncheck-all with indeterminate state.
- Footer clears the back-to-top gap; scroll via the canonical
  width/height/overflow-y pattern from ArtistDetailView.
- Alternate rows keep the sub-item connector next to the checkbox
  (no indent), matching the visual signal without shifting columns.

cc
2026-04-19 21:20:11 -06:00
vicrodh ee9b695e32 feat(mixtape): wire Add to Mixtape across missing menu sites
TrackMenu / AlbumMenu already expose onAddToMixtape; the following
sites just never passed it through:

- ArtistDetailView popular-tracks TrackMenu
- SearchView track results TrackMenu
- LabelView track-list TrackMenu
- PlaylistDetailView hero AlbumMenu (add the whole playlist)

Also refactors ArtistDetailView's follow button icon to use a CSS
mask (background-color: currentColor) instead of a hardcoded invert +
hue-rotate filter chain that only produced purple — so it adapts to
whatever accent color the current theme sets.

cc
2026-04-19 21:18:51 -06:00
vicrodh 837f2ac649 feat(queue): thread includeCurrent through commandRouter + queueStore
Frontend plumbing that lets callers pass {includeCurrent: true} all
the way down to v2_clear_queue so the backend can wipe the now-playing
slot + stop playback when appropriate.

cc
2026-04-19 21:18:26 -06:00
vicrodh f01fc17383 feat(queue): clear-queue includeCurrent flag stops + clears now-playing
QueueManager::clear previously always preserved the current track;
plus bridge.play_index only mutates queue state, never triggers
audio. Result: when the user hit Clear Queue with nothing playing,
a stale track stayed in NOW PLAYING across app restarts.

- QueueManager::clear(keep_current: bool) — existing callers pin to
  true (legacy behavior). New test covers the false path.
- QbzCore::clear_queue / CoreBridge::clear_queue take the flag through.
- v2_clear_queue accepts an optional includeCurrent flag from the
  frontend; when true, calls bridge.stop() first so the audio pipeline
  actually stops, then wipes the current slot too.
- qconnect sync path + qbzd daemon pin keep_current=true (no behavior
  change).

cc
2026-04-19 21:17:09 -06:00
vicrodh de96afccd5 feat(plex): parse and cache track year + genre
Plex exposes album release year (parentYear / parentOriginallyAvailableAt)
and genre (inline attr or nested <Genre tag>). The parser dropped both;
LocalLibrary and DiscographyBuilder could never show a Plex album's year
even though the metadata was available upstream.

- Extend PlexTrack + PlexCachedAlbum structs with year/genre.
- Parse both in parse_track_block, including the ISO-date fallback.
- ALTER TABLE plex_cache_tracks ADD COLUMN year INTEGER / genre TEXT
  (idempotent).
- INSERT + SELECT paths + the album aggregation carry the new columns.

cc
2026-04-19 21:15:46 -06:00
vicrodh 2f769d38cd fix(mixtape): hydrate items in list_collections
list_collections only read the mixtape_collections row and left
items=[], so every consumer (sidebar, Collections/Mixtapes grid,
AddToMixtapeModal) saw zero-item counts for every collection. Load
items per collection at the end of the listing, matching what
get_collection already does.

cc
2026-04-19 21:14:28 -06:00
vicrodh b244d36b5a feat(assets): add monochrome hdd.svg for local-source indicators
Used as a CSS mask in DiscographyBuilder and Collection/Mixtape detail
to render the "local files" source icon tinted to the accent color.

cc
2026-04-19 21:14:12 -06:00
vicrodh 32c6727e2f chore: remove unused .detail-placeholder .hint CSS rule
Leftover from Task 5.3 when the mixtape-detail route rendered a
"Full detail view is built in Phase 6" hint. Phase 6 replaced the
placeholder with MixtapeCollectionDetailView; the .hint selector
has had no consumer since then. svelte-check flagged it; removed.

cc
2026-04-19 02:41:44 -06:00
vicrodh 8f02c542fd fix(collections): remove dead "Build Artist Collection" CTA
The CollectionsView shipped with a secondary CTA that was stubbed to
a console.log pending an artist picker we never built. Shipping a
dead button is worse than not having it. Artist Collections remain
buildable via the circular action button on ArtistDetailView (next
to Follow / Radio) — that path actually works. A future iteration
can add the picker and reintroduce the CTA if it proves useful.

cc
2026-04-19 02:40:20 -06:00
vicrodh d244981376 fix(mixtape): align Back buttons with app convention; dedup discography candidates
Two issues flagged by user review:

1. MixtapeCollectionDetailView and DiscographyBuilderView shipped with
   a custom bordered .back-btn (icon + "Back" text in a rounded box),
   visually inconsistent with the rest of the app. The canonical back
   button across ArtistDetailView / PurchaseAlbumDetailView /
   MusicianPageView / BlacklistManagerView / AwardView is borderless,
   ArrowLeft 16px + translated text, text-muted color with hover to
   text-secondary. Both views now use that exact pattern.

2. DiscographyBuilderView threw Svelte error each_key_duplicate for
   qobuz0060254702534 because the Qobuz artist-page endpoint can return
   the same album under multiple release_groups (albums + compilations
   most commonly). Those duplicates landed in the same group's
   alternates list, and the {#each} keyed by source+source_item_id
   detected the dupe. buildGroups() now dedupes candidates by
   (source, source_item_id) on entry.

cc
2026-04-19 02:32:45 -06:00
vicrodh 2eb60c16a7 fix(artist): make Build Artist Collection button match sibling icon-circle style
The button shipped as a rounded-rectangle pill with icon + text,
visually inconsistent with the circular icon-only siblings (favorite,
radio, network). The brief was "zero pills, reuse existing
conventions"; this swaps to a 44x44 circle matching .favorite-btn
exactly, with a lucide LibraryBig icon and the title attribute
carrying the "Build Artist Collection" label for hover.

cc
2026-04-19 02:28:01 -06:00
vicrodh 7c58425d6c fix(mixtape): remove effect-update-depth loop in MixtapeCollectionDetailView
The view had two $effects — one of them read $collectionsStore AND the
local `collection` state AND wrote `collection` via object spread on
every run. Svelte 5 detected the self-re-triggering cycle and threw
effect_update_depth_exceeded, which froze every interaction on the
detail view after a collection was created.

The store-sync effect was redundant: every mutation handler in this
component already calls loadCollection() after success, so the local
`collection` state stays current without that effect. Removing it
eliminates the loop without losing any behavior. collectionsStore
import dropped accordingly.

cc
2026-04-19 02:24:45 -06:00
vicrodh 2460467e48 feat(mixtape): DiscographyBuilderView for Artist Collections
Cross-source artist discography builder. Fetches the artist's Qobuz
releases (via v2_get_artist_page) and LocalLibrary albums by artist
name (via v2_library_get_albums filtered client-side), normalizes
titles to group variants of the same album, ranks each group by
quality_score (bit_depth × 10M + sample_rate_hz + format_bonus), and
renders a primary row + indented alternate rows per group.

Compilations detected heuristically (best of / greatest hits /
anthology / ...) and unchecked by default. Default selection: primary
of each non-compilation group. User can check alternates to include
them too. Order by release date / title / manual (preserves input
order). Submit creates an artist_collection with
source_type='artist_discography' + source_ref=artistId and enqueues
items in display order.

ArtistDetailView gains a "Build Artist Collection" action button
(LibraryBig icon, secondary style, rendered only when callback prop is
present). Entry point from CollectionsView left as-is (artist picker
deferred). Added 'discography-builder' to ViewType union.

Toast keys toast.collectionCreated / toast.collectionCreateFailed
added to all five locale files (en, es, de, fr, pt).

cc
2026-04-18 20:57:02 -06:00
vicrodh b7458522b3 feat(mixtape): Add to Mixtape/Collection on TrackRow and playlist rows
Two more entry points, wired to the same global modal trigger store.
TrackRow's context menu gains the action for both Qobuz and local
tracks. Playlist rows expose it only for Qobuz playlists — local
playlists are narrowed by the backend resolver (spec §3.1) and
would fail at enqueue time.

cc
2026-04-18 20:43:17 -06:00
vicrodh 6615f6bbe3 feat(mixtape): "Add to Mixtape/Collection" on AlbumCard and AlbumDetailView
Adds a shared modal-trigger store + mounts AddToMixtapeModal once at
the page level. AlbumCard exposes the action via its overflow menu;
AlbumDetailView exposes it as a secondary action button in the top
action row. Both build an AddToMixtapeItem from the album's source /
id / title / artist / artwork / year / track count and invoke
openAddToMixtape(), which the global modal consumes.

cc
2026-04-18 20:38:22 -06:00
vicrodh 9068b2bf14 feat(mixtape): MixtapeCollectionDetailView
Full detail page with a CollectionMosaic header, title, kind tag,
description, item count, and three primary actions (Play / Shuffle /
overflow). Overflow menu exposes Rename, Edit description, Toggle
play mode, Convert kind (disabled for artist_collection), and Delete
with a confirmation dialog.

Item table columns: # | Item (artwork + title + subtitle) | Type |
Source | Quality | Tracks | Year | ⋯. Type column uses a lucide icon
+ uppercase letter-spaced label (no pill). Source reuses <SourceBadge>.
Quality reuses the shared QualityBadge compact component.

Inline per-row overflow menu offers Remove. "Play next" and full
item drag-reorder are stubbed for future work.

+page.svelte's Task 5.3 placeholder is replaced with this component;
onBack returns the user to the matching grid view (Mixtapes or
Collections) based on the collection's kind. getCollection import
removed from +page.svelte (now only used inside the detail component).

cc
2026-04-18 20:33:36 -06:00
vicrodh 9d699ffe41 feat(mixtape): AddToMixtapeModal picker
Shared modal for "Add to Mixtape/Collection" entry points. Lists the
user's collections sorted by recency, with a kind icon + name + item
count + kind tag per row. Clicking a row calls addItem; dedup toast
when backend returns false. "+ Mixtape" / "+ Collection" footer opens
an inline create-panel that creates then adds the current item in one
shot. Search filters by name (case-insensitive substring). ESC closes
the create-panel first, then the modal.

Adds a single new i18n key (common.addedToMixtapeOrCollection) across
5 locales for the success toast.

cc
2026-04-18 20:25:19 -06:00
vicrodh 8f5c05d3cb feat(mixtape): wire MixtapesView and CollectionsView into the page router
Replaces the pre-5.B "Coming soon" placeholders with the real grid
views. Adds an inline create-modal (name + kind toggle) that calls
createCollection and navigates straight to the new collection's
detail placeholder — which itself stays minimal until Phase 6
ships MixtapeCollectionDetailView. Collections' "Build Artist
Collection" secondary CTA is wired to a TODO comment pending
Phase 8 DiscographyBuilderView. Drops dead .coming-soon CSS.

cc
2026-04-18 20:20:36 -06:00
vicrodh 5b3afa882b feat(mixtape): MixtapesView and CollectionsView grid pages
Near-identical grid layouts for the two sections under My QBZ. Both
subscribe to collectionsStore, filter by kind, and render cards with
CollectionMosaic covers. Empty states center the mosaic placeholder
with kind-specific lucide icons and CTAs.

CollectionsView also exposes a "Build Artist Collection" secondary
CTA alongside the regular "+ New Collection" primary. The label
"ARTIST · <name>" is used on artist_collection cards so they are
distinguishable at a glance from plain Collections.

cc
2026-04-18 20:15:26 -06:00
vicrodh dd40263e6b feat(mixtape): CollectionMosaic shared component
Renders a 2x2 or 3x3 grid of album artwork thumbnails as a single
collection cover. 3x3 layout only for Collections with >= 9 items
(dense "shelf" look); 2x2 otherwise. Artist-collection kind gets a
circular avatar overlay at the bottom-right. Empty state centers a
kind-specific lucide icon. Lazy-loaded thumbnails.

cc
2026-04-18 20:08:50 -06:00
vicrodh 45ad331de5 feat(mixtape): frontend store wrapping the 13 v2_* backend commands
Svelte writable holds the flat collection list for sidebar / grid
subscribers. Thin typed wrappers over Tauri invoke map camelCase arg
keys into snake_case response shapes. addItem returns the backend's
dedup boolean so callers can toast "Already in X" when false.

Covered by vitest (mock invoke): load/get/create/rename/description/
play_mode/kind/custom_artwork/delete/addItem/removeItem/reorderItems/
enqueue with default-mode behavior.

cc
2026-04-18 20:06:24 -06:00
vicrodh a4efbf5cea chore(assets): add my-qbz.svg default icon
Referenced by the new My QBZ collapsible nav section (commit 8466a619)
but the asset file itself was untracked — this ensures it ships with
the feature branch for clean builds.

cc
2026-04-18 20:01:13 -06:00
vicrodh c2eabdcb51 fix(sidebar): use CSS mask for Library nav icon with correct monochrome SVG
Replaces /music-library.svg references in Sidebar and TitleBarNav with
/music-library-2.svg (the corrected all-black monochrome asset the user
provided) and swaps the <img> rendering for a <span> with CSS mask so the
icon inherits the theme's text color — same pattern now used for My QBZ,
cassette, collection, and the existing plex-mono icons.

cc
2026-04-18 20:00:59 -06:00
vicrodh bcfd3ab16b fix(sidebar): tint My QBZ nav icons with theme via CSS mask
The previous implementation used <img src="/my-qbz.svg"> etc., which
browsers won't recolor via CSS — so the icons rendered black on
dark themes. Switch the three default SVGs (my-qbz, cassette,
collection) to CSS mask, same pattern TrackRow already uses for
plex-mono.svg: the SVG becomes a silhouette painted with
currentColor, inheriting the theme's text color.

Custom user-uploaded icons for the My QBZ parent still render via
<img> so their colors show as chosen.

cc
2026-04-18 19:59:56 -06:00
vicrodh 8466a61967 feat(ui): My QBZ collapsible nav wrapper with Mixtapes and Collections children
Adds a top-level collapsible nav section "My QBZ" in the sidebar
containing two children — Mixtapes and Collections — that route to
"Coming soon" placeholder views until the full views land in Phase 5.

The parent's display is user-customizable:
- Label (default "My QBZ") via right-click -> Rename
- Icon (default /static/my-qbz.svg) via right-click -> Change icon,
  which opens a native file dialog; selected path is stored as an
  absolute filesystem path, rendered through convertFileSrc() at
  display time.

Both preferences are per-user localStorage via the existing
userStorage.ts wrapper. Collapsed/expanded state also persists.
reloadMyQbzNav() is invoked post-login alongside the other per-user
store resync calls.

No command or internal identifier changes — the nav children identify
as 'mixtapes' / 'collections' in currentView, matching what the
Phase 5 views will expect.

cc
2026-04-18 19:57:35 -06:00
vicrodh 17e2f711e3 refactor(ui): rename user-facing "Favorites" to "Library"
Aligns with Qobuz's own Library rename in their mobile and desktop
beta apps. Command names, store names, i18n keys, file names, and
internal route identifiers are all unchanged — this is strictly a
user-visible text + icon rewrite.

- Sidebar / TitleBar nav Favorites entry uses /static/music-library.svg
  instead of the lucide Heart
- Artist and label favorite buttons use /static/user-add.svg (albums
  and tracks keep the Heart affordance)
- 5 locale files: all values containing "Favorites" / "Favoritos" /
  "Favoriten" / "Favoris" / "Favoritos" rewritten to "Library" and
  locale-appropriate equivalents (Biblioteca / Bibliothek /
  Bibliothèque / biblioteca)
- "Add to Favorites" / "Remove from Favorites" buttons and toasts
  renamed to "Add to Library" / "Remove from Library"
- Hardcoded title= tooltip strings on track Heart buttons replaced
  with $t() calls

cc
2026-04-18 19:50:28 -06:00
vicrodh bcd07cf084 feat(i18n): Mixtapes and Collections keys across 5 locales
Adds mixtapes / collections / itemType / discographyBuilder /
collectionDetail namespaces, plus 6 common.* entries. Mexican
Spanish per project convention for es.json.

cc
2026-04-18 19:00:26 -06:00
vicrodh 2daff794a8 feat(mixtape): queue_source_collection_id session tracking
In-memory Option<String> tracks which Mixtape/Collection the current
queue was built from. Set by v2_enqueue_collection, cleared by any
non-Mixtape queue replacement (set_queue / clear_queue). Append-style
ops (add/add_next/bulk) preserve the context.

Persistence across restart is deferred — the session_queue_state
table does not exist yet; when it arrives, the ALTER in
mixtape::schema will add the source_collection_id column automatically,
and this state just needs a read+write on the appropriate bootstrap
and commit points.

cc
2026-04-18 18:47:07 -06:00
vicrodh a13de3b369 feat(mixtape): v2_skip_to_next_item and v2_skip_to_previous_item
Two commands that read the current queue + index + elapsed time from
the runtime and call next_item_index / previous_item_index helpers
(already tested in mixtape::enqueue) to compute the target seek
position. Boundary detection uses source_item_id_hint with album_id
fallback, so these also work for queues built via "play album"
outside the Mixtape flow.

Commands are registered and invocable from Tauri but not wired to
any frontend control — per spec §4.5, NowPlayingBar changes are
deferred to a future spec.

cc
2026-04-18 18:41:02 -06:00
vicrodh c6b256470a feat(mixtape): enqueue resolver and v2_enqueue_collection
Polymorphic resolver handles album / track / playlist x qobuz / local
variants; each maps to the canonical QueueTrack the existing "play
album" paths use. Album shuffle applied at enqueue time, tracks
within each item stay in their native order. source_item_id_hint
stamped centrally so skip-to-item boundary detection (next task)
works consistently.

Includes next_item_index / previous_item_index helpers with unit
tests for both the exact-hint and album_id-fallback cases.
local_track_to_queue_track converts LocalTrack sample_rate from Hz
to kHz and wraps artwork_path as a file:// URL.

cc
2026-04-18 18:33:53 -06:00
vicrodh b539f67b7c feat(mixtape): Tauri command layer for CRUD
Twelve v2_* commands wrap mixtape::repo with the standard app state
pattern used by commands_v2/playlists.rs. Enum values travel as
strings across the Tauri boundary; camelCase for frontend, snake_case
for Rust.

Also adds LibraryDatabase::with_connection_mut for the reorder command,
which needs a transaction (&mut Connection).

cc
2026-04-18 18:04:08 -06:00
vicrodh c55a208215 feat(mixtape): CRUD repository for collections and items
Full surface for create/get/list/rename/description/play_mode/kind/
delete/touch_play on collections and add/list/remove/reorder on items.
Dedup on exact (source, source_item_id) within a collection. Artist
collection kind is locked (cannot be converted to/from). Cascade
delete covers items. Position compaction on remove; atomic transaction
on reorder.

Covered by 10 unit tests using in-memory SQLite.

cc
2026-04-18 17:57:41 -06:00
vicrodh cf74dae4c5 feat(mixtape): qbz-models types for collections and items
Polymorphic item_type (album | track | playlist) via enum.
Two-value AlbumSource (Qobuz | Local) — LocalLibrary resolves
providers internally. Serde snake_case for JSON interop.

cc
2026-04-18 17:48:20 -06:00
vicrodh 357650300d feat(mixtape): schema migrations for collections and items
Two new tables (mixtape_collections, mixtape_collection_items) with
CASCADE on delete and indexes for the two common query patterns. One
additive column on session_queue_state for queue-source tracking.

Idempotent (CREATE TABLE IF NOT EXISTS, ALTER only when missing),
safe on every app start. The ALTER is skipped gracefully if
session_queue_state hasn't been created yet.

Adds LibraryDatabase::with_connection() helper (qbz-library) so
src-tauri can run external DDL on the shared Connection without
exposing it as a field. Migration is wired in session_lifecycle
immediately after library.init_at() in both the online and offline
activation paths.

cc
2026-04-18 17:46:13 -06:00
vicrodh b2fb251783 feat(queue): add source_item_id_hint to QueueTrack
Reserved for upcoming Mixtape/Collection enqueue paths to mark item
boundaries. Existing enqueue paths populate it with the track's
album_id as a safe fallback so skip-to-item commands behave
correctly even for queues built via "play album" today.

cc
2026-04-18 17:23:59 -06:00
vicrodh c2da9512ff refactor(ui): extract SourceBadge component from AlbumCard
Zero visual change. The Mixtape/Collection detail view will import the
same component. Adds qobuz_streaming as a new value alongside the four
existing LocalLibrary values; AlbumCard's own prop type is unchanged.

cc
2026-04-18 17:13:29 -06:00
vicrodh b62ffc730a refactor(home): rename yourMixes to qobuzMixes
Disambiguates Qobuz's auto-generated "Your Mixes" section from the
upcoming user-owned Mixtapes feature (spec
qbz-nix-docs/specs/2026-04-18-mixtapes-collections-design.md).

- Renamed HomeSectionId type union entry from 'yourMixes' to 'qobuzMixes'
- Updated DEFAULT_SECTIONS in homeSettingsStore.ts
- Renamed translation keys in all 5 locale files (en, es, de, fr, pt)
- Updated section labels to "Qobuz Mixes", "Mixes de Qobuz", etc.
- Updated all component references in HomeView, DynamicSuggestView, FavQView,
  ForYouTab, TopQView, and WeeklySuggestView

cc
2026-04-18 16:53:06 -06:00
vicrodh e5fbdc19fe chore(assets): add cassette and collection SVG icons
Provided by user for the upcoming Mixtapes & Collections feature (spec
qbz-nix-docs/specs/2026-04-18-mixtapes-collections-design.md, §5.5).
Used for sidebar nav items and detail-view headers.

cc
2026-04-18 16:37:36 -06:00
vicrodh eeb1f4b85c Merge branch 'bugfix/issue-329-keyring-defensive' into pre-release
Defensive keyring handling for credentials/mod.rs to fix issue #329:
- 2.5s wall-clock timeout on every Secret Service call
- Session-wide atomic latch so a broken keyring prompts at most once per process
- File-first semantics everywhere (save_oauth_token inverted from keyring-first)

qbz-secrets (offline-cache master key) deliberately left untouched to avoid
breaking existing BACKEND_MARKER_KEYRING blobs. Phase 2.

Fixes #329.

cc
2026-04-18 13:23:57 -06:00
vicrodh 8314b955c4 fix(credentials): defensive keyring handling with timeout and session latch
Linux Secret Service (GNOME Keyring / KWallet) can block indefinitely on
an unlock dialog when the user's login keyring is out of sync with their
session password. Each credential touch (load at bootstrap, save after
login, save-credentials on password path) used to produce its own dialog,
so every login triggered 3-4 prompts the user had to dismiss before the
app could continue (issue #329).

Make credentials/mod.rs defensive:

- Every keyring operation runs on a worker thread with a 2.5 s wall-clock
  timeout (run_with_keyring_timeout). If the user is staring at an
  unlock dialog they can't satisfy, control flow continues after the
  timeout while the worker stays blocked in the background.

- A process-wide atomic (KEYRING_STATE) latches to BROKEN on the first
  failure or timeout. Subsequent keyring_get / keyring_set /
  keyring_delete calls short-circuit and the app falls back to the
  encrypted file path for the rest of the session. One prompt max per
  process. NoEntry does not count as a failure.

- The encrypted file in the config directory is the single source of
  truth for every credential. save_qobuz_credentials already worked this
  way; save_oauth_token was inverted from keyring-first to file-first so
  the keyring is no longer on the success path of OAuth login.

- Load paths try the keyring first (cheap when it works) and fall back
  to the file; the obsolete "migrate file to keyring" branches are gone.

Public API is unchanged. All existing callers compile unmodified. Existing
encrypted files and keyring entries remain readable; no file-format
changes.

qbz-secrets (offline-cache master key) is deliberately untouched — adding
a KDF fallback there without a migration plan would make existing
BACKEND_MARKER_KEYRING blobs undecipherable. Filed as Phase 2 in the
analysis doc at qbz-nix-docs/bugfix/2026-04-18-issue-329-keyring-unlock-dialog.md.

Fixes #329.

cc
2026-04-18 13:18:48 -06:00
vicrodh 9b0b4d62e8 Merge branch 'feature/lyrics-sidebar-controls' into pre-release
Sidebar lyrics display controls per issue #328:
- Popover with Auto-follow, Font, Size (S/M/L/XL), Dimming, Active color,
  Uppercase toggle, Copy to clipboard, Reset
- Per-user persisted preferences via userStorage
- Font select uses the app Dropdown for style consistency
- Reload hook in +page.svelte so scoped storage is read after login
- Active color overrides the karaoke gradient and glow via a new
  --lyrics-active-color CSS custom property, falling back to the theme
  accent when unset
- Immersive lyrics and the standalone lyrics-only view are untouched

cc
2026-04-18 12:43:08 -06:00
vicrodh 6b91bd3872 feat(lyrics): active-line color picker, uppercase toggle, bigger L/XL
Add two persisted prefs to the lyrics sidebar display controls:

- activeColor: hex color override for the karaoke/active-line accent.
  Empty string means follow the theme's --accent-primary. Rendered via
  a new --lyrics-active-color CSS custom property set inline on the
  LyricsLines container; all four references to --accent-primary in
  the active-line gradient and glow shadows now fall back through it.
  Popover row shows a native color input plus a 'Theme' clear button
  that appears only when a custom color is set.

- uppercase: render all lines as uppercase in the sidebar. Applied via
  text-transform on .lyrics-lines.compact.uppercase. Switch toggle in
  the popover.

Bump L and XL sidebar sizes by the requested amount:
- L: 17/20 -> 18/21
- XL: 20/24 -> 22/26
(small and medium are unchanged.)

Both new prefs persist per-user in the same localStorage payload via
the existing sanitize/reload flow, and the hex validator rejects
malformed values on read.

cc
2026-04-18 12:41:34 -06:00
vicrodh 7480df9ede fix(lyrics): move copy button into popover and reload prefs after login
Move the copy-lyrics action from the sidebar header into the controls
popover footer, alongside Reset. The sidebar header is back to a single
Settings trigger. Footer layout uses space-between so Copy sits on the
left and Reset on the right, both sharing the same button style.

Add reloadLyricsDisplay() to the store and call it from +page.svelte
right after resyncPersistedVolume. The store is initialized at module
load time (before login), so the first read falls back to the unscoped
storage key. Without this reload, the logged-in user's saved
preferences — including auto-follow — were never picked up after an
app restart, leaving the sidebar stuck on defaults.

cc
2026-04-18 12:25:08 -06:00
vicrodh 539bc72d85 feat(lyrics): add copy-to-clipboard button in sidebar header
A Copy icon button to the left of the Display settings trigger writes
the current track's lyrics (joined with newlines) to the clipboard via
the Tauri clipboard-manager plugin. The icon briefly swaps to a Check
for 1.5s on success, and a success/error toast is shown. The button is
disabled while lyrics are loading, when an error is displayed, or when
no lyrics are available.

cc
2026-04-18 12:18:13 -06:00
vicrodh 6ee3b5c8cd feat(lyrics): use app Dropdown for font select and add XL size option
Swap the native <select> in LyricsControlsPopover for the shared Dropdown
component so the font picker matches the app's settings style. Widen the
popover to fit the Dropdown trigger and shrink its chrome to keep the
overall scale compact.

Add an XL font size (20/24 px) alongside S/M/L, extending the
LyricsFontSize type, the sanitize validator, the size class in
LyricsLines, and the i18n entry across all five locales.

cc
2026-04-18 08:54:22 -06:00
vicrodh 54d5cde924 feat(lyrics): wire display controls popover into LyricsSidebar
cc
2026-04-18 08:20:15 -06:00
vicrodh a2514289d2 feat(lyrics): add LyricsControlsPopover component
cc
2026-04-18 08:17:46 -06:00
vicrodh b73776d2e6 feat(lyrics): accept optional font/size/dimming props in LyricsLines
cc
2026-04-18 08:15:29 -06:00
vicrodh 6275c43fc2 feat(lyrics): add per-user lyrics display preferences store
cc
2026-04-18 08:04:16 -06:00
vicrodh d84d9a9836 feat(lyrics): add i18n keys for sidebar display controls
cc
2026-04-18 08:00:43 -06:00
vicrodh 260e5c499c feat(login): show MIT-license-aware trademark disclaimer on loading screen
Pin the API-usage + trademark disclaimer to the bottom of the initializing
state of LoginView so the legal notice is visible during startup, not only
on the login screen proper. Update legal.trademarkNotice in all five locales
to mention the MIT license explicitly.

cc
2026-04-18 00:15:17 -06:00
vicrodh 2a9f90e3e7 fix(build): scope x86_64 rustflags so aarch64 builds don't break
The .cargo/config.toml used [build] rustflags which applies globally
to every target. On aarch64-apple-darwin this injects
target-cpu=x86-64-v3 and +ssse3 as "ignored features", but the ring
crate's static CPU feature assertions detect the perturbed feature
set and fail to compile with:

    error[E0080]: evaluation panicked:
    assertion failed: CAPS_STATIC == MIN_STATIC_FEATURES
    at ring-0.17.14/src/cpu/arm/darwin.rs:51

Move the flags under [target.'cfg(target_arch = "x86_64")'] so only
x86_64 builds see them. ARM/Apple Silicon targets get their own AES
hardware path automatically via the aes crate's armv8 dispatch — no
explicit flags needed.

cc
2026-04-17 16:31:33 -06:00
vicrodh 3ce384ad76 Merge branch 'feature/offline-cache-cmaf-hardening' into pre-release
cc
2026-04-17 16:22:50 -06:00
vicrodh e95e07d4a4 style(buttons): homologate circular action-btn primary across the app
Collapse .action-btn-circle.primary to a single size override in
app.css (44x44) so it inherits the same transparent fill + muted
ring as the secondaries. Size is now the only visual differentiator.
The previous accent-hover fill + white ring combination looked
cut-off on some themes and demanded per-theme babysitting — a
consistent, theme-independent visual language is worth more than the
"main action" color cue, which is reinforced already by the larger
glyph (size 20 vs 18).

Also drop LabelView's local scoped override of .action-btn-circle
(bg-tertiary fill + accent-primary primary). It predated the global
rule and drifted. Now everything cascades from app.css.

cc
2026-04-17 16:22:28 -06:00
vicrodh 27483e57e3 fix(gapless): keep one-shot guard engaged after backend rejects
Logs showed play_next_gapless firing every ~1s for the entire end of a
track when the backend answered "not in any cache, gapless not
possible". The .finally() block was clearing gaplessAttemptTrackId,
which defeated the one-shot guard it was supposed to implement: the
guard check gaplessAttemptTrackId !== currentTrack.id flipped back to
true on every event, so each gapless_ready signal re-fired the invoke.

The event handler at line ~634 already clears the guard when the
event reports a different track_id (a real transition), so pinning
the attempt to currentTrack.id and leaving it alone until then is
the correct lifecycle.

cc
2026-04-17 16:22:19 -06:00
vicrodh 71c9d2a39f feat(offline-cache): unlock-aware UI feedback on decrypt
Two polish beats on top of the existing offline:unlock_start/end
signal so the user can tell encrypted-at-rest playback apart from a
slow network:

1. TrackRow gains a "recently unlocked" state: the store holds each
   id in recentlyUnlockedIds for 600ms after unlock_end, and the row
   flashes an opened-padlock (LockOpen) glyph before the equalizer
   takes over. Failure end-events skip the flash so broken decrypts
   don't look celebratory.

2. Toast.svelte subscribes to isAnyUnlocking() and, while any track
   is being decrypted, swaps the spinner for a jiggling Lock icon
   and cycles the shimmer label through Unlocking / Decrypting /
   Loading / Validating. Plain network buffering still shows
   "Buffering" as before.

cc
2026-04-17 15:12:12 -06:00
vicrodh 83427ea400 fix(search): drop chunky QualityBadge from Most Popular card
The rough compact QualityBadge was overflowing the Most Popular card
on narrow layouts (visible on tracks like Mini World). Every other
place in the app already uses formatQuality() text for this density;
the Most Popular card was the last holdout. Now matches ArtistDetail /
Purchases / Label views.

cc
2026-04-17 15:12:03 -06:00
vicrodh a7e2a8e911 feat(ui): animated padlock on track row while offline CMAF decrypt runs
User feedback from live testing: even with gapless working correctly,
the cold first-play of an offline CMAF bundle takes ~500ms to decrypt
on AES-NI hardware, 5-6s on the software fallback. No visible
indicator of what was happening — UX felt like the app was stalling.

Solution: when a track is being decrypted, replace its play glyph in
the track row with an animated padlock (lucide-svelte Lock icon +
CSS keyframe shake/scale). Tells the user "we're unlocking your
content", which is literally what's happening.

Implementation:

- Backend: new helper `load_cmaf_bundle_with_ui_events` wraps the
  spawn_blocking decrypt with two Tauri events:
  - `offline:unlock_start { trackId }`
  - `offline:unlock_end   { trackId, success }`
  The helper takes two ids: `display_track_id` (what the frontend
  knows this track as — Qobuz id or library row id depending on
  flow) and `cmaf_track_id` (the Qobuz id used to key the bundle
  inside load_cmaf_bundle itself). Same track shows the animation
  whether clicked from Qobuz view or Local Library.
- All three v2 decrypt call sites now route through the helper:
  v2_play_track offline branch, v2_play_next_gapless (both the
  Qobuz-id and Library-qobuz_download branches), and
  v2_library_play_track.
- Frontend: new store `unlockingStore` maintains a `Set<trackId>`
  updated from the events, with subscribe/isUnlocking API. Started
  from +page.svelte alongside the existing player/queue pollers.
- TrackRow.svelte: new `isUnlocking` reactive state derived from
  the store, a new branch in the play-number template that renders
  the Lock icon with `lock-shake` animation, scoped CSS keyframes
  (qbz-unlocking — slight rotate + scale + opacity pulse at 1.2s
  loop, accent-primary colour, cursor: progress).

The animation fires on cold decrypt only; warm L1/L2 hits bypass the
decrypt entirely and don't emit the events, so the user never sees
the padlock for a cached track — correct behavior.

cc
2026-04-17 14:11:44 -06:00
vicrodh 38390db408 fix(offline-cache): persist artwork_path so library UI shows cover art
Qobuz-cached tracks (both v1 legacy and new v2 bundles) weren't
showing album art in Local Library. Root cause was a pair of bugs:

1. Legacy v1 path DID download cover.jpg to the organized album
   directory (via save_album_artwork) but passed None as artwork_path
   when inserting into the library index. So the file existed on
   disk but the DB row didn't point at it — the UI had no way to
   find it. Pre-existing bug, not introduced by the v2 work.

2. v2 CMAF bundle path didn't save artwork at all. Worked fine for
   encrypted playback but the tracks-cmaf/<id>/ directory had no
   cover.jpg for the UI to fall back to.

Fix: in both paths, call save_album_artwork next to the cached
content (organized FLAC parent for v1, tracks-cmaf/<id>/ for v2),
then pass the cover.jpg path to insert_qobuz_cached_track_with_
grouping's artwork_path parameter. Library rows now carry the
on-disk path to the artwork and the UI picks it up just like for
user-owned local FLACs.

New downloads will have artwork immediately. Tracks already in the
cache from before this commit will remain artwork-less until
re-downloaded — acceptable since the user can just re-trigger
download per track if they want the art back, and the 30-day
subscription wipe refreshes everything eventually anyway.

cc
2026-04-17 13:35:57 -06:00
vicrodh 82781d3e55 perf(player): bump gapless lead time from 5s to 10s
Offline-cache v2 bundles need runway for the decrypt pipeline. At 10
MB/s (software AES fallback) a 58 MB track needs 6 seconds, which
blew past the old 5s pre-emptive window and missed the gapless handoff
entirely. With AES-NI active the decrypt is ~500ms, so 10s is
harmless overkill — the decrypted bytes just sit in L1 a few seconds
earlier.

Design note: this is complementary to the AES-NI target-feature fix,
not a substitute. A too-small lead time makes gapless brittle even on
fast hardware (any hiccup blows the window); a too-large one is
wasted memory but otherwise fine. 10s is comfortable for every
realistic hardware/track-size combo we'll see.

If we ever want user-visible control, plumb a `gapless_lead_secs`
through AudioSettings and read it at the hot site.

cc
2026-04-17 13:12:08 -06:00
vicrodh d5ef97b84f perf(cmaf): explicitly enable +aes target-feature for AES-NI dispatch
Previous commit tried to enable AES-NI via target-cpu=x86-64-v3 but
that microarchitecture level does NOT include AES-NI — it's a separate
ISA extension added on top. The aes crate kept falling back to software
decrypt (~10 MB/s), so the first live test still showed a 6s gap on
offline-cache gapless for a 58 MB track (~10 MB/s).

Fix: add target-feature=+aes,+ssse3 to rustflags. The aes crate's
runtime dispatch via cpufeatures only works if the AES-NI code path
was actually compiled in, which requires the build-time feature flag.

Expected: 58 MB decrypt drops from ~6s to ~150ms, fits inside the 5s
gapless pre-emptive window with headroom.

cc
2026-04-17 13:00:56 -06:00
vicrodh aae685e701 perf(cmaf): enable AES-NI + zero-alloc decrypt loop
CMAF decrypt was the bottleneck for offline-cache gapless. Live
testing showed a 208 MB HiRes bundle took ~22 seconds to decrypt end-
to-end, which made gapless for anything longer than a 3-minute track
impossible (the gapless pre-emptive window is ~5s before track end,
so a 22s decrypt can't land in time regardless of how early we start).

Two changes, complementary:

1. `.cargo/config.toml` with `target-cpu=x86-64-v3` (Haswell baseline).
   The `aes` crate ships both a software implementation and an AES-NI
   hardware path, runtime-dispatched via `cpufeatures` — but the
   AES-NI path is only compiled in when the appropriate target-feature
   is enabled at build time. Default dev builds compile ONLY the
   software path, which hits ~10 MB/s on a modern CPU. Haswell+ (2013
   and up, every realistic QBZ user) supports AES-NI and clears
   400 MB/s+. For prebuilt distribution binaries we'll want runtime-
   dispatch via subfunction build or dynamic linking, but for self-
   built and release-source-from-tag scenarios this is the right
   default.

2. `decrypt_segments_into` no longer allocates a Vec per frame. Was:
     frame = seg_data[..].to_vec();  // alloc
     decrypt_frame(&mut frame);      // in-place
     output.extend_from_slice(&frame); // copy back
   Now:
     let start = output.len();
     output.extend_from_slice(&seg_data[..]);  // single copy
     decrypt_frame(&mut output[start..]);      // in-place
   For a HiRes FLAC with ~50K frames this saves 50K small allocs +
   50K double-copies. Output Vec is already pre-sized via
   with_capacity(total), so no reallocation growth during extend.

Combined expected impact: 22s decrypt on a 208 MB track → under 500ms,
which fits inside the 5s gapless window with headroom to spare.

cc
2026-04-17 12:45:42 -06:00
vicrodh 6d2d69d903 fix(library): gapless for Qobuz-cached tracks in Local Library
Library auto-advance had a ~6s gap between two Qobuz-cached v2 tracks.
Tracks within Qobuz flow had gapless working because those pass the
Qobuz track id to v2_play_next_gapless and the offline cache is keyed
by that id. From Local Library the frontend passes the LIBRARY row id
(small autoincrement, e.g. 542), so:

- L1 keyed by library row id → miss (prefetches key by Qobuz id)
- L2 keyed by library row id → miss
- offline cache get_cmaf_bundle(542) → miss (cache is keyed by Qobuz id)
- library fallback: file_path for qobuz_download v2 tracks is a
  directory, std::fs::read blows up → gapless returns Ok(false)

Result: gapless declined, track ended, frontend called play_track as
normal transition, which went through v2_library_play_track's full
decrypt path from cold → 5-6s silence.

Fix: in the library-fallback branch of v2_play_next_gapless, detect
source='qobuz_download' and re-query the offline cache by the row's
qobuz_track_id. If a v2 bundle exists, decrypt it on the blocking
pool and feed to play_next using the LIBRARY row id (so the player
keys match what the frontend is waiting for — same pattern as the
earlier library track-id fix). Warm L1 keyed by library row id too,
so next transition between tracks in this library view hits memory
instead of re-decrypting.

This leaves the v1 path working (plain FLAC at segments_path) and
the regular user-owned local FLAC path unchanged.

cc
2026-04-17 12:30:29 -06:00
vicrodh f95199d32b fix(library): pass library row id (not Qobuz id) to play_data
Live testing from Local Library with a v2 CMAF-cached Qobuz track
showed a cascade of UI breakage: seekbar never appeared, track never
auto-advanced, queue-manager fired next_track every 1s for 30+
iterations in a loop, currently-playing song card stayed on the first
track. Audio was playing fine; the UI just couldn't see it.

Root cause: my v2_library_play_track CMAF path was passing the Qobuz
track id (from the library row's qobuz_track_id field) to
player.play_data. Every other piece of the UI state machine — queue
sync, seekbar progress events, auto-advance trigger, now-playing card
— keys off whatever id the frontend invoked with, which is the
library row id (e.g. 542), not the Qobuz id (e.g. 95787326). So the
player was emitting updates about "playing 95787326" while the
frontend was waiting for updates about 542 that never came.

Fix: play_data now takes track_id (library row id) on both the v2
CMAF decrypt branch and the v1 plain-FLAC branch. The offline-cache
DB lookup still uses qobuz_track_id (that DB is keyed by Qobuz id),
the player gets the library id. AudioCache insert also keyed by
library id so Library-side replay hits L1 correctly.

cc
2026-04-17 12:11:16 -06:00
vicrodh 93a908ee73 fix(offline-cache): check L1/L2 before offline tier in gapless
Live testing showed gapless between two offline-cached v2 tracks still
had a 6s gap even with the L1 warming + spawn_blocking + track_id fixes.
Root cause: v2_play_next_gapless checked the offline cache FIRST, which
meant for tracks that were BOTH on disk AND already in L1 (prefetched
from the CDN into memory), we took the slow offline decrypt path even
though instant bytes were sitting in RAM.

Log evidence:
  16:52:09 Prefetch put track 47683552 in L1 (61MB)
  16:53:00 play_next_gapless for 47683552
  16:53:06 [V2/GAPLESS] Track 47683552 from OFFLINE cache (CMAF v2)
           (decrypted 58MB — took ~5s while L1 had the bytes)
  16:53:06 Gapless: no engine, ignoring PlayNext
           (engine dropped at 16:53:05 when old track ended)

The very next transition (47683552 → 47683553), where 47683553 happened
to be ONLY in L1 and not in the offline cache, worked perfectly:
  16:55:58 [V2/GAPLESS] Track 47683553 from MEMORY cache (72MB) ← 60ms
  16:56:02 Gapless transition: track 47683552 -> 47683553 (clean)

Fix: reorder tiers to L1 → L2 → offline → library. The offline v2
decrypt path is expensive precisely because we already warm L1 after
every decrypt — so the second time around (or whenever prefetch beat
us to it), L1 hit is instant. The offline tier is correctly reserved
for the "truly cold" case: track on disk but not in memory.

Also added a "warm L1 from L2" step so a disk-cache hit also populates
memory, matching the warm-L1-on-decrypt pattern the offline path
already did.

cc
2026-04-17 11:14:18 -06:00
vicrodh 49d132b6c2 fix(offline-cache): warm L1 memory cache after v2 CMAF decrypt
Live testing showed v2 offline tracks had a 3-6s gap on gapless
transitions even after the track_id + spawn_blocking fixes, because
the decrypt itself takes 5-7 seconds for a typical 60-200MB FLAC
(disk read of encrypted segments.bin + AES-CTR per-frame decrypt is
slower than the track's natural tail). By the time load_cmaf_bundle
returns, the previous track has ended and the player's gapless engine
has been dropped.

Workable only second time: once a track's decrypted bytes are in L1
memory cache, subsequent accesses are ~60ms. That's what happened on
the second transition we observed — prefetched tracks hit L1 for
free, so gapless landed in time.

Fix: after successfully decrypting a v2 bundle, insert the resulting
plain-FLAC bytes into the AudioCache (L1) before handing them to the
player. Applies to three call sites:

- v2_play_track offline cache branch → warm on first play
- v2_play_next_gapless CMAF v2 branch → warm on gapless success
- v2_library_play_track CMAF v2 branch → warm on Library click

Next access to the same track (replay, scrub, gapless re-queue,
upcoming-track peek) is now a <100ms L1 hit regardless of the v2
cache_format the row has. The decrypt cost is paid once per track
per session, not once per access.

This still leaves the "first play of an offline track" taking 5-7s
before audio starts. That's a separate optimization — candidates are
(a) offline-track prefetch that pre-decrypts upcoming tracks in the
background, (b) storing decrypted FLAC in L2 disk cache so cold
restarts don't have to decrypt, (c) speeding up the decrypt itself.

cc
2026-04-17 10:26:13 -06:00
vicrodh 70deae6722 fix(offline-cache): track-id mapping + spawn_blocking decrypt
Two bugs the live testing surfaced.

1. v2_library_play_track was passing the library row id (autoincrement
   small integer) to the offline-cache DB lookup. The offline cache is
   keyed by the Qobuz track id (the big id like 95787327). So the
   lookup always missed and my earlier "orphan" error fired for EVERY
   v2 track clicked from Local Library. Fix: read qobuz_track_id from
   the library row and use THAT for the offline-cache lookup.

2. load_cmaf_bundle is synchronous (std::fs::read + AES-CTR decrypt +
   FLAC assemble). When called directly from an async fn on the tokio
   executor, a 200MB offline track took ~22 seconds end-to-end during
   concurrent prefetch activity — because the sync work starved the
   executor thread, delaying the queue's auto-advance event, which
   fired play_track as a fallback AFTER the old track stopped (which
   killed the gapless engine). Net: 6-8 second audible gap between
   two offline-cached tracks even though the bytes were on disk.
   Fix: wrap load_cmaf_bundle in tokio::task::spawn_blocking in all
   three call sites (v2_play_track, v2_play_next_gapless,
   v2_library_play_track). The executor stays responsive, gapless
   finishes before the engine drops, transition is clean.

Together these close the two loudest symptoms from the live session:
"Is a directory" when playing v2 from Library, and the seconds-long
gap between consecutive v2 tracks even with gapless enabled.

cc
2026-04-17 10:07:49 -06:00
vicrodh 91a48e458c fix(cmaf): serialize ensure_cmaf_session to kill concurrent-start race
The CMAF session cache is an Arc<RwLock<Option<CmafSession>>>. The old
ensure_cmaf_session did a read-check then dropped the guard then did
its POST unlocked, which meant two concurrent callers would each see
"no session", each POST /session/start, and each receive a different
session_id + infos. The second to finish stored its session as the new
cache, clobbering the first.

That was a problem because file/url wraps the per-track AES key against
whichever session_id the X-Session-Id header carried. If task A got its
wrapped key under session X but the cache got overwritten to Y before
decrypt time, the HKDF over Y-infos produced the wrong session_key and
the AES-CBC unwrap failed with "Unpad Error" — which is exactly the
warning that showed up in prefetch runs during parallel downloads and
caused the >3s gap between offline-cached tracks when the next track's
prefetch had silently fallen back to legacy.

The symptom in logs:
  [CMAF] Starting new session        ← task A
  [CMAF] Starting new session        ← task B (same ms)
  Session started: id=bHoSYBFx...
  Session started: id=bJ-w2wgm...    ← cache now holds B
  [PREFETCH] CMAF failed for track N: Content key unwrap failed:
    AES-CBC unwrap failed: Unpad Error

Fix: double-checked lock pattern. Fast path stays on the read guard
for existing-valid sessions. Slow path takes the write guard, re-checks
under exclusive ownership, and only the first caller actually hits
session/start. Everyone else wakes up and returns the freshly-cached
value.

Compile check only — full behaviour validation in the running dev
session after this commit.

cc
2026-04-17 09:52:39 -06:00
vicrodh 8238ce4de4 fix(offline-cache): route v2 bundles through CMAF in library + gapless
Two symptoms with the same root cause — code paths that touched the
offline cache read file_path as "a plain FLAC file" and handed it
straight to std::fs::read + Symphonia. For v2 bundles the file_path is
the encrypted segments.bin, so both paths exploded.

1. v2_library_play_track: error "Is a directory (os error 21)" when
   clicking a v2-cached track from Local Library.
   Fix: for source='qobuz_download' rows, the offline-cache DB is the
   authoritative source of file paths, not the library index (library
   carries display metadata only). Query get_cmaf_bundle:
     - cache_format=2 → load_cmaf_bundle (decrypt + play)
     - cache_format=1 → read row.segments_path (which for v1 IS the FLAC)
     - no row → clean error instead of reading the library directory

2. v2_play_next_gapless: "Symphonia probe failed: end of stream" with
   ~6 failed retries per track transition → ~6s gap between two v2
   offline-cached tracks.
   Fix: same cache_format branching as v2_play_track already does.
   Reuse load_cmaf_bundle so the probe sees plain FLAC bytes, not
   encrypted mp4 boxes.

The prefetch AES-CBC unpad error during concurrent downloads is the
other piece of today's gap story — session race in ensure_cmaf_session.
That's a separate fix in the next commit.

cc
2026-04-17 09:49:54 -06:00
vicrodh 8ab8fc5dea fix(offline-cache): emit progress events from CMAF download path
The UI's offline-download progress ring listens to
'offline:caching_progress' events. The legacy StreamFetcher::fetch_to_file
emits those per HTTP chunk via app_handle. The new CMAF path went
silent because cmaf_download_raw lives in the qbz-qobuz crate with no
Tauri access — the user saw the completion toast but never saw the
ring fill.

Fix:
- Add an optional CmafProgressCallback to the qbz_qobuz::cmaf public
  API. Typed as Arc<dyn Fn(CmafProgressUpdate) + Send + Sync>.
- New download_full_with_progress and download_raw_with_progress
  variants; the callback-less versions delegate to them with None.
- fetch_all_segments fires the callback once per completed segment
  with cumulative (k, n, bytes_this_segment). Callback is invoked on
  the worker thread after the bytes land, before the rate-limit
  cooldown.
- try_cmaf_offline_download passes a callback that emits
  'offline:caching_progress' events in the exact shape the UI already
  expects (trackId, progressPercent 0..100, bytesDownloaded,
  totalBytes: null, status: 'downloading'). Also emits one
  zero-progress event up front so the ring doesn't sit at "queued"
  while the first segment fetches.

Percentage is computed as (segments_completed / n_segments) * 100,
rounded and clamped. It's segment-granular rather than byte-granular
so the ring advances in N discrete steps (typically 8-20 for a 4-min
track) rather than smoothly — matching what the CMAF pipeline can
actually observe, which is segment-complete events.

cc
2026-04-17 09:01:22 -06:00
vicrodh aa111e15b3 feat(offline-cache): route library playback through CMAF + full purge
Two loose ends after v2 landed:

1. Local Library integration. Qobuz-cached offline tracks already show
   up in the Local Library view (via insert_qobuz_cached_track_with_
   grouping with source='qobuz_download'). v2_library_play_track was
   reading track.file_path and doing std::fs::read() — that works for
   plain-FLAC v1 entries, but for v2 the path is the bundle directory,
   not a playable file. Fixed:
   - Extract the CMAF-load-and-decrypt logic into a shared module
     (offline_cache::playback::load_cmaf_bundle) used by both
     v2_play_track and v2_library_play_track.
   - v2_library_play_track checks source='qobuz_download' +
     cache_format=2 on the row and routes through the shared helper.
     Legacy v1 entries and regular user local files unchanged.

2. purge_all_cached_files. Previously deleted individual file_path
   entries only. For v2 the file_path points inside a track dir
   (segments.bin) — removing just that file orphans init.mp4 and
   manifest.json. Fixed:
   - When the file_path looks like tracks-cmaf/<id>/segments.bin
     (matched by the path shape, not a schema flag), remove the whole
     enclosing <id>/ directory.
   - Belt-and-suspenders: also delete the top-level tracks-cmaf/ dir
     after the per-row pass, so orphaned bundles from corrupted rows
     are swept up too.

Net: Local Library view preserves the "cached Qobuz tracks appear
here" UX, AND the 30-day grace wipe still removes every encrypted
segment + every library row in one atomic operation. No contradiction
between the two behaviors.

Also extends the compliance whitepaper with a section explaining the
Local Library integration so Franck's team can see that the wipe
contract isn't worked around by the UX shortcut.

cc
2026-04-17 08:53:13 -06:00
vicrodh b3ad548a9c feat(subscription-gate): extend offline grace window 3 → 30 days
Matches Qobuz's own mobile app posture. The previous 3-day window was
both user-hostile (punishes anyone on a flaky network) and a compliance
red flag (shorter windows read as 'we're hiding something', longer
windows read as 'we're lenient for a reason'). 30 days is the exact
parity answer.

The useful protection against bulk-download-and-ghost attacks comes
from the CMAF-at-rest offline cache (v2 format), not from aggressive
revalidation. This grace window is a belt over the suspenders.

Changes:
- GRACE_PERIOD_SECS: 3 → 30 days in config/subscription_state.rs, with
  a comment explaining the reasoning for future readers.
- Log message in session_lifecycle no longer says "3 days" (it quoted
  a constant, now says "grace window").
- Disclaimer string in all 5 locales (en/es/de/fr/pt) updated from
  "3 days" to "30 days" so the Offline Playback settings screen
  reflects the actual behavior.

No behavior changes for users with an active subscription. Users who
were within the old 3-day window don't lose cache — the window
extended, not contracted.

cc
2026-04-17 08:28:00 -06:00
vicrodh db6e7021ec feat(offline-cache): play v2 CMAF bundles from disk
Closes the playback side of the offline hardening. v2_play_track's
offline-cache-hit branch now queries the new CMAF bundle columns via
get_cmaf_bundle(), branches on cache_format:

- cache_format = 2 (new): read init.mp4 + segments.bin + manifest.json,
  unwrap the content_key through qbz-secrets, decrypt frames via the
  shared qbz_qobuz::cmaf::decrypt_segments_into, assemble into a
  plain-FLAC Vec<u8>, and feed it to player.play_data — exactly the
  same interface the player has always seen for cache hits.

- cache_format = 1 (legacy): unchanged — read the plain FLAC file at
  segments_path (the old file_path column) and play directly.

Any failure on the v2 path (missing init, wrong-size unwrap, decrypt
error, vault init failure) logs a warning and falls through to the
next cache tier (memory, disk playback cache) or the network — same
degradation model as a stale legacy entry.

load_cmaf_offline_bundle() is isolated in playback.rs so the hot
v2_play_track body stays readable; it owns the "convert a CmafBundleRow
from the DB into audio_data for the player" pipeline.

LoadedBundle in offline_cache/cmaf_store gets a decrypt_to_flac method
so the caller doesn't have to duplicate the "parse init + concat header
+ decrypt segments" dance the streaming path already does.

End-to-end for v2:
  download  → cmaf::download_raw → persist_bundle + wrap key → DB
  play      → get_cmaf_bundle   → read_bundle → unwrap key → decrypt

cc
2026-04-17 08:22:47 -06:00
vicrodh 8d9705dea0 feat(offline-cache): rewire download path to CMAF-first
Closes the last legacy /track/getFileUrl user-facing hole flagged by
the CMAF audit. spawn_track_cache_download now tries the CMAF path
first; only falls through to /track/getFileUrl if any of the CMAF
steps fail (no CoreBridge yet, /file/url returns a non-CMAF response,
network hiccup, SecretBox init failure, etc.).

On CMAF success the on-disk layout is:

    <offline_root>/tracks-cmaf/<track_id>/
        init.mp4        — unencrypted container with FLAC header
        segments.bin    — concatenated encrypted audio segments
        manifest.json   — segment offsets (belt-and-suspenders recovery)

The per-track AES content key and session infos are wrapped via
qbz-secrets::SecretBox before they touch the SQLite row
(content_key_wrapped, infos_wrapped columns from the previous commit).
cache_format flips to 2 on the row; the library-index entry lands
with the same title/artist/album the legacy path used, so the UI is
unchanged.

What is deliberately NOT done on the CMAF path:
- No write_flac_tags / embed_artwork: the bundle on disk is encrypted,
  writing FLAC tags would corrupt it. The library row carries the
  metadata the UI actually reads.
- No organize_cached_file: v2 bundles live under tracks-cmaf/<id>/
  by design, no per-artist/album tree (the files aren't standalone
  playable FLACs anyway).

Two new modules in src-tauri/src/offline_cache/:
- cmaf_store: persist/load/remove the on-disk bundle layout + the
  recovery manifest. I/O only, no crypto, no network.
- secret_vault: lazy SecretBox singleton scoped to the offline-root
  directory. The SecretBox handle is cached in OnceLock so every
  download shares the same keyring entry (or KDF master key).

Existing offline entries keep working — they're cache_format=1, so
they read from the plain-FLAC file_path unchanged. Playback-from-v2
comes in the next commit (task #20).

Legacy fallback still writes tags + organizes files exactly like
before. This keeps users whose v1 cache is still useful unblocked
while the v2 path takes over fresh downloads.

cc
2026-04-17 08:17:18 -06:00
vicrodh 935b3f81e0 feat(offline-cache): schema migration for v2 CMAF bundle storage
Adds columns to cached_tracks for the v2 format that stores Qobuz's raw
CMAF segments bit-identical on disk, with the per-track AES content key
wrapped via qbz-secrets (OS keyring or KDF fallback).

New columns (added via idempotent ALTER TABLE, safe to re-run):
- cache_format    INTEGER DEFAULT 1   — 1 = legacy plain FLAC (existing),
                                          2 = raw CMAF bundle (new)
- init_path       TEXT                — path to init.mp4 (FLAC header +
                                          segment table)
- content_key_wrapped BLOB            — wrapped 16-byte AES content key
- infos_wrapped       BLOB            — wrapped session infos salt
- format_id       INTEGER             — Qobuz format id (5/6/7/27)
- n_segments      INTEGER             — number of audio segments

Existing rows keep cache_format=1 and continue to play from the plain
FLAC at file_path — zero regression for users with populated caches
when the upgrade ships. New downloads will land as cache_format=2. The
two formats coexist until v1 rows age out naturally (user re-download
or subscription-lapse cache wipe).

Adds set_cmaf_bundle() / get_cmaf_bundle() helpers + a CmafBundleRow
struct so the download path and the playback path have one authoritative
DB surface to talk to.

Also adds qbz-secrets as a direct src-tauri dep so the next commit
(rewiring spawn_track_cache_download) can wrap keys right at the
download site.

cc
2026-04-17 07:30:50 -06:00
vicrodh 1743c9e5ec feat(secrets): add qbz-secrets crate for device-bound secret wrapping
Foundation for the offline-cache hardening story. The offline cache
needs to persist per-track AES content keys to disk, but storing them
plaintext would make copying the SQLite DB enough to decrypt the
cached audio on another machine.

qbz-secrets provides a uniform wrap/unwrap API backed by:

1. **OS keyring** (preferred): libsecret/gnome-keyring on Linux,
   Keychain on macOS, DPAPI on Windows. A 256-bit master AES key
   lives inside the OS secure store; all wraps go through it. This
   is the gold-standard device binding used by commercial music
   apps (Spotify, Apple Music, Tidal) for the same class of data.

2. **HKDF fallback**: when the OS keyring is not reachable (headless
   setups — Raspberry Pi, Docker, the future qbzd daemon on a
   server), the master key is derived on demand via HKDF-SHA256
   over service_name + machine_id + a persistent per-install UUID.
   Weaker than keyring (reversible by anyone with filesystem access
   to both sources) but still device-bound against cross-machine
   copy attacks, and lets daemon/headless variants work at all.

Every wrap uses AES-256-GCM with a fresh random 12-byte nonce. The
on-disk envelope carries a version byte + backend marker + nonce +
ciphertext+tag, so (a) we detect tampering via GCM, (b) we refuse to
silently unwrap a blob produced by a backend we can't reach, and (c)
we have a forward-compat path for future key rotation.

4 unit tests cover: small-secret round-trip, 16-byte content-key
round-trip (the exact CMAF use case), GCM tamper detection, and
nonce-randomness (two wraps of the same input differ).

This crate intentionally has zero QBZ dependencies — it's a generic
primitive. Next commits wire it into the offline cache schema + the
DB migration.

cc
2026-04-17 00:53:01 -06:00
vicrodh 391e797c9a refactor(cmaf): lift pipeline into qbz-qobuz + add download_raw
Prep work for offline-cache CMAF hardening. The full CMAF pipeline
(init-segment setup, full-download, decrypt) used to live in
src-tauri/src/commands_v2/helpers.rs — fine for playback but unreachable
from the offline-cache code without dragging Tauri deps around.

Moves:
- try_cmaf_full_download → qbz_qobuz::cmaf::download_full
- try_cmaf_streaming_setup → qbz_qobuz::cmaf::setup_streaming
- CmafStreamingInfo struct → qbz_qobuz::cmaf

Adds:
- qbz_qobuz::cmaf::download_raw + CmafRawBundle — fetches the same track
  but returns the ENCRYPTED segments + init bytes + the unwrapped
  content_key + the session infos, ready to be persisted to disk as-is.
  The offline cache will use this so that cached files are bit-identical
  to what Qobuz delivered (no decrypt-to-disk), with the content key
  stored separately under an OS-keyring-wrapped blob. Coming in next
  commits.
- qbz_qobuz::cmaf::decrypt_segments_into — shared decrypt helper used by
  download_full and (in the next commits) by the offline-playback path
  that reads encrypted segments from disk instead of CDN.

In-tree behaviour is unchanged: try_cmaf_full_download /
try_cmaf_streaming_setup in helpers.rs are now thin wrappers that hand
the CoreBridge's QobuzClient to the crate functions. Same API surface
for playback.rs callers, same log tags, same on-wire behaviour.

v2_cmaf_stream stays in src-tauri because it binds to qbz-player's
BufferWriter + qbz-cache's AudioCache — those are playback-only deps
that don't belong in qbz-qobuz.

Net: -100 LOC out of src-tauri, +390 LOC in a properly-layered crate
module with docs explaining the two variants and why the raw one exists.

cc
2026-04-17 00:46:31 -06:00
vicrodh 19fa779063 Merge branch 'feature/internal/label-endpoints-expansion' into pre-release
Expand label API coverage to the v9.7.0.3 Qobuz Android spec and
retire the legacy /label/get one-shot before Qobuz starts deprecating
endpoints with the web beta rollout.

- 7 new endpoints: getAlbums, getNextReleases, getAwardedReleases,
  getPlaylists, getTopArtists, story, getList (POST)
- Full stack: qbz-qobuz client + qbz-models + qbz-core + CoreBridge +
  v2 tauri commands + lib.rs registration
- LabelView + LabelReleasesView migrated to /label/page + /label/getAlbums
- Legacy /label/get + LabelDetail + v2_get_label purged; qbzd's
  /api/labels/{id} HTTP route recomposes the old shape internally
- Quality badge homologated: swept every track/album row (LabelView
  popular tracks, SearchView track rows ×2, PurchasesView album rows,
  PurchaseAlbumDetailView header, VirtualizedFavoritesAlbumGrid rows)
  to use formatQuality() text instead of the bulky <QualityBadge>.
2026-04-16 23:30:00 -06:00
vicrodh 56041235af style: homologate quality badge in all track/album rows
Sweep of remaining <QualityBadge compact> usages in row/list contexts.
Same fix as the label popular-tracks one: switch to the formatQuality
text representation so every row lines up visually.

Replaced in:
- SearchView.svelte — track rows in track tab & album tab
- PurchasesView.svelte — album list rows
- PurchaseAlbumDetailView.svelte — album metadata header (matches the
  text-only treatment already used by AlbumDetailView)
- VirtualizedFavoritesAlbumGrid.svelte — favorites album list rows

Kept as-is (the badge is a first-class visual element, not a text
indicator in a list):
- Player widgets — NowPlayingBar, ExpandedPlayer, ImmersiveControls,
  ImmersivePlayer
- Immersive visualizer panels (all 13)
- SearchView "Most Popular" promoted card
- AlbumReactivePanel

cc
2026-04-16 23:06:26 -06:00
vicrodh cdd02197ad style(label): homologate quality badge in popular tracks
LabelView's popular tracks section was rendering the <QualityBadge>
component with compact mode — same one we dropped elsewhere. Switch
to the formatQuality() text representation used by ArtistDetailView's
popular tracks so both views look identical.

Also align .track-quality CSS (font-size / color / min-width) with
ArtistDetailView's rules.

cc
2026-04-16 23:01:23 -06:00
vicrodh 6de109b3b8 refactor(labels): purge legacy /label/get stack
/label/get is gone from the Qobuz v9.7.0.3 Android app (source:
c30/b.java doesn't declare it anymore). With the Qobuz beta rollout
the server-side deprecation timer is probably running, so we yank our
dependency now.

Removed:
- LABEL_GET path constant (qbz-qobuz + src-tauri/api)
- get_label() client method (qbz-qobuz + src-tauri/api)
- get_label() wrapper in QbzCore + CoreBridge
- v2_get_label tauri command + its lib.rs registration
- LabelDetail backend type (qbz-models + src-tauri/api/models)
- commands::search::get_label (dead, was never registered)
- Unused LabelDetail import in src/routes/+page.svelte

Preserved:
- Frontend LabelDetail interface (it's a UI view-model shaped by
  LabelReleasesView, not a backend contract)
- /api/labels/{id} HTTP route on qbzd — now composes /label/page +
  /label/getAlbums internally so external HTTP clients still see the
  same { id, name, description, image, albums: { items, total, ... } }
  shape

cc
2026-04-16 22:59:31 -06:00
vicrodh df99e97d2a refactor(labels): migrate LabelView + LabelReleasesView off v2_get_label
LabelReleasesView now fetches /label/page (metadata) + /label/getAlbums
(paginated catalog) in parallel instead of hitting the legacy
/label/get one-shot. loadMore() paginates through /label/getAlbums.

LabelView's loadLabelAlbumsAndDescription() now only fetches the album
list via /label/getAlbums; the description comes exclusively from the
already-in-flight /label/page call (loadLabelPage).

Both views still present the same LabelDetail-shaped view-model;
nothing UI-visible should change. Prepares for deletion of the legacy
/label/get stack in the next commit.

cc
2026-04-16 22:50:39 -06:00
vicrodh 595b71e4eb feat(api): add 7 label endpoints from v9.7.0.3 spec
Closes the gap between our client and the Qobuz Android app's current
label API (source: c30/b.java). Qobuz is rolling out a web beta so the
legacy /label/get is likely on borrowed time — adding the v9.7.0.3
endpoints now so the migration can happen in follow-up commits.

New endpoints (paths + client + core + bridge + v2 command + registered):
- /label/getAlbums           → v2_get_label_albums
    paginated catalog with sort/order/genre_ids/from_date/to_date
- /label/getNextReleases     → v2_get_label_next_releases
- /label/getAwardedReleases  → v2_get_label_awarded_releases
- /label/getPlaylists        → v2_get_label_playlists
- /label/getTopArtists       → v2_get_label_top_artists
- /label/story               → v2_get_label_story
- /label/getList             → v2_get_label_list (POST, mirrors
    track/getList signing)

New response types in qbz-models:
- LabelListPage<T> — generic { has_more, items: [T], total?, offset?,
  limit? } envelope, tolerant to either V2 list or SearchResultsPage
  shapes until samples land
- LabelStoryResponse, LabelGetListResponse — best-effort with optional
  fields so a shape mismatch is non-fatal

The legacy /label/get + get_label() + v2_get_label + LabelDetail are
retained untouched for now; frontend migration and deletion come next.

cc
2026-04-16 22:48:38 -06:00