quality pass 3: preview cleanup, gif filter hoist, config logging

- startOver clears previewPath/trimPreviewPath and resets gif settings
- startOver resets format/fps/dither to config defaults
- Main onMount wraps getConfig in try/catch
- unify DownloadProgress/UpdateDownloadProgress into single type
- default_output_path borrows config instead of cloning
- encode_gif_pass filter prefixes computed once outside retry loop
- config backup path included in warning log
- capture ffmpeg stderr logged at debug level instead of error
- is_newer comment notes pre-release version handling
- Picker hover debounced to ~33ms
- Picker emits picker-cancel on unmount
This commit is contained in:
2026-05-30 00:13:58 +03:00
parent 2cd836b09e
commit f3ff35a48b
6 changed files with 29 additions and 16 deletions
+1 -1
View File
@@ -105,7 +105,7 @@ impl GraphicsCaptureApiHandler for CaptureHandler {
use std::io::{BufRead, BufReader}; use std::io::{BufRead, BufReader};
let reader = BufReader::new(serr); let reader = BufReader::new(serr);
for line in reader.lines().map_while(Result::ok) { for line in reader.lines().map_while(Result::ok) {
tracing::error!("ffmpeg: {line}"); tracing::debug!("ffmpeg: {line}");
} }
}); });
} }
+1 -2
View File
@@ -148,9 +148,8 @@ impl Config {
match toml::from_str::<Self>(&raw) { match toml::from_str::<Self>(&raw) {
Ok(cfg) => Ok(cfg), Ok(cfg) => Ok(cfg),
Err(e) => { Err(e) => {
// Config is corrupt - back it up and return defaults
tracing::warn!("config.toml is corrupt ({e}), backing up and using defaults");
let backup = path.with_extension("toml.bak"); let backup = path.with_extension("toml.bak");
tracing::warn!("config.toml is corrupt ({}), backing up to {:?} and using defaults", e, backup);
let _ = std::fs::copy(path, &backup); let _ = std::fs::copy(path, &backup);
let cfg = Self::default(); let cfg = Self::default();
cfg.save(path)?; cfg.save(path)?;
+2 -7
View File
@@ -200,11 +200,7 @@ struct DownloadProgress {
total: Option<u64>, total: Option<u64>,
} }
#[derive(Clone, Serialize)] type UpdateDownloadProgress = DownloadProgress;
struct UpdateDownloadProgress {
downloaded: u64,
total: Option<u64>,
}
#[tauri::command] #[tauri::command]
async fn download_update( async fn download_update(
@@ -646,8 +642,7 @@ pub struct ExportRequest {
#[tauri::command] #[tauri::command]
fn default_output_path(state: State<'_, AppState>, format: Format) -> String { fn default_output_path(state: State<'_, AppState>, format: Format) -> String {
let cfg = lock(&state.config).clone(); let dir = output_dir(&state.app_dir, &lock(&state.config));
let dir = output_dir(&state.app_dir, &cfg);
dir.join(format!( dir.join(format!(
"bytesize-{}.{}", "bytesize-{}.{}",
timestamp_slug(), timestamp_slug(),
+2
View File
@@ -128,6 +128,8 @@ pub fn write_apply_script(app_dir: &Path) -> Result<PathBuf> {
} }
fn is_newer(latest: &str, current: &str) -> bool { fn is_newer(latest: &str, current: &str) -> bool {
// Note: pre-release suffixes (e.g., "-beta") are filtered out by parse().ok(),
// so "1.0.0-beta" compares equal to "1.0.0". Acceptable for v1.
let mut l: Vec<u32> = latest.split('.').filter_map(|s| s.parse().ok()).collect(); let mut l: Vec<u32> = latest.split('.').filter_map(|s| s.parse().ok()).collect();
let mut c: Vec<u32> = current.split('.').filter_map(|s| s.parse().ok()).collect(); let mut c: Vec<u32> = current.split('.').filter_map(|s| s.parse().ok()).collect();
let max = l.len().max(c.len()); let max = l.len().max(c.len());
+12
View File
@@ -117,11 +117,15 @@
unlistenOverlayClosed = await listen("overlay-closed", () => { unlistenOverlayClosed = await listen("overlay-closed", () => {
useFrame = false useFrame = false
}) })
try {
config = await api.getConfig() config = await api.getConfig()
format = config.export.default_format format = config.export.default_format
fps = config.capture.default_fps fps = config.capture.default_fps
keepAudio = config.capture.capture_audio keepAudio = config.capture.capture_audio
gifDither = config.export.gif_dither gifDither = config.export.gif_dither
} catch (e) {
console.warn("failed to load config:", e)
}
unlistenHotkey = await api.onHotkey((kind) => { unlistenHotkey = await api.onHotkey((kind) => {
if (kind === "start" && phase === "idle") void startRec() if (kind === "start" && phase === "idle") void startRec()
@@ -277,8 +281,16 @@
clip = null; exportResult = null; errMsg = null; encodeProgress = null clip = null; exportResult = null; errMsg = null; encodeProgress = null
thumbnails = []; deletedFrames = new Set() thumbnails = []; deletedFrames = new Set()
thumbCache = new Map() thumbCache = new Map()
previewPath = null; trimPreviewPath = null
if (previewTimer !== null) { clearTimeout(previewTimer); previewTimer = null } if (previewTimer !== null) { clearTimeout(previewTimer); previewTimer = null }
elapsed = 0; phase = "idle" elapsed = 0; phase = "idle"
if (config) {
format = config.export.default_format
fps = config.capture.default_fps
gifDither = config.export.gif_dither
gifBudgetMode = "balanced"
gifColors = 256
}
} }
async function cancelExport() { async function cancelExport() {
+6 -1
View File
@@ -22,12 +22,17 @@
void (async () => { void (async () => {
await refresh() await refresh()
win.onMoved(refresh).then(fn => { if (mounted) unlisten.push(fn) }) win.onMoved(refresh).then(fn => { if (mounted) unlisten.push(fn) })
listen<Rect>("picker-hover", (e) => { hover = e.payload }).then(fn => { if (mounted) unlisten.push(fn) }) let hoverDebounce = 0
listen<Rect>("picker-hover", (e) => {
clearTimeout(hoverDebounce)
hoverDebounce = window.setTimeout(() => { hover = e.payload }, 30)
}).then(fn => { if (mounted) unlisten.push(fn) })
})() })()
return () => { return () => {
mounted = false mounted = false
unlisten.forEach(fn => fn()) unlisten.forEach(fn => fn())
emit("picker-cancel", {}).catch(() => {})
} }
}) })