Commit Graph
100 Commits
Author SHA1 Message Date
vicrodh 9b5a9ffaf5 feat(library): plumb excludeNetworkFolders through tree commands
v2_library_list_folder_children, v2_library_list_folder_tracks,
v2_library_list_folder_tracks_recursive accept and forward the
exclude-network-folders flag.

cc
2026-05-08 17:02:55 -06:00
vicrodh 1d68f7516e feat(qbz-library): network-folder filter on folder-tree primitives
list_folder_children, list_folder_tracks, list_folder_tracks_recursive
now apply the same network-folder exclusion that flat-mode search
honors, so the tree rail and recursive playback see the same source
of truth. Tests cover the on/off cases.

cc
2026-05-08 16:58:59 -06:00
vicrodh 632accbe40 fix(local-library): clear tree-mode state in bulk-action handlers
handleBulkPlayNext, handleBulkPlayLater, handleBulkAddToPlaylist now
call resetMultiSelect() so treeSelectMode and treeSelectedTracksById
are cleared alongside the existing flat-mode reset. Without this, the
BulkActionBar lingered with count 0 after firing from tree mode. The
tree-mode BulkActionBar's onClearSelection closure now delegates to
the same helper for consistency. resetMultiSelect was already
correct (it leaves trackPathById intact, which is what we want).

Also: warn when toggleTreeTrackSelection's cache-miss fallback hits a
track path with no parent folder, instead of silently returning.

cc
2026-05-08 16:37:15 -06:00
vicrodh 5e2670f59f test(qbz-library): empty-folder case for list_folder_tracks_recursive
Verify the recursive listing returns an empty Vec (not an error) when
the requested folder path has no descendants — frontend treats empty
as "nothing to play/queue" and skips the toast.

cc
2026-05-08 16:37:08 -06:00
vicrodh 3a09d8deb8 feat(local-library): recursive multi-select in tree mode
Folder-row checkbox in tree mode selects every descendant track via
v2_library_list_folder_tracks_recursive, deselects them on a second
click, and shows the standard indeterminate state when only some
descendants are selected. Track-kind rows in the tree honour the
same flow so users can deselect individual tracks from a partially-
selected folder. Both checkboxes share the existing selectedTrackIds
set, so the bulk-action bar (play next, play later, add to playlist)
operates on the union without any special-case handling.

Indeterminate state is computed cheaply: a SvelteMap<number, string>
caches track-id -> file_path (populated from the in-memory tracks
list and from each recursive fetch on toggle), and `countSelectedUnder`
walks the small selectedTrackIds set checking the prefix. Folder-row
state derives via a parent-supplied callback; the child reads the
prop reference of selectedTrackIds so reactivity propagates when the
parent reassigns the set.

Adds a dedicated treeSelectMode flag so the flat-mode tracks-tab
selection toggle stays independent. Renders the BulkActionBar at the
end of the tree-mode container when treeSelectMode is on. Adds a new
toast.failedSelectFolderTracks key across all five locales.

cc
2026-05-08 16:27:34 -06:00
vicrodh db2e0136d1 feat(library): expose v2_library_list_folder_tracks_recursive
Tauri wrapper for the qbz-library primitive added in the previous
commit. V2 cleanroom: direct call into qbz-library, no legacy
delegation. Registered in lib.rs alongside the existing folder-tree
commands.

cc
2026-05-08 16:17:26 -06:00
vicrodh 93a242e0d0 feat(qbz-library): add list_folder_tracks_recursive primitive
Returns full LocalTrack rows for every descendant under a folder path,
filtered by COALESCE(source, 'user') = 'user' so qobuz_download rows
never leak. Ordering is file_path ASC for stable on-disk reading
order across heterogeneous subtrees. Reuses escape_like_pattern so
literal '_' / '%' in path segments don't behave as LIKE wildcards.

Used by the tree-mode multi-select to populate selectedTrackIds when
the user ticks a folder-row checkbox; returns the full record (not
just IDs) so the frontend can build queue items without a second
round-trip.

Adds three unit tests covering the recursive walk, file_path
ordering, and special-character escape handling.

cc
2026-05-08 16:17:21 -06:00
vicrodh 8420a5ea0b feat(local-library): tree-mode search with path-parents preserved
When the user types in the search input while in tree mode, matching
folders/tracks stay visible and every ancestor path expands to keep
context. Empty branches collapse out. Clearing the query restores the
user's pre-search expand state. Implementation: in-memory contains over
the loaded `albums` array, debounced 200ms. The match expands the union
of matched paths and their ancestors in `searchExpandedPaths`, which
replaces `treeExpandedPaths` while search is active. Pre-search snapshot
is restored on clear. Tracks remain rendered under any visible folder.

cc
2026-05-08 16:00:27 -06:00
vicrodh a7b40e6e8a chore(local-library): handlePlayRecursive error toast + network-filter parity
- Surface a toast on playback failure so the user gets UI feedback
  rather than only a console error.
- Honor shouldExcludeNetworkFolders() for consistency with loadTracks
  and the rest of the view's search invocations.

cc
2026-05-08 15:55:33 -06:00
vicrodh 03d817f32a feat(local-library): two-column tree mode in Folders tab
Wires LocalLibraryFolderTree (left rail, 240px fixed) and the
LocalLibraryFolderDetail / album-detail flow (right pane) into a
two-column shell that mirrors the Artists tab CSS byte-for-byte.
View-mode segmented control on the Folders toolbar toggles between
Flat (the existing folder-grouped list) and Tree (the new hierarchical
view). The toggle is hidden when browsing Hidden Albums so that
sub-view keeps its existing flat rendering.

Selection routes the right pane: folder paths matching a known
album_group_key drive the existing handleAlbumClick flow (which sets
selectedAlbum and renders the top-level album-detail view); non-album
folders open LocalLibraryFolderDetail with subfolder cards plus
direct-children tracks. Empty-state when nothing is selected uses the
library.foldersTree.selectAFolder string.

Recursive play: handlePlayRecursive fetches all tracks via
v2_library_search (limit:0), client-side prefix-filters on file_path,
sorts by path and queues the result. Backend does not yet expose a
recursive-tracks-under-path command — flagged as a Task 7 trade-off
to revisit if telemetry shows tree-mode play stalling on large
libraries.

Mode persists in library_preferences.folders_view_mode via the
existing v2_set_library_folders_view_mode command, hydrated on mount
through v2_get_library_preferences. Flat mode rendering is
byte-for-byte unchanged: zero deletions in the existing markup, the
new tree shell wraps it via an outer if/else.

LibraryPreferences type extended with the optional folders_view_mode
field so TS strict-mode passes on the new prefs.folders_view_mode
read.

cc
2026-05-08 15:44:00 -06:00
vicrodh b4a7015ae7 chore(local-library): guard FolderDetail $effect against stale fetches
The folderPath snapshot existed but wasn't used to guard the async
writes. Rapid folder switches could land an older fetch's results on
top of the newer selection. Add three short stale-guards on .then,
.catch, and .finally so only the latest in-flight result wins.

cc
2026-05-08 15:33:16 -06:00
vicrodh 6742597cdf feat(local-library): LocalLibraryFolderDetail right-pane component
Renders the contents of a folder that is NOT a known album_group_key —
shows immediate subfolders + direct-children tracks side by side, with
a "Play all recursively" button for the whole folder. Used in the right
column of the upcoming tree-mode two-column layout (Task 7). Extracts
FolderTreeEntry to a shared $lib/types/folderTree.ts module so both
LocalLibraryFolderTree and FolderDetail import the same type.

cc
2026-05-08 15:28:17 -06:00
vicrodh 0e503b75e7 chore(local-library): address Task 5 review nits
- Keep self-import for recursion and replace the misleading "deprecated
  in Svelte 5" comment with a corrected rationale. svelte-check confirms
  `<svelte:self>` is in fact deprecated in Svelte 5 (svelte_self_deprecated)
  and self-import is the recommended replacement; the original code was
  right, only the comment was wrong.
- Switch the row role from `button` to `treeitem` so that `aria-selected`
  is valid (svelte-check rejects aria-selected on role=button) and add
  `aria-expanded` for folders. treeitem is also the semantically correct
  role for a tree row, so screen readers now announce both selection and
  expansion state.
- Add :focus-within parity for the play button so keyboard users see it
  when the row receives focus.

