Files
qbz/crates/qbz-slint/src/commands.rs
T
vicrodh d5be0029b6 feat(qbz-slint): foundation tokens and login screen
M1 progress. Adds the foundation token layer (palette, semantic
colors, spacing, radius, typography) bound to the QBZ dark theme,
three primitives (QbzCheckbox, QbzPrimaryButton, QbzTextLink), and
the LoginScreen feature component.

The login screen mirrors the Svelte LoginView: centered card, logo,
QBZ wordmark, Qobuz ToS checkbox, "Sign in via Browser" button,
system-browser and offline links, and the legal disclaimer. Colors
are lifted verbatim from src/app.css; strings use @tr() markers.

Rust side: typed AppCommand enum; UI callbacks dispatch through it.
M2 wires the command handler to AppRuntime.

cc
2026-05-18 12:13:52 -06:00

53 lines
1.8 KiB
Rust

//! Typed command vocabulary for the Slint POC.
//!
//! Slint UI callbacks carry no payload and no behavior. The Rust layer
//! maps each callback to one of these typed commands. In M2 the command
//! handler is wired to `AppRuntime`; for now it logs, which proves the
//! `Slint callback -> typed command -> Rust` path the POC ADR (section 8)
//! requires.
/// Commands the login screen can emit.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AppCommand {
/// Begin OAuth sign-in. Per the 2026-05-18 decision the POC uses the
/// external system-browser flow only (no in-app webview).
SignInViaBrowser,
/// Explicitly use the system browser for OAuth.
UseSystemBrowser,
/// Start an offline-only session with no Qobuz access.
StartOffline,
/// Open the Qobuz Terms of Service in the system browser.
OpenTermsOfService,
}
impl AppCommand {
/// Stable identifier, used for logging and later instrumentation.
pub fn id(&self) -> &'static str {
match self {
Self::SignInViaBrowser => "sign_in_via_browser",
Self::UseSystemBrowser => "use_system_browser",
Self::StartOffline => "start_offline",
Self::OpenTermsOfService => "open_terms_of_service",
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn command_ids_are_distinct_and_stable() {
let all = [
AppCommand::SignInViaBrowser,
AppCommand::UseSystemBrowser,
AppCommand::StartOffline,
AppCommand::OpenTermsOfService,
];
let ids: Vec<&str> = all.iter().map(AppCommand::id).collect();
assert_eq!(ids.len(), 4);
let unique: std::collections::HashSet<&str> = ids.iter().copied().collect();
assert_eq!(unique.len(), 4, "command ids must be unique");
}
}