harden gif pipeline, capture, and audio resilience

fix gif calibration (sample deleted before measurement), swap the
budget-mode application so resolution shrinks width not fps, correct the
color factor comment. accumulate gif encode progress across retry
attempts instead of resetting, surface an over-budget result on the done
screen. stream the audio head padding instead of loading it into memory,
detect mid-record audio device loss and offer the existing retry flow,
invalidate the cached encoder list when the ffmpeg binary changes.
add a capture quality setting so 4k screens can record at native res,
try a stream copy before re-encoding when fixing capture timestamps,
park the overlay poll thread when idle, sweep stale config backups, add
a diagnostics tab, and consolidate the preview render debounce.
This commit is contained in:
2026-06-17 23:57:28 +03:00
parent f732cdda4d
commit c3f132507a
9 changed files with 624 additions and 83 deletions
+83 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { onMount } from "svelte"
import { api, type Config, type CodecAvailability } from "./api"
import { api, type Config, type CodecAvailability, type DiagnosticsInfo } from "./api"
import HotkeyInput from "./HotkeyInput.svelte"
import { open } from "@tauri-apps/plugin-dialog"
@@ -20,6 +20,7 @@
|| cfg.capture.default_fps !== initialCfg.capture.default_fps
|| cfg.capture.capture_cursor !== initialCfg.capture.capture_cursor
|| cfg.capture.capture_audio !== initialCfg.capture.capture_audio
|| cfg.capture.capture_quality !== initialCfg.capture.capture_quality
|| cfg.export.default_format !== initialCfg.export.default_format
|| cfg.export.gif_dither !== initialCfg.export.gif_dither
|| cfg.export.webm_codec !== initialCfg.export.webm_codec
@@ -31,12 +32,15 @@
|| cfg.output_dir !== initialCfg.output_dir
})
let diagnostics: DiagnosticsInfo | null = $state(null)
const TABS = [
{ id: "capture", label: "Capture" },
{ id: "export", label: "Export" },
{ id: "hotkeys", label: "Hotkeys" },
{ id: "output", label: "Output" },
{ id: "system", label: "System" },
{ id: "diagnostics", label: "Diagnostics" },
]
onMount(async () => {
@@ -49,6 +53,15 @@
if (cfg) document.documentElement.setAttribute("data-theme", cfg.theme)
})
$effect(() => {
if (activeTab !== "diagnostics") return
api.diagnosticsInfo().then(d => { diagnostics = d }).catch(() => { diagnostics = null })
})
async function refreshDiagnostics() {
try { diagnostics = await api.diagnosticsInfo() } catch { diagnostics = null }
}
async function save() {
if (!cfg) return
@@ -124,6 +137,13 @@
{#each [15,24,30,60] as f}<option value={f}>{f} fps</option>{/each}
</select>
</label>
<label class="field">
<span class="field-label">Capture quality</span>
<select bind:value={cfg.capture.capture_quality}>
<option value="auto">Auto (cap 1920px, lower CPU)</option>
<option value="full">Full (native res up to 3840px)</option>
</select>
</label>
<label class="field-check">
<input type="checkbox" bind:checked={cfg.capture.capture_cursor} />
<span>Capture cursor</span>
@@ -247,6 +267,36 @@
</label>
</div>
</div>
{:else if activeTab === "diagnostics"}
<div class="tab-panel">
<div class="panel-head">
<h2>Diagnostics</h2>
<p class="panel-desc">Versions and recent log output</p>
</div>
<div class="field-list">
<div class="diag-row">
<span class="field-label">ByteSize</span>
<span class="diag-val mono">{diagnostics ? `v${diagnostics.app_version}` : "..."}</span>
</div>
<div class="diag-row">
<span class="field-label">ffmpeg</span>
<span class="diag-val mono">{diagnostics ? diagnostics.ffmpeg_version : "..."}</span>
</div>
<div class="diag-row">
<span class="field-label">Log folder</span>
<span class="diag-val mono">{diagnostics ? diagnostics.log_dir : "..."}</span>
<button class="btn-ghost compact" onclick={() => api.openLogDir()} disabled={!diagnostics}>Open</button>
</div>
<div class="diag-tail-wrap">
<div class="diag-tail-head">
<span class="field-label">Recent log</span>
<button class="link" onclick={refreshDiagnostics}>Refresh</button>
</div>
<pre class="diag-tail">{diagnostics ? diagnostics.log_tail || "(empty)" : "loading..."}</pre>
</div>
</div>
</div>
{/if}
{#if hotkeyWarnings.length > 0}
@@ -257,7 +307,7 @@
<button class="btn-ghost" onclick={onClose}>Cancel</button>
</div>
</div>
{:else}
{:else if activeTab !== "diagnostics"}
<div class="panel-foot">
<button class="btn-primary" onclick={save} disabled={saving}>
{saving ? "Saving" : "Save changes"}
@@ -265,6 +315,10 @@
{#if dirty}<span class="unsaved-dot" title="unsaved changes"></span>{/if}
<button class="btn-ghost" onclick={onClose}>Cancel</button>
</div>
{:else}
<div class="panel-foot">
<button class="btn-ghost" onclick={onClose}>Close</button>
</div>
{/if}
</div>
</div>
@@ -528,4 +582,31 @@
margin-left: 8px;
vertical-align: middle;
}
/* ---- Diagnostics ---- */
.diag-row {
display: flex;
align-items: center;
gap: 10px;
}
.diag-row .field-label { flex-shrink: 0; width: 90px; }
.diag-val { font-size: 12px; color: var(--text-2); flex: 1; min-width: 0; word-break: break-all; }
.btn-ghost.compact { padding: 5px 12px; font-size: 12px; }
.diag-tail-wrap { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.diag-tail-head { display: flex; align-items: center; justify-content: space-between; }
.diag-tail {
margin: 0;
padding: 10px;
background: var(--bg-3);
border: 1px solid var(--border);
border-radius: var(--r-sm);
font-family: var(--mono);
font-size: 10px;
line-height: 1.5;
color: var(--text-3);
max-height: 220px;
overflow: auto;
white-space: pre-wrap;
word-break: break-all;
}
</style>