cc
2026-05-08 15:24:11 -06:00
vicrodh ad5d13a0c3 feat(local-library): LocalLibraryFolderTree recursive component
Lazy-loaded recursive tree-row component for the upcoming tree mode in
the Folders tab. Renders one node per call; children loaded on first
expand via v2_library_list_folder_children. ADR-001 compliant (no $t
inside $derived). Indentation by depth * 16px matches Poweramp-style
hierarchy. Recursion uses self-import pattern (svelte:self deprecated
in Svelte 5). Not yet wired into LocalLibraryView - that lands with
the two-column layout integration (Task 7).

cc
2026-05-08 15:13:54 -06:00
vicrodh 5c5fce2423 fix(i18n): relocate folder-tree keys to library.foldersTree namespace
Task 4's structural change of `library.folders` from string to object
broke LocalLibraryView.svelte:4337's dynamic tab label
($t(`library.${tab}`)) which expects a string. Move the new tree keys
to a sibling namespace `library.foldersTree.*` instead, and restore
`library.folders` to its original flat string value.

cc
2026-05-08 14:56:30 -06:00
vicrodh 107efc0f87 i18n: add library.folders.tree keys for tree-mode UI
Five locales (en, es, de, fr, pt). en and es are human-written in the
project's canonical Mexican neutral register; de/fr/pt are machine-
translated drafts flagged in qbz-nix-docs/i18n/pending-translations.md
for community review. Seven keys: modeLabel, flatLabel, selectAFolder,
treeFolderTracks (ICU plural), treeLoading, treeEmpty, playAllRecursive.

The flat library.folders string ("Folders" / "Carpetas" / etc.) was
migrated to an object; the original label is preserved at
library.folders.label. No source code currently references the key,
so the restructuring is non-breaking. "Track" is translated to match
each locale's existing convention (pista, Titel, titre, faixa).

cc
2026-05-08 14:51:57 -06:00
vicrodh a525bc92ec feat(library-prefs): add folders_view_mode for tree/flat selection
New persisted field on LibraryPreferences gating the upcoming Tree
sub-mode in the LocalLibrary Folders tab. Default flat preserves
existing behaviour for current installs. Migration adds the column
non-destructively. Setter v2_set_library_folders_view_mode exposes
the toggle to the frontend; the existing v2_get_library_preferences
returns the new field automatically via serde.

cc
2026-05-08 14:40:47 -06:00
vicrodh 24558d2a7d feat(library): expose v2_library_list_folder_children + folder_tracks
Tauri command wrappers for the qbz-library SQL primitives. V2 cleanroom:
both commands call directly into qbz-library, no legacy delegation.

cc
2026-05-08 14:21:07 -06:00
vicrodh 1bb353429c chore(qbz-library): address Task 1 review nits
- Replace the false "SQLite ORDER BY fragility" rationale on the
  Rust-side sort in list_folder_children with the actual reason
  (rows already in memory; Rust case-insensitive compare clearer
  than COLLATE NOCASE on a CASE-derived column).
- Drop the redundant ESCAPE '\\' clause on the literal '%/%' pattern
  in list_folder_tracks. The pattern contains no escape character;
  the clause was a copy-paste artifact from the user-input LIKE
  patterns where ESCAPE is required.

No behaviour change.

cc
2026-05-08 14:05:49 -06:00
vicrodh 8481f7e8b3 feat(qbz-library): add list_folder_children + list_folder_tracks queries
Two new SQL primitives that walk local_tracks.file_path to reconstruct
filesystem hierarchy without schema changes. Both filter
COALESCE(source, 'user') = 'user' so Plex and Qobuz downloads are
excluded from the eventual tree-mode view in the Folders tab. Both hit
idx_tracks_file_path for the LIKE prefix% portion; per-row level
extraction is in-memory over the prefix-narrowed candidate set. New
FolderTreeEntry enum carries the child rows. Unit tests cover folder/
track interleaving, source filter, special-character paths, and
direct-children vs recursive scoping.

cc
2026-05-08 13:48:26 -06:00
vicrodh 3b93f35d0a fix(audio-settings): default backend_type to per-OS choice, migrate NULL rows
Issue #375: pause-then-resume sometimes leaves audio silent. Diagnosis
in user-reported logs:

  Synced audio settings to CoreBridge player: backend=None, exclusive=false
  ...
  Resume: reinitializing stream at 44100Hz/2ch
  Using default audio device          <- legacy CPAL path
  Using audio device: Default Audio Device
  Audio output initialized successfully  <- silent stream

backend_type=None falls through to init_device's legacy CPAL path which
races against rodio's DeviceSink drop on resume — CPAL hands us a new
default-device handle, but PipeWire is still tearing down the previous
sink, and the new handle ends up routed to a node that produces no
sound. CPAL doesn't fail the open, just gives a silent stream.

The "Sync audio settings on startup" toggle Rico29 was asked to enable
fires correctly (`sync_audio_on_startup=true` in his log) but only
re-syncs whatever is persisted. His persisted backend_type was still
NULL because he never explicitly picked a backend, so the sync was a
no-op.

Fix:

- Default::default() now sets backend_type to Some(AudioBackendType::default()),
  which picks PipeWire on Linux and SystemDefault elsewhere. New installs
  go directly onto the proper backend init path; the runtime still
  degrades gracefully if the chosen backend isn't available on the host
  (try_init_stream_with_backend returns Some(Err(_)) and the existing
  fallback warning fires).

- Migration backfills existing rows where backend_type IS NULL with the
  same per-OS default, serialized via serde_json so the row read path
  round-trips cleanly. macOS users were already getting effective
  SystemDefault dynamically at the call site (audio_settings.backend_type
  .or_else(...)) so behaviour there is unchanged; the migration just
  persists what the runtime was already substituting.

reset_all picks up the new default automatically because it reads
AudioSettings::default().backend_type.

cc
2026-05-08 00:12:59 -06:00
vicrodh 72a81490f4 fix(mixtape-detail): stabilize virtualized list scroll-up behavior
Three issues observed when fast-scrolling collection detail views
(reported on the Macross collection, ~67 items, list mode):

1. Horizontal scroll artifact at the bottom-right corner — same root
   cause as AlbumDetailView's: an absolutely-positioned artwork backdrop
   widens past 100% of the .detail-view. Add overflow-x: hidden alongside
   the existing overflow-y: auto.

2. Empty container when scroll position briefly exceeds the content
   tail. The virtualWindow math could compute firstRow * cols >= total
   during overscroll moments, slicing windowedItems to an empty array.
   Clamp firstRow / firstIdx to total - 1 so at least one row renders
   even when the scroll position has overshot.

