fix: address PR review regressions

This commit is contained in:
webadderall
2026-05-05 11:43:04 +10:00
parent 6cc83b31e9
commit c01981fd5e
5 changed files with 34 additions and 9 deletions
+2 -2
View File
@@ -151,12 +151,12 @@ interface Window {
message?: string;
error?: string;
}>;
pauseCursorCapture: () => Promise<{
pauseCursorCapture: (boundaryMs?: number) => Promise<{
success: boolean;
message?: string;
error?: string;
}>;
resumeCursorCapture: () => Promise<{
resumeCursorCapture: (boundaryMs?: number) => Promise<{
success: boolean;
message?: string;
error?: string;
+4 -4
View File
@@ -293,11 +293,11 @@ contextBridge.exposeInMainWorld("electronAPI", {
resumeNativeScreenRecording: () => {
return ipcRenderer.invoke("resume-native-screen-recording");
},
pauseCursorCapture: () => {
return ipcRenderer.invoke("pause-cursor-capture");
pauseCursorCapture: (boundaryMs?: number) => {
return ipcRenderer.invoke("pause-cursor-capture", boundaryMs);
},
resumeCursorCapture: () => {
return ipcRenderer.invoke("resume-cursor-capture");
resumeCursorCapture: (boundaryMs?: number) => {
return ipcRenderer.invoke("resume-cursor-capture", boundaryMs);
},
startFfmpegRecording: (source: ProcessedDesktopSource) => {
return ipcRenderer.invoke("start-ffmpeg-recording", source);
+6 -1
View File
@@ -3076,7 +3076,12 @@ export default function VideoEditor() {
autoFullTrackClipIdRef.current = id;
autoFullTrackClipEndMsRef.current = totalMs;
if (trimRegions.length > 0) {
setClipRegions(trimsToClips(trimRegions, totalMs));
const derivedClipRegions = trimsToClips(trimRegions, totalMs);
nextClipIdRef.current = deriveNextId(
"clip",
derivedClipRegions.map((region) => region.id),
);
setClipRegions(derivedClipRegions);
clipInitializedRef.current = true;
return;
}
@@ -1479,10 +1479,15 @@ const TimelineEditor = forwardRef<TimelineEditorHandle, TimelineEditorProps>(
const activeClip = clipRegions.find(
(clip) => startPos >= clip.startMs && startPos < clip.endMs,
);
const nextClip = clipRegions.find((clip) => clip.startMs > startPos);
const sorted = [...zoomRegions].sort((a, b) => a.startMs - b.startMs);
const nextRegion = sorted.find((region) => region.startMs > startPos);
const gapToNextClipEdge = activeClip ? activeClip.endMs - startPos : totalMs - startPos;
const gapToNextClipEdge = activeClip
? activeClip.endMs - startPos
: nextClip
? nextClip.startMs - startPos
: 0;
const gapToNextRegion = nextRegion ? nextRegion.startMs - startPos : totalMs - startPos;
const availableDuration = Math.min(gapToNextClipEdge, gapToNextRegion);
@@ -1490,7 +1495,7 @@ const TimelineEditor = forwardRef<TimelineEditorHandle, TimelineEditorProps>(
(region) => startPos >= region.startMs && startPos < region.endMs,
);
return !isOverlapping && availableDuration >= defaultDuration;
return !isOverlapping && availableDuration >= defaultRegionDurationMs;
},
[videoDuration, totalMs, zoomRegions, defaultRegionDurationMs, clipRegions],
);
+15
View File
@@ -5,7 +5,9 @@ import {
findClipAtTimelineTime,
mapSourceTimeToTimelineTime,
mapTimelineTimeToSourceTime,
trimsToClips,
} from "./types";
import { deriveNextId } from "./projectPersistence";
describe("extendAutoFullTrackClip", () => {
it("extends the default full-track clip when metadata duration grows", () => {
@@ -141,4 +143,17 @@ describe("clip timeline mapping", () => {
expect(findClipAtTimelineTime(500, clips)?.id).toBe("clip-1");
expect(findClipAtTimelineTime(5_000, clips)).toBeNull();
});
it("derives the next clip id after converting trim gaps into clip ids", () => {
const clipsFromTrims = trimsToClips(
[
{ id: "trim-gap-1", startMs: 1_000, endMs: 2_000 },
{ id: "trim-gap-2", startMs: 4_000, endMs: 5_000 },
],
6_000,
);
expect(clipsFromTrims.map((clip) => clip.id)).toEqual(["clip-1", "clip-2", "clip-3"]);
expect(deriveNextId("clip", clipsFromTrims.map((clip) => clip.id))).toBe(4);
});
});