# Quit + Screenshot Shortcuts **Date:** 2026-09-23 09:08 UTC **Task:** Add Q to quit, S/Shift+S to save screenshot with/without captions, update About dialog shortcuts ## Changes Made ### Rust backend - **`src-tauri/src/commands/export.rs`** — Added `save_screenshot` Tauri command. Accepts output directory, video title, timestamp label, and PNG byte data. Uses the existing `generate_output_path` and `expand_tilde_path` from `clip_exporter` for consistent filename generation. Creates output directory if it doesn't exist. - **`src-tauri/src/lib.rs`** — Registered `export::save_screenshot` in the invoke handler. ### Frontend bindings - **`src/lib/bindings/export.ts`** — Added `saveScreenshot()` function that invokes the new Rust command. ### Screenshot utility - **`src/lib/utils/screenshot.ts`** (new file) — Canvas-based screenshot capture: - Draws the current video frame onto an offscreen canvas at native resolution (`videoWidth` x `videoHeight`) - Optionally composites captions using Canvas 2D text APIs, matching the CSS caption style (font, color, background, outline/shadow, word highlighting, position) - Scales caption font size proportionally from preview to native resolution - Exports as PNG blob, converts to byte array, sends to Rust backend - Filename format: `{videoTitle} - {totalMs}ms-screenshot.png` ### VideoPlayer - **`src/lib/components/VideoPlayer.svelte`** — Added `export function getParsedCues()` to expose parsed VTT cues to the parent component. ### App keybindings - **`src/App.svelte`** — Added: - `Q` — Quit app via `exit(0)` from `@tauri-apps/plugin-process` - `S` — Screenshot with captions - `Shift+S` — Screenshot without captions - `bind:this={videoPlayerRef}` on VideoPlayer for accessing `getParsedCues()` - `captureScreenshot(withCaptions)` async function that orchestrates the capture ### About dialog - **`src/lib/components/AboutDialog.svelte`** — Added Q, S, and Shift+S to the global shortcuts list. ## Verification - `svelte-check`: 0 errors, 0 warnings - `vitest run`: 69 tests passed across 10 test files - `cargo check`: compiles clean ## Lessons Learned - Canvas 2D text rendering requires explicit scaling when compositing at native resolution vs. CSS preview resolution. Using `videoHeight / clientHeight` as the scale factor ensures caption size matches visually. - The `toBlob` → `arrayBuffer` → `Array.from(Uint8Array)` pipeline is necessary because Tauri's IPC expects `Vec` on the Rust side, which maps to `number[]` in TypeScript invoke calls. ## Follow-up Items - Visual QA recommended to verify caption rendering fidelity on screenshots matches the preview exactly (especially text wrapping and word-level highlighting). - Could add a brief toast notification on successful screenshot save (currently only logs to console).