From 3a43d288d7b934111d3e99a06ef5dc6674f0ac37 Mon Sep 17 00:00:00 2001 From: webadderall <131426131+webadderall@users.noreply.github.com> Date: Sat, 5 Sep 2026 11:53:54 +1000 Subject: [PATCH] fix(windows): enable auto zoom for narrow captures --- src/components/video-editor/VideoEditor.tsx | 1 + .../video-editor/hooks/useFreshRecordingAutoZoom.ts | 10 ++++++++++ .../video-editor/hooks/useTimelineEditingController.ts | 2 ++ .../video-editor/timeline/zoomSuggestionUtils.test.ts | 4 ++++ .../video-editor/timeline/zoomSuggestionUtils.ts | 8 ++++++++ 5 files changed, 25 insertions(+) diff --git a/src/components/video-editor/VideoEditor.tsx b/src/components/video-editor/VideoEditor.tsx index 84c973b4..3cfd072e 100644 --- a/src/components/video-editor/VideoEditor.tsx +++ b/src/components/video-editor/VideoEditor.tsx @@ -252,6 +252,7 @@ export default function VideoEditor() { t, shortcuts, isMac, + appPlatform, timeline, appearance, videoPath, diff --git a/src/components/video-editor/hooks/useFreshRecordingAutoZoom.ts b/src/components/video-editor/hooks/useFreshRecordingAutoZoom.ts index bdde5833..e774f5b7 100644 --- a/src/components/video-editor/hooks/useFreshRecordingAutoZoom.ts +++ b/src/components/video-editor/hooks/useFreshRecordingAutoZoom.ts @@ -11,6 +11,7 @@ import type { CursorTelemetryPoint, ZoomRegion } from "../types"; import type { VideoPlaybackRef } from "../VideoPlayback"; interface UseFreshRecordingAutoZoomParams { + appPlatform: string; videoPath: string | null; loading: boolean; isPreviewReady: boolean; @@ -28,6 +29,7 @@ interface UseFreshRecordingAutoZoomParams { } export function useFreshRecordingAutoZoom({ + appPlatform, videoPath, loading, isPreviewReady, @@ -48,6 +50,8 @@ export function useFreshRecordingAutoZoom({ }, [setAutoSuggestZoomsTrigger]); useEffect(() => { + if (!appPlatform) return; + if ( videoPath && pendingFreshRecordingAutoZoomPathRef.current === videoPath && @@ -55,6 +59,7 @@ export function useFreshRecordingAutoZoom({ !shouldAutoApplyFreshRecordingZoomsForSource( videoPlaybackRef.current?.video?.videoWidth, videoPlaybackRef.current?.video?.videoHeight, + appPlatform, ) ) { pendingFreshRecordingAutoZoomPathRef.current = null; @@ -107,6 +112,7 @@ export function useFreshRecordingAutoZoom({ }, 500); }, [ videoPath, + appPlatform, loading, isPreviewReady, duration, @@ -122,6 +128,8 @@ export function useFreshRecordingAutoZoom({ ]); useEffect(() => { + if (!appPlatform) return; + if ( !videoPath || !isPreviewReady || @@ -130,6 +138,7 @@ export function useFreshRecordingAutoZoom({ shouldAutoApplyFreshRecordingZoomsForSource( videoPlaybackRef.current?.video?.videoWidth, videoPlaybackRef.current?.video?.videoHeight, + appPlatform, ) ) { return; @@ -142,6 +151,7 @@ export function useFreshRecordingAutoZoom({ }); }, [ autoSuggestedVideoPathRef, + appPlatform, isPreviewReady, setZoomRegions, videoPath, diff --git a/src/components/video-editor/hooks/useTimelineEditingController.ts b/src/components/video-editor/hooks/useTimelineEditingController.ts index a61a29e1..4ea31153 100644 --- a/src/components/video-editor/hooks/useTimelineEditingController.ts +++ b/src/components/video-editor/hooks/useTimelineEditingController.ts @@ -25,6 +25,7 @@ type Input = { t: ReturnType["t"]; shortcuts: ReturnType["shortcuts"]; isMac: boolean; + appPlatform: string; timeline: ReturnType; appearance: ReturnType; videoPath: string | null; @@ -154,6 +155,7 @@ export function useTimelineEditingController(input: Input) { ], ); const freshZoom = useFreshRecordingAutoZoom({ + appPlatform: input.appPlatform, videoPath: input.videoPath, loading: input.loading, isPreviewReady: input.isPreviewReady, diff --git a/src/components/video-editor/timeline/zoomSuggestionUtils.test.ts b/src/components/video-editor/timeline/zoomSuggestionUtils.test.ts index f1a6dd21..5f237d5e 100644 --- a/src/components/video-editor/timeline/zoomSuggestionUtils.test.ts +++ b/src/components/video-editor/timeline/zoomSuggestionUtils.test.ts @@ -38,6 +38,10 @@ describe("shouldAutoApplyFreshRecordingZoomsForSource", () => { expect(shouldAutoApplyFreshRecordingZoomsForSource(1080, 1080)).toBe(false); }); + it("allows narrow Windows window captures when click telemetry is available", () => { + expect(shouldAutoApplyFreshRecordingZoomsForSource(936, 1028, "win32")).toBe(true); + }); + it("does not block when source dimensions are not available yet", () => { expect(shouldAutoApplyFreshRecordingZoomsForSource()).toBe(true); }); diff --git a/src/components/video-editor/timeline/zoomSuggestionUtils.ts b/src/components/video-editor/timeline/zoomSuggestionUtils.ts index bf38efa6..fbdc5a68 100644 --- a/src/components/video-editor/timeline/zoomSuggestionUtils.ts +++ b/src/components/video-editor/timeline/zoomSuggestionUtils.ts @@ -43,7 +43,15 @@ export interface InteractionZoomSuggestionResult { export function shouldAutoApplyFreshRecordingZoomsForSource( sourceWidth?: number, sourceHeight?: number, + platform?: string, ): boolean { + // Window capture on Windows legitimately produces portrait and near-square + // sources. Click telemetry is already normalized to that captured window, so + // its aspect ratio is not a reason to suppress interaction-based zooms. + if (platform === "win32") { + return true; + } + if ( !Number.isFinite(sourceWidth) || !Number.isFinite(sourceHeight) ||