- Add v2_save_session_state and v2_load_session_state commands
- Update favoritesStore to use V2 cache commands
- Update albumFavoritesStore to use V2 cache commands
- Update artistFavoritesStore to use V2 cache commands
- Update sessionService to use V2 session commands
- Update playbackContextStore to use V2 context commands
Previously, V2 queue commands had a dual-queue bug:
- Writes (v2_set_queue, v2_add_to_queue, etc.) went to AppState.queue (legacy)
- Reads (v2_get_queue_state) came from CoreBridge/QbzCore queue
- Result: frontend sets queue, syncs, gets empty/stale data
This commit fixes the architecture:
- All V2 queue commands now use CoreBridge methods
- Added queue methods to QbzCore: add_track, add_tracks, add_track_next,
set_queue, remove_track, remove_upcoming_track, move_track, play_index,
next_track, previous_track, peek_upcoming
- Added corresponding methods to CoreBridge
- Fixed v2_set_shuffle to use CoreBridge (was using legacy AppState)
- Fixed runtime requirements: v2_toggle_shuffle and v2_clear_queue now
use RequiresUserSession like other queue commands (consistency)
- Prefetch now gets upcoming tracks from CoreBridge, not legacy queue
- Updated tests to match V2 behavior (v2_toggle_shuffle, available field)
- HomeView: fix OfflineCacheStatus type for getTrackOfflineCacheStatus prop
- PlaylistDetailView: fix trackToReplace null access in console.log
- SearchView: add id and isViewMore to Album/Artist interfaces
- Toast: add 'warning' type support
- playbackContextStore: add 'search' to ContextType union
- queueStore: add trackId to QueueTrack interface
- trackActions: add queueDisplayTrackNext/Later and buildQueueTrackFromDisplayTrack
- +page.svelte: fix numerous type issues including:
- selectedAlbum closure captures for TypeScript narrowing
- handleDisplayTrackDownload signature for DisplayTrack
- handleSearchTrackDownload for SearchView's Track type
- ImportSummary callback signature
- QobuzTrack hires_streamable property usage
- album.tracks.items instead of .data
npm run check now passes with 0 errors (138 warnings remain, mostly a11y)
- SearchView.svelte: Fix async onMount pattern to properly return cleanup
- vite.config.js: Add ts-nocheck to suppress Node.js global errors
Reduces npm run check errors from 42 to 40.
ListenBrainzV2State::clear_credentials() now resets internal client to
fresh state, not just wrapper fields.
LastFmV2State:
- Added clear_session() method that clears session_key AND pending_token
- init_with_session(None) now calls clear_session() instead of no-op
Ensures no credentials leak across sessions on logout/deactivate.
Closes Must-Fix #2 from MUST_FIX_BEFORE_RELEASE_RUNTIME_V2.md
Added rollback_auth_state() helper that clears legacy_auth, corebridge_auth,
and emits AuthChanged event on partial login failures.
Applied to all error paths in v2_auto_login, v2_manual_login, and v2_login:
- CoreBridge auth failure now rolls back
- Session activation failure now rolls back
Ensures runtime_get_status never reports half-authenticated state.
Closes Must-Fix #1 from MUST_FIX_BEFORE_RELEASE_RUNTIME_V2.md
V2 ListenBrainz now_playing and scrobble commands now accept optional
MusicBrainz identifiers (recording_mbid, release_mbid, artist_mbids),
ISRC, and duration_ms parameters for richer scrobbles.
The AdditionalInfo struct is populated when any metadata is provided,
automatically including QBZ media player identification.
Integrates ListenBrainzV2State, MusicBrainzV2State, and LastFmV2State
from qbz-integrations crate into the session activation/deactivation
lifecycle.
In activate_session:
- After legacy integrations init (which loads from SQLite), sync
credentials to V2 states
- ListenBrainz V2: gets token, user_name, enabled from legacy client
- MusicBrainz V2: gets enabled state (use_proxy defaults to true)
- LastFm V2: initialized to clean state (no legacy equivalent)
In deactivate_session:
- Clear V2 state credentials to prevent cross-user leaks
- Reset states to defaults
This ensures V2 commands (using qbz-integrations crate) have access
to the same credentials as legacy commands, enabling a smooth
migration path.
Add centralized require_tos_accepted() helper function that checks
ToS acceptance before any authentication attempt. This prevents
non-UI clients (TUI/CLI/tests) from bypassing the ToS gate.
Affected commands:
- v2_auto_login: Returns tos_not_accepted error code
- v2_manual_login: Returns tos_not_accepted error code
- v2_login: Returns RuntimeError::Internal
The ToS check was already in runtime_bootstrap, but these commands
could be called directly. Now the gate is enforced at the backend
level regardless of entry point.
Also updates obsolete comment about frontend handling ToS.
Fixes login consistency issues:
1. ToS gate enforcement:
- LegalSettingsState now initialized GLOBALLY at app startup (not per-session)
- runtime_bootstrap checks ToS BEFORE attempting auto-login
- If ToS not accepted, skip auto-login and return to login screen
2. Session activation severity parity:
- runtime_bootstrap now treats activate_session failure as FATAL
- On failure: rollback auth state, set degraded, return error
- Matches behavior of v2_auto_login/v2_manual_login
3. LegalSettings is now truly global:
- Removed from session_lifecycle activate/deactivate
- ToS acceptance persists across sessions
- Can be checked before user is logged in
Acceptance criteria:
- ToS false + credentials -> no auto-login
- ToS true + credentials + activation OK -> session restored
- ToS true + credentials + activation fails -> error, no session
Extract casting functionality (Chromecast, AirPlay, DLNA) to standalone
qbz-cast crate. This crate is Tauri-agnostic and can be used by TUI/CLI
clients.
- Move device connection, discovery, threading, and media server to crate
- Keep only Tauri commands in src-tauri/src/cast/
- Thin re-exports in src-tauri for backwards compatibility
- Remove duplicate dependencies from src-tauri Cargo.toml
Backend:
- v2_auto_login/v2_manual_login now FAIL if activate_session fails
(was: log and continue with success:true, causing "logged in but not ready")
- Session activation is now REQUIRED, not optional
Frontend:
- Remove duplicate activate_user_session call from handleLoginSuccess
(V2 login already activates session internally)
- Remove duplicate deactivate_user_session call from handleLogout
(v2_logout already deactivates session internally)
- LoginView now uses runtime_bootstrap as SINGLE SOURCE OF TRUTH
(was: v2_init_client + legacy is_logged_in/get_user_info checks)
- PlaylistDetailView uses runtime_get_status for user_id
(was: legacy get_current_user_id)
This eliminates the "double-brain" where frontend used both legacy
and V2 paths, causing state divergence and intermittent failures.
Create qbz-library crate with:
- LibraryScanner: directory scanning for audio files
- MetadataExtractor: audio metadata extraction via lofty
- LibraryDatabase: SQLite persistence with WAL mode
- CueParser: CUE sheet parsing for single-file albums
- Thumbnails: artwork extraction and thumbnail generation
- Tag sidecar: album metadata override files
src-tauri re-exports from qbz-library for backwards compatibility.
Enables TUI/headless clients to manage local libraries without Tauri.
Create qbz-cache crate with:
- AudioCache: L1 in-memory LRU cache (~300MB)
- PlaybackCache: L2 disk-based cache (~500MB)
- LRU eviction with spillover from L1 to L2
src-tauri now re-exports from qbz-cache for backwards compatibility.
This enables TUI/headless clients to use caching without Tauri.
Convert queue commands (16) and playback commands (10) from String
errors to typed RuntimeError:
- Queue: get_queue_state, set_repeat_mode, toggle_shuffle, etc.
- Playback: pause, resume, stop, seek, volume, get_state, etc.
Runtime checks now use direct ? propagation instead of map_err.
Bridge method errors wrapped with RuntimeError::Internal.
Wire qbz-integrations to src-tauri Cargo.toml. The crate provides
Tauri-independent implementations of Last.fm, ListenBrainz, and
MusicBrainz integrations.
Next step: Create V2 commands that use the new crate, then gradually
deprecate the existing in-tree implementations.
Replace String errors with typed RuntimeError variants across all 17
audio settings V2 commands for consistent error handling:
- Lock errors: RuntimeError::Internal
- Session not active: RuntimeError::UserSessionNotActivated
- Store errors: RuntimeError::Internal
This aligns with the runtime contract (ADR_RUNTIME_SESSION_CONTRACT.md)
for typed errors that clients can pattern match.
Addresses multiple review findings for V2 architecture:
1. Create session_lifecycle.rs module:
- activate_session(): Full session activation callable from anywhere
- deactivate_session(): Full teardown with proper runtime state cleanup
- activate_offline_session(): Minimal session for offline/local-only use
2. Make runtime_bootstrap autocontenido:
- Now activates session after successful auth (Step 4)
- No longer delegates to frontend for session activation
3. Fix v2_login to be canonical:
- Performs full flow: legacy auth -> corebridge auth -> session activation
- Updates all runtime state flags
4. Fix v2_logout to be canonical:
- Calls deactivate_session (teardown stores + clear runtime state)
- Proper cleanup of legacy and corebridge auth
5. Fix deactivate_session:
- Now clears session_activated flag (was missing)
- Now clears corebridge_auth flag (was missing)
- Emits UserSessionDeactivated event
6. Add v2_set_repeat_mode runtime check:
- Now requires RequiresUserSession like other queue mutations
7. Fix LoginView early session activation:
- Removed premature activate_user_session call before auto-login confirmed
- ToS check uses localStorage fallback if no session
8. Fix offline mode:
- Add v2_activate_offline_session command
- Offline mode now activates minimal session so queue commands work