fix(windows): enable auto zoom for narrow captures

This commit is contained in:
webadderall
2026-09-05 14:11:27 +10:00
parent e0e4bf4099
commit 3a43d288d7
5 changed files with 25 additions and 0 deletions
@@ -252,6 +252,7 @@ export default function VideoEditor() {
t,
shortcuts,
isMac,
appPlatform,
timeline,
appearance,
videoPath,
@@ -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,
@@ -25,6 +25,7 @@ type Input = {
t: ReturnType<typeof useI18n>["t"];
shortcuts: ReturnType<typeof useShortcuts>["shortcuts"];
isMac: boolean;
appPlatform: string;
timeline: ReturnType<typeof useTimelineState>;
appearance: ReturnType<typeof useAppearanceState>;
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,
@@ -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);
});
@@ -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) ||