Skip to content

Create polished demo videos without editing skills. Mac/Windows/Linux

Fix over-aggressive text cursor inference on Windows

webadderalla9a3486543e5
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');
+ }
}
}