From b6e56e3b4706bd0ef0f7b002522cedf7ed89c748 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Mon, 6 Jul 2026 21:47:00 -0600 Subject: [PATCH 1/2] =?UTF-8?q?feat(session):=20guest=20local-only=20profi?= =?UTF-8?q?le=20=E2=80=94=20offline=20mode=20without=20a=20prior=20login?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'Start offline' link was gated on has-previous-session and the shell backstop refused to open without a recorded user, so a user who never logged in (e.g. a purchases-only Qobuz account, #553) could not use the app at all. The link is now always visible and the offline shell falls back to the GUEST profile — user 0, the Tauri-era fallback this port used to refuse — building a real per-user store set (local library, mixtapes, prefs) under users/0. AppRuntime::activate_offline already resolved user 0 and never persists it as the last-user marker, so the guest never masquerades as a real session. First real login takes possession: AppRuntime::activate renames the users/0 data+cache dirs to the account's id when that account has no profile on this machine yet (existing profiles always win — the guest dirs stay parked, no merge). Best-effort, login never breaks on a failed rename. cc --- crates/qbz-app/src/shell.rs | 40 ++++++++++++++++++++++++ crates/qbz-app/src/user_data.rs | 17 ++++++++++ crates/qbz-ui/ui/login/LoginScreen.slint | 5 ++- crates/qbz/src/main.rs | 19 +++++++---- 4 files changed, 74 insertions(+), 7 deletions(-) diff --git a/crates/qbz-app/src/shell.rs b/crates/qbz-app/src/shell.rs index 4abf82938..31ca79198 100644 --- a/crates/qbz-app/src/shell.rs +++ b/crates/qbz-app/src/shell.rs @@ -193,6 +193,7 @@ impl AppRuntime { /// activates against them, and persists the last-user marker so the /// session can be restored on the next launch. pub async fn activate(&self, user_id: u64) -> Result<(), String> { + Self::adopt_guest_profile(user_id); self.user_paths.set_user(user_id); let data_dir = self.user_paths.user_data_dir()?; let cache_dir = self.user_paths.user_cache_dir()?; @@ -201,6 +202,45 @@ impl AppRuntime { Ok(()) } + /// First real login takes possession of the guest profile (#553): data + /// built while logged off (local library, mixtapes, per-user prefs — + /// `users/0/`) is renamed to this account IF the account has no profile + /// on this machine yet. An existing profile always wins — the guest + /// dirs then stay parked at user 0, no merge is attempted. Best-effort: + /// a failed rename logs and falls through to a fresh profile; login + /// must never break here. + fn adopt_guest_profile(user_id: u64) { + if user_id == 0 { + return; + } + for (kind, guest, target) in [ + ( + "data", + UserDataPaths::data_dir_for(0), + UserDataPaths::data_dir_for(user_id), + ), + ( + "cache", + UserDataPaths::cache_dir_for(0), + UserDataPaths::cache_dir_for(user_id), + ), + ] { + let (Ok(guest), Ok(target)) = (guest, target) else { + continue; + }; + if guest.is_dir() && !target.exists() { + match std::fs::rename(&guest, &target) { + Ok(()) => { + log::info!("[AppRuntime] guest profile {kind} adopted by the new session") + } + Err(e) => log::warn!( + "[AppRuntime] guest profile {kind} adoption failed ({e}); starting fresh" + ), + } + } + } + } + /// Activate an offline-only session using the last known user. /// /// Falls back to user id `0` (an empty profile) when no previous session diff --git a/crates/qbz-app/src/user_data.rs b/crates/qbz-app/src/user_data.rs index 9db44d858..10d9c7b2f 100644 --- a/crates/qbz-app/src/user_data.rs +++ b/crates/qbz-app/src/user_data.rs @@ -82,6 +82,23 @@ impl UserDataPaths { Ok(base) } + /// Data directory for an ARBITRARY user id (no active-user requirement): + /// ~/.local/share/qbz/users/{uid}/ — the same layout `user_data_dir` + /// resolves for the active user. Used by the guest-profile adoption + /// (#553), which must compare two users' paths before either is active. + pub fn data_dir_for(user_id: u64) -> Result { + Ok(Self::global_data_dir()? + .join("users") + .join(user_id.to_string())) + } + + /// Cache twin of [`Self::data_dir_for`]: ~/.cache/qbz/users/{uid}/. + pub fn cache_dir_for(user_id: u64) -> Result { + Ok(Self::global_cache_dir()? + .join("users") + .join(user_id.to_string())) + } + /// Get the global (non-user-scoped) data directory: ~/.local/share/qbz/ pub fn global_data_dir() -> Result { dirs::data_dir() diff --git a/crates/qbz-ui/ui/login/LoginScreen.slint b/crates/qbz-ui/ui/login/LoginScreen.slint index 80d8eb1b5..ccc35f090 100644 --- a/crates/qbz-ui/ui/login/LoginScreen.slint +++ b/crates/qbz-ui/ui/login/LoginScreen.slint @@ -258,7 +258,10 @@ export component LoginScreen inherits Rectangle { Rectangle { height: Spacing.sm; } } - if OfflineState.has-previous-session: HorizontalLayout { + // Always visible (#553): without a previous session this + // opens the GUEST profile (user 0) — Local Library only, + // adopted by the account on the first real login. + HorizontalLayout { alignment: center; QbzTextLink { label: @tr("Start offline (no access to Qobuz™ services)"); diff --git a/crates/qbz/src/main.rs b/crates/qbz/src/main.rs index 1229e1c90..cad4e988c 100644 --- a/crates/qbz/src/main.rs +++ b/crates/qbz/src/main.rs @@ -537,12 +537,19 @@ async fn enter_shell_offline( image_cache: artwork::ImageCache, settings_ctx: Arc, ) -> Result<(), String> { - // Never open the empty user-0 profile: offline mode needs a previous - // session's data (Tauri falls back to user 0; the port refuses — the - // login UI hides the link in that case, this is the backstop). - let Some(user_id) = qbz_app::user_data::UserDataPaths::load_last_user_id() else { - return Err("no previous session — offline mode requires a prior login".to_string()); - }; + // No previous session → the GUEST profile, user 0 (#553; restores the + // Tauri fallback this port used to refuse). The guest builds a real + // per-user store set (local library, mixtapes, prefs) under users/0; + // the first successful login ADOPTS it (AppRuntime::activate renames + // users/0 to the real id when that account has no profile here yet). + // `activate_offline` below resolves the same id — 0 is never persisted + // as the last-user marker, so it never masquerades as a real session. + let user_id = qbz_app::user_data::UserDataPaths::load_last_user_id().unwrap_or(0); + if user_id == 0 { + log::info!( + "[qbz-slint] offline shell: no previous session — entering the guest profile (user 0)" + ); + } // Session scaffolding at the last user (session store, runtime state). runtime.activate_offline().await?; From a4dce34b28a45912b580d584bb84049cbbe744b1 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Mon, 6 Jul 2026 21:59:39 -0600 Subject: [PATCH 2/2] feat(ui): login disclaimer line for the guest offline mode One sentence under the subscription notice so the always-visible 'Start offline' link is self-explanatory: QBZ works as an offline player without a Qobuz account, with no access to the Qobuz library. One msgid x7 locales. cc --- crates/qbz-ui/translations/de/LC_MESSAGES/qbz-ui.po | 4 ++++ crates/qbz-ui/translations/en/LC_MESSAGES/qbz-ui.po | 4 ++++ crates/qbz-ui/translations/es/LC_MESSAGES/qbz-ui.po | 4 ++++ crates/qbz-ui/translations/fr/LC_MESSAGES/qbz-ui.po | 4 ++++ crates/qbz-ui/translations/ja/LC_MESSAGES/qbz-ui.po | 4 ++++ crates/qbz-ui/translations/pt/LC_MESSAGES/qbz-ui.po | 4 ++++ crates/qbz-ui/translations/ru/LC_MESSAGES/qbz-ui.po | 4 ++++ crates/qbz-ui/ui/login/LoginScreen.slint | 2 ++ 8 files changed, 30 insertions(+) diff --git a/crates/qbz-ui/translations/de/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/de/LC_MESSAGES/qbz-ui.po index 9b479fc1f..e26398316 100644 --- a/crates/qbz-ui/translations/de/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/de/LC_MESSAGES/qbz-ui.po @@ -4451,3 +4451,7 @@ msgstr "SONSTIGES" msgid "Border" msgstr "Rand" + +# Guest local-only mode disclaimer line (login screen, #553) +msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)." +msgstr "QBZ kann ohne Qobuz™-Konto als Offline-Player genutzt werden (kein Zugriff auf die Qobuz™-Bibliothek)." diff --git a/crates/qbz-ui/translations/en/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/en/LC_MESSAGES/qbz-ui.po index 48ba36084..cad6c8774 100644 --- a/crates/qbz-ui/translations/en/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/en/LC_MESSAGES/qbz-ui.po @@ -223,3 +223,7 @@ msgstr "Border" msgid "Favorite" msgstr "Favorite" + +# Guest local-only mode disclaimer line (login screen, #553) +msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)." +msgstr "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)." diff --git a/crates/qbz-ui/translations/es/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/es/LC_MESSAGES/qbz-ui.po index afb52f5fe..cb3784521 100644 --- a/crates/qbz-ui/translations/es/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/es/LC_MESSAGES/qbz-ui.po @@ -4481,3 +4481,7 @@ msgstr "OTROS" msgid "Border" msgstr "Borde" + +# Guest local-only mode disclaimer line (login screen, #553) +msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)." +msgstr "QBZ puede usarse como reproductor sin conexión sin una cuenta de Qobuz™ (sin acceso a la biblioteca de Qobuz™)." diff --git a/crates/qbz-ui/translations/fr/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/fr/LC_MESSAGES/qbz-ui.po index fcb59d409..214d40731 100644 --- a/crates/qbz-ui/translations/fr/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/fr/LC_MESSAGES/qbz-ui.po @@ -4451,3 +4451,7 @@ msgstr "AUTRE" msgid "Border" msgstr "Bordure" + +# Guest local-only mode disclaimer line (login screen, #553) +msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)." +msgstr "QBZ peut être utilisé comme lecteur hors ligne sans compte Qobuz™ (pas d'accès à la bibliothèque Qobuz™)." diff --git a/crates/qbz-ui/translations/ja/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/ja/LC_MESSAGES/qbz-ui.po index 7ce5750cc..cd8ce6fce 100644 --- a/crates/qbz-ui/translations/ja/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/ja/LC_MESSAGES/qbz-ui.po @@ -4440,3 +4440,7 @@ msgstr "その他" msgid "Border" msgstr "境界線" + +# Guest local-only mode disclaimer line (login screen, #553) +msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)." +msgstr "QBZはQobuz™アカウントなしでオフラインプレーヤーとして使用できます(Qobuz™ライブラリにはアクセスできません)。" diff --git a/crates/qbz-ui/translations/pt/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/pt/LC_MESSAGES/qbz-ui.po index 03f092cd0..6424ba152 100644 --- a/crates/qbz-ui/translations/pt/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/pt/LC_MESSAGES/qbz-ui.po @@ -4451,3 +4451,7 @@ msgstr "OUTROS" msgid "Border" msgstr "Borda" + +# Guest local-only mode disclaimer line (login screen, #553) +msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)." +msgstr "O QBZ pode ser usado como reprodutor offline sem conta Qobuz™ (sem acesso à biblioteca Qobuz™)." diff --git a/crates/qbz-ui/translations/ru/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/ru/LC_MESSAGES/qbz-ui.po index 05deb32f7..657b427cb 100644 --- a/crates/qbz-ui/translations/ru/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/ru/LC_MESSAGES/qbz-ui.po @@ -4464,3 +4464,7 @@ msgstr "ДРУГОЕ" msgid "Border" msgstr "Граница" + +# Guest local-only mode disclaimer line (login screen, #553) +msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)." +msgstr "QBZ можно использовать как офлайн-плеер без учётной записи Qobuz™ (без доступа к библиотеке Qobuz™)." diff --git a/crates/qbz-ui/ui/login/LoginScreen.slint b/crates/qbz-ui/ui/login/LoginScreen.slint index ccc35f090..cda2097aa 100644 --- a/crates/qbz-ui/ui/login/LoginScreen.slint +++ b/crates/qbz-ui/ui/login/LoginScreen.slint @@ -276,6 +276,8 @@ export component LoginScreen inherits Rectangle { // --- Legal disclaimer ------------------------------------ Text { text: @tr("QBZ requires an active Qobuz™ subscription. Your credentials are sent directly to Qobuz™.") + + "\n" + + @tr("QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library).") + "\n" + @tr("This application uses the Qobuz API but is not certified by Qobuz.") + " "