From 7a4ba815fe8b8a551cc4e9cedff77d81359d700a Mon Sep 17 00:00:00 2001 From: Alvin-Zilverstand <524715@vistacollege.nl> Date: Mon, 14 Sep 2026 13:00:49 +0200 Subject: [PATCH] feat: first-run onboarding wizard for privacy, capture, storage, and hotkeys --- docs/implementation-status.md | 6 +- src-tauri/src/main.rs | 40 ++++++++ src/settings.rs | 28 ++++++ ui/src/main.ts | 182 ++++++++++++++++++++++++++++++++++ ui/styles.css | 134 +++++++++++++++++++++++++ 5 files changed, 387 insertions(+), 3 deletions(-) diff --git a/docs/implementation-status.md b/docs/implementation-status.md index 0eeb2e7..4fdacab 100644 --- a/docs/implementation-status.md +++ b/docs/implementation-status.md @@ -50,6 +50,7 @@ - Auto-update checks the GitHub repo releases (`Alvin-Zilverstand/clipforge-game-clipper`) for the latest MSI/NSIS installer, compares it against the running version, downloads it to temp, launches the installer, and exits the app to finish; version comparison, asset selection, and parsing are unit tested plus one ignored live test against the GitHub API. - A GitHub Actions release workflow publishes MSI/NSIS assets on tag push; auto-update will pick up newer releases automatically once the repo ships a tag newer than the running app version. - The Settings screen shows the current version, checks for updates, and offers a Download & install button when a newer release exists. +- First-run onboarding wizard walks new installs through privacy/audio, capture-source, storage, and hotkey setup before showing the main app; it uses the defaults already saved in `settings.json` so existing users are unaffected. - Vite TypeScript UI builds and has interactive Library, Recording, Auto Clip, Uploads, and Settings views. - Library search, event/upload filters, and grid/list switching are functional in the UI. - User-visible notices are shown for major actions and failures instead of relying only on console output. @@ -61,13 +62,12 @@ - Valve GSI receiver is a lightweight MVP receiver; config templates can be generated from the Auto Clip screen. CS2 round/bomb/match-start and Dota 2 match-start/match-end transitions are mapped, but per-player kill/death/objective event detection for Dota 2 and other Source titles is still needed. - Auto start/stop is conservative but live: when auto-record is enabled, supported detected games can start recording and stop when the game disappears. - Recorder service still runs inside the Tauri process instead of a separate background service process. -- Installer onboarding is still not implemented. - Auto-update requires a GitHub release whose tag is newer than the running app version and that ships MSI/NSIS assets (the existing `v0.0.1` release carries 0.1.0 assets, so it correctly reports up to date). ## Next Engineering Steps 1. Add per-process loopback capture so individual application audio can be captured independently of the system mix. 2. Add per-player kill/death/objective event detection for Dota 2 and other Source titles beyond the current match-level transitions. -3. Add installer/onboarding screens for privacy, capture source, storage, and hotkeys. -4. Exercise the GitHub Actions release workflow with a real tag push and verify the published assets appear in a GitHub Release. +3. Exercise the GitHub Actions release workflow with a real tag push and verify the published assets appear in a GitHub Release. +4. Split the recorder service into a separate background process so capture survives app restarts. 5. Run manual QA on Windows gaming hardware and tune CPU/GPU overhead. diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 382d27f..e3c4147 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -132,6 +132,7 @@ struct DesktopStatus { game_quality_overrides: Vec, effective_quality_applied: bool, app_version: String, + onboarding_complete: bool, } #[derive(Debug, Clone, Serialize)] @@ -428,6 +429,43 @@ fn set_capture_settings( Ok(status_from_recorder(&recorder, capture.as_ref())) } +#[tauri::command] +fn finish_onboarding( + system_audio_enabled: Option, + mic_enabled: Option, + separate_audio_tracks: Option, + auto_record_enabled: Option, + replay_buffer_seconds: Option, + storage_limit_gb: Option, + runtime: State<'_, AppRuntime>, +) -> Result { + let mut recorder = runtime.recorder.lock().map_err(|error| error.to_string())?; + let capture = runtime.capture.lock().map_err(|error| error.to_string())?; + if let Some(enabled) = system_audio_enabled { + recorder.settings.privacy.system_audio_enabled = enabled; + } + if let Some(enabled) = mic_enabled { + recorder.settings.privacy.mic_enabled = enabled; + } + if let Some(enabled) = separate_audio_tracks { + recorder.settings.privacy.separate_audio_tracks = enabled; + } + if let Some(enabled) = auto_record_enabled { + recorder.settings.privacy.desktop_capture_requires_confirmation = !enabled; + } + if let Some(seconds) = replay_buffer_seconds { + recorder.settings.replay_buffer = Duration::from_secs(seconds); + recorder.settings.clamp_replay_buffer(); + } + if let Some(gb) = storage_limit_gb { + recorder.settings.storage_limit_gb = gb.clamp(5, 5000); + } + recorder.settings.onboarding_complete = true; + save_settings(&runtime.library_root, &recorder.settings) + .map_err(|error| format!("Could not save onboarding settings: {error}"))?; + Ok(status_from_recorder(&recorder, capture.as_ref())) +} + fn even_between(value: u32, min: u32, max: u32) -> u32 { let value = value.clamp(min, max); value - (value % 2) @@ -1573,6 +1611,7 @@ fn main() { set_upload_settings, set_auto_clip_event_enabled, set_capture_settings, + finish_onboarding, write_gsi_configs, poll_auto_clip_events, save_manual_clip, @@ -1873,6 +1912,7 @@ fn status_from_recorder(recorder: &RecorderService, capture: Option<&ActiveCaptu game_quality_overrides: quality_override_dtos(&recorder.settings), effective_quality_applied: game_override_is_active(&recorder.settings, &game_id), app_version: env!("CARGO_PKG_VERSION").to_string(), + onboarding_complete: recorder.settings.onboarding_complete, } } diff --git a/src/settings.rs b/src/settings.rs index 0b15704..de16c73 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -91,6 +91,8 @@ pub struct AppSettings { pub upload: UploadSettings, #[serde(default)] pub quality_overrides_by_game: BTreeMap, + #[serde(default)] + pub onboarding_complete: bool, } impl AppSettings { @@ -137,6 +139,7 @@ impl AppSettings { }, upload: UploadSettings::default(), quality_overrides_by_game: BTreeMap::new(), + onboarding_complete: false, } } @@ -286,6 +289,31 @@ mod tests { let _ = fs::remove_dir_all(root); } + #[test] + fn new_install_starts_onboarding_and_legacy_config_upgrades_it() { + let root = std::env::temp_dir().join(format!( + "clipforge-settings-onboarding-{}", + SystemTimeCompat::millis() + )); + fs::create_dir_all(&root).expect("settings root"); + let mut value = + serde_json::to_value(AppSettings::default_for_root(&root)).expect("settings json"); + value + .as_object_mut() + .expect("settings object") + .remove("onboarding_complete"); + fs::write( + settings_path(&root), + serde_json::to_string_pretty(&value).expect("legacy settings"), + ) + .expect("write legacy settings"); + + let loaded = load_or_create_settings(&root).expect("load migrated settings"); + + assert!(!loaded.onboarding_complete); + let _ = fs::remove_dir_all(root); + } + struct SystemTimeCompat; impl SystemTimeCompat { diff --git a/ui/src/main.ts b/ui/src/main.ts index cd6e121..b5f1fd9 100644 --- a/ui/src/main.ts +++ b/ui/src/main.ts @@ -84,6 +84,7 @@ type DesktopStatus = { game_quality_overrides: GameQualityOverrideDto[]; effective_quality_applied: boolean; app_version: string; + onboarding_complete: boolean; }; type ClipDto = { @@ -188,6 +189,8 @@ type AppState = { excludedWindowText: string; separateAudioTracks: boolean; appVersion: string; + onboardingComplete: boolean; + onboardingStep: number; gameQualityOverrides: GameQualityOverrideDto[]; effectiveQualityApplied: boolean; update: UpdateInfo; @@ -275,6 +278,8 @@ const state: AppState = { excludedWindowText: "", separateAudioTracks: false, appVersion: "0.1.0", + onboardingComplete: true, + onboardingStep: 0, gameQualityOverrides: [], effectiveQualityApplied: false, update: { @@ -297,6 +302,12 @@ if (!root) { const appRoot = root; function render() { + if (!state.onboardingComplete) { + appRoot.innerHTML = renderOnboardingWizard(); + bindEvents(); + return; + } + const selectedClip = state.clips.find((clip) => clip.id === state.selectedClipId) ?? state.clips[0]; appRoot.innerHTML = `
@@ -326,6 +337,98 @@ function render() { bindEvents(); } +function renderOnboardingWizard() { + const step = state.onboardingStep; + const steps = ["Privacy", "Capture source", "Storage", "Hotkeys"]; + const stepBody = (() => { + switch (step) { + case 0: + return ` +

What should ClipForge record?

+

You can change any of these later in Settings. Audio is mixed into + your clips; enable separate tracks to keep system and mic audio in distinct tracks.

+
+ + + +
`; + case 1: + return ` +

When should recording start?

+

Auto-clipping keeps a rolling buffer and saves highlights when + supported games detect events. Continuous recording saves the full session.

+
+ +
+
+ +
`; + case 2: + return ` +

How much disk space is ClipForge allowed to use?

+

The rolling buffer shrinks automatically to fit this limit. + Finished clips are saved to your library and are never pruned.

+
+ +
`; + case 3: + return ` +

You're almost set

+

These hotkeys are active while the app is running. You can + customize them anytime in Settings.

+
    +
  • Save last ${state.replayBufferSeconds}s clip${escapeHtml(state.hotkeyClipLast60s)}
  • +
  • Save last 30s clip${escapeHtml(state.hotkeyClipLast30s)}
  • +
  • Toggle recording${escapeHtml(state.hotkeyToggleRecording)}
  • +
  • Take screenshot${escapeHtml(state.hotkeyScreenshot)}
  • +
`; + default: + return ""; + } + })(); + + return ` +
+
+
+
+ CF +
+

Welcome to ClipForge

+

Set up capture in a few quick steps.

+
+
+
    + ${steps + .map( + (name, index) => ` +
  1. ${name}
  2. + `, + ) + .join("")} +
+
${stepBody}
+
+ ${step === 0 ? `` : ``} + ${step < steps.length - 1 ? `` : ``} +
+
+
+
+ `; +} + function renderRecordingBar() { const lowDisk = state.freeDiskGb < 2 && state.freeDiskGb > 0; const statusText = lowDisk @@ -1006,6 +1109,24 @@ function bindEvents() { void clearGameQualityOverride(); }); + appRoot.querySelector("[data-action='onboarding-next']")?.addEventListener("click", () => { + state.onboardingStep = Math.min(state.onboardingStep + 1, 3); + render(); + }); + + appRoot.querySelector("[data-action='onboarding-back']")?.addEventListener("click", () => { + state.onboardingStep = Math.max(state.onboardingStep - 1, 0); + render(); + }); + + appRoot.querySelector("[data-action='onboarding-finish']")?.addEventListener("click", () => { + void finishOnboarding(); + }); + + appRoot.querySelector("[data-action='onboarding-skip']")?.addEventListener("click", () => { + void skipOnboarding(); + }); + appRoot.querySelector("[data-action='download-update']")?.addEventListener("click", () => { void downloadUpdate(); }); @@ -1302,6 +1423,9 @@ state.separateAudioTracks = status.separate_audio_tracks ?? false; state.appVersion = status.app_version ?? state.appVersion; state.gameQualityOverrides = status.game_quality_overrides ?? []; state.effectiveQualityApplied = status.effective_quality_applied ?? false; + if (typeof status.onboarding_complete === "boolean") { + state.onboardingComplete = status.onboarding_complete; + } } async function trimSelectedClip() { @@ -1754,6 +1878,64 @@ async function clearGameQualityOverride() { } } +async function finishOnboarding() { + if (!tauriInvoke) { + state.onboardingComplete = true; + render(); + return; + } + + const systemAudio = document + .querySelector("[data-action='onboard-system-audio']")?.checked ?? state.systemAudioEnabled; + const mic = document + .querySelector("[data-action='onboard-mic']")?.checked ?? state.micEnabled; + const separate = document + .querySelector("[data-action='onboard-separate-tracks']")?.checked ?? state.separateAudioTracks; + const autoRecord = document + .querySelector("[data-action='onboard-auto-record']")?.checked ?? state.autoRecordEnabled; + const buffer = Number( + document.querySelector("[data-action='onboard-buffer']")?.value ?? state.replayBufferSeconds, + ); + const storage = Number( + document.querySelector("[data-action='onboard-storage']")?.value ?? state.storageLimitGb, + ); + + try { + const status = await tauriInvoke("finish_onboarding", { + systemAudioEnabled: systemAudio, + micEnabled: mic, + separateAudioTracks: separate, + autoRecordEnabled: autoRecord, + replayBufferSeconds: buffer, + storageLimitGb: storage, + }); + applyDesktopStatus(status); + state.onboardingStep = 0; + render(); + } catch (error) { + console.warn("Could not finish onboarding", error); + showNotice(`Could not finish setup: ${String(error)}`); + } +} + +async function skipOnboarding() { + if (!tauriInvoke) { + state.onboardingComplete = true; + render(); + return; + } + + try { + const status = await tauriInvoke("finish_onboarding", {}); + applyDesktopStatus(status); + state.onboardingStep = 0; + render(); + } catch (error) { + console.warn("Could not skip onboarding", error); + showNotice(`Could not skip setup: ${String(error)}`); + } +} + async function checkForUpdates() { if (!tauriInvoke) { return; diff --git a/ui/styles.css b/ui/styles.css index fbb1046..4cf9c8e 100644 --- a/ui/styles.css +++ b/ui/styles.css @@ -541,3 +541,137 @@ textarea { text-align: center; } } + +/* Onboarding wizard */ +.onboarding-shell { + grid-template-columns: minmax(0, 1fr); +} + +.onboarding-workspace { + display: grid; + place-items: center; + padding: 40px 20px; +} + +.wizard-card { + width: min(560px, 100%); + background: #17191f; + border: 1px solid #2a2e38; + border-radius: 16px; + padding: 28px; +} + +.wizard-header { + display: flex; + align-items: center; + gap: 14px; + margin-bottom: 22px; +} + +.wizard-header h1 { + margin: 0; + font-size: 22px; +} + +.wizard-steps { + display: flex; + gap: 6px; + padding: 0; + margin: 0 0 22px; + list-style: none; +} + +.wizard-steps li { + flex: 1; + padding: 8px 6px; + border-radius: 8px; + background: #242a36; + color: #9ca3af; + font-size: 12px; + font-weight: 600; + text-align: center; +} + +.wizard-steps li.active { + background: #064e3b; + color: #6ee7b7; +} + +.wizard-steps li.done { + color: #34d399; +} + +.wizard-body h2 { + margin: 0 0 8px; + font-size: 18px; +} + +.wizard-body .muted { + margin-top: 0; +} + +.wizard-options { + display: grid; + gap: 4px; + margin: 18px 0; +} + +.wizard-actions { + display: flex; + justify-content: space-between; + align-items: center; + gap: 10px; + margin-top: 24px; +} + +.ghost-button, +.primary-button { + padding: 10px 18px; + border-radius: 8px; + font-weight: 600; + cursor: pointer; +} + +.ghost-button { + background: transparent; + border: 1px solid #374151; + color: #d1d5db; +} + +.primary-button { + background: #10b981; + border: 1px solid #10b981; + color: #06281f; +} + +.primary-button:hover { + background: #34d399; +} + +.hotkey-list { + list-style: none; + margin: 18px 0 0; + padding: 0; + display: grid; + gap: 10px; +} + +.hotkey-list li { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + padding: 10px 12px; + background: #242a36; + border-radius: 8px; +} + +.hotkey-list kbd { + background: #101114; + border: 1px solid #374151; + border-bottom-width: 2px; + border-radius: 6px; + padding: 4px 10px; + font-size: 12px; + color: #f5f7fb; +}