# Performance, Captions, Clip UX, and Resizable Panels **Date:** 2026-09-21 14:39 **Task:** Fix timeline performance, caption positioning, clip creation workflow, resizable panels, and deselect UX ## Changes Made ### 1. Performance Optimization (3 files) **`src/lib/components/VideoPlayer.svelte`**: - Throttled `handleTimeUpdate` to ~15fps (66ms interval) using `performance.now()` check. Previously every `ontimeupdate` event triggered a reactive cascade through `session.currentTime`. **`src/lib/components/Timeline.svelte`**: - **In-flight guard**: Added `detailFetchInFlight` flag to prevent overlapping waveform range extraction subprocess calls. Only one ffmpeg call runs at a time. - **Increased debounce**: Waveform detail fetch debounce increased from 300ms to 500ms. - **Playhead-only redraws**: Split the monolithic redraw `$effect` into two: - Structural changes (clips, zoom, waveform data, thumbnails) trigger a full `drawMainCanvas()` which saves an `ImageData` snapshot. - `session.currentTime` changes trigger a lightweight `drawPlayheadOnly()` that restores the snapshot and draws only the playhead — avoiding the expensive thumbnail/waveform/clip rendering on every time update. - **Thumbnail load callback**: Registered a callback via `setThumbnailLoadCallback` so thumbnail image loads trigger a targeted redraw instead of relying on the next reactive cycle. **`src/lib/timeline/thumbnailRenderer.ts`**: - Added `pendingLoads` Set to prevent creating duplicate `Image` objects for the same path across rapid redraws. - Added `setThumbnailLoadCallback` API so the Timeline can request a redraw when thumbnails finish loading asynchronously. - Image `onerror` handler cleans up the pending state. ### 2. Caption Positioning (1 file) **`src/lib/components/VideoPlayer.svelte`**: - Added `:global(video::cue)` CSS to center captions at the bottom of the video with a semi-transparent black background, white text, and 16px font size. Used `:global()` to bypass Svelte scoping since `::cue` is a browser-level pseudo-element. - Added `position: relative` to the `