@open-take/compositor 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-take/compositor",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Polish compositor (D3) — event log + captured frames -> polished mp4 + editable revideo composition.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,7 +22,7 @@
22
22
  "@revideo/core": "0.11.0",
23
23
  "@revideo/ui": "0.11.0",
24
24
  "@revideo/vite-plugin": "0.11.0",
25
- "@open-take/revideo-renderer": "0.2.1"
25
+ "@open-take/revideo-renderer": "0.2.3"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^22.10.1",
package/src/camera.ts CHANGED
@@ -84,6 +84,15 @@ function growDown(box: BBox, video: { w: number; h: number }): BBox {
84
84
  * field-anchored and height-capped (its reveal is open-ended); every other
85
85
  * kind trusts the captured effect region, else shapes one from the bbox. */
86
86
  function roiForBeat(b: Beat, video: { w: number; h: number }): BBox | undefined {
87
+ // A press with an EXPLICIT zoom=always + a located reveal element: the
88
+ // author named exactly what to frame — that box outranks the frame-diff
89
+ // effectBox. A press payoff behind a scrim (modal / command palette) diffs
90
+ // as a full-frame repaint, which would flatten the punch to ~1× (issue #3);
91
+ // and a tiny incidental effectBox (a save indicator) would yank the frame
92
+ // somewhere else entirely (issue #8). click/hover keep effectBox preference:
93
+ // there the payoff usually lands AWAY from the element, which is the whole
94
+ // point of the frame-diff seam.
95
+ if (b.kind === "press" && b.intent === "always" && b.box) return b.box;
87
96
  if (b.kind === "type" && b.box) {
88
97
  // Bound the frame to "field + top of results": keep the effectBox's real
89
98
  // reveal WIDTH, but cap the HEIGHT to growDown's result-sized window so an
@@ -163,17 +172,25 @@ export function directCamera(
163
172
  boundary: true,
164
173
  reason: "plan: zoom=never → full view",
165
174
  };
166
- if (b.intent === "always")
175
+ if (b.intent === "always") {
176
+ // An explicit "always" must never ship a no-op: a wide ROI can fit-scale
177
+ // into the imperceptible band (rest…~1.1×) and render an enabled zoom
178
+ // the eye can't see (issue #1). Floor at minZoomScale — the author asked
179
+ // for a punch, so give the smallest one that reads as one.
180
+ const floored = roi ? Math.max(scale, cam.minZoomScale) : scale;
167
181
  return {
168
182
  roi,
169
- scale,
183
+ scale: floored,
170
184
  forceFull: false,
171
185
  forcePunch: true,
172
186
  boundary: true,
173
187
  reason: roi
174
- ? `plan: zoom=always → ${scale.toFixed(2)}× (framing from ROI)`
188
+ ? floored > scale
189
+ ? `plan: zoom=always → ROI fit ${scale.toFixed(2)}× is imperceptible — floored to ${floored.toFixed(2)}×`
190
+ : `plan: zoom=always → ${floored.toFixed(2)}× (framing from ROI)`
175
191
  : "plan: zoom=always but no bbox to frame → full view",
176
192
  };
193
+ }
177
194
 
178
195
  // a scroll is a pan beat: content moves, the frame stays full-view.
179
196
  if (b.kind === "scroll")
@@ -214,7 +231,11 @@ export function directCamera(
214
231
 
215
232
  // the opening beat orients: open on the whole app (Q3 — falls out of "the
216
233
  // camera opens full", no zoomFirst flag). A cold-open uses zoom=always.
217
- if (i === 0)
234
+ // Only when the beat actually opens the video, though: a first action ≥2s
235
+ // in (a leading `wait`, a slow warmup) already gave the viewer the full
236
+ // view — forcing it wide again just robs the hero moment (issue #2; the
237
+ // default warmup alone puts an immediate first action at ~1s).
238
+ if (i === 0 && b.tMs < 2000)
218
239
  return {
219
240
  roi,
220
241
  scale,
package/src/math.ts CHANGED
@@ -229,12 +229,35 @@ export function keyvalR(t: number, kfs: KF<CamRect>[], ease: (u: number) => numb
229
229
  return kfs[kfs.length - 1]![1];
230
230
  }
231
231
 
232
- export function buildStageKeyframes(comp: TakeComposition): StageKeyframes {
232
+ // The camera schedule shared by buildStageKeyframes (the render path) and
233
+ // cameraRampSchedule (the refine surfaces — A/B windows, review badges): which
234
+ // events anchor a camera move, when each ramp departs, and when it lands.
235
+ // One computation so the badge/window timing can never drift from the render.
236
+ type CameraSchedule = {
237
+ anchors: {
238
+ evIdx: number;
239
+ tMs: number;
240
+ durationMs: number;
241
+ inAtMs: number;
242
+ scale: number;
243
+ center: Pt;
244
+ glide?: Pt;
245
+ }[];
246
+ targets: CamRect[];
247
+ restR: CamRect;
248
+ /** per-anchor ramp window, SECONDS */
249
+ ramps: { start: number; end: number }[];
250
+ /** per-anchor landing time, SECONDS (≥ ramp start + a minimal real ramp;
251
+ * == tMs for every on-time ramp, later for a dwell-delayed pull-out) */
252
+ landTs: number[];
253
+ rectFor: (center: Pt, scale: number) => CamRect;
254
+ };
255
+
256
+ function buildCameraSchedule(comp: TakeComposition): CameraSchedule {
233
257
  const { videoWidth: vW, videoHeight: vH } = comp.source;
234
258
  const { width: oW, height: oH } = comp.output;
235
259
  const rest = restStageScale(vW, vH, oW, oH, comp.framing.insetFrac);
236
260
  const restC: Pt = { x: vW / 2, y: vH / 2 };
237
- const HOLD = comp.cursor.holdMs / 1000;
238
261
  const ZOUT_MS = comp.cursor.zoomOutMs;
239
262
 
240
263
  // A framing target is clamped ONCE, here at build time (the viewport crop
@@ -258,25 +281,32 @@ export function buildStageKeyframes(comp: TakeComposition): StageKeyframes {
258
281
  // Framing anchors over time. A zoom-enabled beat ramps to its target; a
259
282
  // scroll (content pans) and a zoom-less press (Escape/Enter whose effect is
260
283
  // global) ramp back to REST so the frame is full-view through them — without
261
- // these, a prior zoom would persist across the scroll/keypress. Other
262
- // disabled beats (a "never" click) keep holding the prior framing, unchanged.
263
- type Anchor = {
264
- tMs: number;
265
- durationMs: number;
266
- inAtMs: number;
267
- scale: number;
268
- center: Pt;
269
- glide?: Pt;
284
+ // these, a prior zoom would persist across the scroll/keypress. Every OTHER
285
+ // disabled beat (a "never" click/hover/type/drag) means the same thing —
286
+ // the director only ever disables a beat to show it FULL-VIEW — so it too
287
+ // anchors to rest, but only while the camera is actually away from rest: a
288
+ // disabled beat over an already-resting camera adds no anchor, keeping
289
+ // legacy compositions (and their badge/A/B windows) byte-identical. The old
290
+ // hold-prior-framing behavior left a `zoom:"never"` GLOBAL payoff cropped
291
+ // inside the previous beat's punch (the 2026-07-27 interlinear field run).
292
+ const anchors: CameraSchedule["anchors"] = [];
293
+ const awayFromRest = (): boolean => {
294
+ const a = anchors[anchors.length - 1];
295
+ if (!a) return false;
296
+ return (
297
+ Math.abs(a.scale - rest) > 1e-6 ||
298
+ Math.abs(a.center.x - restC.x) > 0.5 ||
299
+ Math.abs(a.center.y - restC.y) > 0.5
300
+ );
270
301
  };
271
- const anchors: Anchor[] = [];
272
- for (const e of comp.events) {
273
- const base = { tMs: e.tMs, durationMs: e.durationMs ?? 0, inAtMs: e.zoom.inAtMs };
274
- if (e.kind === "scroll" || (e.kind === "press" && !e.zoom.enabled)) {
302
+ comp.events.forEach((e, evIdx) => {
303
+ const base = { evIdx, tMs: e.tMs, durationMs: e.durationMs ?? 0, inAtMs: e.zoom.inAtMs };
304
+ if (e.kind === "scroll" || (!e.zoom.enabled && (e.kind === "press" || awayFromRest()))) {
275
305
  anchors.push({ ...base, scale: rest, center: restC });
276
306
  } else if (e.zoom.enabled) {
277
307
  anchors.push({ ...base, scale: e.zoom.scale, center: e.zoom.center, glide: e.zoom.glide });
278
308
  }
279
- }
309
+ });
280
310
 
281
311
  const targets = anchors.map((e) => rectFor(e.center, e.scale));
282
312
 
@@ -291,17 +321,93 @@ export function buildStageKeyframes(comp: TakeComposition): StageKeyframes {
291
321
  // ramp: a pull-out with no window is a jump cut, which is strictly worse
292
322
  // than leaving a payoff a little early.
293
323
  const ZIN_MS = comp.cursor.zoomInMs;
294
- const rampStartS = anchors.map((e, i) => {
324
+ const DWELL_MS = comp.cursor.pullOutDwellMs ?? 0;
325
+ const ramps = anchors.map((e, i) => {
295
326
  const from = i > 0 ? targets[i - 1]! : restR;
296
327
  const pullOut = targets[i]!.w > from.w + 1e-6;
297
328
  const isDefaultInAt = Math.abs(e.inAtMs - Math.max(0, e.tMs - ZIN_MS)) < 1;
298
- if (!pullOut || !isDefaultInAt) return e.inAtMs / 1000;
329
+ if (!pullOut || !isDefaultInAt) return { start: e.inAtMs / 1000, end: e.tMs / 1000 };
299
330
  const desired = e.tMs - ZOUT_MS;
300
331
  const prevEndMs = i > 0 ? anchors[i - 1]!.tMs + anchors[i - 1]!.durationMs : 0;
301
- const start =
302
- desired >= prevEndMs ? desired : Math.min(prevEndMs, e.tMs - Math.min(ZOUT_MS, ZIN_MS));
303
- return Math.max(start, 0) / 1000;
332
+ const floor = prevEndMs + DWELL_MS;
333
+ if (desired >= floor) return { start: Math.max(desired, 0) / 1000, end: e.tMs / 1000 };
334
+ if (DWELL_MS > 0) {
335
+ // The dwell floor pushes the departure past the on-time window: keep the
336
+ // full pull-out ramp and LAND LATE (after the action instant) rather than
337
+ // flee a frame the viewer is still reading. The landing is capped at the
338
+ // next anchor's ramp start at push time.
339
+ return { start: floor / 1000, end: (floor + ZOUT_MS) / 1000 };
340
+ }
341
+ const start = Math.min(prevEndMs, e.tMs - Math.min(ZOUT_MS, ZIN_MS));
342
+ return { start: Math.max(start, 0) / 1000, end: e.tMs / 1000 };
304
343
  });
344
+ // Second pass: a dwell-floored ramp must still FIT a real ramp before the
345
+ // next anchor departs — otherwise the landT cap would invert it into a
346
+ // 1ms jump cut (push()'s monotone clamp collapses it). Give up dwell time
347
+ // before ramp time: shrink the dwell so at least min(zoomOutMs, zoomInMs)
348
+ // of real ramp survives, and when even zero dwell has no room fall back to
349
+ // the exact legacy squeeze. (Anchor starts never depend on earlier ramps'
350
+ // ends, so one forward pass over pass-1 values is complete.)
351
+ if (DWELL_MS > 0) {
352
+ const minRamp = Math.min(ZOUT_MS, ZIN_MS);
353
+ for (let i = 0; i < ramps.length - 1; i++) {
354
+ const r = ramps[i]!;
355
+ const e = anchors[i]!;
356
+ if (r.end <= e.tMs / 1000 + 1e-9) continue; // on-time ramp — not dwell-late
357
+ const latestStart = ramps[i + 1]!.start - 0.01 - minRamp / 1000;
358
+ if (r.start <= latestStart) continue; // the late landing fits
359
+ const prevEndMs = i > 0 ? anchors[i - 1]!.tMs + anchors[i - 1]!.durationMs : 0;
360
+ if (latestStart * 1000 >= prevEndMs) {
361
+ r.start = latestStart;
362
+ r.end = Math.min(r.start + ZOUT_MS / 1000, ramps[i + 1]!.start - 0.01);
363
+ } else {
364
+ const start = Math.min(prevEndMs, e.tMs - minRamp);
365
+ r.start = Math.max(start, 0) / 1000;
366
+ r.end = e.tMs / 1000;
367
+ }
368
+ }
369
+ }
370
+
371
+ // A dwell-delayed pull-out lands after its own action instant; cap the
372
+ // landing so it can never run into the next anchor's ramp (floored at a
373
+ // minimal real ramp — the fits-check in the dwell pass guarantees room).
374
+ // An on-time ramp (end === tMs, every legacy entry) keeps the exact old
375
+ // landing; a pass-2-shrunk ramp may deliberately land BEFORE its tMs.
376
+ const landTs = anchors.map((e, i) => {
377
+ const nextStart = anchors[i + 1] ? ramps[i + 1]!.start : Number.POSITIVE_INFINITY;
378
+ const rampEnd = ramps[i]!.end;
379
+ return rampEnd === e.tMs / 1000
380
+ ? rampEnd
381
+ : Math.max(
382
+ ramps[i]!.start + Math.min(ZOUT_MS, ZIN_MS) / 1000,
383
+ Math.min(rampEnd, nextStart - 0.01),
384
+ );
385
+ });
386
+
387
+ return { anchors, targets, restR, ramps, landTs, rectFor };
388
+ }
389
+
390
+ /** Per-EVENT camera ramp timing (ms), for the refine surfaces (A/B windows,
391
+ * review badges): when the camera actually departs toward a beat and when it
392
+ * lands. `null` for a beat the camera holds through (no anchor). Derived from
393
+ * the same schedule the render uses, so a dwell-delayed pull-out (which
394
+ * departs after the stored inAtMs and can land after its own tMs) is
395
+ * reflected instead of approximated from inAtMs. */
396
+ export function cameraRampSchedule(
397
+ comp: TakeComposition,
398
+ ): ({ startMs: number; landMs: number } | null)[] {
399
+ const { anchors, ramps, landTs } = buildCameraSchedule(comp);
400
+ const out: ({ startMs: number; landMs: number } | null)[] = comp.events.map(() => null);
401
+ anchors.forEach((a, i) => {
402
+ out[a.evIdx] = { startMs: ramps[i]!.start * 1000, landMs: landTs[i]! * 1000 };
403
+ });
404
+ return out;
405
+ }
406
+
407
+ export function buildStageKeyframes(comp: TakeComposition): StageKeyframes {
408
+ const { anchors, targets, restR, ramps, landTs, rectFor } = buildCameraSchedule(comp);
409
+ const HOLD = comp.cursor.holdMs / 1000;
410
+ const ZOUT_MS = comp.cursor.zoomOutMs;
305
411
 
306
412
  const rf: { t: number; r: CamRect }[] = [{ t: 0, r: restR }];
307
413
  const push = (t: number, r: CamRect) => {
@@ -310,21 +416,22 @@ export function buildStageKeyframes(comp: TakeComposition): StageKeyframes {
310
416
 
311
417
  let cur = restR;
312
418
  anchors.forEach((e, i) => {
313
- const clickT = e.tMs / 1000;
314
419
  // the action plays out (typing/drawing/scrolling) for durationMs after tMs
315
420
  // — hold the target framing through it (a point click has duration 0).
316
421
  const actionEnd = (e.tMs + e.durationMs) / 1000;
317
422
  const next = anchors[i + 1];
318
- const holdEndT = next ? rampStartS[i + 1]! : actionEnd + HOLD;
319
- push(rampStartS[i]!, cur); // hold current until ramp begins
320
- push(clickT, targets[i]!); // ONE eased rect segment lands at the action
423
+ const nextStart = next ? ramps[i + 1]!.start : Number.POSITIVE_INFINITY;
424
+ const landT = landTs[i]!;
425
+ const holdEndT = Math.max(next ? nextStart : actionEnd + HOLD, landT);
426
+ push(ramps[i]!.start, cur); // hold current until ramp begins
427
+ push(landT, targets[i]!); // ONE eased rect segment lands at the action
321
428
  cur = targets[i]!;
322
429
  // glide: drift the held centre across the hold window (velocity px/s ·
323
430
  // holdSeconds), so a held zoom slowly pans instead of sitting dead-static.
324
431
  // Clamped like any target so the drift can't leave the recording.
325
432
  let holdR = cur;
326
433
  if (e.glide && (e.glide.x !== 0 || e.glide.y !== 0)) {
327
- const holdDur = Math.max(0, holdEndT - clickT);
434
+ const holdDur = Math.max(0, holdEndT - landT);
328
435
  holdR = rectFor(
329
436
  { x: e.center.x + e.glide.x * holdDur, y: e.center.y + e.glide.y * holdDur },
330
437
  e.scale,
@@ -345,6 +452,70 @@ export function buildStageKeyframes(comp: TakeComposition): StageKeyframes {
345
452
  return { r: rf.map((f) => [f.t, f.r]), T };
346
453
  }
347
454
 
455
+ // --- asymptotic settle (zoomSettleFrac) --------------------------------
456
+
457
+ /** Residual (1 − progress) of an overdamped spring's unit step response, on
458
+ * NORMALISED segment time u = (t − t0)/(t1 − t0). ω0 is solved so the
459
+ * residual at u=1 (the action instant) equals `frac`; past u=1 the same
460
+ * curve keeps decaying — the tail that replaces the legacy cut. ζ=1.2 gives
461
+ * the reference-measured shape: a fast main ramp (peak velocity ~14% in)
462
+ * plus a slow settle pole; at frac 0.04 the tail τ ≈ duration/3.6 (730ms →
463
+ * ~205ms, 1340ms → ~375ms — the frame-tracked reference tails; a different
464
+ * frac shifts ω0 and with it τ). */
465
+ function settleDecay(frac: number): (u: number) => number {
466
+ const zeta = 1.2;
467
+ const s = Math.sqrt(zeta * zeta - 1);
468
+ const l1 = zeta + s;
469
+ const l2 = zeta - s;
470
+ const resid = (x: number) => (l1 * Math.exp(-l2 * x) - l2 * Math.exp(-l1 * x)) / (l1 - l2);
471
+ let lo = 0.1;
472
+ let hi = 60;
473
+ for (let i = 0; i < 60; i++) {
474
+ const mid = (lo + hi) / 2;
475
+ if (resid(mid) > frac) lo = mid;
476
+ else hi = mid;
477
+ }
478
+ const w0T = (lo + hi) / 2;
479
+ return (u: number) => (u <= 0 ? 1 : resid(w0T * u));
480
+ }
481
+
482
+ /** Evaluate the rect track with moves that settle ASYMPTOTICALLY: each ramp
483
+ * covers 1−frac of its distance by its keyframe end, then keeps creeping
484
+ * toward the target through the following hold (never a velocity cliff). A
485
+ * ramp launches from wherever the previous tail actually is (position-
486
+ * continuous chaining); every emitted rect is a convex combination of
487
+ * build-time-clamped rects, and the valid-rect set is convex (linear
488
+ * half-plane bounds in cx,cy,w), so in-between rects stay valid exactly as
489
+ * in the lerped path. */
490
+ function settleRectAt(kfs: KF<CamRect>[], decay: (u: number) => number, t: number): CamRect {
491
+ let from = kfs[0]![1];
492
+ for (let i = 0; i < kfs.length - 1; i++) {
493
+ const [t0, r0] = kfs[i]!;
494
+ const [t1, r1] = kfs[i + 1]!;
495
+ if (r0.cx === r1.cx && r0.cy === r1.cy && r0.w === r1.w) continue; // hold — the active tail keeps running
496
+ if (t < t0) break;
497
+ // find when the NEXT move begins — this move's tail runs until then
498
+ let handoff = Number.POSITIVE_INFINITY;
499
+ for (let j = i + 1; j < kfs.length - 1; j++) {
500
+ const [ta, ra] = kfs[j]!;
501
+ const [, rb] = kfs[j + 1]!;
502
+ if (ra.cx !== rb.cx || ra.cy !== rb.cy || ra.w !== rb.w) {
503
+ handoff = ta;
504
+ break;
505
+ }
506
+ }
507
+ const evalT = Math.min(t, handoff);
508
+ const d = decay((evalT - t0) / Math.max(t1 - t0, 1e-6));
509
+ from = {
510
+ cx: r1.cx + (from.cx - r1.cx) * d,
511
+ cy: r1.cy + (from.cy - r1.cy) * d,
512
+ w: r1.w + (from.w - r1.w) * d,
513
+ };
514
+ if (t < handoff) return from;
515
+ }
516
+ return from;
517
+ }
518
+
348
519
  /** The one camera evaluator — scene.tsx (render) and the editor preview both
349
520
  * consume THIS, so preview and export can never drift. */
350
521
  export function stageCamera(comp: TakeComposition): {
@@ -363,8 +534,13 @@ export function stageCamera(comp: TakeComposition): {
363
534
  comp.output.height,
364
535
  comp.framing.insetFrac,
365
536
  );
537
+ // zoomSettleFrac swaps the segment-lerped track for the asymptotic-settle
538
+ // evaluator; explicit zoomSpring/zoomEase keep their exact legacy curves.
539
+ const frac = comp.cursor.zoomSettleFrac ?? 0;
540
+ const useSettle = frac > 0 && comp.cursor.zoomSpring == null && !comp.cursor.zoomEase;
541
+ const decay = useSettle ? settleDecay(frac) : undefined;
366
542
  const at = (t: number) => {
367
- const r = keyvalR(t, stage.r, ease);
543
+ const r = decay ? settleRectAt(stage.r, decay, t) : keyvalR(t, stage.r, ease);
368
544
  return { scale: oW / r.w, center: { x: r.cx, y: r.cy } };
369
545
  };
370
546
  // Peak by sampling (not just keyframe extremes): a spring ease overshoots
package/src/presets.ts CHANGED
@@ -40,17 +40,41 @@ export function zoomLevelName(scale: number, tol = 0.07): ZoomLevelName | null {
40
40
  // default state speakable.
41
41
  export type MotionPreset = Pick<
42
42
  CursorConfig,
43
- "travelWidthsPerSec" | "holdMs" | "zoomInMs" | "zoomOutMs"
43
+ "travelWidthsPerSec" | "holdMs" | "zoomInMs" | "zoomOutMs" | "pullOutDwellMs"
44
44
  > & { zoomEase?: undefined };
45
45
  // zoomIn/zoomOut anchored to the measured reference springs (730/1340 —
46
46
  // see DEFAULT_CURSOR); calm/brisk scale both while keeping out ≈ 1.8× in.
47
- // Each preset also CLEARS a legacy zoomEase (spread leaves the key undefined;
48
- // JSON drops it) so applying a pace migrates an old composition onto the
49
- // default measured-SS spring curve instead of silently keeping the old bezier.
47
+ // pullOutDwellMs (the minimum stay on a payoff before a squeezed pull-out may
48
+ // flee) scales with the same feel: a calm cut breathes longer, a brisk one
49
+ // tolerates a shorter beat. Each preset also CLEARS a legacy zoomEase (spread
50
+ // leaves the key undefined; JSON drops it) so applying a pace migrates an old
51
+ // composition onto the default measured-SS spring curve instead of silently
52
+ // keeping the old bezier.
50
53
  export const MOTION: Record<"calm" | "natural" | "brisk", MotionPreset> = {
51
- calm: { travelWidthsPerSec: 0.28, holdMs: 1500, zoomInMs: 900, zoomOutMs: 1650, zoomEase: undefined },
52
- natural: { travelWidthsPerSec: 0.35, holdMs: 1100, zoomInMs: 730, zoomOutMs: 1340, zoomEase: undefined },
53
- brisk: { travelWidthsPerSec: 0.45, holdMs: 750, zoomInMs: 550, zoomOutMs: 1000, zoomEase: undefined },
54
+ calm: {
55
+ travelWidthsPerSec: 0.28,
56
+ holdMs: 1500,
57
+ zoomInMs: 900,
58
+ zoomOutMs: 1650,
59
+ pullOutDwellMs: 1000,
60
+ zoomEase: undefined,
61
+ },
62
+ natural: {
63
+ travelWidthsPerSec: 0.35,
64
+ holdMs: 1100,
65
+ zoomInMs: 730,
66
+ zoomOutMs: 1340,
67
+ pullOutDwellMs: 800,
68
+ zoomEase: undefined,
69
+ },
70
+ brisk: {
71
+ travelWidthsPerSec: 0.45,
72
+ holdMs: 750,
73
+ zoomInMs: 550,
74
+ zoomOutMs: 1000,
75
+ pullOutDwellMs: 600,
76
+ zoomEase: undefined,
77
+ },
54
78
  };
55
79
  export type MotionName = keyof typeof MOTION;
56
80
 
@@ -60,7 +84,11 @@ export function motionName(cursor: CursorConfig): MotionName | null {
60
84
  Math.abs(cursor.travelWidthsPerSec - m.travelWidthsPerSec) < 0.015 &&
61
85
  Math.abs(cursor.holdMs - m.holdMs) < 60 &&
62
86
  Math.abs(cursor.zoomInMs - m.zoomInMs) < 60 &&
63
- Math.abs(cursor.zoomOutMs - m.zoomOutMs) < 60
87
+ Math.abs(cursor.zoomOutMs - m.zoomOutMs) < 60 &&
88
+ // absent = a pre-dwell composition — still nameable by its four legacy
89
+ // knobs; only an explicit different value makes the pace "custom".
90
+ (cursor.pullOutDwellMs == null ||
91
+ Math.abs(cursor.pullOutDwellMs - (m.pullOutDwellMs ?? 0)) < 60)
64
92
  )
65
93
  return name;
66
94
  }
package/src/render.ts CHANGED
@@ -286,6 +286,17 @@ async function renderTakeExclusive(
286
286
  );
287
287
  }
288
288
 
289
+ // Head trim (composition.startMs): deliver the timeline from startMs on,
290
+ // through the SAME range mechanism the A/B windows use — the composition
291
+ // timeline (tMs, badges, keyframes) is untouched; only the delivered head
292
+ // moves. An explicit rangeSec (an A/B clip window) wins: those windows are
293
+ // authored on the composition timeline and already judged as clips.
294
+ const rangeSec =
295
+ opts.rangeSec ??
296
+ (composition.startMs && composition.startMs > 0
297
+ ? ([composition.startMs / 1000, composition.durationMs / 1000 + 120] as [number, number])
298
+ : undefined);
299
+
289
300
  // Revideo spawns its bundled ffprobe directly. Repair installer permissions
290
301
  // here so published consumers are protected even though they do not run the
291
302
  // monorepo root's postinstall script.
@@ -309,7 +320,7 @@ async function renderTakeExclusive(
309
320
  outFile: "take.mp4",
310
321
  outDir: RENDER_OUT,
311
322
  workers: 1,
312
- ...(opts.rangeSec ? { projectSettings: { range: opts.rangeSec } } : {}),
323
+ ...(rangeSec ? { projectSettings: { range: rangeSec } } : {}),
313
324
  logProgress: opts.logProgress ?? false,
314
325
  ...(opts.onProgress
315
326
  ? {
package/src/types.ts CHANGED
@@ -117,6 +117,11 @@ export type CaptureLog = {
117
117
  /** the ordered ground-truth actions (click / type / drag) */
118
118
  events: CaptureEvent[];
119
119
  tEndMs?: number;
120
+ /** Steps the capture DROPPED (target not found / endpoint unresolved) — the
121
+ * take still completes, but a missing beat must reach the end-of-run
122
+ * summary and (with --strict) the exit code, not just an early stderr line
123
+ * buried under render progress. `step` is the plan's 0-based step index. */
124
+ skipped?: { step: number; action: string; target?: string; reason: string }[];
120
125
  };
121
126
 
122
127
  // --- the composition (editable) ----------------------------------------
@@ -223,6 +228,28 @@ export type CursorConfig = {
223
228
  * shapes the curve. Bounce > 0 overshoots the RECT (a touch past the target
224
229
  * frame, then settle) — keep it small. */
225
230
  zoomSpring?: number;
231
+ /** Fraction of a camera ramp still UNfinished at its keyframe end (the action
232
+ * instant), left to settle as an asymptotic overdamped tail that continues
233
+ * INTO the hold — so a move tapers out like a physical camera instead of
234
+ * stopping on a velocity cliff at the keyframe. Frame-tracked on the
235
+ * reference export: its moves keep sub-threshold motion ~0.5s past the
236
+ * visible end (tail τ ≈ 220ms in / ≈ 370ms out), while the cut spring's
237
+ * τ = duration/6.9 ends 2-3× harder. ~0.04 (the shipped default) reproduces
238
+ * the reference tails over the default zoomInMs/zoomOutMs. 0 = legacy
239
+ * cut+normalized spring (absent falls back to the default on NEW plans; an
240
+ * old composition without the field renders as it always did). Ignored when
241
+ * zoomSpring or zoomEase is set (those keep their exact legacy curves). */
242
+ zoomSettleFrac?: number;
243
+ /** Minimum stay (ms) after the previous action's visible end before a
244
+ * PULL-OUT ramp may begin. When the beat gap is too tight the pull-out now
245
+ * departs late and LANDS late (after its own action instant) instead of
246
+ * fleeing a frame the viewer is still reading — the reference recorder's
247
+ * reactive pattern (payoff plays while the camera is still arriving).
248
+ * ~800 (the shipped default) reads as a natural beat; pace presets scale it.
249
+ * 0/absent = legacy (a squeezed pull-out departs the instant the previous
250
+ * action ends and lands exactly on its action). Named pullOut- because
251
+ * holdMs already covers the ordinary post-action dwell. */
252
+ pullOutDwellMs?: number;
226
253
  /** ms to delay the synthetic cursor along a DRAG stroke, compensating for the
227
254
  * capture pipeline latency: the captured ink appears ~this long after the pen
228
255
  * actually moved, so without the delay the (exact-time) cursor leads the ink.
@@ -338,6 +365,14 @@ export type TakeComposition = {
338
365
  start: Pt;
339
366
  events: CompEvent[];
340
367
  durationMs: number;
368
+ /** Head trim (ms of the composition timeline cut from the delivered mp4).
369
+ * Capture starts at navigation, so the first frames show the app before it
370
+ * painted (plus any cold-cache font swap) — trim them here instead of
371
+ * post-processing with ffmpeg, so the refine loop keeps applying to the file
372
+ * actually shipped. Event tMs values stay on the untrimmed timeline (the
373
+ * capture is the ground truth); only the delivered head moves. 0/absent =
374
+ * no trim. */
375
+ startMs?: number;
341
376
  /** render-time review decoration (badges/watermark/label); never persisted */
342
377
  review?: ReviewDecor;
343
378
  };
@@ -397,6 +432,14 @@ export const DEFAULT_CURSOR: CursorConfig = {
397
432
  // critically-damped spring that IS the measured SS curve over these windows.
398
433
  zoomOutMs: 1340,
399
434
  zoomInMs: 730,
435
+ // Asymptotic settle + pull-out dwell — the A/B "C variant" Pascal signed off
436
+ // (2026-07-26): each camera move keeps a ~4% residual settling INTO the hold
437
+ // (no velocity cliff at the keyframe — the frame-tracked reference tail), and
438
+ // a squeezed pull-out stays ≥800ms on the payoff, landing late instead of
439
+ // fleeing a frame the viewer is still reading. Old compositions without the
440
+ // fields keep the legacy cut/squeeze schedule byte-identically.
441
+ zoomSettleFrac: 0.04,
442
+ pullOutDwellMs: 800,
400
443
  // The captured ink trails the pen by the screencast/encode pipeline latency τ;
401
444
  // delay the cursor by τ so its tip rides the ink front. Set to τ EXACTLY and
402
445
  // the cursor locks to the ink at ALL stroke speeds (both are the same time-
package/src/validate.ts CHANGED
@@ -16,7 +16,7 @@
16
16
  // action needs a re-capture, not a JSON edit. Pass the capture log to enforce
17
17
  // this; without it the check is skipped (we can't know the ground truth).
18
18
 
19
- import { restStageScale } from "./math";
19
+ import { buildStageKeyframes, restStageScale } from "./math";
20
20
  import type { CaptureLog, TakeComposition } from "./types";
21
21
 
22
22
  export type CompositionIssue = {
@@ -154,11 +154,13 @@ export function validateComposition(
154
154
  `scale ${z.scale.toFixed(3)} is below rest ${rest.toFixed(3)} — that zooms OUT past the frame (dead space)`,
155
155
  `raise to ≥ ${rest.toFixed(2)}, or set zoom.enabled=false for a full-view beat`,
156
156
  );
157
- else if (z.scale <= rest + 1e-6)
157
+ else if (z.scale < rest * 1.2)
158
+ // the whole dead band, not just ≈rest exactly: a 1.03× "zoom" renders
159
+ // an enabled move the eye can't see (issue #1 — it shipped silently).
158
160
  warn(
159
161
  `${p}.zoom.scale`,
160
- `scale ${z.scale.toFixed(3)} ≈ rest — zoom is enabled but does nothing visible`,
161
- "raise scale to actually zoom, or set enabled=false",
162
+ `scale ${z.scale.toFixed(3)} is within 20% of rest ${rest.toFixed(3)} — an imperceptible zoom (enabled but invisible)`,
163
+ "raise scale to ≥ ~1.25 to actually zoom, or set enabled=false",
162
164
  );
163
165
  if (z.scale > maxScale)
164
166
  warn(
@@ -205,6 +207,30 @@ export function validateComposition(
205
207
  );
206
208
  }
207
209
 
210
+ // asymptotic settle: the residual left to creep out after the action instant.
211
+ // Beyond ~0.15 the camera visibly hasn't arrived when the action fires.
212
+ const settleFrac = comp.cursor.zoomSettleFrac;
213
+ if (settleFrac != null && !(settleFrac >= 0 && settleFrac <= 0.15))
214
+ err(
215
+ "cursor.zoomSettleFrac",
216
+ `zoomSettleFrac ${settleFrac} outside [0, 0.15]`,
217
+ "~0.04 = the reference-measured tail; 0 = legacy cut spring",
218
+ );
219
+ else if (settleFrac != null && settleFrac > 0 && (comp.cursor.zoomEase || spring != null))
220
+ warn(
221
+ "cursor.zoomSettleFrac",
222
+ `zoomSettleFrac is IGNORED while cursor.${comp.cursor.zoomEase ? "zoomEase" : "zoomSpring"} is set — the render is byte-identical to not setting it`,
223
+ "delete cursor.zoomEase / cursor.zoomSpring (a pace preset clears zoomEase) to activate the settle tail",
224
+ );
225
+
226
+ const dwell = comp.cursor.pullOutDwellMs;
227
+ if (dwell != null && !(dwell >= 0 && dwell <= 5000))
228
+ err(
229
+ "cursor.pullOutDwellMs",
230
+ `pullOutDwellMs ${dwell} outside [0, 5000]`,
231
+ "600-1000 reads as a natural beat; 0 = legacy (depart as soon as the action ends)",
232
+ );
233
+
208
234
  // tail: the composition must outlast the last action (+ a little settle)
209
235
  if (comp.durationMs < lastEnd)
210
236
  err(
@@ -219,6 +245,48 @@ export function validateComposition(
219
245
  `allow ≥ ${comp.cursor.zoomOutMs}ms (cursor.zoomOutMs) of tail`,
220
246
  );
221
247
 
248
+ // A dwell-delayed final pull-out can land LATER than the legacy tail math
249
+ // above assumes — check the actual schedule, not the formula. (Guarded: the
250
+ // schedule needs a structurally sound composition; earlier errors mean this
251
+ // check would throw, and its absence is already explained by them.)
252
+ if ((comp.cursor.pullOutDwellMs ?? 0) > 0 && issues.every((i) => i.severity !== "error")) {
253
+ try {
254
+ const kfs = buildStageKeyframes(comp).r;
255
+ let motionEndS = 0;
256
+ for (let i = 0; i < kfs.length - 1; i++) {
257
+ const [, a] = kfs[i]!;
258
+ const [t1, b] = kfs[i + 1]!;
259
+ if (a.cx !== b.cx || a.cy !== b.cy || a.w !== b.w) motionEndS = t1;
260
+ }
261
+ if (motionEndS * 1000 > comp.durationMs + 1)
262
+ warn(
263
+ "durationMs",
264
+ `the camera is still mid-motion at durationMs (dwell-delayed landing ends ~${Math.round(motionEndS * 1000)}ms)`,
265
+ `raise durationMs to ≥ ${Math.round(motionEndS * 1000)}`,
266
+ );
267
+ } catch {
268
+ /* never let a diagnostics pass throw */
269
+ }
270
+ }
271
+
272
+ // head trim: cut dead pre-paint frames, never a beat. The trim only moves
273
+ // the delivered head — tMs values stay on the capture timeline.
274
+ const startMs = comp.startMs;
275
+ if (startMs != null) {
276
+ if (!(startMs >= 0) || startMs >= comp.durationMs)
277
+ err(
278
+ "startMs",
279
+ `startMs ${startMs} outside [0, durationMs ${comp.durationMs})`,
280
+ "the head trim must leave a video",
281
+ );
282
+ else if (comp.events[0] && startMs > comp.events[0].zoom.inAtMs)
283
+ warn(
284
+ "startMs",
285
+ `startMs ${startMs} cuts into the first beat (camera/cursor already moving at ${comp.events[0].zoom.inAtMs}ms)`,
286
+ `keep the trim ≤ ${comp.events[0].zoom.inAtMs} so the delivered video opens at rest`,
287
+ );
288
+ }
289
+
222
290
  // --- CAPTURE-LOCKED: action tMs must match the recording ---
223
291
  // The video is temporal: a beat's tMs is WHEN it is visible in the capture.
224
292
  // A render-only edit cannot move that, so a drifted tMs would fire the