quality pass: safe timestamps, cancel support, dedup, frontend polish
- replace unsafe GetLocalTime with safe SystemTime epoch - lock() logs warning on mutex poison recovery - extract try_start_audio/start_click_recorder helpers to dedup capture code - cancel_export now actually kills ffmpeg via polling loop + cancel flag - extract visible_window_bounds helper for DWM rect lookups - clear_temp_segments cleans thumbs dir and preview files - gif_params takes focused GifBudgetInput instead of full TranscodeRequest - consistent error messages with full context chain - reduce overlay clickthrough poll from 30ms to 80ms - throttle trim preview to 10Hz - bound thumbnail cache at 5 entries - timer ticks until stopCapture resolves - crop fields validate against clip dimensions - settings shows unsaved indicator dot - edit grid uses minmax for fluid responsive layout - animations respect prefers-reduced-motion - pauseRec only clears timer after successful pause - refreshPreview logs errors instead of swallowing - remove dead _deps string from preview effect
This commit is contained in:
+23
-13
@@ -171,10 +171,10 @@
|
||||
}
|
||||
|
||||
async function stopRec() {
|
||||
clearTick()
|
||||
void emit("recording-state", { phase: "idle", fps })
|
||||
try {
|
||||
const c = await api.stopCapture()
|
||||
clearTick()
|
||||
clip = c
|
||||
phase = "editing"
|
||||
trimStart = 0
|
||||
@@ -188,13 +188,17 @@
|
||||
outputPath = await api.defaultOutputPath(format)
|
||||
const sensible = Math.min(50, Math.max(minMB(c.duration_secs), Math.round(c.duration_secs * 0.5)))
|
||||
targetMB = sensible
|
||||
} catch (e) { errMsg = String(e); phase = "idle" }
|
||||
} catch (e) { errMsg = String(e); phase = "idle"; clearTick() }
|
||||
}
|
||||
|
||||
async function pauseRec() {
|
||||
clearTick()
|
||||
try { await api.pauseCapture(); phase = "paused" }
|
||||
catch (e) { errMsg = String(e); tick() }
|
||||
try {
|
||||
await api.pauseCapture()
|
||||
clearTick()
|
||||
phase = "paused"
|
||||
} catch (e) {
|
||||
errMsg = String(e)
|
||||
}
|
||||
void emit("recording-state", { phase: "paused", fps })
|
||||
}
|
||||
|
||||
@@ -216,7 +220,7 @@
|
||||
try {
|
||||
previewPath = await api.renderPreview(format, fps, Math.round(targetMB * 1_048_576), format === "gif" ? gifBudgetMode : undefined, format === "gif" ? gifDither : undefined, format === "gif" ? gifColors : undefined)
|
||||
previewCacheBust = Date.now()
|
||||
} catch { previewPath = null }
|
||||
} catch (e) { previewPath = null; console.warn("preview render failed:", e) }
|
||||
finally { previewLoading = false }
|
||||
}
|
||||
|
||||
@@ -229,6 +233,10 @@
|
||||
try {
|
||||
const thumbs = await api.extractThumbnails(fps)
|
||||
thumbCache.set(cacheKey, thumbs)
|
||||
if (thumbCache.size > 5) {
|
||||
const firstKey = thumbCache.keys().next().value
|
||||
if (firstKey) thumbCache.delete(firstKey)
|
||||
}
|
||||
thumbnails = thumbs
|
||||
deletedFrames = new Set()
|
||||
} catch (e) { errMsg = String(e) }
|
||||
@@ -302,6 +310,7 @@
|
||||
let dragging: 'start' | 'end' | null = $state(null)
|
||||
let trimPreviewPath: string | null = $state(null)
|
||||
let trimPreviewBust: number = $state(0)
|
||||
let lastTrimPreview = 0
|
||||
|
||||
function pointerToSecs(e: PointerEvent): number {
|
||||
if (!trackEl || !clip) return 0
|
||||
@@ -312,6 +321,9 @@
|
||||
}
|
||||
|
||||
async function updateTrimPreview(secs: number) {
|
||||
const now = Date.now()
|
||||
if (now - lastTrimPreview < 100) return // 10Hz max
|
||||
lastTrimPreview = now
|
||||
try {
|
||||
trimPreviewPath = await api.renderRawPreview(secs)
|
||||
trimPreviewBust = Date.now()
|
||||
@@ -367,8 +379,6 @@
|
||||
|
||||
$effect(() => {
|
||||
if (phase === "editing" && format) {
|
||||
// Read these so the effect re-runs when they change
|
||||
const _deps = format === "gif" ? `${gifBudgetMode}-${gifDither}-${gifColors}-${fps}-${targetMB}` : `${fps}-${targetMB}`
|
||||
const timer = window.setTimeout(() => { void refreshPreview() }, 300)
|
||||
return () => { clearTimeout(timer) }
|
||||
}
|
||||
@@ -754,19 +764,19 @@
|
||||
<div class="crop-grid">
|
||||
<label class="crop-field">
|
||||
<span>X</span>
|
||||
<input type="number" min="0" bind:value={cropX} />
|
||||
<input type="number" min="0" max={clip?.width ?? 9999} bind:value={cropX} />
|
||||
</label>
|
||||
<label class="crop-field">
|
||||
<span>Y</span>
|
||||
<input type="number" min="0" bind:value={cropY} />
|
||||
<input type="number" min="0" max={clip?.height ?? 9999} bind:value={cropY} />
|
||||
</label>
|
||||
<label class="crop-field">
|
||||
<span>W</span>
|
||||
<input type="number" min="1" bind:value={cropW} />
|
||||
<input type="number" min="1" max={clip?.width ?? 9999} bind:value={cropW} />
|
||||
</label>
|
||||
<label class="crop-field">
|
||||
<span>H</span>
|
||||
<input type="number" min="1" bind:value={cropH} />
|
||||
<input type="number" min="1" max={clip?.height ?? 9999} bind:value={cropH} />
|
||||
</label>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -1151,7 +1161,7 @@
|
||||
.edit {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1.4fr 1fr;
|
||||
grid-template-columns: minmax(300px, 1.4fr) minmax(250px, 1fr);
|
||||
gap: 1px;
|
||||
background: var(--border);
|
||||
min-height: 0;
|
||||
|
||||
+15
-1
@@ -11,6 +11,9 @@
|
||||
let hotkeyWarnings: string[] = $state([])
|
||||
let showAdvanced: boolean = $state(false)
|
||||
let activeTab: string = $state("capture")
|
||||
let initialCfg: string = $state("")
|
||||
|
||||
let dirty = $derived(cfg ? JSON.stringify(cfg) !== initialCfg : false)
|
||||
|
||||
const TABS = [
|
||||
{ id: "capture", label: "Capture" },
|
||||
@@ -20,7 +23,7 @@
|
||||
{ id: "system", label: "System" },
|
||||
]
|
||||
|
||||
onMount(async () => { cfg = await api.getConfig() })
|
||||
onMount(async () => { cfg = await api.getConfig(); initialCfg = JSON.stringify(cfg) })
|
||||
|
||||
async function save() {
|
||||
if (!cfg) return
|
||||
@@ -44,6 +47,7 @@
|
||||
if (failed.length > 0) {
|
||||
hotkeyWarnings = [`${failed.join(", ")} - hotkey may be in use by another app`]
|
||||
} else {
|
||||
initialCfg = JSON.stringify(cfg)
|
||||
onClose()
|
||||
}
|
||||
} finally { saving = false }
|
||||
@@ -231,6 +235,7 @@
|
||||
<button class="btn-primary" onclick={save} disabled={saving}>
|
||||
{saving ? "Saving" : "Save changes"}
|
||||
</button>
|
||||
{#if dirty}<span class="unsaved-dot" title="unsaved changes"></span>{/if}
|
||||
<button class="btn-ghost" onclick={onClose}>Cancel</button>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -481,4 +486,13 @@
|
||||
}
|
||||
.btn-warn:hover:not(:disabled) { background: var(--stop-hover); }
|
||||
.btn-warn:disabled { opacity: 0.4; cursor: not-allowed; }
|
||||
|
||||
.unsaved-dot {
|
||||
width: 6px; height: 6px;
|
||||
border-radius: 50%;
|
||||
background: var(--warn);
|
||||
display: inline-block;
|
||||
margin-left: 8px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user