@@ -48,7 +48,10 @@ import {
4848 replacePillSpan ,
4949 resolvePillIds ,
5050} from "../../src/lib/ai-edition/timeline/timelineMap" ;
51- import { trimAppliesToClip } from "../../src/lib/ai-edition/timeline/trim-mapping" ;
51+ import {
52+ trimAppliesToClip ,
53+ trimToTimelineSpan ,
54+ } from "../../src/lib/ai-edition/timeline/trim-mapping" ;
5255// ponytail: relative, and it has to stay that way — `electron/` never resolves
5356// the `@/` alias (the main-process build does not declare it), which is why the
5457// scale table was moved out of `components/video-editor/types.ts` to be
@@ -57,6 +60,10 @@ import {
5760 effectiveZoomScale ,
5861 ZOOM_DEPTH_LEGEND ,
5962} from "../../src/lib/ai-edition/timeline/zoom-scale" ;
63+ import {
64+ transitionCutsMs ,
65+ zoomTransitions ,
66+ } from "../../src/lib/ai-edition/timeline/zoom-transitions" ;
6067import { SETTING_BOUNDS } from "../../src/lib/projectDefaults" ;
6168
6269export interface AgentToolExecution {
@@ -713,6 +720,46 @@ function roundSec(ms: number): number {
713720 return Math . round ( ms ) / 1000 ;
714721}
715722
723+ // Each zoom pill's camera moves in virtual ms, and how much of each a trim cuts off (#1028).
724+ // The pill shows the hold only: the move in runs before it, the move out after it, and a
725+ // trim over either makes the export jump at the cut.
726+ function zoomTransitionsForAgent ( document : AxcutDocument ) {
727+ const legacy = document . legacyEditor as Record < string , unknown > | null ;
728+ const speedRegions =
729+ ( legacy ?. speedRegions as
730+ | Array < { id : string ; startMs : number ; endMs : number ; speed : number } >
731+ | undefined ) ?? [ ] ;
732+ const trims = document . timeline . trimRanges . flatMap ( ( trim ) => {
733+ const span = trimToTimelineSpan ( trim , document . timeline . clips ) ;
734+ return span ? [ { startMs : span . start * 1000 , endMs : span . end * 1000 } ] : [ ] ;
735+ } ) ;
736+ return coalesceForAgent ( document . zoomRanges ) . map ( ( zoom ) => {
737+ const transitions = zoomTransitions ( { ...zoom , scale : effectiveZoomScale ( zoom ) } , speedRegions ) ;
738+ return { zoom, transitions, cut : transitionCutsMs ( zoom , transitions , trims ) } ;
739+ } ) ;
740+ }
741+
742+ /** The transitions this edit cut that were not cut, or not this way, before it: the warning a
743+ * zoom or trim write carries, like `cursorAnchor`: reported, never refused. */
744+ function cutTransitionsReport ( before : AxcutDocument , after : AxcutDocument ) {
745+ const cutsOf = ( document : AxcutDocument ) =>
746+ zoomTransitionsForAgent ( document ) . flatMap ( ( { zoom, cut } ) =>
747+ ( [ "in" , "out" ] as const )
748+ . map ( ( side ) => ( {
749+ zoomId : zoom . id ,
750+ side,
751+ cutSec : roundSec ( side === "in" ? cut . inMs : cut . outMs ) ,
752+ key : `${ zoom . id } :${ side } :${ zoom . startMs } :${ zoom . endMs } ` ,
753+ } ) )
754+ . filter ( ( c ) => c . cutSec > 0 ) ,
755+ ) ;
756+ const known = new Set ( cutsOf ( before ) . map ( ( c ) => `${ c . key } :${ c . cutSec } ` ) ) ;
757+ const cuts = cutsOf ( after )
758+ . filter ( ( c ) => ! known . has ( `${ c . key } :${ c . cutSec } ` ) )
759+ . map ( ( { key : _key , ...c } ) => c ) ;
760+ return cuts . length ? { cutTransitions : cuts } : { } ;
761+ }
762+
716763// Compact projection of the document for the model: everything it needs to
717764// reference ids and times, nothing it doesn't (no waveform paths, no history).
718765//
@@ -764,7 +811,10 @@ export function documentSnapshotForModel(
764811 zoomNote :
765812 `renderedScale is what the viewer sees (depth is an ordinal, not a factor: ${ ZOOM_DEPTH_LEGEND } ). ` +
766813 "When a zoom carries customScale it wins over depth and depthIsOverridden is true — " +
767- "a setZoom that only changes depth on such a zoom clears customScale so the depth takes effect." ,
814+ "a setZoom that only changes depth on such a zoom clears customScale so the depth takes effect. " +
815+ "startSec–endSec is where the zoom HOLDS: it animates in over zoomInFromSec–startSec and out over " +
816+ "endSec–zoomOutUntilSec (transitionSec of screen time each, stretched on the timeline by a speed " +
817+ "region). cutByTrim names the move a trim cuts into (in, out or both): the export jumps at that cut." ,
768818 project : { id : document . project . id , title : document . project . title } ,
769819 primaryAssetId : document . project . primaryAssetId ?? document . assets [ 0 ] ?. id ?? null ,
770820 autoFocusAll,
@@ -821,10 +871,16 @@ export function documentSnapshotForModel(
821871 endSec : s . endSec ,
822872 reason : s . reason ,
823873 } ) ) ,
824- zoomRanges : coalesceForAgent ( document . zoomRanges ) . map ( ( z ) => ( {
874+ zoomRanges : zoomTransitionsForAgent ( document ) . map ( ( { zoom : z , transitions , cut } ) => ( {
825875 id : z . id ,
826876 startSec : roundSec ( z . startMs ) ,
827877 endSec : roundSec ( z . endMs ) ,
878+ zoomInFromSec : roundSec ( transitions . inFromMs ) ,
879+ zoomOutUntilSec : roundSec ( transitions . outUntilMs ) ,
880+ transitionSec : roundSec ( transitions . durationMs ) ,
881+ ...( cut . inMs > 0 || cut . outMs > 0
882+ ? { cutByTrim : cut . inMs > 0 ? ( cut . outMs > 0 ? "both" : "in" ) : "out" }
883+ : { } ) ,
828884 depth : z . depth ,
829885 renderedScale : effectiveZoomScale ( z ) ,
830886 // Emitted only when set: an unconditional `customScale: null` on every
@@ -1501,7 +1557,12 @@ export function executeAgentTool(
15011557 return {
15021558 ok : true ,
15031559 document : next ,
1504- resultJson : JSON . stringify ( { trimRangeId : trim . id , startSec, endSec } ) ,
1560+ resultJson : JSON . stringify ( {
1561+ trimRangeId : trim . id ,
1562+ startSec,
1563+ endSec,
1564+ ...cutTransitionsReport ( document , next ) ,
1565+ } ) ,
15051566 summary : `added trim ${ formatSec ( startSec ) } – ${ formatSec ( endSec ) } ` ,
15061567 } ;
15071568 }
@@ -1548,7 +1609,12 @@ export function executeAgentTool(
15481609 return {
15491610 ok : true ,
15501611 document : next ,
1551- resultJson : JSON . stringify ( { trimRangeId, startSec, endSec } ) ,
1612+ resultJson : JSON . stringify ( {
1613+ trimRangeId,
1614+ startSec,
1615+ endSec,
1616+ ...cutTransitionsReport ( document , next ) ,
1617+ } ) ,
15521618 summary : `moved trim to ${ formatSec ( startSec ) } – ${ formatSec ( endSec ) } ` ,
15531619 } ;
15541620 }
@@ -1744,6 +1810,7 @@ export function executeAgentTool(
17441810 renderedScale : effectiveZoomScale ( zoom ) ,
17451811 ...landingReport ( landing , startMs / 1000 , endMs / 1000 ) ,
17461812 ...( anchor ? { cursorAnchor : anchor } : { } ) ,
1813+ ...cutTransitionsReport ( document , next ) ,
17471814 } ) ,
17481815 summary :
17491816 `added zoom ${ formatSec ( landing . startSec ) } – ${ formatSec ( landing . endSec ) } ` +
@@ -1828,6 +1895,7 @@ export function executeAgentTool(
18281895 ...( clearsCustomScale ? { clearedCustomScale : true } : { } ) ,
18291896 ...landingReport ( landing , startMs / 1000 , endMs / 1000 ) ,
18301897 ...( anchor ? { cursorAnchor : anchor } : { } ) ,
1898+ ...cutTransitionsReport ( document , next ) ,
18311899 } ) ,
18321900 summary :
18331901 `updated zoom ${ formatSec ( landing . startSec ) } – ${ formatSec ( landing . endSec ) } ` +
0 commit comments