Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(auto-zoom): judge a press without its own mouse-up by the grace window
EtienneLescot016e97fde2e4
diff --git a/src/lib/ai-edition/timeline/zoom-suggestions.test.ts b/src/lib/ai-edition/timeline/zoom-suggestions.test.tsindex 6569abb66..3cff335ef 100644--- a/src/lib/ai-edition/timeline/zoom-suggestions.test.ts+++ b/src/lib/ai-edition/timeline/zoom-suggestions.test.ts@@ -135,6 +135,39 @@ describe("buildAutoZoomSuggestions", () => {expect(suggestions).toEqual([]);});+ it("keeps a tap whose release shares its press sample when the cursor hides later", () => {+ // The take records mouse-ups, but the second tap was released within one sampler tick.+ const suggestions = buildAutoZoomSuggestions({+ cursorTelemetry: [+ { ...click(500, 0.8, 0.2), visible: true },+ { timeMs: 600, cx: 0.8, cy: 0.2, visible: true, interactionType: "mouseup" },+ { ...click(3000, 0.2, 0.8), visible: true },+ { timeMs: 3500, cx: 0.2, cy: 0.8, visible: false, interactionType: "move" },+ ],+ totalMs: 6000,+ existingRegions: [],+ defaultDurationMs: 1000,+ });+ expect(suggestions.map((suggestion) => suggestion.focus)).toEqual([+ { cx: 0.8, cy: 0.2 },+ { cx: 0.2, cy: 0.8 },+ ]);+ });++ it("keeps a click whose mouse-up sample is already hidden", () => {+ // Released, then typing hid the pointer before the next sampler tick.+ const suggestions = buildAutoZoomSuggestions({+ cursorTelemetry: [+ { ...click(1000, 0.5, 0.5), visible: true },+ { timeMs: 1033, cx: 0.5, cy: 0.5, visible: false, interactionType: "mouseup" },+ ],+ totalMs: 4000,+ existingRegions: [],+ defaultDurationMs: 1000,+ });+ expect(suggestions.map((suggestion) => suggestion.focus)).toEqual([{ cx: 0.5, cy: 0.5 }]);+ });+it("does not join visible samples across a hidden interval into a dwell", () => {const suggestions = buildAutoZoomSuggestions({cursorTelemetry: [diff --git a/src/lib/ai-edition/timeline/zoom-suggestions.ts b/src/lib/ai-edition/timeline/zoom-suggestions.tsindex 26c7f0946..3e8418015 100644--- a/src/lib/ai-edition/timeline/zoom-suggestions.ts+++ b/src/lib/ai-edition/timeline/zoom-suggestions.ts@@ -127,19 +127,19 @@ const CLICK_INTERACTION_TYPES: ReadonlySet<NonNullable<CursorTelemetryPoint["int*/function detectZoomClickCandidates(samples: CursorTelemetryPoint[]): ZoomDwellCandidate[] {const candidates: ZoomDwellCandidate[] = [];- const hasMouseupTelemetry = samples.some((sample) => sample.interactionType === "mouseup");- // PipeWire and older sidecars have clicks but no mouse-up events. A hidden sample on the next- // sampler tick still identifies a slider press; a much later hidden interval must not erase an- // already completed click merely because that format cannot mark its release.- const LEGACY_PRESS_GRACE_MS = 150;+ // A press without its own mouse-up sample has no known release: PipeWire and older sidecars+ // record none, and the Windows and macOS samplers fold a release into the press sample when both+ // land in one tick. A hidden sample on the next sampler tick still identifies a slider press; a+ // much later hidden interval (typing, leaving the display) must not erase a completed click.+ const UNRELEASED_PRESS_GRACE_MS = 150;let pendingClick: CursorTelemetryPoint | null = null;let hiddenAtMs: number | null = null;- const finishPress = () => {+ const finishPress = (released: boolean) => {if (!pendingClick) return;const hiddenDuringPress =hiddenAtMs !== null &&- (hasMouseupTelemetry || hiddenAtMs - pendingClick.timeMs <= LEGACY_PRESS_GRACE_MS);+ (released || hiddenAtMs - pendingClick.timeMs <= UNRELEASED_PRESS_GRACE_MS);if (!hiddenDuringPress) {candidates.push({centerTimeMs: pendingClick.timeMs,@@ -153,16 +153,16 @@ function detectZoomClickCandidates(samples: CursorTelemetryPoint[]): ZoomDwellCafor (const sample of samples) {if (sample.interactionType && CLICK_INTERACTION_TYPES.has(sample.interactionType)) {- finishPress();+ finishPress(false);pendingClick = sample.visible === false ? null : sample;- continue;- }- if (pendingClick && sample.visible === false && hiddenAtMs === null) {+ } else if (sample.interactionType === "mouseup") {+ // Sampled after the release: its visibility says nothing about the press.+ finishPress(true);+ } else if (pendingClick && sample.visible === false && hiddenAtMs === null) {hiddenAtMs = sample.timeMs;}- if (sample.interactionType === "mouseup") finishPress();}- finishPress();+ finishPress(false);return candidates;}