From 9ac5a30a17e25a9fbf3ac0406724cf7cfaf1c3f1 Mon Sep 17 00:00:00 2001 From: Alvin-Zilverstand <524715@vistacollege.nl> Date: Wed, 9 Sep 2026 15:29:59 +0200 Subject: [PATCH] Add opt-in automatic recording --- src-tauri/src/main.rs | 50 ++++++++++++++++++++++++++++++++++--------- ui/src/main.ts | 25 ++++++++++++++++++++++ 2 files changed, 65 insertions(+), 10 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 9ececc0..1446b92 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -57,6 +57,7 @@ struct DesktopStatus { detected_game: Option, replay_buffer_seconds: u64, mic_enabled: bool, + auto_record_enabled: bool, upload_enabled: bool, session_recording: bool, capture_active: bool, @@ -99,23 +100,37 @@ fn get_status(runtime: State<'_, AppRuntime>) -> Result { #[tauri::command] fn refresh_detected_game(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())?; let detected = detect_game(&running_processes(), &default_profiles()); + let mut should_auto_start = false; - match detected { - Some(game) => { - if recorder.state.detected_game_id.as_deref() != Some(&game.game_id) { - recorder.start_for_game(game.game_id, SystemTime::now()); + { + let mut recorder = runtime.recorder.lock().map_err(|error| error.to_string())?; + let capture = runtime.capture.lock().map_err(|error| error.to_string())?; + + match detected { + Some(game) => { + should_auto_start = game.process.process_name.len() > 0 + && default_profiles() + .iter() + .any(|profile| profile.game_id == game.game_id && profile.auto_record) + && capture.is_none() + && !recorder.settings.privacy.desktop_capture_requires_confirmation; + if recorder.state.detected_game_id.as_deref() != Some(&game.game_id) { + recorder.start_for_game(game.game_id, SystemTime::now()); + } } + None if capture.is_none() => { + let _ = recorder.stop(); + } + None => {} } - None if capture.is_none() => { - let _ = recorder.stop(); + + if !should_auto_start { + return Ok(status_from_recorder(&recorder, capture.as_ref())); } - None => {} } - Ok(status_from_recorder(&recorder, capture.as_ref())) + start_capture_inner(runtime.inner()) } #[tauri::command] @@ -145,6 +160,19 @@ fn set_mic_enabled(enabled: bool, runtime: State<'_, AppRuntime>) -> Result, +) -> Result { + let mut recorder = runtime.recorder.lock().map_err(|error| error.to_string())?; + let capture = runtime.capture.lock().map_err(|error| error.to_string())?; + recorder.settings.privacy.desktop_capture_requires_confirmation = !enabled; + save_settings(&runtime.library_root, &recorder.settings) + .map_err(|error| format!("Could not save settings: {error}"))?; + Ok(status_from_recorder(&recorder, capture.as_ref())) +} + #[tauri::command] fn write_gsi_configs(runtime: State<'_, AppRuntime>) -> Result, String> { write_gsi_config_templates(&runtime.library_root) @@ -686,6 +714,7 @@ fn main() { list_clips, set_replay_buffer, set_mic_enabled, + set_auto_record_enabled, write_gsi_configs, poll_auto_clip_events, save_manual_clip, @@ -805,6 +834,7 @@ fn status_from_recorder(recorder: &RecorderService, capture: Option<&ActiveCaptu detected_game: recorder.state.detected_game_id.clone(), replay_buffer_seconds: recorder.settings.replay_buffer.as_secs(), mic_enabled: recorder.settings.privacy.mic_enabled, + auto_record_enabled: !recorder.settings.privacy.desktop_capture_requires_confirmation, upload_enabled: false, session_recording: matches!(recorder.state.status, RecordingStatus::RecordingSession), capture_active: capture.is_some(), diff --git a/ui/src/main.ts b/ui/src/main.ts index d502ba2..9bb5cc5 100644 --- a/ui/src/main.ts +++ b/ui/src/main.ts @@ -40,6 +40,7 @@ type DesktopStatus = { detected_game: string | null; replay_buffer_seconds: number; mic_enabled: boolean; + auto_record_enabled: boolean; upload_enabled: boolean; session_recording: boolean; capture_active: boolean; @@ -83,6 +84,7 @@ type AppState = { ffmpegPath: string | null; systemAudioAvailable: boolean; micEnabled: boolean; + autoRecordEnabled: boolean; autoUpload: boolean; uploadProvider: "catbox" | "litterbox" | "custom_http" | "lustful"; customUploadEndpoint: string; @@ -120,6 +122,7 @@ const state: AppState = { ffmpegPath: null, systemAudioAvailable: false, micEnabled: false, + autoRecordEnabled: false, autoUpload: false, uploadProvider: "catbox", customUploadEndpoint: "", @@ -453,6 +456,7 @@ function renderSettingsView() {

Privacy

Local-first

+
@@ -531,6 +535,12 @@ function bindEvents() { render(); }); + appRoot.querySelector("[data-action='toggle-auto-record']")?.addEventListener("change", (event) => { + state.autoRecordEnabled = (event.target as HTMLInputElement).checked; + render(); + void saveAutoRecordSetting(state.autoRecordEnabled); + }); + appRoot.querySelectorAll("[data-upload-provider]").forEach((button) => { button.addEventListener("click", () => { state.uploadProvider = button.dataset.uploadProvider as AppState["uploadProvider"]; @@ -620,6 +630,7 @@ function applyDesktopStatus(status: DesktopStatus) { state.detectedGame = status.detected_game ?? "Waiting for game"; state.replayBufferSeconds = status.replay_buffer_seconds; state.micEnabled = status.mic_enabled; + state.autoRecordEnabled = status.auto_record_enabled; state.autoUpload = status.upload_enabled; state.sessionRecording = status.session_recording; state.captureActive = status.capture_active; @@ -762,6 +773,20 @@ async function saveMicSetting(enabled: boolean) { } } +async function saveAutoRecordSetting(enabled: boolean) { + if (!tauriInvoke) { + return; + } + + try { + const status = await tauriInvoke("set_auto_record_enabled", { enabled }); + applyDesktopStatus(status); + render(); + } catch (error) { + console.warn("Could not save auto-record setting", error); + } +} + async function refreshStatus() { if (!tauriInvoke) { return;