From 045900f6f4b71ceeaf487b9b06f28c56ddfd562d Mon Sep 17 00:00:00 2001 From: webadderall <131426131+webadderall@users.noreply.github.com> Date: Sun, 15 Mar 2026 18:02:47 +1100 Subject: [PATCH] Fix over-aggressive text cursor inference on Windows --- .../timeline/zoomSuggestionUtils.ts | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/src/components/video-editor/timeline/zoomSuggestionUtils.ts b/src/components/video-editor/timeline/zoomSuggestionUtils.ts index 02dada5c..d0333d84 100644 --- a/src/components/video-editor/timeline/zoomSuggestionUtils.ts +++ b/src/components/video-editor/timeline/zoomSuggestionUtils.ts @@ -42,34 +42,38 @@ export function normalizeCursorTelemetry( .sort((a, b) => a.timeMs - b.timeMs) .map((sample) => normalizeTelemetrySample(sample, totalMs)); - const interactions = detectInteractionCandidates(normalized); - for (const candidate of interactions) { - if (candidate.kind === 'text-selection') { - applyCursorTypeInRange(normalized, candidate.centerTimeMs - 140, candidate.centerTimeMs + 1200, 'text'); - continue; + const hasExplicitCursorTypeSamples = normalized.some((sample) => Boolean(sample.cursorType)); + + if (hasExplicitCursorTypeSamples) { + const interactions = detectInteractionCandidates(normalized); + for (const candidate of interactions) { + if (candidate.kind === 'text-selection') { + applyCursorTypeInRange(normalized, candidate.centerTimeMs - 140, candidate.centerTimeMs + 1200, 'text'); + continue; + } + + if (candidate.kind === 'text-field-click' || candidate.kind === 'text-focus-like') { + applyCursorTypeInRange(normalized, candidate.centerTimeMs - 100, candidate.centerTimeMs + 900, 'text'); + continue; + } } - if (candidate.kind === 'text-field-click' || candidate.kind === 'text-focus-like') { - applyCursorTypeInRange(normalized, candidate.centerTimeMs - 100, candidate.centerTimeMs + 900, 'text'); - continue; - } - } + for (const sample of normalized) { + if (sample.interactionType !== 'click' && sample.interactionType !== 'double-click') { + continue; + } - for (const sample of normalized) { - if (sample.interactionType !== 'click' && sample.interactionType !== 'double-click') { - continue; - } + const mouseUp = normalized.find((candidate) => candidate.timeMs > sample.timeMs && candidate.interactionType === 'mouseup'); + if (!mouseUp) { + continue; + } - const mouseUp = normalized.find((candidate) => candidate.timeMs > sample.timeMs && candidate.interactionType === 'mouseup'); - if (!mouseUp) { - continue; - } - - const dragDuration = mouseUp.timeMs - sample.timeMs; - const dragDistance = Math.hypot(mouseUp.cx - sample.cx, mouseUp.cy - sample.cy); - if (dragDuration >= 160 && dragDistance > 0.015) { - const isTextDrag = Math.abs(mouseUp.cx - sample.cx) > Math.abs(mouseUp.cy - sample.cy) * 1.8; - applyCursorTypeInRange(normalized, sample.timeMs, mouseUp.timeMs, isTextDrag ? 'text' : 'closed-hand'); + const dragDuration = mouseUp.timeMs - sample.timeMs; + const dragDistance = Math.hypot(mouseUp.cx - sample.cx, mouseUp.cy - sample.cy); + if (dragDuration >= 160 && dragDistance > 0.015) { + const isTextDrag = Math.abs(mouseUp.cx - sample.cx) > Math.abs(mouseUp.cy - sample.cy) * 1.8; + applyCursorTypeInRange(normalized, sample.timeMs, mouseUp.timeMs, isTextDrag ? 'text' : 'closed-hand'); + } } }