Files
Lumotia/src-tauri/src/commands/onboarding.rs
Jake 3770815fbf
Some checks failed
check / cargo check (macos-latest) (push) Has been cancelled
check / cargo check (ubuntu-22.04) (push) Has been cancelled
check / cargo check (windows-latest) (push) Has been cancelled
check / svelte build + lint (push) Has been cancelled
agent: lumotia — v0.1 release-completion run
Closes the code-side v0.1 ship gate. All quality gates green:
cargo fmt/clippy/test (~327 tests), npm check (0/0), vitest 13/13,
scripts/dogfood-rebrand-drill.sh 8/8.

Phase F — first-run onboarding promoted to v0.1
- FirstRunPage with skip-to-main + failure recovery + event recording
- Six onboarding commands (record/list/has-completed + lumotia_events)
- Storage migration v17 (onboarding_events + lumotia_events tables)

UI hardening (in-scope items from v0.1-ui-hardening.md)
- StatusPill + PostCaptureCard components, 21st preview entry
- Sidebar recording-as-sacred-state (opacity + aria-disabled, reduced-motion)
- Settings 6-section regroup + Help section + Activation log + Privacy toggle
- Error-state copy sweep (DictationPage + SettingsPage, plain-language)
- Global :focus-visible rule, textarea outlines restored
- Ctrl+K / Ctrl+, / Escape bindings in +layout

LLM resilience
- rule_based_extract_tasks (regex-free imperative-verb extractor) +
  extract_tasks_with_fallback wrapper — task extraction never returns zero
- tokio::time::timeout(120s) wraps cleanup/tags/tasks commands

Release artefacts
- LICENSE (canonical AGPL-3.0), CHANGELOG (Keep-a-Changelog format)
- v0.1-release-notes, privacy-and-ai-use, install-warnings,
  tester-onboarding-kit, tester-acceptance-runbook, code-signing-setup,
  apple-silicon-rb08-runbook, virtual-audio-setup, v0.1-contrast-audit
- Workspace versioning + AGPL spdx; npm exact-pin (10 ranges removed)
- AppImage SHA-256 sidecar in build.yml
- README v0.1 section + Reporting-issues; canonical repo slug

Closure pass — items moved from human-required to code-complete
- KI-02 Linux idle inhibit: zbus 5 → org.freedesktop.login1.Manager.Inhibit
- KI-03 Windows sleep prevention: SetThreadExecutionState(ES_CONTINUOUS|...)
- acquire/release_idle_inhibit Tauri commands, wired in DictationPage
- Diagnostic-bundle frontend wire-up (Settings → Help button)
- WCAG-AA contrast fix via .btn-filled-text utility (no token changes)
- 8 destructive-action sites wrapped in plain-language confirm() guards
- KNOWN-ISSUES.md + v0.1-known-limitations.md updated (KI-02/03 fixed)

Scripts
- pre-tag-verify.sh, tag-day.sh, smoke-linux + driver
- parse-diagnostic-bundle.sh, parse-activation-log.py

Per-item audit trail: docs/release/v0.1-completion-status.md
Remaining: W-01…W-08 (signing certs, hardware probes, smoke matrix,
tester recruitment) — see docs/release/v0.1-known-limitations.md.
2026-05-15 06:59:08 +01:00

98 lines
3.2 KiB
Rust

// Tauri commands for onboarding flow + opt-in activation log.
//
// These are thin adapters over the storage helpers — no business logic lives
// here. Every sqlx::Error is mapped to a String so Tauri can serialise it
// to the frontend as a rejected Promise.
use std::time::{SystemTime, UNIX_EPOCH};
use lumotia_storage::{
clear_lumotia_events as db_clear_lumotia_events,
has_completed_onboarding as db_has_completed_onboarding,
insert_lumotia_event as db_insert_lumotia_event,
insert_onboarding_event as db_insert_onboarding_event,
list_lumotia_events as db_list_lumotia_events,
list_onboarding_events as db_list_onboarding_events, LumotiaEventRow, OnboardingEventRow,
};
use crate::AppState;
/// Record a single onboarding step.
///
/// `event` — short snake_case identifier, e.g. `"started"`, `"completed"`, `"skipped"`.
/// `version` — app version string, e.g. `"0.1.0"`.
/// `skipped` — `true` if the user bypassed this step.
/// `notes` — optional freeform annotation.
#[tauri::command]
pub async fn record_onboarding_event(
state: tauri::State<'_, AppState>,
event: String,
version: String,
skipped: bool,
notes: Option<String>,
) -> Result<(), String> {
let now = SystemTime::now()
.duration_since(UNIX_EPOCH)
.map(|d| d.as_secs() as i64)
.unwrap_or(0);
db_insert_onboarding_event(&state.db, &event, &version, skipped, notes.as_deref(), now)
.await
.map_err(|e| e.to_string())
}
/// List all recorded onboarding events, oldest first.
#[tauri::command]
pub async fn list_onboarding_events(
state: tauri::State<'_, AppState>,
) -> Result<Vec<OnboardingEventRow>, String> {
db_list_onboarding_events(&state.db)
.await
.map_err(|e| e.to_string())
}
/// Returns `true` if the user has ever recorded a `completed` or `skipped`
/// onboarding event — i.e. first-run onboarding should not be shown again.
#[tauri::command]
pub async fn has_completed_onboarding(state: tauri::State<'_, AppState>) -> Result<bool, String> {
db_has_completed_onboarding(&state.db)
.await
.map_err(|e| e.to_string())
}
/// Append a single entry to the opt-in local activation log.
///
/// `kind` — event kind, e.g. `"app_launched"`, `"recording_started"`.
/// `payload` — optional JSON blob with event-specific context.
#[tauri::command]
pub async fn record_lumotia_event(
state: tauri::State<'_, AppState>,
kind: String,
payload: Option<String>,
) -> Result<(), String> {
let now = SystemTime::now()
.duration_since(UNIX_EPOCH)
.map(|d| d.as_secs() as i64)
.unwrap_or(0);
db_insert_lumotia_event(&state.db, &kind, payload.as_deref(), now)
.await
.map_err(|e| e.to_string())
}
/// List all activation log events, oldest first.
#[tauri::command]
pub async fn list_lumotia_events(
state: tauri::State<'_, AppState>,
) -> Result<Vec<LumotiaEventRow>, String> {
db_list_lumotia_events(&state.db)
.await
.map_err(|e| e.to_string())
}
/// Delete all rows from the activation log.
#[tauri::command]
pub async fn clear_lumotia_events(state: tauri::State<'_, AppState>) -> Result<(), String> {
db_clear_lumotia_events(&state.db)
.await
.map_err(|e| e.to_string())
}