4 Commits
Author SHA1 Message Date
Alvin-Zilverstand 777d54ba5b fix: load thumbnails with asset protocol scope, fit screenshot thumbnails, add opt-in tray-on-close
Build Windows Release / Rust tests (push) Canceled after 0s
Build Windows Release / Windows installer (push) Canceled after 0s
2026-09-14 15:06:29 +02:00
Alvin-Zilverstand ae1612547a ci: run rust tests in parallel with installer build and speed up release compile
Build Windows Release / Rust tests (push) Canceled after 0s
Build Windows Release / Windows installer (push) Canceled after 0s
2026-09-14 14:14:47 +02:00
Alvin-Zilverstand d2dd2f9c27 fix: detect capture capabilities after window init to avoid MTA COM crash 2026-09-14 14:12:40 +02:00
Alvin-Zilverstand bde7d78c3d fix: stop status polling from spawning FFmpeg and hide subprocess console windows
Build Windows Release / Windows installer (push) Canceled after 0s
2026-09-14 13:51:46 +02:00
15 changed files with 261 additions and 56 deletions

No files matched your search

+25 -3
View File
@@ -32,6 +32,31 @@ concurrency:
cancel-in-progress: true
jobs:
tests:
name: Rust tests
runs-on: windows-latest
defaults:
run:
shell: pwsh
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: |
.
src-tauri
- name: Run Rust tests
run: cargo test
windows-installer:
name: Windows installer
runs-on: windows-latest
@@ -81,9 +106,6 @@ jobs:
- name: Install frontend dependencies
run: pnpm install --frozen-lockfile
- name: Run Rust tests
run: cargo test
- name: Build Windows desktop installers
run: pnpm run desktop:build
+4
View File
@@ -52,7 +52,11 @@
- 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.
- The default clip library root is `~/Documents/ClipForge` (rather than the process working directory), and a first-run migration moves any legacy `clipforge-library` folder found in the CWD into the new location while rewriting stored clip paths in the SQLite database.
- Capture capabilities (bundled FFmpeg discovery, WASAPI/ddagrab support) are detected once at startup and cached, so background workers (`refresh_detected_game` every 2s, UI status poll every 3s) never spawn FFmpeg; all FFmpeg/console subprocesses are launched with a hidden console window on Windows, preventing the app from freezing and flashing a terminal repeatedly.
- Vite TypeScript UI builds and has interactive Library, Recording, Auto Clip, Uploads, and Settings views.
- Tauri's asset protocol is enabled and scoped to `$DOCUMENT/ClipForge/**` and `$PICTURE/ClipForge/**`, so `convertFileSrc` URLs load for clip thumbnails, video previews, and screenshot images (previously returned blocked asset responses).
- Screenshot thumbnails use `object-fit: contain` so the full screenshot is shown without cropping.
- An opt-in "Minimize to tray" setting keeps ClipForge running in the system tray when the main window is closed; closing the window hides it, and the tray menu offers "Open ClipForge" to restore it or "Quit ClipForge" to exit fully. The toggle is under Settings > Tray and defaults to off.
- 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.
+7
View File
@@ -1463,6 +1463,12 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "http-range"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573"
[[package]]
name = "httparse"
version = "1.10.1"
@@ -3591,6 +3597,7 @@ dependencies = [
"gtk",
"heck 0.5.0",
"http",
"http-range",
"jni",
"libc",
"log",
+1 -2
View File
@@ -11,10 +11,9 @@ tauri-build = { version = "2.5.3", features = [] }
[dependencies]
clipforge = { path = ".." }
serde = { version = "1", features = ["derive"] }
tauri = { version = "2.9.5", features = [] }
tauri = { version = "2.9.5", features = ["protocol-asset", "tray-icon"] }
tauri-plugin-global-shortcut = "2"
[profile.release]
lto = "thin"
codegen-units = 1
strip = true
+141 -34
View File
@@ -3,7 +3,7 @@
use clipforge::audio::{list_ffmpeg_dshow_audio_inputs, AudioDeviceKind};
use clipforge::capture::{
ffmpeg_is_available, ffmpeg_supports_filter, ffmpeg_supports_input_device,
ffmpeg_supports_filter, ffmpeg_supports_input_device,
find_ffmpeg_executable, CaptureBackend, CaptureConfig, CaptureMethod, CaptureSource,
EncoderPreference, FfmpegReplayCaptureBackend,
};
@@ -25,6 +25,7 @@ use clipforge::native_audio::{
NativeAudioSource,
};
use clipforge::native_wgc::NativeWgcReplayCaptureBackend;
use clipforge::proc::hidden_command;
use clipforge::recorder::{RecorderAction, RecorderService};
use clipforge::settings::{load_or_create_settings, save_settings, AppSettings};
use clipforge::storage::{clip_path, is_inside_root, resolve_library_root, LibraryPaths};
@@ -38,9 +39,12 @@ use std::io::{Read, Write};
use std::net::TcpListener;
use std::path::PathBuf;
use std::process::Command;
use std::sync::Mutex;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Mutex, OnceLock};
use std::thread;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use tauri::menu::{Menu, MenuItem};
use tauri::tray::TrayIconBuilder;
use tauri::{Manager, State};
struct AppRuntime {
@@ -52,6 +56,41 @@ struct AppRuntime {
valve_events: Mutex<Vec<RawGameEvent>>,
hotkey_shortcuts: Mutex<Option<HotkeyShortcuts>>,
app_handle: Mutex<Option<tauri::AppHandle>>,
capture_capabilities: OnceLock<CaptureCapabilities>,
quitting: AtomicBool,
}
#[derive(Clone)]
struct CaptureCapabilities {
ffmpeg_path: Option<PathBuf>,
system_audio_available: bool,
desktop_duplication_available: bool,
}
const DEFAULT_CAPS: CaptureCapabilities = CaptureCapabilities {
ffmpeg_path: None,
system_audio_available: false,
desktop_duplication_available: false,
};
fn native_system_loopback_available_bg() -> bool {
std::thread::scope(|scope| scope.spawn(native_system_loopback_available).join().unwrap_or(false))
}
fn detect_capture_capabilities() -> CaptureCapabilities {
let ffmpeg_path = find_ffmpeg_executable();
let (system_audio_available, desktop_duplication_available) = match &ffmpeg_path {
Some(path) => (
native_system_loopback_available_bg() || ffmpeg_supports_input_device(path, "wasapi"),
ffmpeg_supports_filter(path, "ddagrab"),
),
None => (native_system_loopback_available_bg(), false),
};
CaptureCapabilities {
ffmpeg_path,
system_audio_available,
desktop_duplication_available,
}
}
struct HotkeyShortcuts {
@@ -132,6 +171,7 @@ struct DesktopStatus {
effective_quality_applied: bool,
app_version: String,
onboarding_complete: bool,
minimize_to_tray: bool,
}
#[derive(Debug, Clone, Serialize)]
@@ -194,7 +234,7 @@ struct AutoClipEventDto {
fn get_status(runtime: State<'_, AppRuntime>) -> Result<DesktopStatus, String> {
let recorder = runtime.recorder.lock().map_err(|error| error.to_string())?;
let capture = runtime.capture.lock().map_err(|error| error.to_string())?;
Ok(status_from_recorder(&recorder, capture.as_ref()))
Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities))
}
#[tauri::command]
@@ -233,7 +273,7 @@ fn refresh_detected_game_inner(runtime: &AppRuntime) -> Result<DesktopStatus, St
if !should_auto_start {
if !should_auto_stop {
return Ok(status_from_recorder(&recorder, capture.as_ref()));
return Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities));
}
}
}
@@ -259,7 +299,7 @@ fn set_replay_buffer(seconds: u64, runtime: State<'_, AppRuntime>) -> Result<Des
recorder.settings.clamp_replay_buffer();
save_settings(&runtime.library_root, &recorder.settings)
.map_err(|error| format!("Could not save settings: {error}"))?;
Ok(status_from_recorder(&recorder, capture.as_ref()))
Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities))
}
#[tauri::command]
@@ -269,7 +309,7 @@ fn set_mic_enabled(enabled: bool, runtime: State<'_, AppRuntime>) -> Result<Desk
recorder.settings.privacy.mic_enabled = 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()))
Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities))
}
#[tauri::command]
@@ -282,7 +322,7 @@ fn set_system_audio_enabled(
recorder.settings.privacy.system_audio_enabled = 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()))
Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities))
}
#[tauri::command]
@@ -328,7 +368,7 @@ fn set_mic_device(
recorder.settings.privacy.mic_device = device.filter(|value| !value.trim().is_empty());
save_settings(&runtime.library_root, &recorder.settings)
.map_err(|error| format!("Could not save settings: {error}"))?;
Ok(status_from_recorder(&recorder, capture.as_ref()))
Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities))
}
#[tauri::command]
@@ -341,7 +381,20 @@ fn set_auto_record_enabled(
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()))
Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities))
}
#[tauri::command]
fn set_minimize_to_tray_enabled(
enabled: bool,
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())?;
recorder.settings.minimize_to_tray_enabled = 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(), &runtime.capture_capabilities))
}
#[tauri::command]
@@ -373,7 +426,7 @@ fn set_upload_settings(
recorder.settings.upload.custom_headers = parse_header_lines(&custom_headers.join("\n"));
save_settings(&runtime.library_root, &recorder.settings)
.map_err(|error| format!("Could not save upload settings: {error}"))?;
Ok(status_from_recorder(&recorder, capture.as_ref()))
Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities))
}
#[tauri::command]
@@ -399,7 +452,7 @@ fn set_auto_clip_event_enabled(
}
save_settings(&runtime.library_root, &recorder.settings)
.map_err(|error| format!("Could not save auto-clip setting: {error}"))?;
Ok(status_from_recorder(&recorder, capture.as_ref()))
Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities))
}
#[tauri::command]
@@ -425,7 +478,7 @@ fn set_capture_settings(
recorder.settings.privacy.separate_audio_tracks = separate_audio_tracks;
save_settings(&runtime.library_root, &recorder.settings)
.map_err(|error| format!("Could not save capture settings: {error}"))?;
Ok(status_from_recorder(&recorder, capture.as_ref()))
Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities))
}
#[tauri::command]
@@ -462,7 +515,7 @@ fn finish_onboarding(
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()))
Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities))
}
fn even_between(value: u32, min: u32, max: u32) -> u32 {
@@ -686,7 +739,7 @@ fn start_capture_inner(runtime: &AppRuntime) -> Result<DesktopStatus, String> {
let mut capture = runtime.capture.lock().map_err(|error| error.to_string())?;
if capture.is_some() {
return Ok(status_from_recorder(&recorder, capture.as_ref()));
return Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities));
}
let storage = clipforge::storage::check_storage_space(&recorder.paths.buffer_root);
@@ -780,7 +833,7 @@ fn start_capture_inner(runtime: &AppRuntime) -> Result<DesktopStatus, String> {
backend,
});
Ok(status_from_recorder(&recorder, capture.as_ref()))
Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities))
}
#[tauri::command]
@@ -823,7 +876,7 @@ fn stop_capture_inner(runtime: &AppRuntime) -> Result<DesktopStatus, String> {
if matches!(recorder.state.status, RecordingStatus::RecordingSession) {
recorder.toggle_session_recording();
}
Ok(status_from_recorder(&recorder, capture.as_ref()))
Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities))
}
#[tauri::command]
@@ -864,7 +917,7 @@ fn reveal_clip(clip_id: String, runtime: State<'_, AppRuntime>) -> Result<(), St
return Err(format!("Clip file does not exist: {}", clip.path.display()));
}
Command::new("explorer")
hidden_command("explorer")
.arg(format!("/select,{}", clip.path.display()))
.spawn()
.map_err(|error| error.to_string())?;
@@ -1102,7 +1155,7 @@ fn take_screenshot(runtime: State<'_, AppRuntime>) -> Result<DesktopStatus, Stri
handle_screenshot()?;
let recorder = runtime.recorder.lock().map_err(|error| error.to_string())?;
let capture = runtime.capture.lock().map_err(|error| error.to_string())?;
Ok(status_from_recorder(&recorder, capture.as_ref()))
Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities))
}
#[tauri::command]
@@ -1111,7 +1164,7 @@ fn reveal_screenshot(path: String) -> Result<(), String> {
if !path.exists() {
return Err(format!("Screenshot file does not exist: {}", path.display()));
}
Command::new("explorer")
hidden_command("explorer")
.arg(format!("/select,{}", path.display()))
.spawn()
.map_err(|error| error.to_string())?;
@@ -1130,7 +1183,7 @@ fn list_screenshots() -> Result<Vec<String>, String> {
fn reveal_crash_logs(runtime: State<'_, AppRuntime>) -> Result<(), String> {
let logs_dir = runtime.library_root.join("logs");
fs::create_dir_all(&logs_dir).map_err(|error| error.to_string())?;
Command::new("explorer")
hidden_command("explorer")
.arg(logs_dir.display().to_string())
.spawn()
.map_err(|error| error.to_string())?;
@@ -1554,7 +1607,7 @@ fn set_hotkeys(
register_hotkeys(&app_handle, runtime.inner())?;
}
Ok(status_from_recorder(&recorder, capture.as_ref()))
Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities))
}
fn main() {
@@ -1573,17 +1626,66 @@ fn main() {
valve_events: Mutex::new(Vec::new()),
hotkey_shortcuts: Mutex::new(None),
app_handle: Mutex::new(None),
capture_capabilities: OnceLock::new(),
quitting: AtomicBool::new(false),
})
.setup(|app| {
.on_window_event(|window, event| {
if let tauri::WindowEvent::CloseRequested { api, .. } = event {
let app = window.app_handle();
let runtime = app.state::<AppRuntime>();
let minimize_to_tray = runtime
.recorder
.lock()
.map(|recorder| recorder.settings.minimize_to_tray_enabled)
.unwrap_or(false);
if minimize_to_tray && !runtime.quitting.load(Ordering::SeqCst) {
api.prevent_close();
let _ = window.hide();
}
}
})
.setup(|app| {
let handle = app.handle().clone();
// Store app handle for hotkey re-registration
{
let runtime = app.state::<AppRuntime>();
// Detect capture capabilities after Tauri has initialized COM for the
// main thread. Detecting before setup (e.g. WASAPI on the main thread)
// puts the thread in MTA mode and makes window creation fail with
// RPC_E_CHANGED_MODE.
let _ = runtime.capture_capabilities.set(detect_capture_capabilities());
let _ = runtime.app_handle.lock().map(|mut guard| {
*guard = Some(handle.clone());
});
}
if let Some(icon) = app.default_window_icon().cloned() {
let show_item = MenuItem::with_id(app, "show", "Open ClipForge", true, None::<&str>)?;
let quit_item = MenuItem::with_id(app, "quit", "Quit ClipForge", true, None::<&str>)?;
let menu = Menu::with_items(app, &[&show_item, &quit_item])?;
TrayIconBuilder::new()
.icon(icon)
.tooltip("ClipForge")
.menu(&menu)
.show_menu_on_left_click(false)
.on_menu_event(|app, event| match event.id.as_ref() {
"show" => {
if let Some(window) = app.get_webview_window("main") {
let _ = window.unminimize();
let _ = window.show();
let _ = window.set_focus();
}
}
"quit" => {
let runtime = app.state::<AppRuntime>();
runtime.quitting.store(true, Ordering::SeqCst);
app.exit(0);
}
_ => {}
})
.build(app)?;
}
start_valve_gsi_receiver(handle.clone());
start_backend_workers(handle.clone());
@@ -1607,6 +1709,7 @@ fn main() {
list_audio_devices,
set_mic_device,
set_auto_record_enabled,
set_minimize_to_tray_enabled,
set_upload_settings,
set_auto_clip_event_enabled,
set_capture_settings,
@@ -1864,7 +1967,12 @@ fn enforce_storage_cap(runtime: &AppRuntime) -> Result<(), String> {
Ok(())
}
fn status_from_recorder(recorder: &RecorderService, capture: Option<&ActiveCapture>) -> DesktopStatus {
fn status_from_recorder(
recorder: &RecorderService,
capture: Option<&ActiveCapture>,
capabilities: &OnceLock<CaptureCapabilities>,
) -> DesktopStatus {
let capabilities = capabilities.get().unwrap_or(&DEFAULT_CAPS);
let game_id = recorder.state.detected_game_id.clone().unwrap_or_default();
let quality = recorder.settings.effective_quality_for(&game_id).clone();
DesktopStatus {
@@ -1894,15 +2002,13 @@ fn status_from_recorder(recorder: &RecorderService, capture: Option<&ActiveCaptu
capture_path: capture.map(|active| active.session_output_path.display().to_string()),
clip_count: recorder.library.all().len(),
library_root: recorder.paths.clip_root.display().to_string(),
ffmpeg_available: ffmpeg_is_available(),
ffmpeg_path: find_ffmpeg_executable().map(|path| path.display().to_string()),
system_audio_available: native_system_loopback_available()
|| find_ffmpeg_executable()
.map(|path| ffmpeg_supports_input_device(&path, "wasapi"))
.unwrap_or(false),
desktop_duplication_available: find_ffmpeg_executable()
.map(|path| ffmpeg_supports_filter(&path, "ddagrab"))
.unwrap_or(false),
ffmpeg_available: capabilities.ffmpeg_path.is_some(),
ffmpeg_path: capabilities
.ffmpeg_path
.as_ref()
.map(|path| path.display().to_string()),
system_audio_available: capabilities.system_audio_available,
desktop_duplication_available: capabilities.desktop_duplication_available,
auto_clip_enabled_events: auto_clip_event_dtos(&recorder.settings),
hotkey_clip_last_60s: recorder.settings.hotkeys.clip_last_60s.clone(),
hotkey_clip_last_30s: recorder.settings.hotkeys.clip_last_30s.clone(),
@@ -1919,6 +2025,7 @@ fn status_from_recorder(recorder: &RecorderService, capture: Option<&ActiveCaptu
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,
minimize_to_tray: recorder.settings.minimize_to_tray_enabled,
}
}
@@ -1970,7 +2077,7 @@ fn set_game_quality_override(
.insert(game_id, preset);
save_settings(&runtime.library_root, &recorder.settings)
.map_err(|error| format!("Could not save quality override: {error}"))?;
Ok(status_from_recorder(&recorder, capture.as_ref()))
Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities))
}
#[tauri::command]
@@ -1983,7 +2090,7 @@ fn clear_game_quality_override(
recorder.settings.quality_overrides_by_game.remove(&game_id);
save_settings(&runtime.library_root, &recorder.settings)
.map_err(|error| format!("Could not save quality override: {error}"))?;
Ok(status_from_recorder(&recorder, capture.as_ref()))
Ok(status_from_recorder(&recorder, capture.as_ref(), &runtime.capture_capabilities))
}
fn clip_to_dto(clip: &Clip) -> ClipDto {
+9 -1
View File
@@ -21,7 +21,15 @@
],
"withGlobalTauri": true,
"security": {
"csp": null
"csp": null,
"assetProtocol": {
"enable": true,
"scope": [
"$DOCUMENT/ClipForge/**",
"$PICTURE/ClipForge/**",
"$HOME/.clipforge/**"
]
}
}
},
"bundle": {
+2 -2
View File
@@ -1,5 +1,5 @@
use crate::proc::hidden_command;
use std::path::Path;
use std::process::Command;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AudioDeviceKind {
@@ -14,7 +14,7 @@ pub struct AudioDevice {
}
pub fn list_ffmpeg_dshow_audio_inputs(ffmpeg: &Path) -> Vec<AudioDevice> {
let Ok(output) = Command::new(ffmpeg)
let Ok(output) = hidden_command(ffmpeg)
.args([
"-hide_banner",
"-list_devices",
+7 -6
View File
@@ -1,7 +1,8 @@
use crate::proc::hidden_command;
use std::fmt;
use std::io::Write;
use std::path::PathBuf;
use std::process::{Child, Command, Stdio};
use std::process::{Child, Stdio};
use std::thread;
use std::time::{Duration, Instant};
@@ -114,7 +115,7 @@ pub fn find_ffmpeg_executable() -> Option<PathBuf> {
let candidates = ["ffmpeg.exe", "ffmpeg"];
for candidate in candidates {
if Command::new(candidate).arg("-version").output().is_ok() {
if hidden_command(candidate).arg("-version").output().is_ok() {
return Some(PathBuf::from(candidate));
}
}
@@ -127,7 +128,7 @@ pub fn ffmpeg_is_available() -> bool {
}
pub fn ffmpeg_supports_input_device(executable: &std::path::Path, device: &str) -> bool {
let Ok(output) = Command::new(executable)
let Ok(output) = hidden_command(executable)
.args(["-hide_banner", "-devices"])
.output()
else {
@@ -144,7 +145,7 @@ pub fn ffmpeg_supports_input_device(executable: &std::path::Path, device: &str)
}
pub fn ffmpeg_supports_filter(executable: &std::path::Path, filter: &str) -> bool {
let Ok(output) = Command::new(executable)
let Ok(output) = hidden_command(executable)
.args(["-hide_banner", "-filters"])
.output()
else {
@@ -368,7 +369,7 @@ impl CaptureBackend for FfmpegCaptureBackend {
}
let plan = self.plan(&config);
let child = Command::new(&plan.executable)
let child = hidden_command(&plan.executable)
.args(&plan.args)
.stdin(Stdio::piped())
.stdout(Stdio::null())
@@ -474,7 +475,7 @@ impl Drop for FfmpegReplayCaptureBackend {
}
fn spawn_ffmpeg(plan: &FfmpegRecordingPlan) -> Result<Child, CaptureError> {
Command::new(&plan.executable)
hidden_command(&plan.executable)
.args(&plan.args)
.stdin(Stdio::piped())
.stdout(Stdio::null())
+1
View File
@@ -14,6 +14,7 @@ pub mod media;
pub mod models;
pub mod native_audio;
pub mod native_wgc;
pub mod proc;
pub mod recorder;
pub mod settings;
pub mod storage;
+4 -4
View File
@@ -1,7 +1,7 @@
use crate::proc::hidden_command;
use std::fs;
use std::io;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -96,7 +96,7 @@ pub fn concat_segments(
}
fs::write(&list_path, list)?;
let status = Command::new(ffmpeg)
let status = hidden_command(ffmpeg)
.args([
"-y",
"-hide_banner",
@@ -137,7 +137,7 @@ pub fn trim_clip(
fs::create_dir_all(parent)?;
}
let status = Command::new(ffmpeg)
let status = hidden_command(ffmpeg)
.args([
"-y",
"-hide_banner",
@@ -168,7 +168,7 @@ pub fn generate_thumbnail(ffmpeg: &Path, input: &Path, output: &Path) -> Result<
fs::create_dir_all(parent)?;
}
let status = Command::new(ffmpeg)
let status = hidden_command(ffmpeg)
.args([
"-y",
"-hide_banner",
+16
View File
@@ -0,0 +1,16 @@
use std::path::Path;
use std::process::Command;
/// Builds a `Command` that never shows a console window on Windows. FFmpeg and other
/// console subprocesses otherwise flash a terminal window each time they start from a
/// GUI (Tauri) process, which looks like the app constantly opening and closing.
pub fn hidden_command(program: impl AsRef<Path>) -> Command {
let mut command = Command::new(program.as_ref());
#[cfg(windows)]
{
use std::os::windows::process::CommandExt;
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
command.creation_flags(CREATE_NO_WINDOW);
}
command
}
+2 -2
View File
@@ -1,7 +1,7 @@
use crate::capture::{CaptureConfig, CaptureError, CaptureMethod, CaptureSource, EncoderPreference};
use crate::proc::hidden_command;
use dirs;
use std::path::PathBuf;
use std::process::Command;
use std::time::{SystemTime, UNIX_EPOCH};
impl Default for ScreenshotCapture {
@@ -145,7 +145,7 @@ impl ScreenshotCapture {
output_path.display().to_string(),
]);
let status = Command::new(&self.executable)
let status = hidden_command(&self.executable)
.args(&args)
.status()
.map_err(|e| CaptureError::DeviceUnavailable(e.to_string()))?;
+3
View File
@@ -93,6 +93,8 @@ pub struct AppSettings {
pub quality_overrides_by_game: BTreeMap<String, QualityPreset>,
#[serde(default)]
pub onboarding_complete: bool,
#[serde(default)]
pub minimize_to_tray_enabled: bool,
}
impl AppSettings {
@@ -140,6 +142,7 @@ impl AppSettings {
upload: UploadSettings::default(),
quality_overrides_by_game: BTreeMap::new(),
onboarding_complete: false,
minimize_to_tray_enabled: false,
}
}
+34 -2
View File
@@ -85,6 +85,7 @@ type DesktopStatus = {
effective_quality_applied: boolean;
app_version: string;
onboarding_complete: boolean;
minimize_to_tray: boolean;
};
type ClipDto = {
@@ -190,6 +191,7 @@ type AppState = {
separateAudioTracks: boolean;
appVersion: string;
onboardingComplete: boolean;
minimizeToTray: boolean;
onboardingStep: number;
gameQualityOverrides: GameQualityOverrideDto[];
effectiveQualityApplied: boolean;
@@ -279,6 +281,7 @@ const state: AppState = {
separateAudioTracks: false,
appVersion: "0.1.0",
onboardingComplete: true,
minimizeToTray: false,
onboardingStep: 0,
gameQualityOverrides: [],
effectiveQualityApplied: false,
@@ -868,6 +871,12 @@ function renderSettingsView() {
<h2>${state.storageLimitGb} GB buffer cap</h2>
<p class="muted">Old temporary buffer segments are removed automatically once the buffer reaches the cap; saved clips are kept.</p>
</article>
<article class="settings-panel">
<p class="eyebrow">Tray</p>
<h2>Close behavior</h2>
<label class="toggle"><input type="checkbox" ${state.minimizeToTray ? "checked" : ""} data-action="toggle-minimize-to-tray" /> Keep running in the system tray when I close the window</label>
<p class="muted">When enabled, closing the ClipForge window hides it to the tray and it keeps recording. Use "Quit ClipForge" from the tray icon to exit fully.</p>
</article>
<article class="settings-panel">
<p class="eyebrow">About & support</p>
<h2>ClipForge ${escapeHtml(state.appVersion)}</h2>
@@ -1004,6 +1013,12 @@ function bindEvents() {
void saveAutoRecordSetting(state.autoRecordEnabled);
});
appRoot.querySelector<HTMLInputElement>("[data-action='toggle-minimize-to-tray']")?.addEventListener("change", (event) => {
state.minimizeToTray = (event.target as HTMLInputElement).checked;
render();
void saveMinimizeToTraySetting(state.minimizeToTray);
});
appRoot.querySelectorAll<HTMLButtonElement>("[data-upload-provider]").forEach((button) => {
button.addEventListener("click", () => {
state.uploadProvider = button.dataset.uploadProvider as UploadProvider;
@@ -1426,6 +1441,9 @@ state.separateAudioTracks = status.separate_audio_tracks ?? false;
if (typeof status.onboarding_complete === "boolean") {
state.onboardingComplete = status.onboarding_complete;
}
if (typeof status.minimize_to_tray === "boolean") {
state.minimizeToTray = status.minimize_to_tray;
}
}
async function trimSelectedClip() {
@@ -1672,11 +1690,25 @@ async function saveAutoRecordSetting(enabled: boolean) {
}
}
async function refreshStatus() {
async function saveMinimizeToTraySetting(enabled: boolean) {
if (!tauriInvoke) {
return;
}
try {
const status = await tauriInvoke<DesktopStatus>("set_minimize_to_tray_enabled", { enabled });
applyDesktopStatus(status);
render();
} catch (error) {
console.warn("Could not save minimize-to-tray setting", error);
}
}
async function refreshStatus() {
if (!tauriInvoke || !state.onboardingComplete) {
return;
}
try {
const status = await tauriInvoke<DesktopStatus>("refresh_detected_game");
applyDesktopStatus(status);
@@ -1700,7 +1732,7 @@ async function refreshAudioDevices() {
}
async function pollAutoClips() {
if (!tauriInvoke || !state.captureActive) {
if (!tauriInvoke || !state.captureActive || !state.onboardingComplete) {
return;
}
+5
View File
@@ -327,6 +327,11 @@ h3 {
object-fit: cover;
}
.screenshot-thumb img {
object-fit: contain;
background: #000;
}
.thumb.kill {
background: linear-gradient(135deg, #1f2937, #7f1d1d);
}