3. The user-visible regression that started this thread: scrolling
   UP from deep in the list could not reach scrollTop = 0 even though
   the "Top" button worked. Two fixes layered together:

   a. overflow-anchor: none on .detail-view. Browser scroll-anchoring
      tries to preserve visual stability when content above the viewport
      changes height — but the virtualizer manages its own spacer
      heights, so the auto-anchoring nudges scrollTop in the opposite
      direction of user input. Disabling it lets the wheel input win.

   b. content-visibility: auto gated to expanded mode. Until now
      .item-block applied it unconditionally. The grid view's .grid-card
      already had this exact issue diagnosed and fixed (see the inline
      comment "doubling up with content-visibility: auto caused cards to
      re-eject and re-paint on scroll-back"); .item-block had been left
      behind. Layering native content-visibility on top of manual
      virtualization caused the browser to intermittently treat rendered
      rows as off-screen during fast scroll, snapping them to the
      contain-intrinsic-size hint for a frame, which the spacer math
      doesn't predict — producing the empty-viewport-with-stuck-scroll
      symptom. The .lazy class now scopes content-visibility to expanded
      mode, where virtualization is OFF and the optimization is needed.

Smoothness during very fast wheel scroll is still imperfect but the
viewport no longer goes blank and scroll-up reaches the top reliably.

cc
2026-05-08 00:01:40 -06:00
vicrodh d452838cd1 fix(album-detail): clip horizontal overflow from artwork backdrop
The .has-art-bg ::before pseudo-element renders the album artwork
heavily blurred at transform: scale(1.15) for the Qobuz/Feishin-style
header. Without overflow-x: hidden on the .album-detail container, the
15% horizontal upscale of the absolutely-positioned backdrop bleeds
past the right edge and surfaces a horizontal scrollbar on the page.
Add overflow-x: hidden to the existing overflow-y: auto so the blur
stays clipped without affecting vertical scroll.

cc
2026-05-08 00:01:16 -06:00
vicrodh a67e3c9217 Merge PR #391 (Vudgekek): macOS CoreAudio Exclusive Mode
Adds CoreAudio Hog Mode integration on macOS so Exclusive Mode actually
takes the device exclusively (previously the macOS path used the
Linux-shaped logic without any kernel-level lock). Pins the CoreAudio
device id through Hog Mode acquisition, sample-rate switching, and
stream creation so System Default doesn't drift mid-session. Linux
behaviour is unchanged.

Review asks (all four resolved by Vudgekek + afonsojramos):

- set_coreaudio_hardware_volume falls back to software volume on Err
  rather than reporting success, so knob-only DACs keep a working
  volume slider via engine.set_volume().
- CoreAudioExclusiveGuard snapshots the device's hardware volume on
  acquire and restores it before releasing Hog Mode, so leaving
  Exclusive Mode returns the DAC to the user's pre-Exclusive level.
  Guard is constructed before the FFI call so partial-acquire failures
  still trigger Drop and release.
- Linux unused-variable warnings on stream_opt and exclusive_guard
  cleaned up via cfg_attr(allow(unused_variables)) on the macOS-only
  guard plumbing. cargo check is clean.
- Silent shared-mode regression on macOS when backend init fails:
  init_device now sets_current_device(None) and returns None on
  exclusive_mode==true so the user sees an error instead of
  unknowingly playing in shared mode.

Bonus: 5f10b4ba adds real CoreAudio device-rate detection for macOS
Shared Mode, +90 lines in backend.rs.

Conflict resolution: single textual collision in
crates/qbz-audio/src/lib.rs (both branches added a pub use line).
Resolved by keeping both, alphabetical order — coreaudio_direct
re-export from pr-391, device_reservation re-export from pre-release.
All other auto-merges verified line-by-line: AlsaDirectStream's
DeviceReservation::acquire flow (alsa_direct.rs:60-97), the macOS
exclusive_mode guard (player/mod.rs:1077-1085 in qbz-player and the
mirror in src-tauri:1024), and CoreAudioExclusiveGuard's volume
snapshot/restore (coreaudio_direct.rs:351,369,373,388) all coexist
correctly because each branch touched different functions.

cargo check clean across all four crates. 9 device_reservation +
3 reserve_dac + 214 src-tauri unit tests pass.

cc
2026-05-07 19:09:37 -06:00
vicrodh d214125d1c feat(settings): expose reserve-DAC toggle in Audio settings
Mirrors the HiFi Wizard control (landing in Task 8) inline under
Exclusive Mode. Status row polls v2_get_dac_reservation_status every
5s while the row is rendered. Hidden when the selected device is not
a card-specific ALSA prefix (hw:, plughw:, front:, surround*, iec958:,
hdmi:). Six i18n keys consumed at settings.audio.reserveDac.*.

cc
2026-05-07 15:42:57 -06:00
vicrodh 4a8af7d316 i18n: add reserveDac keys for ALSA exclusive hardening UI
Five locales (en, es, de, fr, pt). English and Spanish are human-written
in the project's canonical Mexican neutral register; de/fr/pt are
machine-translated drafts. Pending-translations note recorded in
qbz-nix-docs/i18n/pending-translations.md (outside git scope).

Keys: settings.audio.reserveDac.{label, description, statusActive, statusContested, statusUnavailable, wirePlumberNote}.

UI surfaces (Settings mirror + HiFi Wizard) consume these in Tasks 7-8.

cc
2026-05-07 15:09:37 -06:00
vicrodh 11b46bbe9f chore(reservation): address Task 5 review feedback
- Document the Contested-vs-Unavailable classification limitation on
  the DacReservationStatus enum and its call site, deferring the
  stash-the-last-error refactor until Tasks 7-8 confirm the UI needs
  the distinction.
- Lift is_card_specific_device to pub(crate) in lib.rs and delete the
  duplicate in commands_v2/audio.rs to prevent the allow-list from
  diverging when new ALSA prefixes are added.
- Drop the misleading "or non-card device" clause from the
  apply_dac_reservation degraded-path log; non-card devices are
  filtered earlier and cannot reach this log line.

No behaviour change.

cc
2026-05-07 14:50:58 -06:00
vicrodh 4797fec939 feat(reservation): per-process DAC reservation + Tauri commands
Lifetime B from the design spec: a long-lived DeviceReservation guard
held in AppState, gated by the reserve_dac_while_running setting.
Acquired at startup if the persisted flag is true and the selected
device targets a single ALSA card; reapplied when the user picks a
different DAC; released on toggle-off, on a switch to a non-card
device, or AppState drop.

DB persistence: ALTER TABLE migration adds the column, SELECT and
reset_all are extended, set_reserve_dac_while_running setter parallels
the established pattern for boolean audio settings.

Tauri commands (V2 cleanroom):
- v2_set_reserve_dac_while_running(enabled)  - persist + apply
- v2_get_dac_reservation_status() -> DacReservationStatus

Status enum mirrors the four cases in the spec: Inactive (toggle off,
or non-card-specific device), Active (we hold the bus name), Contested
(another app holds the device at higher priority - guard is None but
the toggle is on), Unavailable (D-Bus unreachable, degraded guard).

v2_set_audio_output_device gains an AppState dependency so DAC changes
trigger a reservation handover when the toggle is on.

UI surfaces (Settings mirror + HiFi Wizard) land in Tasks 7-8.

cc
2026-05-07 13:48:51 -06:00
vicrodh a1a056c4b9 feat(audio-settings): add reserve_dac_while_running flag
Opt-in flag for the per-process DAC reservation lifetime (Lifetime B
in the spec). Defaults to false; serde default ensures legacy settings
JSON files round-trip cleanly without the field. Task 5 will read this
flag in AppState startup and the v2_set_reserve_dac_while_running
Tauri command.

Strictly additive: no existing field changed, no behaviour change for
users with the flag at its default (false).

cc
2026-05-07 12:39:59 -06:00
vicrodh d2185f7a6b fix(qbz-audio): resolve ALSA card by id, not by long name
The CARD= parameter in ALSA device strings refers to the card's short
id (e.g. "C20", "HDMI", "Generic"), not its long descriptive name
("Cambridge Audio USB Audio 2.0"). The previous resolver called
Card::get_name() and silently swallowed errors, so every CARD=<id>
lookup failed and acquire() degraded gracefully -- meaning the
reservation has been non-functional for users with named-card device
strings since Task 3 landed.

Reported by the maintainer on Cambridge DacMagic Plus exposed as
front:CARD=C20,DEV=0, 2026-05-07. Smoke-test scenario 2 had been a
false positive: audio worked because we degraded silently, not because
the reservation succeeded.

In alsa-rs 0.10, Card::get_name() wraps snd_card_get_name and despite
the name returns the LONG descriptive string. The short id (what
aplay -l shows in brackets and what CARD= references) is exposed via
ctl::CardInfo::get_id() (snd_ctl_card_info_get_id). Open a Ctl per
card, read the id from its CardInfo, and surface ALSA enumeration
errors as ReservationError::AlsaError instead of unwrap_or_default()
into an empty string.

cc
2026-05-07 12:07:03 -06:00
vicrodh a4eb441c4e fix(qbz-audio): accept all ALSA plugin prefixes; degrade on parse failure
The previous parse_card_index only accepted hw: and plughw: prefixes,
which broke playback for users whose ALSA device string uses front:,
plughw:, surround*:, iec958:, hdmi:, etc. The plugin prefix is
irrelevant for D-Bus reservation purposes - what matters is the card
identifier in the args. Generalise the parser to extract the card
from any plugin prefix.

Defence in depth: when parse_card_index fails (unrecognised string,
no card identifier extractable, etc.), acquire() now logs a warning
and returns a degraded guard instead of propagating the error.
This preserves playback for non-card-targeting names like 'default'
and 'pulse' that are not meaningful for per-card reservation.

Reported on Cambridge DacMagic Plus exposed as front:CARD=C20,DEV=0,
2026-05-07.

cc
2026-05-07 11:10:12 -06:00
vicrodh 6b7ed75cc9 chore(qbz-audio): polish AlsaDirectStream reservation wiring
- Skip the 50 ms PipeWire-vacate margin on the degraded D-Bus path;
  no reservation transition happened, so no settle delay is needed.
- Add TODO(Task 5) breadcrumb for the app_device_name placeholder
  so Task 5's UI surfacing wires it to the user-facing DAC name.
- Soften the timing-claim comment on the sleep; the specific "~2-4 ms"
  was spec-cited, not measured in this commit.
- Lift the 50 ms literal into a named PIPEWIRE_VACATE_MARGIN const.

No behaviour change for the active-reservation path.

cc
2026-05-07 10:19:59 -06:00
vicrodh 92633dcf12 feat(qbz-audio): hold device reservation for AlsaDirectStream lifetime
Acquire org.freedesktop.ReserveDevice1.Audio<N> before opening the PCM,
hold for the entire stream lifetime, release on Drop after the PCM
closes. Closes the path where exclusive open would silently fight an
active PipeWire route.

Field order in AlsaDirectStream is significant: _reservation is the
last field so it drops AFTER the PCM closes, ensuring the kernel-level
exclusive lock is released before the D-Bus bus name is freed and
PipeWire reclaims the device.

This is the canonical Lifetime-A consumer the device_reservation
acquire doc-comment's tight-coupling rule allows: a DeviceReservation
created immediately before a real PCM::new() and held for as long as
the PCM is open. A 50 ms defensive sleep gives PipeWire time to vacate
the device after releasing the reservation.

cc
2026-05-07 10:09:07 -06:00
vicrodh 41b844cfa8 chore(qbz-audio): document tight-coupling rule and refactor contention proxy
- Document the load-bearing tight-coupling rule on acquire(): never
  construct a DeviceReservation without an immediate device consumer.
  Cambridge DacMagic Plus was stranded by a standalone reservation
  churn during initial Task 2 smoke testing on 2026-05-07.
- Document the Connection lifecycle: zbus does not pool session-bus
  connections, so acquire() pays a SASL handshake per call. Task 5
  will add acquire_with_connection() to reuse a long-lived bus.
- Refactor resolve_contention to open a single holder Proxy and read
  Priority + ApplicationName through it, instead of opening two.
- Specificity polish on the QBZ_APPLICATION_NAME dead-code comment;
  defensive-InQueue comment; release_name From-chain comment;
  clippy doc-list-overindentation fixes.

No behaviour change.

cc
2026-05-07 10:00:57 -06:00
vicrodh bc5d316e5a feat(qbz-audio): wire zbus client for ReserveDevice1 acquisition
Implements the full priority-resolution algorithm: request bus name
with DO_NOT_QUEUE; on EXISTS look up holder Priority via the
Properties interface; if our priority (5) is higher, call
RequestRelease and retry with REPLACE_EXISTING; if equal-or-lower,
return HigherPriorityHolder. AlreadyOwner is treated as success for
same-connection idempotency. Drop releases the bus name and logs
the ReleaseName reply variant.

D-Bus failure paths degrade to a no-op guard so playback continues
exactly as before in environments without a session bus.

Smoke-tested against PipeWire/WirePlumber via dbus-monitor.

cc
2026-05-07 09:43:37 -06:00
vicrodh f0ea0c88ec chore(qbz-audio): address Task 1 review feedback
- Add ReservationError::AlsaError variant; stop conflating ALSA
  enumeration errors with DbusError.
- Mirror ReservationError variant set on the non-Linux stub so cross-
  platform pattern matching compiles on every target.
- Add empty Drop to stub for RAII symmetry with the Linux variant.
- Collapse ReservationState to its real Task 1 shape (Degraded only);
  Task 2 reintroduces Active when it has real fields.
- Rewrite acquire() doc-comment to honestly describe Task 1's behaviour
  and hint at Task 2's full failure-mode set.

No behaviour change. Foundation commit for Task 2.

cc
2026-05-07 09:18:19 -06:00
vicrodh 4bc4213b97 feat(qbz-audio): add device-reservation module skeleton with parsers
Adds the new module that will host the org.freedesktop.ReserveDevice1
D-Bus client. This commit only ships the public surface, the parser
helpers (hw:N -> Audio<N> bus name, hw:CARD=name resolution) and unit
tests for them. acquire() currently returns a degraded guard; D-Bus
implementation lands in the next commit.

cc
2026-05-07 08:57:31 -06:00
vicrodh a705e4f297 Merge feature/internal/discord-rpc-v2 into pre-release
Discord Rich Presence (#336): when the user opts in, QBZ pushes the current
track as Listening status in Discord with cover, progress bar, and Get QBZ
button. Off by default, silent degrade when Discord is unavailable, sandbox
override block in Settings -> Integrations.

cc
2026-05-07 02:01:22 -06:00
vicrodh 3a0c2ab6ce build(flatpak): expose discord-ipc-0 socket for RPC
Adds --filesystem=xdg-run/discord-ipc-0 to the self-hosted Flatpak manifest
so Discord Rich Presence can reach the IPC socket from inside the sandbox.
The Flathub manifest is updated separately at release time.

Refs #336.

cc
2026-05-07 01:47:54 -06:00
vicrodh f2b0ce7071 feat(discord-rpc): settings UI with toggle and sandbox override block
Adds a Discord Rich Presence section to Settings -> Integrations:
- Toggle wired to discordRpcService (off by default, persisted in localStorage)
- Collapsible override block under the toggle with the flatpak override
  command and a Snap fallback note. Always shown - runtime detection isn't
  worth the complexity for a help block.

Refs #336.

cc
2026-05-07 01:42:42 -06:00
vicrodh 6b08cf6848 i18n(discord-rpc): add translation keys for 5 locales
Adds settings.integrations.discordRpc keys (label, description, overrideHeader,
flatpakNote, snapNote) to en/es/de/fr/pt for the Discord Rich Presence settings
toggle and sandbox override block.

Refs #336.

cc
2026-05-07 01:38:04 -06:00
vicrodh 232276f4fa feat(discord-rpc): wire initDiscordRpc into app boot
Calls discordRpcService.initDiscordRpc() once from +page.svelte onMount so
the backend state matches the persisted toggle and the playerStore subscriber
is registered when the user has opted in.

Refs #336.

cc
2026-05-07 01:35:19 -06:00
vicrodh 7531c2f092 feat(discord-rpc): frontend service with localStorage toggle and dedupe
Creates discordRpcService that:
- persists the user toggle in localStorage (qbz-discord-rpc-enabled, off by default)
- on enable, subscribes to playerStore and forwards (track_id, is_playing) transitions
- dedupes by (track_id, is_playing) so currentTime ticks don't spam the backend
- silently ignores backend errors (headless, sandbox-blocked, etc.)

Refs #336.

cc
2026-05-07 01:32:07 -06:00
vicrodh 82453b8fee feat(discord-rpc): backend module and Tauri commands
Adds src-tauri/src/discord_rpc.rs with DiscordRpcState (Mutex<Option<client>>
+ AtomicBool enabled) and three V2 commands:
- v2_discord_rpc_set_enabled
- v2_discord_rpc_update
- v2_discord_rpc_clear

Lazy connect on first update; silent degrade when Discord is unavailable.
Hardcoded Application ID 1501835855587708988 (public identifier).

Refs #336.

cc
2026-05-07 01:29:03 -06:00
vicrodh 2b5366eb06 chore(deps): add discord-rich-presence 0.2.4
For Discord Rich Presence integration (#336).

cc
2026-05-07 01:20:27 -06:00
vicrodh 9bab69310b chore(deps): batch bump minor/patch versions
Manual batch instead of merging the 10 dependabot PRs individually so
Cargo.lock and package-lock.json each see a single coherent update.

Rust (src-tauri/Cargo.lock):
- tokio 1.52.1 -> 1.52.2 (#401)
- rustls 0.23.37 -> 0.23.40 (#400)
- tauri-plugin-opener 2.5.3 -> 2.5.4 (#399)
- tauri-plugin-deep-link 2.4.8 -> 2.4.9 (#397)
- notify-rust 4.16.1 -> 4.17.0 (#394)

npm (package.json + package-lock.json):
- @sveltejs/kit 2.58.0 -> 2.59.1 (#398)
- @tauri-apps/plugin-dialog 2.7.0 -> 2.7.1 (#396)
- jsdom 29.1.0 -> 29.1.1 (#395)
- @tauri-apps/api 2.10.1 -> 2.11.0 (#393)
- svelte-check 4.4.6 -> 4.4.8 (#392)

cargo check + npm run check both clean.

cc
2026-05-07 00:19:45 -06:00
vicrodh a9c17365e6 Merge feature/internal/artist-header-gradient into pre-release
Apply the album/artist detail backdrop overhaul:
- Blurred artwork background instead of a flat palette gradient
- Gradient extended to artist detail, sharing the existing toggle
- Image cache plumbed through extractPalette so artist images bypass
  Qobuz CDN's missing CORS headers and Vibrant can read pixels
- Per-view height tuning so each fade lands above its own toolbar
- Artist jump-nav transparent at rest, gains its background only when
  pinned (IntersectionObserver sentinel)
- Reactive text + action button overrides extended to artist view

cc
2026-05-07 00:13:55 -06:00
vicrodh 55a200a8da feat(detail-views): blurred artwork backdrop and artist-page gradient
Promote the album/artist detail header gradient from a flat
palette-color fade to a Qobuz/Feishin-style blurred backdrop, and
extend it to the artist page.

- artworkPalette: route the URL through getCachedImageUrl before
  handing it to Vibrant. Qobuz CDN sends Access-Control-Allow-Origin
  for album covers but not artist images, which tainted the canvas
  Vibrant uses and made pixel reads fail. The cache resolves to a
  local asset:// path and primes the disk store for next time.
- AlbumDetailView and ArtistDetailView: ::before now renders the
  artwork itself with filter:blur + saturate, masked to fade into the
  theme background; ::after carries the contrast scrim so the blur
  layer doesn't muddle it. The CSS variable --art-image-url carries
  the locally-resolved URL so the backdrop image is served from disk
  instead of being re-downloaded.
- Heights tuned per view: artist's header is taller (image + bio +
  actions) than album's, so artist gets 340 × scale(1.1) and album
  gets 280 × scale(1.15) so each fade lands above its respective
  toolbar / JUMP TO bar.
- ArtistDetailView jump-nav: now transparent at rest and gains its
  background only when stuck (IntersectionObserver against a 1px
  sentinel placed right above it). Stops the bar from cutting a
  flat-color stripe across the gradient when it's not pinned.
- Reactive text + action button overrides on .has-art-bg apply to
  the artist page too: back button, bio text, bio toggle, and the
  action-btn-circle family read in white-tinted variants over the
  colored backdrop.

cc
2026-05-07 00:12:58 -06:00
vicrodh eed2f4f636 refactor(playlist-detail): unify selection on multiSelectMode and remove visual flash
Custom sort had two parallel selection systems: an inherent per-row
checkbox column (selectedTrackKeys) used solely to enable Move Up/Down
in a separate batch toolbar, and the toolbar's multiSelectMode for
bulk actions. They had different stores, different widths, and one
disabled the other. Consolidate onto multiSelectMode; drag and the
existing per-row reorder controls cover ordering, and the wrapper
propagates dragTrackIds for group moves.

- Drop selectedTrackKeys, isSelectionMode, toggleTrackSelection,
  clearSelection, selectAllTracks, moveSelectedUp, moveSelectedDown
  and the associated batch-controls toolbar / col-checkbox header
  branch / inherent per-row checkbox.
- Move the multi-select checkbox out of TrackRow into the wrapper so
  the column order in custom sort reads [checkbox][reorder][TrackRow];
  TrackRow's internal track-checkbox is hidden via :global so its
  click + keyboard handlers stay wired through selectable=true.
- Reserve 24px for the row-checkbox and the header col-select-all at
  all times and animate opacity (180ms) instead of width. Toggling
  select no longer reflows the columns to its right; the checkbox
  fades inside a slot that was always there.
- Stable each-key for virtualized rows: use track identity
  (`<namespace>-<id>-<number>`) instead of `${visibleTrackRange.start
  + loopIdx}-${track.id}`. The old key mixed scroll state into the
  identity, so a re-render that bumped trackListScrollTop reused row
  instances against new data — rows showed mismatched track / # /
  album combinations until the next paint.

cc
2026-05-06 23:26:01 -06:00
vicrodh 8977e721c6 refactor(album-detail): align tracklist columns and smooth select-mode toggle
- Reduce table-header left padding to 4px and switch the # column to
  text-align: left so track numbers line up with the bare quality badge
  in the toolbar above. Track rows in the album-detail context get the
  same 4px left padding via a :global override on .track-list and the
  track-number column switches to flex-start so the row stays aligned.
- Match the select-all checkbox width to the track-row checkbox (24px)
  and shrink the checkbox itself to 15x15 so the header checkbox lands
  on the same x as the per-row ones.
- Always render the select-all and track-row checkbox containers and
  animate width + opacity in/out (180ms ease) so toggling select mode
  no longer pops the column into existence.
- Move the AlbumMenu (...) trigger to the end of the action row so the
  bulk-action triggers (CassetteTape, multi-select) sit before the
  overflow menu — same convention as other detail views.

cc
2026-05-06 22:21:51 -06:00
Victor RH ecb8f96fa1 Merge pull request #390 from afonsojramos/bugfix/internal/track-change-click
fix(audio): eliminate macOS track-change crackle
2026-05-06 22:09:41 -06:00
Victor RH 1fdf0bfcb2 Merge pull request #389 from vicrodh/dependabot/cargo/src-tauri/openssl-0.10.79
chore(deps): bump openssl from 0.10.78 to 0.10.79 in /src-tauri
2026-05-06 22:09:31 -06:00
vicrodh f4c9b71366 Merge feature/internal/album-header-gradient into pre-release
Album detail UX overhaul:
- Artwork-derived gradient backdrop on the album header (opt-out toggle in
  Settings > Appearance > Album header gradient).
- Bare mode for QualityBadgeStatic so quality reads inline without a
  pill container.
- Shrink label/awards sidebar by ~20%.
- Inline tracks count and duration with the metadata row, format duration
  as Xh Ym Zs.
- Plumb album description with sanitized HTML and click-to-expand.
- Tracklist toolbar with track search and inline quality badge.
- Featured artists and explicit (parental warning) badge in the artist
  line.
- Reactive divider between header and tracklist (visible only when the
  gradient is off), reactive action button colors, metadata centering
  when there is no description.

cc
2026-05-06 22:08:33 -06:00
vicrodh 5b05b6fae3 feat(album-detail): tracklist toolbar, featured artist line, explicit badge, header polish
Inline UX iteration for the album detail header and tracklist:

- Tracklist toolbar above the table: bare quality badge on the left,
  borderless search input on the right (filters tracks by title or
  artist), with min-height alignment so badge and input share a baseline.
- Artist line renders the explicit badge (when parental warning) before
  the main artist and appends featured artists separated by a dot, each
  clickable to its discography. Featured names use a quieter weight and
  size to keep the main artist primary.
- Reactive divider between header and tracklist: visible only when the
  artwork gradient is off; when on, the gradient itself provides the
  demarcation.
- Symmetric vertical breathing room around the toolbar (20px top to
  optically compensate for the 40px-tall table-header below) and the
  same offset on the album sidebar so the LABEL section aligns with the
  toolbar row.
- Action buttons in the header (play/shuffle/heart/etc.) react to the
  gradient backdrop with white-tinted strokes and a brighter hover.
- Metadata column vertically centers against the artwork when the
  album has no description.

i18n keys added in all five locales: tracklist.searchPlaceholder,
tracklist.noMatches.

cc
2026-05-06 22:08:06 -06:00
vicrodh e8d58196c5 feat(album): plumb featured artists and parental warning
Add Album.parental_warning and Album.artists (with the new AlbumArtist
struct) to qbz-models so the /album/get response surfaces both fields.
Mirror them in the QobuzAlbum / AlbumDetail TypeScript types and
populate featuredArtists (filtered to non-main contributors) and
parentalWarning in convertQobuzAlbum. Wire onFeaturedArtistClick from
the route so featured artist names route to their discography.

cc
2026-05-06 22:06:54 -06:00
vicrodh e1447159bb feat(album-detail): plumb album description with click-to-expand toggle
Pass Qobuz album.description through adapter and AlbumDetail prop, then
render below the metadata row with a 2-line clamp and a Read more / Show
less toggle. Description HTML (Qobuz CMS markup with paragraph and
emphasis tags) is sanitized through the existing allowlist before being
inserted as HTML so the formatting renders cleanly without exposing
data-* attributes.

cc
2026-05-06 21:01:59 -06:00
vicrodh 7e87de4352 refactor(album-detail): inline tracks/duration in metadata row
Folds the standalone .album-quality and .album-stats lines into the
existing date/label/genre row, since the quality string moves to the
tracklist toolbar in a follow-up. Plumbs durationSeconds through
AlbumDetail and the Qobuz adapter, plus bitDepth/samplingRate so the
inline QualityBadgeStatic can render the same tier label as Mixtape and
Collection rows. Total duration renders as Xh Ym Zs (no leading zeros).

cc
2026-05-06 20:52:15 -06:00
vicrodh 16e134fba1 refactor(album-detail): shrink label/awards sidebar by ~20%
The right-side sidebar was carrying too much weight versus the tracklist.
Drops the column from 280px to 224px and proportionally reduces avatar,
icon, and font sizes so the label/awards stack reads as supporting
metadata rather than competing with the track table.

cc
2026-05-06 20:49:00 -06:00
vicrodh a2866f8d96 feat(quality-badge): add bare prop for inline (no-container) usage
When bare={true}, the badge drops its background, border, padding,
min-width, and fixed height so it can render inline above a tracklist
toolbar without visually competing with the table header.

cc
2026-05-06 20:46:20 -06:00
vicrodh 0d784545eb feat(album-detail): album header gradient backdrop from artwork palette
Extracts the dominant color from album artwork (via node-vibrant) and
paints it as a soft top-down gradient behind the album header, with an
appearance toggle to opt out. Adds the .has-art-bg state class plus
contrast-lifted overrides for back button, info text, and artist link.

cc
2026-05-06 20:40:18 -06:00
vicrodh 19f33cb157 Merge feature/internal/local-library-followups into pre-release
Local Library follow-ups:
- fix tracks tab empty on initial load (active tab loader trigger)
- relocate edit-tabs button into folder management toolbar with sort icon
- give Albums tab the full Folders action bar (group/filter/sort/view/select)
- include Plex albums in metadata-grouped Albums view
- show Albums in Edit Library Tabs modal
- declare standard line-clamp alongside -webkit-line-clamp

cc
2026-05-06 18:56:36 -06:00
vicrodh 4bbff02c4b style: declare standard line-clamp alongside -webkit-line-clamp
svelte-check warned about missing standard property next to the
-webkit-line-clamp prefix in 9 spots across 8 components. Add the
standard line-clamp declaration with the same value to clear the
warnings without changing rendering.

cc
2026-05-06 18:56:18 -06:00
vicrodh ebe98ab4b8 fix(library): show Albums in Edit Library Tabs modal
The modal sanitizer filtered tab_order against availableTabs, which
omitted 'albums', so the metadata-grouped Albums tab never appeared
in the order/visibility editor. Add it to both availableTabs and
DEFAULT_TAB_ORDER to match the backend default and LocalLibraryView.

cc
2026-05-06 18:56:15 -06:00
vicrodh a1197983cf fix(library): include Plex albums in metadata-grouped Albums view
loadMetadataAlbums only queried the local SQLite library, so the new
Albums tab was missing all Plex-cached content while the Folders tab
showed it. Mirror the merge pattern from loadLibraryData: fetch Plex
cached albums in parallel and concatenate after mapping.

cc
2026-05-06 18:56:09 -06:00
vicrodh ea98a34f8e feat(library): give Albums tab the full Folders action bar (group/filter/sort/view/select)
Albums was a stripped-down VirtualizedAlbumList over metadataAlbums with
no controls. Folders had the full toolbar (group dropdown, quality/format
filter, sort, view toggle, multi-select with bulk actions, alpha index).
The user wants Albums to be 1:1 with Folders, no reinvention.

Implementation:
- Extracted the album-controls block into a Svelte 5 snippet
  `albumControls(alphaGroups)` declared at the top of the library-view
  template. The snippet body references the existing shared state
  (group/filter/sort/view/select); only `alphaGroups` differs per source.
- Extracted the body of `filteredAndGroupedAlbums` into a helper
  `buildFilteredAndGroupedAlbums(source)` and added a parallel
  `filteredAndGroupedMetadataAlbums` derived for the Albums tab.
- Generalized album-selection state: `currentAlbumsSource` switches
  between `albums` and `metadataAlbums` based on activeTab; Select All
  and the keyboard shortcut now operate on the active list. Bulk action
  handlers look up album IDs across both lists (the two ID spaces don't
  overlap) so playlists/queues/mixtapes work from either tab.
- Moved the album BulkActionBar out of the Folders branch so it renders
  once for either tab.
- handleTabChange clears in-flight album selection when crossing tabs.
- metadataAlbums state declarations moved up to live next to `albums`
  because the new selection derivations reference them earlier in scope.

cc
2026-05-06 18:10:04 -06:00
vicrodh 9130bdc913 refactor(library): relocate tab order editor into folder management toolbar
The gear icon mounted next to the tab buttons inside .jump-links was
visually noisy and overloaded a UX area meant for navigation. Moved it
into the folder-actions toolbar of the Library Settings panel, alongside
the existing folder management icon-btns (FolderPlus, PenLine, Trash2),
where ordering controls sit naturally. Swapped the icon from Settings
(generic) to ListOrdered (semantically a list-ordering action).

Removed the orphaned .jump-link.tab-edit-btn CSS rule.

cc
2026-05-06 18:01:06 -06:00
vicrodh fa38c8a552 fix(library): trigger active tab loader after preferences settle on mount
The visible-tabs rework moved tab order behind LibraryPreferences, so the
initial activeTab can be any of folders/albums/artists/tracks. Mount only
called loadLibraryData (folders + stats), leaving Tracks/Artists/Albums
empty until the user manually clicked a different tab and back.

Extracted the lazy-load switch from handleTabChange into
ensureActiveTabDataLoaded() and call it from both handleTabChange and
onMount once preferences (and therefore activeTab) have settled. Folders
needs no branch because loadLibraryData populates it.

cc
2026-05-06 17:59:20 -06:00
vicrodh 2b8e1a66e1 Merge branch 'feature/internal/local-library-tab-order' into pre-release
Includes Phase 2 (rename Albums to Folders + per-user tab order
preferences) and Phase 3 (new metadata-grouped Albums view + V2
commands + frontend wiring) of the Local Library design.

cc
2026-05-06 17:35:08 -06:00
vicrodh 8426783990 Merge branch 'bugfix/internal/local-library-artwork-per-track' into pre-release
cc
2026-05-06 17:35:08 -06:00
vicrodh 863e5dc86f feat(local-library): add metadata-grouped Albums tab
Wires the new Albums tab in LocalLibraryView via the metadata-grouped
V2 commands. Default tab order in LibraryPreferences now includes
'albums' between 'folders' and 'artists'; existing users get the new
slot via sanitizeLibraryPreferences's backfill of missing default tabs.

LocalAlbum interface gains the optional source_folders field exposed by
v2_library_get_albums_metadata. fetchAlbumTracks branches on the album
record's source_folders presence: metadata rows fetch via
v2_library_get_album_tracks_metadata, folder rows keep using
v2_library_get_album_tracks. No separate viewMode plumbing is needed
because the discriminator travels on the row itself.

The Albums tab renders through the same VirtualizedAlbumList component
as Folders (single ungrouped group, no controls in this initial pass),
loaded lazily on first visit via loadMetadataAlbums. Cache invalidates
on every loadLibraryData, post-scan, and library-clear so a re-scan
surfaces fresh metadata grouping.

cc
2026-05-06 17:27:40 -06:00
vicrodh bf02556837 feat(commands_v2): expose metadata-grouped Local Library album queries
v2_library_get_albums_metadata and v2_library_get_album_tracks_metadata
mirror the existing folder-grouped commands but call the new
get_albums_metadata_grouped and get_album_tracks_metadata. Frontend
wiring lands in the next commit.

cc
2026-05-06 17:16:28 -06:00
vicrodh 54074a5580 feat(library): add metadata-grouped album queries
New album_grouping module exports the SQL CASE-WHEN expression for the
metadata group key shared by both new queries. The expression has three
priorities: (1) usable album tag => album|artist key, (2) fallback to
existing folder-based album_group_key, (3) orphan bucket
'__unknown_album__'.

get_albums_metadata_grouped runs the grouped query and returns
LocalAlbum rows with directory_path empty and source_folders populated
with the comma-separated list of contributing folders. Pinned 'Unknown
Album' to the bottom via ORDER BY.

get_album_tracks_metadata fetches all tracks belonging to a metadata
group, ordered by disc/track number.

Adds idx_local_tracks_album_lookup index on (album, album_artist,
artist) to keep the GROUP BY index-backed at 16k+ track libraries.

LocalAlbum gains an optional source_folders field (None for folder-
grouped rows; Some(comma-separated) for metadata-grouped rows). The
existing folder-grouped query continues to populate it as None so no
downstream consumer breaks.

Hidden filter (album_settings.hidden) does not apply to metadata-
grouped rows in this iteration; revisiting requires extending
album_settings to support metadata keys.

cc
2026-05-06 17:10:51 -06:00
vicrodh 1a5c9b81ce feat(local-library): rename Albums tab to Folders, add tab order modal
Frontend half of Phase 2: rename the existing 'Albums' tab (which has
always shown folder-grouped data) to 'Folders' so the label matches
the behavior. NorinB filed issue #380 because of this discrepancy.

Wires LocalLibraryView to the new per-user library_preferences backend
(landed in the previous commit). LibraryEditModal is a clone of
FavoritesEditModal trimmed to the Library prefs scope (tab_order +
hidden_tabs only).

Tabs render in the user-defined order, hidden tabs are skipped. Active
tab on session start is the first visible tab. Default order matches
the current tab list with 'folders' in place of the old 'albums';
Phase 3 will add the new metadata-grouped 'albums' to the default.

i18n updated in 5 locales: new library.folders key + library.editTabs
block. Existing 'Library Folders' settings header moved to the new
library.folderListTitle key to free up library.folders for the tab
label.

cc
2026-05-06 16:57:38 -06:00
vicrodh a5ab9965d0 feat(library): add per-user Library tab preferences store
Mirrors the FavoritesPreferences pattern so the Local Library can have
a user-configurable tab order and hidden-tabs list, persisted per user
in library_preferences.db. Adds the LibraryPreferences struct, the
single-row SQLite table, the LibraryPreferencesState lifecycle, and
the V2 get/save commands.

Default order matches the current LocalLibraryView tab list with the
renamed 'folders' tab in place of the old 'albums' tab. Phase 3 will
add 'albums' (the new metadata-grouped view) to this default.

Frontend wiring lands in the next commit on this branch.

cc
2026-05-06 16:50:27 -06:00
vicrodh 523cce46fd fix(library): apply per-track artwork fix to second scan loop, suppress legitimate users
A code review of the previous commit surfaced a second scan loop in
legacy_compat.rs that had the same destructive update_album_group_artwork
pattern. Apply the same fix: per-folder cache + drop the destructive
call. Same intent and shape as the main loop fix.

The deprecated marker also surfaced three callers that are NOT bugs
and stay as-is, with #[allow(deprecated)] + a comment to make the
intent explicit:
- CUE ingestion: a CUE sheet is one physical album, so a single cover
  for all CUE tracks is semantically correct.
- v2_library_set_album_artwork: user-initiated set-cover-for-album, by
  design propagates to all tracks.
- Discogs backfill: only fires for albums with no existing artwork, so
  there is nothing per-track to destroy.

cc
2026-05-06 16:38:14 -06:00
vicrodh 7eba2749f5 fix(library): preserve per-track artwork during scan, cache folder lookups
The scan loop called update_album_group_artwork after every successful
track insert, which propagated one track's artwork to every track in
the same group. Tracks with unique embedded covers ended up sharing
whichever cover was processed last. Drop the call; per-track artwork
is resolved correctly by extract_artwork (embedded) + find_folder_artwork
(cover.jpg fallback) before insert_track.

Replace the propagation's caching effect with an in-memory per-folder
HashMap that memoizes find_folder_artwork for the duration of the scan
run, avoiding repeated folder walks for tracks without embedded art.

Mark update_album_group_artwork #[deprecated] so no future caller
reintroduces the bug. Keep it compilable.

Existing libraries already have collapsed artwork paths in the DB and
need a re-scan to recover per-track covers; called out in release notes.

cc
2026-05-06 16:32:27 -06:00
vicrodh 74289fb682 Merge branch 'feature/internal/qconnect-honor-peer-seek-on-local-renderer' into pre-release
cc
2026-05-06 14:21:56 -06:00
vicrodh 6afbc94171 fix(qconnect): honor peer-controller seeks when qbz is the active renderer
Fixes #387: seeks issued from the official Qobuz mobile app while qbz
acts as the active renderer were silently dropped — audio kept playing
from the original position while the controller's progress bar locked.

Two independent gates were swallowing the command between the
WebSocket and the audio thread; either alone is enough to break the
flow, so both move together.

1. Upstream filter (crates/qconnect-app/src/app.rs)

   The is_echo guard treated every SET_STATE with playing_state=None
   AND current_track=None as a pure server echo and skipped emitting
   RendererCommandApplied. iOS sends a real seek as exactly that
   shape (only current_position_ms set, the rest unchanged), so the
   command never reached the bridge handler.

   Add current_position_ms.is_none() to the guard. Pure echoes still
   match (server echoes carry only next_track); position-only seeks
   pass through.

2. Downstream gate (src-tauri/src/qconnect/corebridge.rs)

   The seek branch was conditioned on peer_renderer_active — i.e. it
   only acted when qbz was the controller observing a peer renderer,
   never when qbz was the renderer itself. Removed; the existing
   is_echo_reset and abs_diff > 2 checks already filter the redundant-
   seek case the gate was originally added to defend against (147bcbd7).
   Drop the now-unused is_peer_renderer_active import.

Verified manually: seeks from iPhone (renderer_id=3) targeting qbz
(renderer_id=2) at ~1/4 and ~5/6 of a 150s track now translate to
local audio jumps to the correct positions.

cc
2026-05-06 14:21:27 -06:00
vicrodh 86e22bf886 Merge branch 'feature/internal/seekbar-uniform-poll-cadence' into pre-release
cc
2026-05-06 12:51:32 -06:00
vicrodh 1e16ec52f5 fix(playback): poll player state at uniform 250ms cadence
The previous adaptive scheme dropped to 5s when idle and 1s when
paused-with-track. PLAYBACK_STATE_WAKEUP catches synchronous V2
mutations (pause/resume/stop/seek) instantly, but play_data() is
asynchronous: it queues an AudioCommand::Play over a channel and
returns. The audio thread sets is_playing/start_playback_timer only
after decoder + device init (500-2000ms), so the wakeup fires too
early — the loop reads stale state, decides 'idle' or 'paused', and
sleeps for the full long branch before catching the actual transition.

current_position() is wall-clock based (now - playback_start_millis),
so by the time the next idle tick arrives, position is already past
second 1 and the seekbar appears to jump straight to 2+.

Polling uniformly at 250ms catches the async transition within one
cadence and keeps the seekbar showing 0:00 -> 0:01 -> 0:02 from the
start. Cost is negligible (~10 atomic reads x 4 Hz), and should_emit
filters every no-change iteration so the frontend wire is unaffected.

cc
2026-05-06 12:34:01 -06:00
vicrodh b0716962e0 Merge branch 'feature/internal/seekbar-cold-start-latency' into pre-release
cc
2026-05-06 12:26:11 -06:00
vicrodh 8288350559 feat(playback): wake state polling loop on V2 playback mutations
The background task in lib.rs that emits playback:state to the frontend
sleeps adaptively: 250ms while playing, 1s when paused-with-track, and
5s when idle. The 5s idle branch leaves the seekbar blank for several
seconds on cold start because the loop only reads new state — and only
then emits — after the sleep ends, even though audio is already playing.

Add a tokio::sync::Notify (PLAYBACK_STATE_WAKEUP) shared via the
existing commands_v2::helpers module. Race the sleep against
PLAYBACK_STATE_WAKEUP.notified() with tokio::select. Each V2 command
that mutates playback state (play_track, pause, resume, stop, seek)
calls notify_one after the underlying bridge call succeeds, so the
loop wakes within milliseconds and emits the new state immediately.

notify_one stores up to one permit when no waiter is parked, so a
notification fired between iterations is delivered on the next select.

Make commands_v2::helpers a pub(crate) module so the static is
reachable from lib.rs and the V2 command modules.

cc
2026-05-06 11:42:21 -06:00
vicrodh 0aa923e32a Merge branch 'feature/internal/offline-cache-manager' into pre-release
cc
2026-05-06 10:49:52 -06:00
vicrodh 534c81016d feat(offline_cache_manager): cache size limit modal
Adds a pencil icon next to the usage bar in the manager's stats header.
Click opens a Modal (shared Modal.svelte) with a number input bound to
the current limit in GB plus Save / Cancel buttons. Validates >= 5 GB
client-side and surfaces a toast on success or error. Save calls
v2_set_offline_cache_limit which now persists across restarts. New
i18n keys land in all five locales (en/es/de/fr/pt).

cc
2026-05-06 10:24:55 -06:00
vicrodh 1b07036454 feat(offline_cache): enforce cache size limit on new track downloads
Pre-flight check_cache_limit reads the current total_size_bytes and
returns an informative error if the cache is already at or over the
configured limit. Wired into v2_cache_track_for_offline (single) and
v2_cache_tracks_batch_for_offline (batch). Re-download paths are not
gated since they target tracks already counted toward the total. The
check intentionally does not predict the new track's size; preventing
cache from growing further once at the limit is enough for v1.

cc
2026-05-06 10:23:27 -06:00
vicrodh 362f3154ac feat(offline_cache): persist cache size limit across restarts
Adds cache_limit_bytes column to offline_settings (idempotent ALTER
TABLE) plus get/set methods on the OfflineState store. v2_set_offline_cache_limit
now writes the value to disk in addition to the in-memory cache_state.
At session activation, OfflineCacheState::apply_persisted_limit reads
the stored value and seeds the in-memory limit so the user's chosen cap
survives app restarts. Legacy installs with NULL persisted value keep
the in-memory 5 GB default seeded by init_at.

cc
2026-05-06 10:23:18 -06:00
vicrodh 7ca515be7e feat(offline_cache): bump default cache size limit from 2 GB to 5 GB
Hi-res FLAC tracks at 24-bit/192 kHz routinely run 60-100 MB each, so a
2 GB cap held only ~25-30 album downloads before users had to clear
space. 5 GB is the new floor for the default; users can raise it from
the manager view and the value persists across restarts (next commits).

cc
2026-05-06 10:20:50 -06:00
vicrodh e71cd71f60 feat(i18n): rename Re-download album to Re-download all tracks
The old label implied the entire album would be downloaded, but the
action only re-fetches tracks that were previously cached. Updated in
all 5 locales (en/es/de/fr/pt). The translation key stays
offlineManager.row.actions.redownloadAlbum.

cc
2026-05-06 10:19:03 -06:00
vicrodh a1b29e4f72 feat(offline_cache_manager): live progress rings on album and track rows
Replaces the static '⟳' / '…' status glyphs with the same SVG progress
ring used by DownloadButton. Album-row ring shows the average progress
across currently-downloading tracks; track-row ring tracks per-track
progressPercent. Queued state renders an indeterminate spinner
(75%-fill rotating). Same pattern, no new dependencies.

cc
2026-05-06 10:13:30 -06:00
vicrodh f72f21838e feat(offline_cache_manager): show album cover artwork in rows
Backend cache rows do not store an artwork URL, so on each fresh load we
hydrate per album_id via v2_get_album in batches of 8 with parallel
Promise.all and an in-memory cache. Failures per album are tolerated and
recorded as null so the row falls back to the placeholder. Re-rollups
triggered by progress events and remove operations re-apply the cache so
covers do not flicker on state updates.

cc
2026-05-06 10:11:33 -06:00
vicrodh 695063916f feat(offline_cache_manager): expand albums by default
Auto-expand every album's track list on each rollup so the user sees
per-track status (size, badges, action menus) without needing to click
each row open. The set is sticky for the session — collapsing an album
manually persists until the next loadAll, and a fresh load re-expands.

cc
2026-05-06 10:08:43 -06:00
vicrodh 23995067a9 fix(offline_cache_manager): correct fully-cached batch response shape
v2_check_albums_fully_cached_batch returns a HashMap<String, bool> which
serializes as a JSON object, not an array of tuples. The previous typing
made new Map(result) silently throw with object-is-not-iterable, which
aborted loadAll before buildRollup ran and forced the empty state on
every load. Use Record<string, boolean> + Object.entries instead, and
log loadAll errors so future shape mismatches do not fail silently.

cc
2026-05-06 10:06:25 -06:00
vicrodh 17452f5691 feat(settings): replace Open folder button with Manage offline cache navigation
Repoints the handler from v2_open_offline_cache_folder to navigateTo('offline-manager').
The encrypted CMAF bundle layout makes the folder content meaningless to
users; the new in-app manager is the correct affordance for free-up-space
and per-album/per-track operations.

cc
2026-05-06 08:19:53 -06:00
vicrodh ad0ae8cb0e feat(routing): add offline-manager view branch and exclude from last_view persistence
Wires the new OfflineCacheManagerView into +page.svelte's view switch with
onBack returning to settings, onGoToAlbum delegating to handleAlbumClick,
and onGoToFavorites returning to the user's last favorites tab. Adds
'offline-manager' to the ViewType union so the new branch type-checks.

Excludes 'offline-manager' from last_view persistence by routing it through
getSessionFallbackView('offline-manager') -> 'settings' (its entry point),
guarding against Phantom CSS Error Cause 3 on rehydration when the cache DB
is not yet ready at first paint.

cc
2026-05-06 08:17:13 -06:00
vicrodh 41ca8ea65b feat(views): polish empty state CTA in offline cache manager
Adds Go to Favorites button wired to the onGoToFavorites prop. Removes
the eslint suppression now that all three navigation props are used.

cc
2026-05-06 08:05:43 -06:00
vicrodh c4fe11aa71 feat(views): add album rows with expand and per-track actions to manager
Album rows show cover placeholder, title/artist, cached ratio, dominant
quality, size, and status badge. Menu actions: re-download album, retry
failed (visible only when applicable), remove from offline (with ask()
confirm), go to album. Expanded rows show per-track actions
(re-download, remove). Singles pseudo-album omits redownload-album and
go-to-album; remove iterates per-track.

cc
2026-05-06 08:03:38 -06:00
vicrodh 026e654295 feat(views): add alpha-index artist rail to offline cache manager
Rail groups artists by leading letter with sticky headers. Horizontal
alphabet bar above scrolls the rail to the chosen letter. Inactive
letters dimmed.

cc
2026-05-06 07:59:42 -06:00
vicrodh b4b4b050d8 feat(views): add offline cache manager shell with header and stats
Header + stats section with usage bar, sort dropdown, and Show only failed
toggle. Loading and empty states are placeholders for the next tasks
(left rail in P6.2, right pane in P6.3, empty CTA in P6.4).

cc
2026-05-06 07:57:11 -06:00
vicrodh 6807259813 feat(stores): wire reactive state and V2 invokes for offline cache manager
Adds the runtime API: loadAll, subscribeToProgress, removeAlbum,
redownloadAlbum, redownloadTrack, removeTrack, selectArtist,
toggleExpand, setSort, setShowOnlyFailed. Reuses buildRollup on every
mutation so derived ArtistGroup state stays consistent.

Subscribes to four downloader events: caching_started, caching_progress,
caching_processed (the canonical Ready signal), and caching_failed. The
intermediate caching_completed event is intentionally ignored since
caching_processed already covers post-processing completion.

Renamed the file to offlineCacheManagerStore.svelte.ts because Svelte 5
runes ($state, etc.) are only legal inside .svelte / .svelte.ts /
.svelte.js modules. Updated the vitest import in the sibling .test.ts
to match the new path.

cc
2026-05-06 07:53:10 -06:00
vicrodh 4f624e038d feat(stores): add offlineCacheManagerStore types and buildRollup pure function
Pure function maps flat CachedTrackInfo[] into ArtistGroup[] with album
sub-groups, status rollup, quality dominance, and Singles bucket for
albumId-less tracks. Covered by vitest with 7 cases.

cc
2026-05-06 07:48:33 -06:00