Make auto-zoom duration and click-merge gap configurable
Feature request: make auto-zoom timing configurable
Right now the only auto-zoom settings are the on/off toggle and Default zoom amount. How long each zoom lasts is hardcoded in generate_zoom_segments_from_clicks:
https://github.com/CapSoftware/Cap/blob/848d18fe7b601f1b92ada6563e56e1fba4ebe1e0/apps/desktop-gpui/src/editor_edits.rs#L2135-L2139
const CLICK_PRE_PADDING_MS: f64 = 300.0;
const CLICK_POST_PADDING_MS: f64 = 2500.0;
const MERGE_GAP_MS: f64 = 2500.0;
Each click gets about 2.8 s of zoom. Zooms are merged when the gap between them is under 2.5 s, so any clicks less than ~5 s apart end up in one long zoom. In a fast product demo that turns into one zoom covering most of the recording. In my case, 7 clicks over about 6 s became a single 5.6 s zoom in a 9 s clip, and I had to trim it by hand.
Proposal: add these to Settings next to "Default zoom amount":
- Zoom hold after click (currently 2.5 s)
- Merge nearby clicks gap (currently 2.5 s), or a toggle to never merge
Even one "Auto zoom length: Short / Normal / Long" preset would cover most cases.
Version: Cap 0.6.1 (macOS, Homebrew cask)
I'd like to take this on.
Root Cause & Proposed Implementation
In apps/desktop-gpui/src/editor_edits.rs, generate_zoom_segments_from_clicks currently hardcodes CLICK_POST_PADDING_MS = 2500.0 and MERGE_GAP_MS = 2500.0.
To make auto-zoom timing configurable while preserving backwards-compatible defaults (2.5s hold duration and 2.5s merge gap):
apps/desktop-gpui/src/editor_edits.rs:- Introduce
AutoZoomTiming { post_padding_ms, merge_gap_ms }(Default:2500.0mshold,2500.0msmerge gap) andAutoZoomTiming::from_seconds(hold_seconds: Option<f32>, merge_gap_seconds: Option<f32>). - Add
generate_zoom_segments_for_timeline_with_timingandgenerate_zoom_segments_from_clicks_with_timing(withmerge_gap_ms == 0.0disabling gap-based merging of non-overlapping click intervals while still coalescing directly overlapping intervals).
- Introduce
apps/desktop-gpui/src/store.rs:- Add
auto_zoom_duration: Option<f32>(autoZoomDuration) andauto_zoom_merge_gap: Option<f32>(autoZoomMergeGap) toGeneralSettings.
- Add
apps/desktop-gpui/src/settings_window.rs&apps/desktop-gpui/src/editor_window.rs:- Add Zoom hold duration (
1s,1.5s,2.5s,3.5s,5s) and Merge nearby clicks gap (Off,1s,1.5s,2.5s,3.5s,5s) rows next to Default zoom amount in General Settings, and pass the loadedAutoZoomTiminginEditorWindow::generate_auto_zoom.
- Add Zoom hold duration (
- Tests:
- Add unit tests in
editor_edits.rs(auto_zoom_respects_custom_hold_duration_and_merge_gap) andstore.rs(typed_reads_match_the_store_shape).
- Add unit tests in
I have a verified branch ready on my fork (feat/issue-2928-configurable-auto-zoom-timing) and can open a PR as soon as assigned.
Thanks for the suggestion! Making the zoom hold and merge gap configurable makes sense for fast demos.