feat: first-run onboarding wizard for privacy, capture, storage, and hotkeys

This commit is contained in:
Alvin-Zilverstand committed 2026-09-14 13:00:49 +02:00
1 parent 6839fdbf47
commit 7a4ba815fe
5 files changed
+387 -3

No files matched your search

+3 -3
View File
@@ -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.
+40
View File
@@ -132,6 +132,7 @@ struct DesktopStatus {
game_quality_overrides: Vec<GameQualityOverrideDto>,
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<bool>,
mic_enabled: Option<bool>,
separate_audio_tracks: Option<bool>,
auto_record_enabled: Option<bool>,
replay_buffer_seconds: Option<u64>,
storage_limit_gb: Option<u64>,
runtime: State<'_, AppRuntime>,
) -> Result<DesktopStatus, String> {
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,
}
}
+28
View File
@@ -91,6 +91,8 @@ pub struct AppSettings {
pub upload: UploadSettings,
#[serde(default)]
pub quality_overrides_by_game: BTreeMap<String, QualityPreset>,
#[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 {
+182
View File
@@ -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 = `
<main class="app-shell">
@@ -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 `
<h2>What should ClipForge record?</h2>
<p class="muted">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.</p>
<div class="wizard-options">
<label class="toggle"><input type="checkbox" ${state.systemAudioEnabled ? "checked" : ""} data-action="onboard-system-audio" /> Capture system audio</label>
<label class="toggle"><input type="checkbox" ${state.micEnabled ? "checked" : ""} data-action="onboard-mic" /> Capture microphone</label>
<label class="toggle"><input type="checkbox" ${state.separateAudioTracks ? "checked" : ""} data-action="onboard-separate-tracks" /> Keep system and mic in separate tracks</label>
</div>`;
case 1:
return `
<h2>When should recording start?</h2>
<p class="muted">Auto-clipping keeps a rolling buffer and saves highlights when
supported games detect events. Continuous recording saves the full session.</p>
<div class="wizard-options">
<label class="toggle"><input type="checkbox" ${state.autoRecordEnabled ? "checked" : ""} data-action="onboard-auto-record" /> Start recording automatically when a game is detected</label>
</div>
<div class="field-row">
<label>Replay buffer
<select data-action="onboard-buffer">
${[30, 60, 120, 240, 300]
.map(
(seconds) =>
`<option value="${seconds}" ${state.replayBufferSeconds === seconds ? "selected" : ""}>${seconds < 60 ? `${seconds}s` : `${seconds / 60} min`}</option>`,
)
.join("")}
</select>
</label>
</div>`;
case 2:
return `
<h2>How much disk space is ClipForge allowed to use?</h2>
<p class="muted">The rolling buffer shrinks automatically to fit this limit.
Finished clips are saved to your library and are never pruned.</p>
<div class="field-row">
<label>Storage limit (GB)
<input type="number" min="5" max="5000" step="5" value="${state.storageLimitGb}" data-action="onboard-storage" />
</label>
</div>`;
case 3:
return `
<h2>You're almost set</h2>
<p class="muted">These hotkeys are active while the app is running. You can
customize them anytime in Settings.</p>
<ul class="hotkey-list">
<li><span>Save last ${state.replayBufferSeconds}s clip</span><kbd>${escapeHtml(state.hotkeyClipLast60s)}</kbd></li>
<li><span>Save last 30s clip</span><kbd>${escapeHtml(state.hotkeyClipLast30s)}</kbd></li>
<li><span>Toggle recording</span><kbd>${escapeHtml(state.hotkeyToggleRecording)}</kbd></li>
<li><span>Take screenshot</span><kbd>${escapeHtml(state.hotkeyScreenshot)}</kbd></li>
</ul>`;
default:
return "";
}
})();
return `
<main class="app-shell onboarding-shell">
<section class="workspace onboarding-workspace">
<div class="wizard-card">
<div class="wizard-header">
<span class="brand-mark">CF</span>
<div>
<h1>Welcome to ClipForge</h1>
<p class="muted">Set up capture in a few quick steps.</p>
</div>
</div>
<ol class="wizard-steps">
${steps
.map(
(name, index) => `
<li class="${index === step ? "active" : ""} ${index < step ? "done" : ""}">${name}</li>
`,
)
.join("")}
</ol>
<div class="wizard-body">${stepBody}</div>
<div class="wizard-actions">
${step === 0 ? `<button class="ghost-button" data-action="onboarding-skip">Skip setup</button>` : `<button class="ghost-button" data-action="onboarding-back">Back</button>`}
${step < steps.length - 1 ? `<button class="primary-button" data-action="onboarding-next">Continue</button>` : `<button class="primary-button" data-action="onboarding-finish">Get clipping</button>`}
</div>
</div>
</section>
</main>
`;
}
function renderRecordingBar() {
const lowDisk = state.freeDiskGb < 2 && state.freeDiskGb > 0;
const statusText = lowDisk
@@ -1006,6 +1109,24 @@ function bindEvents() {
void clearGameQualityOverride();
});
appRoot.querySelector<HTMLButtonElement>("[data-action='onboarding-next']")?.addEventListener("click", () => {
state.onboardingStep = Math.min(state.onboardingStep + 1, 3);
render();
});
appRoot.querySelector<HTMLButtonElement>("[data-action='onboarding-back']")?.addEventListener("click", () => {
state.onboardingStep = Math.max(state.onboardingStep - 1, 0);
render();
});
appRoot.querySelector<HTMLButtonElement>("[data-action='onboarding-finish']")?.addEventListener("click", () => {
void finishOnboarding();
});
appRoot.querySelector<HTMLButtonElement>("[data-action='onboarding-skip']")?.addEventListener("click", () => {
void skipOnboarding();
});
appRoot.querySelector<HTMLButtonElement>("[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<HTMLInputElement>("[data-action='onboard-system-audio']")?.checked ?? state.systemAudioEnabled;
const mic = document
.querySelector<HTMLInputElement>("[data-action='onboard-mic']")?.checked ?? state.micEnabled;
const separate = document
.querySelector<HTMLInputElement>("[data-action='onboard-separate-tracks']")?.checked ?? state.separateAudioTracks;
const autoRecord = document
.querySelector<HTMLInputElement>("[data-action='onboard-auto-record']")?.checked ?? state.autoRecordEnabled;
const buffer = Number(
document.querySelector<HTMLSelectElement>("[data-action='onboard-buffer']")?.value ?? state.replayBufferSeconds,
);
const storage = Number(
document.querySelector<HTMLInputElement>("[data-action='onboard-storage']")?.value ?? state.storageLimitGb,
);
try {
const status = await tauriInvoke<DesktopStatus>("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<DesktopStatus>("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;
+134
View File
@@ -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;
}