Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32e258dee7 | ||
|
|
777d54ba5b | ||
|
|
ae1612547a | ||
|
|
d2dd2f9c27 | ||
|
|
bde7d78c3d |
No files matched your search
@@ -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
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clipforge"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"dirs",
|
||||
"reqwest",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "clipforge"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
description = "Windows-first local game clipping app scaffold with replay buffer and event auto-clipping core."
|
||||
license = "MIT"
|
||||
|
||||
@@ -52,9 +52,26 @@
|
||||
- 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.
|
||||
- Versions are bumped to `0.1.1` across root `Cargo.toml`, `src-tauri/Cargo.toml`, `tauri.conf.json`, `package.json`, and the frontend `appVersion` constant.
|
||||
- The updater now requires both a newer release and a published installer asset before offering a download; the UI always shows "Check for updates" and only shows a Download button when an installer is available.
|
||||
- The clip folder can be changed at runtime via `set_clip_directory`; the library root and asset-protocol scope are rebuilt without restarting the app.
|
||||
- An optional auto-prune toggle deletes the oldest non-manual clips once the saved library exceeds the configured storage limit.
|
||||
- Free disk space and storage-limit status are cached for 10 seconds, reducing repeated FS calls from the background and UI polls.
|
||||
- A RAM-backed clip buffer (512 MB cap) keeps recent segments in memory and merges them with disk segments when manual, auto, or hotkey clips are saved; this lowers disk I/O and lets clips span RAM-only material.
|
||||
- Clip-related commands (`save_manual_clip`, `start_capture`, `stop_capture`, `trim_clip`, `upload_clip`, `take_screenshot`) now run as async Tauri commands so they execute off the main thread.
|
||||
- The recording toggle flips optimistically in the UI and rolls back on error.
|
||||
- The backend emits `clip-saved`, `clip-deleted`, `screenshots-changed`, and `storage-cleanup` events; the UI listens for them and refreshes clips and screenshots on demand.
|
||||
- A modal viewer opens for clips and screenshots; when a clip's MP4 cannot load, the modal shows the file path and a Reveal-in-Explorer button instead of a broken `<video>` element.
|
||||
- Bitrate settings now offer a preset dropdown (Low / Medium / Stream-ready / High / Ultra) plus a custom numeric input.
|
||||
- Auto Clip rules are displayed per game with an Enable / Disable toggle per game, plus Enable all / Disable all / Restore defaults buttons.
|
||||
- The app icon source is now a checked-in SVG (`src-tauri/icons/icon.svg`); all platform raster icons and `icon.ico` are regenerated from a 1024×1024 PNG rendered from that SVG.
|
||||
|
||||
## Not Fully Working Yet
|
||||
|
||||
@@ -64,11 +81,13 @@
|
||||
- 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.
|
||||
- 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).
|
||||
- RAM-backed clipping reduces disk churn but cannot eliminate it entirely; FFmpeg still writes final clips to disk, and very large segment histories may briefly exceed the RAM cap before pruning.
|
||||
- SVG icon rasterization depends on the sharp-based tooling used during development; the generated `icon.ico` and PNGs are checked in so normal builds do not require it.
|
||||
|
||||
## 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. 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.
|
||||
3. Split the recorder service into a separate background process so capture survives app restarts.
|
||||
4. Run manual QA on Windows gaming hardware and tune CPU/GPU overhead.
|
||||
5. Exercise the GitHub Actions release workflow with the `v0.1.1` tag push and verify the published assets appear in a GitHub Release.
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "clipforge",
|
||||
"version": "0.1.0",
|
||||
"name": "clipforge",
|
||||
"version": "0.1.1",
|
||||
"private": true,
|
||||
"packageManager": "pnpm@11.19.0",
|
||||
"type": "module",
|
||||
|
||||
@@ -358,7 +358,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clipforge"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"dirs 5.0.1",
|
||||
"reqwest 0.12.28",
|
||||
@@ -372,7 +372,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clipforge-desktop"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"clipforge",
|
||||
"serde",
|
||||
@@ -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,6 +1,6 @@
|
||||
[package]
|
||||
name = "clipforge-desktop"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
description = "Tauri desktop shell for ClipForge."
|
||||
license = "MIT"
|
||||
@@ -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
|
||||
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 6.0 KiB |
|
After Width: | Height: | Size: 8.1 KiB |
|
After Width: | Height: | Size: 8.7 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 9.2 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 8.0 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#fff</color>
|
||||
</resources>
|
||||
|
After Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 32 KiB |
@@ -0,0 +1,12 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">
|
||||
<defs>
|
||||
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0%" stop-color="#2b6cff"/>
|
||||
<stop offset="100%" stop-color="#8b5cf6"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="1024" height="1024" rx="224" fill="url(#bg)"/>
|
||||
<text x="512" y="718" font-family="Arial, Helvetica, sans-serif" font-size="560" font-weight="800" text-anchor="middle" fill="#ffffff">CF</text>
|
||||
<circle cx="766" cy="264" r="66" fill="#34d399"/>
|
||||
<circle cx="766" cy="264" r="28" fill="#191d26"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 605 B |
|
After Width: | Height: | Size: 925 B |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 8.4 KiB |
|
After Width: | Height: | Size: 9.2 KiB |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "ClipForge",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"identifier": "app.clipforge.desktop",
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm run dev",
|
||||
@@ -21,7 +21,15 @@
|
||||
],
|
||||
"withGlobalTauri": true,
|
||||
"security": {
|
||||
"csp": null
|
||||
"csp": null,
|
||||
"assetProtocol": {
|
||||
"enable": true,
|
||||
"scope": [
|
||||
"$DOCUMENT/ClipForge/**",
|
||||
"$PICTURE/ClipForge/**",
|
||||
"$HOME/.clipforge/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -4,6 +4,7 @@ pub mod capture;
|
||||
pub mod crashlog;
|
||||
pub mod database;
|
||||
pub mod game_detection;
|
||||
pub mod ram_buffer;
|
||||
pub mod game_watcher;
|
||||
pub mod gsi_config;
|
||||
pub mod hotkeys;
|
||||
@@ -14,6 +15,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;
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,325 @@
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
/// One finished replay segment held entirely in memory. Encoders write to a
|
||||
/// file path, so a background worker moves each completed segment from disk
|
||||
/// into RAM (and removes the on-disk copy) right after it is finalized.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RamSegment {
|
||||
pub file_name: String,
|
||||
pub modified_at: SystemTime,
|
||||
pub data: Vec<u8>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct RamReplayBuffer {
|
||||
segments: Vec<RamSegment>,
|
||||
}
|
||||
|
||||
/// Hard ceiling so the in-memory replay buffer can never exhaust the
|
||||
/// machine's RAM, even if the replay window grows well beyond the default.
|
||||
pub const DEFAULT_RAM_CAP_BYTES: usize = 512 * 1024 * 1024;
|
||||
|
||||
impl RamReplayBuffer {
|
||||
pub fn insert(&mut self, file_name: String, modified_at: SystemTime, data: Vec<u8>) {
|
||||
self.segments.retain(|segment| segment.file_name != file_name);
|
||||
self.segments.push(RamSegment {
|
||||
file_name,
|
||||
modified_at,
|
||||
data,
|
||||
});
|
||||
self.segments
|
||||
.sort_by(|left, right| left.modified_at.cmp(&right.modified_at));
|
||||
}
|
||||
|
||||
pub fn contains(&self, file_name: &str) -> bool {
|
||||
self.segments
|
||||
.iter()
|
||||
.any(|segment| segment.file_name == file_name)
|
||||
}
|
||||
|
||||
/// Keeps only segments younger than the replay window plus one segment of
|
||||
/// slack, mirroring the disk-side policy in `prune_old_segments`.
|
||||
pub fn prune_to_window(
|
||||
&mut self,
|
||||
window: Duration,
|
||||
segment_duration: Duration,
|
||||
now: SystemTime,
|
||||
) {
|
||||
let cutoff = now
|
||||
.checked_sub(window + segment_duration)
|
||||
.unwrap_or(SystemTime::UNIX_EPOCH);
|
||||
self.segments.retain(|segment| segment.modified_at >= cutoff);
|
||||
}
|
||||
|
||||
/// Safety net: drops the oldest segments until the retained bytes fit
|
||||
/// under `cap`. Independent of the configured replay window.
|
||||
pub fn cap_bytes(&mut self, cap: usize) {
|
||||
let mut total: usize = self.segments.iter().map(|segment| segment.data.len()).sum();
|
||||
while total > cap {
|
||||
let Some(oldest) = self.segments.first() else {
|
||||
break;
|
||||
};
|
||||
total = total.saturating_sub(oldest.data.len());
|
||||
self.segments.remove(0);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear(&mut self) {
|
||||
self.segments.clear();
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.segments.is_empty()
|
||||
}
|
||||
|
||||
pub fn buffered_bytes(&self) -> usize {
|
||||
self.segments.iter().map(|segment| segment.data.len()).sum()
|
||||
}
|
||||
}
|
||||
|
||||
/// A save candidate that may live either on disk (not yet ingested into RAM)
|
||||
/// or strictly in RAM.
|
||||
#[derive(Debug)]
|
||||
pub struct MergedSegment {
|
||||
pub modified_at: SystemTime,
|
||||
pub file_name: String,
|
||||
pub on_disk: Option<PathBuf>,
|
||||
pub in_ram: Option<RamSegment>,
|
||||
}
|
||||
|
||||
/// Merges the rolling segments for a save operation: everything still on disk
|
||||
/// plus everything held in RAM, deduplicated by file name (a segment is either
|
||||
/// on disk or already ingested), and sorted oldest-first. When `window` is
|
||||
/// provided only segments inside the window are kept; `None` selects the whole
|
||||
/// buffer (used when finishing a session recording).
|
||||
pub fn merged_segments(
|
||||
ram: &RamReplayBuffer,
|
||||
buffer_dir: &Path,
|
||||
window: Option<Duration>,
|
||||
segment_duration: Duration,
|
||||
now: SystemTime,
|
||||
) -> io::Result<Vec<MergedSegment>> {
|
||||
let cutoff = match window {
|
||||
Some(window) => now
|
||||
.checked_sub(window + segment_duration)
|
||||
.unwrap_or(SystemTime::UNIX_EPOCH),
|
||||
None => SystemTime::UNIX_EPOCH,
|
||||
};
|
||||
|
||||
let mut merged: Vec<MergedSegment> = collect_disk_segments(buffer_dir)?
|
||||
.into_iter()
|
||||
.filter(|segment| segment.modified_at >= cutoff)
|
||||
.map(|segment| MergedSegment {
|
||||
modified_at: segment.modified_at,
|
||||
file_name: segment.file_name,
|
||||
on_disk: Some(segment.path),
|
||||
in_ram: None,
|
||||
})
|
||||
.collect();
|
||||
|
||||
for ram_segment in ram
|
||||
.segments
|
||||
.iter()
|
||||
.filter(|segment| segment.modified_at >= cutoff)
|
||||
{
|
||||
if let Some(disk) = merged
|
||||
.iter_mut()
|
||||
.find(|candidate| candidate.file_name == ram_segment.file_name)
|
||||
{
|
||||
disk.in_ram = Some(ram_segment.clone());
|
||||
} else {
|
||||
merged.push(MergedSegment {
|
||||
modified_at: ram_segment.modified_at,
|
||||
file_name: ram_segment.file_name.clone(),
|
||||
on_disk: None,
|
||||
in_ram: Some(ram_segment.clone()),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
merged.sort_by(|left, right| left.modified_at.cmp(&right.modified_at));
|
||||
Ok(merged)
|
||||
}
|
||||
|
||||
/// Materializes RAM-held segments into real files inside `staging_dir` so that
|
||||
/// FFmpeg can concatenate them, and returns the ordered list of paths covering
|
||||
/// the whole merge (disk files are used in place, never copied).
|
||||
pub fn spool_merged(
|
||||
staging_dir: &Path,
|
||||
prefix: &str,
|
||||
merged: &[MergedSegment],
|
||||
) -> io::Result<Vec<PathBuf>> {
|
||||
if merged.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
fs::create_dir_all(staging_dir)?;
|
||||
let mut paths = Vec::with_capacity(merged.len());
|
||||
for (index, segment) in merged.iter().enumerate() {
|
||||
if let Some(path) = &segment.on_disk {
|
||||
paths.push(path.clone());
|
||||
} else if let Some(segment) = &segment.in_ram {
|
||||
let staged = staging_dir.join(format!(
|
||||
"{prefix}-{index:04}-{}",
|
||||
sanitize_file_name(&segment.file_name)
|
||||
));
|
||||
fs::write(&staged, &segment.data)?;
|
||||
paths.push(staged);
|
||||
}
|
||||
}
|
||||
Ok(paths)
|
||||
}
|
||||
|
||||
fn sanitize_file_name(name: &str) -> String {
|
||||
name.chars()
|
||||
.map(|character| {
|
||||
if character.is_ascii_alphanumeric() || matches!(character, '-' | '_' | '.') {
|
||||
character
|
||||
} else {
|
||||
'_'
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Lists `.mp4` files directly inside a buffer directory (current session only).
|
||||
pub fn collect_disk_segments(buffer_dir: &Path) -> io::Result<Vec<DiskSegmentFile>> {
|
||||
let mut segments = Vec::new();
|
||||
if !buffer_dir.exists() {
|
||||
return Ok(segments);
|
||||
}
|
||||
for entry in fs::read_dir(buffer_dir)? {
|
||||
let entry = entry?;
|
||||
let path = entry.path();
|
||||
if path.extension().and_then(|value| value.to_str()) != Some("mp4") {
|
||||
continue;
|
||||
}
|
||||
let file_name = entry.file_name().to_string_lossy().into_owned();
|
||||
let modified_at = entry.metadata()?.modified().unwrap_or(SystemTime::UNIX_EPOCH);
|
||||
segments.push(DiskSegmentFile {
|
||||
file_name,
|
||||
path,
|
||||
modified_at,
|
||||
});
|
||||
}
|
||||
segments.sort_by(|left, right| left.modified_at.cmp(&right.modified_at));
|
||||
Ok(segments)
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct DiskSegmentFile {
|
||||
pub file_name: String,
|
||||
pub path: PathBuf,
|
||||
pub modified_at: SystemTime,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn segment(file_name: &str, age: u64, now: SystemTime) -> RamSegment {
|
||||
RamSegment {
|
||||
file_name: file_name.to_string(),
|
||||
modified_at: now - Duration::from_secs(age),
|
||||
data: file_name.as_bytes().to_vec(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn window_prune_drops_only_stale_segments() {
|
||||
let now = SystemTime::now();
|
||||
let mut ram = RamReplayBuffer::default();
|
||||
ram.insert("a.mp4".to_string(), now - Duration::from_secs(60), vec![1]);
|
||||
ram.insert("b.mp4".to_string(), now - Duration::from_secs(20), vec![2]);
|
||||
ram.insert("c.mp4".to_string(), now - Duration::from_secs(2), vec![3]);
|
||||
|
||||
ram.prune_to_window(Duration::from_secs(30), Duration::from_secs(5), now);
|
||||
|
||||
let remaining: Vec<&str> = ram
|
||||
.segments
|
||||
.iter()
|
||||
.map(|segment| segment.file_name.as_str())
|
||||
.collect();
|
||||
assert_eq!(remaining, vec!["b.mp4", "c.mp4"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn byte_cap_frees_oldest_first() {
|
||||
let now = SystemTime::now();
|
||||
let mut ram = RamReplayBuffer::default();
|
||||
ram.insert("a.mp4".to_string(), now - Duration::from_secs(30), vec![0; 100]);
|
||||
ram.insert("b.mp4".to_string(), now - Duration::from_secs(20), vec![0; 100]);
|
||||
ram.insert("c.mp4".to_string(), now - Duration::from_secs(10), vec![0; 100]);
|
||||
|
||||
ram.cap_bytes(250);
|
||||
|
||||
let first = ram.segments.first().map(|segment| segment.file_name.as_str());
|
||||
assert_eq!(first, Some("b.mp4"));
|
||||
assert_eq!(ram.buffered_bytes(), 200);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn merge_prefers_disk_copy_and_is_sorted() {
|
||||
let root = std::env::temp_dir().join(format!(
|
||||
"clipforge-ram-{}",
|
||||
crate::media::timestamp_millis(SystemTime::now())
|
||||
));
|
||||
fs::create_dir_all(&root).expect("test root");
|
||||
let now = SystemTime::now();
|
||||
fs::write(root.join("disk.mp4"), b"disk").expect("disk file");
|
||||
// The disk file's real mtime is essentially "now", so it sorts after
|
||||
// the RAM-held segment that claims to be 6 seconds old.
|
||||
let disk_modified_at = fs::metadata(root.join("disk.mp4"))
|
||||
.expect("disk metadata")
|
||||
.modified()
|
||||
.expect("disk modified");
|
||||
|
||||
let mut ram = RamReplayBuffer::default();
|
||||
ram.insert(
|
||||
"disk.mp4".to_string(),
|
||||
now - Duration::from_secs(10),
|
||||
b"ram-copy".to_vec(),
|
||||
);
|
||||
ram.insert(
|
||||
"ram-only.mp4".to_string(),
|
||||
now - Duration::from_secs(6),
|
||||
b"ram-only".to_vec(),
|
||||
);
|
||||
ram.insert(
|
||||
"old.mp4".to_string(),
|
||||
now - Duration::from_secs(120),
|
||||
b"old".to_vec(),
|
||||
);
|
||||
|
||||
let merged = merged_segments(
|
||||
&ram,
|
||||
&root,
|
||||
Some(Duration::from_secs(60)),
|
||||
Duration::from_secs(5),
|
||||
now,
|
||||
)
|
||||
.expect("merge");
|
||||
|
||||
let file_names: Vec<String> = merged
|
||||
.iter()
|
||||
.map(|segment| segment.file_name.clone())
|
||||
.collect();
|
||||
// Sorted oldest-first: ram-only (6s old) before the just-written disk.mp4.
|
||||
assert_eq!(file_names, vec!["ram-only.mp4", "disk.mp4"]);
|
||||
// The disk file wins over the identical RAM copy.
|
||||
let disk_merge = &merged[1];
|
||||
assert!(disk_merge.on_disk.is_some());
|
||||
assert_eq!(
|
||||
disk_merge.on_disk.as_ref().unwrap().file_name().unwrap().to_str(),
|
||||
Some("disk.mp4")
|
||||
);
|
||||
assert!(disk_merge.modified_at >= disk_modified_at);
|
||||
|
||||
let spool = root.join("staging");
|
||||
let paths = spool_merged(&spool, "clip", &merged).expect("spool");
|
||||
assert_eq!(paths.len(), 2);
|
||||
let _ = fs::remove_dir_all(root);
|
||||
}
|
||||
}
|
||||
@@ -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()))?;
|
||||
|
||||
@@ -47,7 +47,10 @@ pub struct AutoClipSettings {
|
||||
pub pre_roll: Duration,
|
||||
pub post_roll: Duration,
|
||||
pub merge_window: Duration,
|
||||
#[serde(default)]
|
||||
pub enabled_events_by_game: BTreeMap<String, BTreeSet<String>>,
|
||||
#[serde(default)]
|
||||
pub disabled_games: BTreeSet<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@@ -93,6 +96,10 @@ 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,
|
||||
#[serde(default)]
|
||||
pub auto_prune_old_clips: bool,
|
||||
}
|
||||
|
||||
impl AppSettings {
|
||||
@@ -136,10 +143,13 @@ impl AppSettings {
|
||||
post_roll: Duration::from_secs(8),
|
||||
merge_window: Duration::from_secs(12),
|
||||
enabled_events_by_game: BTreeMap::new(),
|
||||
disabled_games: BTreeSet::new(),
|
||||
},
|
||||
upload: UploadSettings::default(),
|
||||
quality_overrides_by_game: BTreeMap::new(),
|
||||
onboarding_complete: false,
|
||||
minimize_to_tray_enabled: false,
|
||||
auto_prune_old_clips: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,18 @@ impl LibraryPaths {
|
||||
}
|
||||
}
|
||||
|
||||
/// Builds paths while honoring a user-selected clip directory. Thumbs,
|
||||
/// sessions, and the rolling buffer stay under the library root.
|
||||
pub fn with_clip_root(root: impl Into<PathBuf>, clip_root: impl Into<PathBuf>) -> Self {
|
||||
let root = root.into();
|
||||
Self {
|
||||
clip_root: clip_root.into(),
|
||||
thumbs_root: root.join("thumbs"),
|
||||
sessions_root: root.join("sessions"),
|
||||
buffer_root: root.join("buffer"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ensure(&self) -> io::Result<()> {
|
||||
fs::create_dir_all(&self.clip_root)?;
|
||||
fs::create_dir_all(&self.thumbs_root)?;
|
||||
|
||||
@@ -112,10 +112,20 @@ pub fn build_update_check(
|
||||
release: &GitHubRelease,
|
||||
) -> Result<UpdateCheck, UpdateCheckError> {
|
||||
let latest_version = normalize_version(&release.tag_name);
|
||||
let update_available = compare_versions(current_version, &latest_version) == Ordering::Less;
|
||||
let newer_release_exists = compare_versions(current_version, &latest_version) == Ordering::Less;
|
||||
let installer = select_installer_asset(&release.assets);
|
||||
|
||||
let message = if update_available {
|
||||
// A newer tag without a published installer is not something the user can
|
||||
// download, so never claim the app is installable in that state.
|
||||
let update_available = newer_release_exists && installer.is_some();
|
||||
|
||||
let message = if !newer_release_exists {
|
||||
"You are on the latest version.".to_string()
|
||||
} else if installer.is_none() {
|
||||
format!(
|
||||
"A newer version ({latest_version}) exists, but no installer has been published for it yet."
|
||||
)
|
||||
} else {
|
||||
let file = installer
|
||||
.as_ref()
|
||||
.map(|asset| asset.name.as_str())
|
||||
@@ -123,8 +133,6 @@ pub fn build_update_check(
|
||||
format!(
|
||||
"A newer version ({latest_version}) is available — {file}, ready to download."
|
||||
)
|
||||
} else {
|
||||
"You are on the latest version.".to_string()
|
||||
};
|
||||
|
||||
Ok(UpdateCheck {
|
||||
@@ -217,6 +225,79 @@ mod tests {
|
||||
assert_eq!(compare_versions("0.3.0", "0.3.0"), Ordering::Equal);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn installed_040_detects_published_050_as_available_update() {
|
||||
let release = GitHubRelease {
|
||||
tag_name: "v0.0.5".to_string(),
|
||||
published_at: Some("2026-09-08T00:00:00Z".to_string()),
|
||||
body: None,
|
||||
assets: vec![GitHubAsset {
|
||||
name: "ClipForge_0.1.1_x64_en-US.msi".to_string(),
|
||||
size: Some(1_000_000),
|
||||
browser_download_url: "https://example.test/ClipForge_0.1.1.msi".to_string(),
|
||||
}],
|
||||
};
|
||||
let check = build_update_check("0.0.4", &release).expect("check");
|
||||
|
||||
assert!(check.update_available, "v0.0.4 must see v0.0.5 as an update");
|
||||
assert_eq!(check.latest_version, "0.0.5");
|
||||
assert_eq!(
|
||||
check.installer_file.as_deref(),
|
||||
Some("ClipForge_0.1.1_x64_en-US.msi")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn same_version_is_reported_as_up_to_date() {
|
||||
let release = GitHubRelease {
|
||||
tag_name: "v0.1.1".to_string(),
|
||||
published_at: None,
|
||||
body: None,
|
||||
assets: vec![GitHubAsset {
|
||||
name: "ClipForge_0.1.1_x64-setup.exe".to_string(),
|
||||
size: None,
|
||||
browser_download_url: "https://example.test/setup.exe".to_string(),
|
||||
}],
|
||||
};
|
||||
let check = build_update_check("0.1.1", &release).expect("check");
|
||||
|
||||
assert!(!check.update_available);
|
||||
assert_eq!(check.message, "You are on the latest version.");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn newer_tag_without_installer_is_not_offered_for_download() {
|
||||
let release = GitHubRelease {
|
||||
tag_name: "v0.9.0".to_string(),
|
||||
published_at: Some("2026-09-09T00:00:00Z".to_string()),
|
||||
body: Some("notes".to_string()),
|
||||
assets: vec![GitHubAsset {
|
||||
name: "checksums.txt".to_string(),
|
||||
size: Some(128),
|
||||
browser_download_url: "https://example.test/checksums.txt".to_string(),
|
||||
}],
|
||||
};
|
||||
let check = build_update_check("0.1.1", &release).expect("check");
|
||||
|
||||
assert!(!check.update_available);
|
||||
assert!(check.download_url.is_none());
|
||||
assert!(check.message.contains("no installer has been published"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn patch_versions_compare_numerically_not_lexically() {
|
||||
assert_eq!(compare_versions("0.0.9", "0.0.10"), Ordering::Less);
|
||||
assert_eq!(compare_versions("0.0.10", "0.0.10"), Ordering::Equal);
|
||||
assert_eq!(compare_versions("0.0.11", "0.0.10"), Ordering::Greater);
|
||||
assert_eq!(compare_versions("0.1.0", "0.1.1"), Ordering::Less);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn older_tag_backports_do_not_mask_newer_release() {
|
||||
assert_eq!(compare_versions("0.2.0", "0.1.1"), Ordering::Greater);
|
||||
assert_eq!(compare_versions("0.1.1", "0.2.0"), Ordering::Less);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn leading_v_and_prerelease_tags_are_ignored() {
|
||||
assert_eq!(compare_versions("v0.1.0", "v0.2.0"), Ordering::Less);
|
||||
|
||||
@@ -70,6 +70,7 @@ type DesktopStatus = {
|
||||
system_audio_available: boolean;
|
||||
desktop_duplication_available: boolean;
|
||||
auto_clip_enabled_events: AutoClipEventDto[];
|
||||
auto_clip_disabled_games: string[];
|
||||
hotkey_clip_last_60s: string;
|
||||
hotkey_clip_last_30s: string;
|
||||
hotkey_toggle_session_recording: string;
|
||||
@@ -79,12 +80,16 @@ type DesktopStatus = {
|
||||
capture_bitrate_kbps: number;
|
||||
capture_resolution: string;
|
||||
storage_limit_gb: number;
|
||||
clip_directory: string;
|
||||
storage_limit_exceeded: boolean;
|
||||
auto_prune_old_clips: boolean;
|
||||
excluded_window_titles: string[];
|
||||
separate_audio_tracks: boolean;
|
||||
game_quality_overrides: GameQualityOverrideDto[];
|
||||
effective_quality_applied: boolean;
|
||||
app_version: string;
|
||||
onboarding_complete: boolean;
|
||||
minimize_to_tray: boolean;
|
||||
};
|
||||
|
||||
type ClipDto = {
|
||||
@@ -176,6 +181,7 @@ type AppState = {
|
||||
screenshots: string[];
|
||||
uploadHistory: UploadHistoryEntry[];
|
||||
autoEvents: AutoEvent[];
|
||||
disabledGames: string[];
|
||||
hotkeyClipLast60s: string;
|
||||
hotkeyClipLast30s: string;
|
||||
hotkeyToggleRecording: string;
|
||||
@@ -185,21 +191,36 @@ type AppState = {
|
||||
captureBitrateKbps: number;
|
||||
captureResolution: string;
|
||||
storageLimitGb: number;
|
||||
clipDirectory: string;
|
||||
storageLimitExceeded: boolean;
|
||||
autoPruneOldClips: boolean;
|
||||
excludedWindowTitles: string[];
|
||||
excludedWindowText: string;
|
||||
separateAudioTracks: boolean;
|
||||
appVersion: string;
|
||||
onboardingComplete: boolean;
|
||||
minimizeToTray: boolean;
|
||||
onboardingStep: number;
|
||||
gameQualityOverrides: GameQualityOverrideDto[];
|
||||
effectiveQualityApplied: boolean;
|
||||
update: UpdateInfo;
|
||||
modal: {
|
||||
open: boolean;
|
||||
kind: "clip" | "screenshot";
|
||||
clipId: string;
|
||||
screenshotPath: string;
|
||||
videoFailed: boolean;
|
||||
videoError: string;
|
||||
};
|
||||
};
|
||||
|
||||
type TauriGlobal = {
|
||||
core?: {
|
||||
invoke?: <T>(command: string, args?: Record<string, unknown>) => Promise<T>;
|
||||
};
|
||||
event?: {
|
||||
listen?: <T>(eventName: string, handler: (event: { payload: T }) => void) => Promise<() => void>;
|
||||
};
|
||||
};
|
||||
|
||||
declare global {
|
||||
@@ -265,6 +286,7 @@ const state: AppState = {
|
||||
{ id: "dota-multi", gameId: "dota-2", eventType: "multi_kill", game: "Dota 2", event: "Multi-kill", enabled: true },
|
||||
{ id: "dota-mvp", gameId: "dota-2", eventType: "mvp", game: "Dota 2", event: "MVP", enabled: true },
|
||||
],
|
||||
disabledGames: [],
|
||||
hotkeyClipLast60s: "F8",
|
||||
hotkeyClipLast30s: "Shift+F8",
|
||||
hotkeyToggleRecording: "Alt+F7",
|
||||
@@ -274,11 +296,23 @@ const state: AppState = {
|
||||
captureBitrateKbps: 6000,
|
||||
captureResolution: "1280x720",
|
||||
storageLimitGb: 50,
|
||||
clipDirectory: "",
|
||||
storageLimitExceeded: false,
|
||||
autoPruneOldClips: false,
|
||||
excludedWindowTitles: [],
|
||||
excludedWindowText: "",
|
||||
separateAudioTracks: false,
|
||||
appVersion: "0.1.0",
|
||||
appVersion: "0.1.1",
|
||||
modal: {
|
||||
open: false,
|
||||
kind: "clip",
|
||||
clipId: "",
|
||||
screenshotPath: "",
|
||||
videoFailed: false,
|
||||
videoError: "",
|
||||
},
|
||||
onboardingComplete: true,
|
||||
minimizeToTray: false,
|
||||
onboardingStep: 0,
|
||||
gameQualityOverrides: [],
|
||||
effectiveQualityApplied: false,
|
||||
@@ -333,10 +367,105 @@ function render() {
|
||||
${renderActiveView(selectedClip)}
|
||||
</section>
|
||||
</main>
|
||||
${renderModal()}
|
||||
`;
|
||||
bindEvents();
|
||||
}
|
||||
|
||||
function openClipModal(clipId: string) {
|
||||
state.selectedClipId = clipId;
|
||||
state.modal.open = true;
|
||||
state.modal.kind = "clip";
|
||||
state.modal.clipId = clipId;
|
||||
state.modal.videoFailed = false;
|
||||
state.modal.videoError = "";
|
||||
render();
|
||||
}
|
||||
|
||||
function openScreenshotModal(path: string) {
|
||||
state.modal.open = true;
|
||||
state.modal.kind = "screenshot";
|
||||
state.modal.screenshotPath = path;
|
||||
state.modal.videoFailed = false;
|
||||
state.modal.videoError = "";
|
||||
render();
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
state.modal.open = false;
|
||||
render();
|
||||
}
|
||||
|
||||
function renderModal() {
|
||||
if (!state.modal.open) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (state.modal.kind === "screenshot") {
|
||||
const path = state.modal.screenshotPath;
|
||||
return `
|
||||
<div class="modal-overlay" data-action="modal-backdrop">
|
||||
<div class="modal" role="dialog" aria-modal="true" aria-label="Screenshot preview">
|
||||
<div class="modal-header">
|
||||
<h2>Screenshot preview</h2>
|
||||
<button class="modal-close" data-action="modal-close" aria-label="Close">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<img src="${convertFileSrc(path)}" alt="Screenshot preview" />
|
||||
<p class="muted file-path">${escapeHtml(path)}</p>
|
||||
<div class="actions">
|
||||
<button data-action="reveal-screenshot" data-screenshot-path="${escapeHtml(path)}">Open in Explorer</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
const clip = state.clips.find((candidate) => candidate.id === state.modal.clipId);
|
||||
if (!clip) {
|
||||
return "";
|
||||
}
|
||||
const durationDisplay = formatDuration(parseTimestamp(clip.duration));
|
||||
const canPlay = Boolean(clip.videoUrl) && !state.modal.videoFailed;
|
||||
return `
|
||||
<div class="modal-overlay" data-action="modal-backdrop">
|
||||
<div class="modal" role="dialog" aria-modal="true" aria-label="Clip preview">
|
||||
<div class="modal-header">
|
||||
<h2>${escapeHtml(clip.title)}</h2>
|
||||
<button class="modal-close" data-action="modal-close" aria-label="Close">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
${
|
||||
canPlay
|
||||
? `<video controls preload="metadata" autoplay src="${clip.videoUrl}" poster="${clip.thumbnailUrl ?? ""}" id="modal-video"></video>`
|
||||
: `
|
||||
<div class="video-error">
|
||||
<h3>Preview could not load</h3>
|
||||
<p class="muted">${escapeHtml(state.modal.videoError || "No preview is available for this clip.")}</p>
|
||||
<p class="muted file-path">${escapeHtml(clip.path || "No file path on record.")}</p>
|
||||
<div class="actions">
|
||||
<button data-action="modal-reveal">Reveal in Explorer</button>
|
||||
<button data-action="modal-retry">Try loading again</button>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
<p class="muted">${escapeHtml(clip.game)} · ${escapeHtml(clip.event)} · ${escapeHtml(clip.createdAt)} · ${escapeHtml(clip.uploadState)}</p>
|
||||
<label>Trim start <input value="00:00" data-action="modal-trim-start" /></label>
|
||||
<label>Trim end <input value="${escapeHtml(durationDisplay)}" data-action="modal-trim-end" /></label>
|
||||
<div class="actions">
|
||||
<button data-action="modal-trim">Trim</button>
|
||||
<button data-action="modal-upload">Upload</button>
|
||||
<button data-action="modal-reveal">Reveal</button>
|
||||
<button data-action="modal-delete">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderOnboardingWizard() {
|
||||
const step = state.onboardingStep;
|
||||
const steps = ["Privacy", "Capture source", "Storage", "Hotkeys"];
|
||||
@@ -540,6 +669,7 @@ function renderScreenshotCard(path: string) {
|
||||
<h3>${escapeHtml(filename)}</h3>
|
||||
<p class="muted">${escapeHtml(path)}</p>
|
||||
<div class="actions">
|
||||
<button data-action="open-modal-screenshot" data-screenshot-path="${escapeHtml(path)}">Preview</button>
|
||||
<button data-action="reveal-screenshot" data-screenshot-path="${escapeHtml(path)}">Open</button>
|
||||
</div>
|
||||
</article>
|
||||
@@ -573,6 +703,9 @@ function renderClipCard(clip: Clip) {
|
||||
</div>
|
||||
<h3>${escapeHtml(clip.title)}</h3>
|
||||
<p>${escapeHtml(clip.game)} · ${escapeHtml(clip.source)} · ${escapeHtml(clip.duration)}</p>
|
||||
<div class="actions">
|
||||
<button data-action="open-modal-clip" data-clip-id="${clip.id}">Preview</button>
|
||||
</div>
|
||||
</article>
|
||||
`;
|
||||
}
|
||||
@@ -716,6 +849,12 @@ function renderRecordingView() {
|
||||
}
|
||||
|
||||
function renderAutoClipView() {
|
||||
const games: Array<{ gameId: string; game: string }> = [];
|
||||
for (const event of state.autoEvents) {
|
||||
if (!games.some((game) => game.gameId === event.gameId)) {
|
||||
games.push({ gameId: event.gameId, game: event.game });
|
||||
}
|
||||
}
|
||||
return `
|
||||
<section class="table-panel">
|
||||
<div class="section-heading">
|
||||
@@ -725,18 +864,40 @@ function renderAutoClipView() {
|
||||
</div>
|
||||
<div class="status-pill">Local APIs only</div>
|
||||
</div>
|
||||
<div class="event-list">
|
||||
${state.autoEvents
|
||||
.map(
|
||||
(event) => `
|
||||
<label class="event-row">
|
||||
<span><strong>${escapeHtml(event.game)}</strong><small>${escapeHtml(event.event)}</small></span>
|
||||
<input type="checkbox" ${event.enabled ? "checked" : ""} data-event-id="${event.id}" />
|
||||
</label>
|
||||
`,
|
||||
)
|
||||
.join("")}
|
||||
<div class="actions auto-clip-global-actions">
|
||||
<button data-action="auto-clip-enable-all">Enable all games</button>
|
||||
<button data-action="auto-clip-disable-all">Disable all games</button>
|
||||
<button data-action="auto-clip-restore">Restore defaults</button>
|
||||
</div>
|
||||
${games
|
||||
.map((game) => {
|
||||
const gameEvents = state.autoEvents.filter((event) => event.gameId === game.gameId);
|
||||
const gameEnabled = !state.disabledGames.includes(game.gameId);
|
||||
return `
|
||||
<section class="auto-clip-group ${gameEnabled ? "" : "disabled"}">
|
||||
<div class="auto-clip-group-head">
|
||||
<label class="toggle">
|
||||
<input type="checkbox" ${gameEnabled ? "checked" : ""} data-game-id="${escapeHtml(game.gameId)}" data-action="toggle-game-clips" />
|
||||
<strong>${escapeHtml(game.game)}</strong>
|
||||
</label>
|
||||
<span class="status-pill">${gameEnabled ? "Clipping enabled" : "Clipping disabled"}</span>
|
||||
</div>
|
||||
<div class="event-list">
|
||||
${gameEvents
|
||||
.map(
|
||||
(event) => `
|
||||
<label class="event-row">
|
||||
<span><strong>${escapeHtml(event.event)}</strong></span>
|
||||
<input type="checkbox" ${event.enabled ? "checked" : ""} data-event-id="${event.id}" ${gameEnabled ? "" : "disabled"} />
|
||||
</label>
|
||||
`,
|
||||
)
|
||||
.join("")}
|
||||
</div>
|
||||
</section>
|
||||
`;
|
||||
})
|
||||
.join("")}
|
||||
<div class="actions">
|
||||
<button data-action="write-gsi-configs">Write GSI Configs</button>
|
||||
</div>
|
||||
@@ -855,7 +1016,17 @@ function renderSettingsView() {
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<label>Video bitrate (kbps) <input type="number" min="500" max="50000" step="500" value="${state.captureBitrateKbps}" data-action="capture-bitrate" /></label>
|
||||
<label>Video bitrate preset
|
||||
<select data-action="capture-bitrate-preset" aria-label="Bitrate preset">
|
||||
<option value="2500" ${state.captureBitrateKbps <= 3500 ? "selected" : ""}>Low (2500)</option>
|
||||
<option value="4500" ${state.captureBitrateKbps > 3500 && state.captureBitrateKbps <= 5500 ? "selected" : ""}>Medium (4500)</option>
|
||||
<option value="6000" ${state.captureBitrateKbps > 5500 && state.captureBitrateKbps <= 8000 ? "selected" : ""}>Stream-ready (6000)</option>
|
||||
<option value="10000" ${state.captureBitrateKbps > 8000 && state.captureBitrateKbps <= 12000 ? "selected" : ""}>High (10000)</option>
|
||||
<option value="14000" ${state.captureBitrateKbps > 12000 ? "selected" : ""}>Ultra (14000)</option>
|
||||
<option value="custom" ${state.captureBitrateKbps < 2500 || state.captureBitrateKbps > 14000 ? "selected" : ""}>Custom…</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>Custom bitrate (kbps) <input type="number" min="500" max="50000" step="500" value="${state.captureBitrateKbps}" data-action="capture-bitrate" /></label>
|
||||
<label>Buffer storage cap (GB) <input type="number" min="5" max="5000" step="1" value="${state.storageLimitGb}" data-action="capture-storage-gb" /></label>
|
||||
<label>Excluded window titles
|
||||
<textarea rows="2" placeholder="comma separated, e.g. Brave, Discord - Settings" data-action="excluded-windows">${escapeHtml(state.excludedWindowText)}</textarea>
|
||||
@@ -865,8 +1036,21 @@ function renderSettingsView() {
|
||||
</article>
|
||||
<article class="settings-panel">
|
||||
<p class="eyebrow">Storage</p>
|
||||
<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>
|
||||
<h2>Clips & replay buffer</h2>
|
||||
<label>Clip folder
|
||||
<input value="${escapeHtml(state.clipDirectory)}" data-action="clip-directory" spellcheck="false" placeholder="C:\\Users\\You\\Videos\\Clips" />
|
||||
</label>
|
||||
<button data-action="change-clip-dir">Apply Clip Folder</button>
|
||||
${state.storageLimitExceeded ? `<p class="warn">The saved library is currently above the ${state.storageLimitGb} GB limit.</p>` : ""}
|
||||
<label class="toggle"><input type="checkbox" ${state.autoPruneOldClips ? "checked" : ""} data-action="toggle-auto-prune" /> Auto-delete oldest clips when the library exceeds the ${state.storageLimitGb} GB limit</label>
|
||||
<p class="muted">${state.autoPruneOldClips ? "When the limit is exceeded, the oldest automatic/event/session clips are deleted (oldest first) until you are back under it. Clips you saved manually are never auto-deleted." : "Up to the limit, the rolling replay buffer is always pruned automatically to keep it from growing. Saved clips are kept. Enable auto-cleanup above to also trim oldest clips when the limit is exceeded."}</p>
|
||||
<p class="muted">This limit is set in Capture Settings (buffer storage cap).</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>
|
||||
@@ -874,9 +1058,8 @@ function renderSettingsView() {
|
||||
<p class="muted">${escapeHtml(state.update.message)}</p>
|
||||
${state.update.updateAvailable ? `
|
||||
<button data-action="download-update" ${state.update.applying ? "disabled" : ""}>Download & install v${escapeHtml(state.update.latestVersion)}</button>
|
||||
` : `
|
||||
<button data-action="check-updates" ${state.update.applying ? "disabled" : ""}>Check for updates</button>
|
||||
`}
|
||||
` : ""}
|
||||
<button data-action="check-updates" ${state.update.applying ? "disabled" : ""}>${state.update.checked ? "Check for updates again" : "Check for updates"}</button>
|
||||
<button data-action="reveal-crash-logs">Reveal Crash Logs</button>
|
||||
</article>
|
||||
<article class="settings-panel">
|
||||
@@ -1004,6 +1187,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;
|
||||
@@ -1053,6 +1242,30 @@ function bindEvents() {
|
||||
});
|
||||
});
|
||||
|
||||
appRoot.querySelectorAll<HTMLInputElement>("[data-action='toggle-game-clips']").forEach((input) => {
|
||||
input.addEventListener("change", () => {
|
||||
const gameId = input.dataset.gameId;
|
||||
if (gameId) {
|
||||
state.disabledGames = input.checked
|
||||
? state.disabledGames.filter((game) => game !== gameId)
|
||||
: [...state.disabledGames, gameId];
|
||||
void invokeSetGameAutoClipEnabled(gameId, input.checked);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='auto-clip-enable-all']")?.addEventListener("click", () => {
|
||||
void invokeAutoClipBulk("enable_all_auto_clips");
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='auto-clip-disable-all']")?.addEventListener("click", () => {
|
||||
void invokeAutoClipBulk("disable_all_auto_clips");
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='auto-clip-restore']")?.addEventListener("click", () => {
|
||||
void invokeAutoClipBulk("restore_default_auto_clips");
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLInputElement>("[data-action='hotkey-clip-60s']")?.addEventListener("change", (event) => {
|
||||
state.hotkeyClipLast60s = (event.target as HTMLInputElement).value;
|
||||
});
|
||||
@@ -1078,7 +1291,19 @@ function bindEvents() {
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLInputElement>("[data-action='capture-bitrate']")?.addEventListener("input", (event) => {
|
||||
state.captureBitrateKbps = Number((event.target as HTMLInputElement).value);
|
||||
state.captureBitrateKbps = Number((event.target as HTMLInputElement).value);
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLSelectElement>("[data-action='capture-bitrate-preset']")?.addEventListener("change", (event) => {
|
||||
const preset = (event.target as HTMLSelectElement).value;
|
||||
if (preset !== "custom") {
|
||||
const value = Number(preset);
|
||||
state.captureBitrateKbps = value;
|
||||
const input = appRoot.querySelector<HTMLInputElement>("[data-action='capture-bitrate']");
|
||||
if (input) {
|
||||
input.value = String(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLInputElement>("[data-action='capture-storage-gb']")?.addEventListener("input", (event) => {
|
||||
@@ -1101,6 +1326,18 @@ function bindEvents() {
|
||||
void checkForUpdates();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLInputElement>("[data-action='clip-directory']")?.addEventListener("input", (event) => {
|
||||
state.clipDirectory = (event.target as HTMLInputElement).value;
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='change-clip-dir']")?.addEventListener("click", () => {
|
||||
void changeClipDirectory();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLInputElement>("[data-action='toggle-auto-prune']")?.addEventListener("change", (event) => {
|
||||
void setAutoPruneEnabled((event.target as HTMLInputElement).checked);
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='save-override']")?.addEventListener("click", () => {
|
||||
void saveGameQualityOverride();
|
||||
});
|
||||
@@ -1135,6 +1372,63 @@ function bindEvents() {
|
||||
void revealCrashLogs();
|
||||
});
|
||||
|
||||
appRoot.querySelectorAll<HTMLButtonElement>("[data-action='open-modal-clip']").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
const clipId = button.dataset.clipId;
|
||||
if (clipId) {
|
||||
openClipModal(clipId);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
appRoot.querySelectorAll<HTMLButtonElement>("[data-action='open-modal-screenshot']").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
const path = button.dataset.screenshotPath;
|
||||
if (path) {
|
||||
openScreenshotModal(path);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='modal-close']")?.addEventListener("click", closeModal);
|
||||
|
||||
appRoot.querySelector<HTMLElement>("[data-action='modal-backdrop']")?.addEventListener("click", (event) => {
|
||||
if (event.target === event.currentTarget) {
|
||||
closeModal();
|
||||
}
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='modal-trim']")?.addEventListener("click", () => {
|
||||
void trimClipFromModal();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='modal-upload']")?.addEventListener("click", () => {
|
||||
state.selectedClipId = state.modal.clipId;
|
||||
void uploadSelectedClip();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='modal-reveal']")?.addEventListener("click", () => {
|
||||
state.selectedClipId = state.modal.clipId;
|
||||
void revealSelectedClip();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='modal-delete']")?.addEventListener("click", () => {
|
||||
state.selectedClipId = state.modal.clipId;
|
||||
void deleteSelectedClip();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='modal-retry']")?.addEventListener("click", () => {
|
||||
state.modal.videoFailed = false;
|
||||
state.modal.videoError = "";
|
||||
render();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLVideoElement>("#modal-video")?.addEventListener("error", () => {
|
||||
state.modal.videoFailed = true;
|
||||
state.modal.videoError = "The clip file could not be loaded as a preview. It may have been moved or deleted, or the media table of contents is unreadable.";
|
||||
render();
|
||||
});
|
||||
|
||||
appRoot.querySelectorAll<HTMLButtonElement>("[data-action='reveal-screenshot']").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
const path = button.dataset.screenshotPath;
|
||||
@@ -1358,17 +1652,27 @@ async function saveClip() {
|
||||
}
|
||||
|
||||
async function toggleRecording() {
|
||||
const wasActive = state.captureActive;
|
||||
// Optimistically flip the button so the UI reacts instantly; the real status
|
||||
// returned by the backend reconciles it (or it is rolled back on error).
|
||||
state.captureActive = !wasActive;
|
||||
state.recordingState = state.captureActive ? "RecordingSession" : "Buffering";
|
||||
render();
|
||||
|
||||
if (tauriInvoke) {
|
||||
try {
|
||||
const status = await tauriInvoke<DesktopStatus>(state.captureActive ? "stop_capture" : "start_capture");
|
||||
const status = await tauriInvoke<DesktopStatus>(wasActive ? "stop_capture" : "start_capture");
|
||||
applyDesktopStatus(status);
|
||||
await refreshClips();
|
||||
showNotice(state.captureActive ? "Recording started" : "Recording stopped");
|
||||
render();
|
||||
return;
|
||||
} catch (error) {
|
||||
state.captureActive = wasActive;
|
||||
state.recordingState = wasActive ? "RecordingSession" : "Buffering";
|
||||
console.error("Could not toggle desktop recording", error);
|
||||
showNotice(`Could not toggle recording: ${String(error)}`);
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1400,6 +1704,7 @@ function applyDesktopStatus(status: DesktopStatus) {
|
||||
state.ffmpegPath = status.ffmpeg_path;
|
||||
state.systemAudioAvailable = status.system_audio_available;
|
||||
state.desktopDuplicationAvailable = status.desktop_duplication_available;
|
||||
state.disabledGames = status.auto_clip_disabled_games ?? [];
|
||||
for (const event of state.autoEvents) {
|
||||
const enabled = status.auto_clip_enabled_events.find(
|
||||
(candidate) => candidate.game_id === event.gameId && candidate.event_type === event.eventType,
|
||||
@@ -1417,6 +1722,11 @@ function applyDesktopStatus(status: DesktopStatus) {
|
||||
state.captureBitrateKbps = status.capture_bitrate_kbps;
|
||||
state.captureResolution = status.capture_resolution;
|
||||
state.storageLimitGb = status.storage_limit_gb;
|
||||
state.clipDirectory = status.clip_directory ?? state.clipDirectory;
|
||||
state.storageLimitExceeded = status.storage_limit_exceeded ?? false;
|
||||
if (typeof status.auto_prune_old_clips === "boolean") {
|
||||
state.autoPruneOldClips = status.auto_prune_old_clips;
|
||||
}
|
||||
state.excludedWindowTitles = status.excluded_window_titles ?? [];
|
||||
state.excludedWindowText = (status.excluded_window_titles ?? []).join(", ");
|
||||
state.separateAudioTracks = status.separate_audio_tracks ?? false;
|
||||
@@ -1426,6 +1736,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() {
|
||||
@@ -1461,6 +1774,39 @@ async function trimSelectedClip() {
|
||||
}
|
||||
}
|
||||
|
||||
async function trimClipFromModal() {
|
||||
if (!tauriInvoke) {
|
||||
return;
|
||||
}
|
||||
|
||||
const clip = state.clips.find((candidate) => candidate.id === state.modal.clipId);
|
||||
if (!clip) {
|
||||
return;
|
||||
}
|
||||
|
||||
const startInput = appRoot.querySelector<HTMLInputElement>("[data-action='modal-trim-start']");
|
||||
const endInput = appRoot.querySelector<HTMLInputElement>("[data-action='modal-trim-end']");
|
||||
const startSeconds = parseTimestamp(startInput?.value ?? "0");
|
||||
const endSeconds = parseTimestamp(endInput?.value ?? clip.duration);
|
||||
|
||||
try {
|
||||
const dto = await tauriInvoke<ClipDto>("trim_clip", {
|
||||
clipId: clip.id,
|
||||
startSeconds,
|
||||
endSeconds,
|
||||
});
|
||||
const trimmed = clipFromDto(dto);
|
||||
state.clips.unshift(trimmed);
|
||||
state.selectedClipId = trimmed.id;
|
||||
await refreshClips();
|
||||
showNotice("Trimmed clip created");
|
||||
closeModal();
|
||||
} catch (error) {
|
||||
console.error("Could not trim clip", error);
|
||||
showNotice(`Could not trim clip: ${String(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function saveSelectedClipMetadata() {
|
||||
if (!tauriInvoke || !state.selectedClipId) {
|
||||
return;
|
||||
@@ -1672,11 +2018,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);
|
||||
@@ -1699,23 +2059,36 @@ async function refreshAudioDevices() {
|
||||
}
|
||||
}
|
||||
|
||||
async function pollAutoClips() {
|
||||
if (!tauriInvoke || !state.captureActive) {
|
||||
async function onClipSaved() {
|
||||
if (!tauriInvoke || !state.onboardingComplete) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const clips = await tauriInvoke<ClipDto[]>("poll_auto_clip_events");
|
||||
if (clips.length === 0) {
|
||||
return;
|
||||
await refreshClips();
|
||||
const newest = state.clips[0];
|
||||
if (newest) {
|
||||
state.selectedClipId = newest.id;
|
||||
state.activeView = "Library";
|
||||
render();
|
||||
} else {
|
||||
render();
|
||||
}
|
||||
const created = clips.map(clipFromDto);
|
||||
state.clips = [...created, ...state.clips.filter((clip) => !created.some((fresh) => fresh.id === clip.id))];
|
||||
state.selectedClipId = created[0].id;
|
||||
state.activeView = "Library";
|
||||
} catch (error) {
|
||||
console.warn("Could not refresh clips after save event", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function onClipDeleted() {
|
||||
if (!tauriInvoke) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await refreshClips();
|
||||
render();
|
||||
} catch (error) {
|
||||
console.warn("Could not poll auto clips", error);
|
||||
console.warn("Could not refresh clips after delete event", error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1766,6 +2139,36 @@ async function saveAutoClipEventSetting(eventRule: AutoEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
async function invokeSetGameAutoClipEnabled(gameId: string, enabled: boolean) {
|
||||
if (!tauriInvoke) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const status = await tauriInvoke<DesktopStatus>("set_game_auto_clip_enabled", { gameId, enabled });
|
||||
applyDesktopStatus(status);
|
||||
showNotice(enabled ? "Auto-clipping enabled for game" : "Auto-clipping disabled for game");
|
||||
render();
|
||||
} catch (error) {
|
||||
console.warn("Could not update per-game auto-clip setting", error);
|
||||
showNotice(`Could not update per-game auto-clip setting: ${String(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function invokeAutoClipBulk(command: "enable_all_auto_clips" | "disable_all_auto_clips" | "restore_default_auto_clips") {
|
||||
if (!tauriInvoke) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const status = await tauriInvoke<DesktopStatus>(command);
|
||||
applyDesktopStatus(status);
|
||||
showNotice("Auto-clip rules updated");
|
||||
render();
|
||||
} catch (error) {
|
||||
console.warn("Could not update auto-clip rules", error);
|
||||
showNotice(`Could not update auto-clip rules: ${String(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function saveHotkeys() {
|
||||
if (!tauriInvoke) {
|
||||
return;
|
||||
@@ -1817,6 +2220,37 @@ async function saveCaptureSettings() {
|
||||
}
|
||||
}
|
||||
|
||||
async function changeClipDirectory() {
|
||||
if (!tauriInvoke) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const status = await tauriInvoke<DesktopStatus>("set_clip_directory", {
|
||||
clipDir: state.clipDirectory.trim(),
|
||||
});
|
||||
applyDesktopStatus(status);
|
||||
showNotice("Clip folder applied.");
|
||||
render();
|
||||
} catch (error) {
|
||||
console.warn("Could not set clip folder", error);
|
||||
showNotice(`Could not set clip folder: ${String(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function setAutoPruneEnabled(enabled: boolean) {
|
||||
if (!tauriInvoke) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const status = await tauriInvoke<DesktopStatus>("set_auto_prune_enabled", { enabled });
|
||||
applyDesktopStatus(status);
|
||||
render();
|
||||
} catch (error) {
|
||||
console.warn("Could not update auto-cleanup setting", error);
|
||||
showNotice(`Could not update auto-cleanup setting: ${String(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
function parseResolution(value: string): [number, number] {
|
||||
const [width, height] = value.split("x").map((part) => Number(part));
|
||||
return [
|
||||
@@ -2143,9 +2577,29 @@ async function loadDesktopBridge() {
|
||||
window.setInterval(() => {
|
||||
void refreshStatus();
|
||||
}, 3_000);
|
||||
// Hotkey screenshots are taken behind Tauri's back, so keep a light poll to
|
||||
// pick up new ones; clip/library changes arrive via backend events instead.
|
||||
window.setInterval(() => {
|
||||
void pollAutoClips();
|
||||
}, 2_000);
|
||||
void refreshScreenshots();
|
||||
}, 5_000);
|
||||
const listen = window.__TAURI__?.event?.listen;
|
||||
if (listen) {
|
||||
void listen("clip-saved", () => {
|
||||
void onClipSaved();
|
||||
});
|
||||
void listen("clip-deleted", () => {
|
||||
void onClipDeleted();
|
||||
});
|
||||
void listen("screenshots-changed", () => {
|
||||
void refreshScreenshots();
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Escape" && state.modal.open) {
|
||||
closeModal();
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn("Tauri bridge unavailable", error);
|
||||
}
|
||||
|
||||
@@ -280,6 +280,14 @@ h3 {
|
||||
color: #9ba7b8;
|
||||
}
|
||||
|
||||
.settings-panel .warn {
|
||||
color: #e6b116;
|
||||
background: rgba(230, 177, 22, 0.08);
|
||||
border-left: 3px solid #e6b116;
|
||||
padding: 8px 10px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.file-path {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
@@ -327,6 +335,11 @@ h3 {
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.screenshot-thumb img {
|
||||
object-fit: contain;
|
||||
background: #000;
|
||||
}
|
||||
|
||||
.thumb.kill {
|
||||
background: linear-gradient(135deg, #1f2937, #7f1d1d);
|
||||
}
|
||||
@@ -466,7 +479,44 @@ textarea {
|
||||
|
||||
.event-list {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.auto-clip-group {
|
||||
margin-top: 18px;
|
||||
padding: 14px;
|
||||
border: 1px solid #2c3140;
|
||||
border-radius: 10px;
|
||||
background: #12161d;
|
||||
}
|
||||
|
||||
.auto-clip-group.disabled {
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
.auto-clip-group-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.auto-clip-group-head .toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.auto-clip-group .event-list {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.auto-clip-global-actions {
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.event-row {
|
||||
@@ -675,3 +725,100 @@ textarea {
|
||||
font-size: 12px;
|
||||
color: #f5f7fb;
|
||||
}
|
||||
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 50;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: rgba(10, 12, 16, 0.75);
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.modal {
|
||||
width: min(880px, 100%);
|
||||
max-height: 92vh;
|
||||
overflow-y: auto;
|
||||
background: #191d26;
|
||||
border: 1px solid #2c3442;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 14px 18px;
|
||||
border-bottom: 1px solid #2c3442;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
background: #191d26;
|
||||
}
|
||||
|
||||
.modal-header h2 {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
background: #2c3442;
|
||||
border: 1px solid #3a4556;
|
||||
border-radius: 8px;
|
||||
color: #e7edfb;
|
||||
font-size: 18px;
|
||||
line-height: 1;
|
||||
padding: 6px 12px;
|
||||
cursor: pointer;
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.modal-close:hover {
|
||||
background: #38445a;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 18px;
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.modal-body video {
|
||||
width: 100%;
|
||||
max-height: 56vh;
|
||||
background: #000;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.modal-body img {
|
||||
max-width: 100%;
|
||||
max-height: 56vh;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.modal-body label,
|
||||
.modal-body input {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.video-error {
|
||||
border: 1px dashed rgba(231, 237, 251, 0.25);
|
||||
border-radius: 8px;
|
||||
padding: 18px;
|
||||
background: #141821;
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.video-error h3 {
|
||||
margin: 0;
|
||||
color: #f87171;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.video-error-detail {
|
||||
color: #9ba7b8;
|
||||
}
|
||||