Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
revert(editor): an added word no longer splits the clip it lands in
EtienneLescotd829afcfdce0
diff --git a/src/components/ai-edition/RightPanes.tsx b/src/components/ai-edition/RightPanes.tsxindex bc2bce966..dfe3d159c 100644--- a/src/components/ai-edition/RightPanes.tsx+++ b/src/components/ai-edition/RightPanes.tsx@@ -68,7 +68,6 @@ import {findCueWordId,isInsertedWord,isSilenceWord,- placementRawExtent,type TranscriptLane,type TrimRun,voiceoverPlacements,@@ -1001,8 +1000,6 @@ export function TranscriptPane({key={section.clip.id}index={idx}section={section}- continuation={continuesPreviousSection(sections[idx - 1], section)}- runLabel={runLabelFor(sections, idx)}busy={busyAssetIds.includes(section.clip.assetId)}busyLabel={transcriptionBusyLabel(transcriptions?.[section.clip.assetId], transcriptionLabel) ??@@ -1021,50 +1018,6 @@ export function TranscriptPane({);}-/**- * Whether this section merely continues the previous one: same media, and the previous- * clip ends exactly where this one starts, on the source clock and on the ruler alike.- *- * Inserting a word SPLITS the clip it lands in — [before · freeze · after] — so one word- * turned one recording into three headed blocks, each announcing the same filename and a- * sliver of timecode. They are one continuous read and now render as one: the header- * appears on the first section of the run, the rest flow straight on from it. Two clips- * over the same media that are NOT contiguous still get a header each, which is the case- * the header exists for.- */-function continuesPreviousSection(- previous: ClipSection | undefined,- section: ClipSection,-): boolean {- if (!previous || previous.clip.assetId !== section.clip.assetId) return false;- const EPSILON_SEC = 0.001;- const sourceMeets =- Math.abs((previous.clip.sourceEndSec ?? Number.NaN) - section.clip.sourceStartSec) <- EPSILON_SEC;- // A placement's ruler end is derived, not stored: the voiceover lane has no clip behind- // it to read a `timelineEndSec` from.- const previousEnd = placementRawExtent(previous.clip)?.endSec;- const rulerMeets =- previousEnd !== undefined &&- Math.abs(previousEnd - section.clip.timelineStartSec) < EPSILON_SEC;- return sourceMeets && rulerMeets;-}--/** The source range the whole run covers, for the one header that fronts it. */-function runLabelFor(sections: ClipSection[], index: number): { start: number; end: number } {- let last = index;- while (- last + 1 < sections.length &&- continuesPreviousSection(sections[last], sections[last + 1])- ) {- last += 1;- }- return {- start: sections[index].clip.sourceStartSec,- end: sections[last].clip.sourceEndSec ?? sections[last].clip.sourceStartSec,- };-}-// One contentEditable block per clip — header (vignette + filename +// range) and a flowing word stream. The stream contains every transcript// word inside the clip's source range, color-coded by whether the word@@ -1080,8 +1033,6 @@ function runLabelFor(sections: ClipSection[], index: number): { start: number; econst TranscriptClipBlock = memo(function TranscriptClipBlock({index,section,- continuation,- runLabel,busy,busyLabel,cueWordId,@@ -1094,10 +1045,6 @@ const TranscriptClipBlock = memo(function TranscriptClipBlock({}: {index: number;section: ClipSection;- /** This section reads straight on from the one above — no header, no gap. */- continuation: boolean;- /** Source range of the whole contiguous run this section fronts. */- runLabel: { start: number; end: number };busy: boolean;busyLabel?: string;cueWordId: string | null;@@ -1117,9 +1064,10 @@ const TranscriptClipBlock = memo(function TranscriptClipBlock({[clip.assetId, clip.id],);const filename = asset?.label ?? clip.assetId;- // The run's range, not this clip's: a split clip's own sliver would read as a- // 0:02.5—0:02.5 recording.- const sourceRangeLabel = `${formatMs(runLabel.start * 1000)}—${formatMs(runLabel.end * 1000)}`;+ const sourceRangeLabel =+ clip.sourceEndSec !== undefined+ ? `${formatMs(clip.sourceStartSec * 1000)}—${formatMs(clip.sourceEndSec * 1000)}`+ : `${formatMs(clip.sourceStartSec * 1000)}—`;const editorRef = useRef<HTMLDivElement | null>(null);const pendingCaretWordIdRef = useRef<string | null>(null);@@ -1396,85 +1344,79 @@ const TranscriptClipBlock = memo(function TranscriptClipBlock({return (<span- // Inline, so the pieces of a split clip flow into one sentence instead of each- // taking a line of its own — an inserted word splits the clip it lands in, and a- // block box per piece is what turned one recording into three. The header inside- // is block-level and still breaks the line before itself, which is where the gap- // between two real recordings comes from.- style={{ display: "inline" }}+ style={{+ display: "block",+ marginBottom: 16,+ }}>- {continuation ? null : (+ <span+ style={{+ display: "flex",+ alignItems: "center",+ gap: 10,+ padding: "0 4px 4px",+ borderBottom: "1px solid var(--border-soft)",+ marginBottom: 6,+ }}+ ><span- data-clip-header="true"style={{- display: "flex",+ width: 22,+ height: 22,+ display: "inline-flex",alignItems: "center",- gap: 10,- padding: "0 4px 4px",- borderBottom: "1px solid var(--border-soft)",- marginTop: index > 0 ? 16 : 0,- marginBottom: 6,+ justifyContent: "center",+ background: "var(--accent-soft)",+ color: "var(--accent)",+ borderRadius: "var(--r-sm)",+ font: "700 12px/1 var(--font-mono)",+ flexShrink: 0,}}>+ {index + 1}+ </span>+ <span style={{ minWidth: 0, flex: 1 }}>+ <span+ style={{+ display: "block",+ font: "600 13px/1.2 var(--font-body)",+ color: "var(--fg)",+ overflow: "hidden",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",+ }}+ >+ {filename}+ </span>+ <span+ style={{+ display: "block",+ font: "400 11px/1.3 var(--font-mono)",+ color: "var(--muted)",+ marginTop: 2,+ }}+ >+ {ts("transcript.clipLabel", { index: index + 1 })} · {sourceRangeLabel}+ </span>+ </span>+ {/* A block whose transcript is being regenerated is read-only — say it,+ rather than letting the word stream look live and drop the edits. */}+ {busy ? (<spanstyle={{- width: 22,- height: 22,display: "inline-flex",alignItems: "center",- justifyContent: "center",- background: "var(--accent-soft)",- color: "var(--accent)",- borderRadius: "var(--r-sm)",- font: "700 12px/1 var(--font-mono)",+ gap: 5,flexShrink: 0,+ font: "500 11px/1 var(--font-body)",+ color: "var(--accent)",}}>- {index + 1}- </span>- <span style={{ minWidth: 0, flex: 1 }}>- <span- style={{- display: "block",- font: "600 13px/1.2 var(--font-body)",- color: "var(--fg)",- overflow: "hidden",- textOverflow: "ellipsis",- whiteSpace: "nowrap",- }}- >- {filename}- </span>- <span- style={{- display: "block",- font: "400 11px/1.3 var(--font-mono)",- color: "var(--muted)",- marginTop: 2,- }}- >- {ts("transcript.clipLabel", { index: index + 1 })} · {sourceRangeLabel}- </span>+ <Loader2 size={12} className="animate-spin" />+ {ts("transcript.transcribing")}</span>- {/* A block whose transcript is being regenerated is read-only — say it,- rather than letting the word stream look live and drop the edits. */}- {busy ? (- <span- style={{- display: "inline-flex",- alignItems: "center",- gap: 5,- flexShrink: 0,- font: "500 11px/1 var(--font-body)",- color: "var(--accent)",- }}- >- <Loader2 size={12} className="animate-spin" />- {ts("transcript.transcribing")}- </span>- ) : null}- </span>- )}+ ) : null}+ </span>{words.length === 0 ? (<pstyle={{diff --git a/src/components/ai-edition/TranscriptPane.sharedMedia.test.tsx b/src/components/ai-edition/TranscriptPane.sharedMedia.test.tsxindex 5d0934718..7b553b2eb 100644--- a/src/components/ai-edition/TranscriptPane.sharedMedia.test.tsx+++ b/src/components/ai-edition/TranscriptPane.sharedMedia.test.tsx@@ -180,85 +180,3 @@ describe("transcript pane with two clips over one media", () => {).toEqual(["clip_2:w2"]);});});--// ─── Headers on a clip an inserted word split ────────────────────-// Inserting a word splits the clip it lands in — [before · freeze · after] — so one word-// turned one recording into three blocks, each announcing the same filename and a sliver-// of timecode ("Clip 2 · 0:02.5—0:02.5"). They are one continuous read: one header, and-// the words flow straight on. The two-copies case above must keep its two headers, which-// is what tells the split apart from a media genuinely placed twice.--const SPLIT_CLIPS: AxcutClip[] = [- {- id: "clip_1_fzA",- assetId: "asset_1",- sourceStartSec: 0,- sourceEndSec: 6,- timelineStartSec: 0,- timelineEndSec: 6,- wordRefs: [],- origin: "user",- reason: "",- },- {- id: "clip_1_fz",- assetId: "asset_1",- sourceStartSec: 6,- sourceEndSec: 6,- timelineStartSec: 6,- timelineEndSec: 6.5,- wordRefs: [],- origin: "user",- reason: "Inserted word — held frame",- frozenSec: 0.5,- },- {- id: "clip_1_fzB",- assetId: "asset_1",- sourceStartSec: 6,- sourceEndSec: 12,- timelineStartSec: 6.5,- timelineEndSec: 12.5,- wordRefs: [],- origin: "user",- reason: "",- },-];--function renderClips(clips: AxcutClip[]) {- return render(- <I18nProvider>- <TranscriptPane- clips={clips}- transcripts={[TRANSCRIPT]}- assets={[ASSET]}- trimRanges={[]}- busyAssetIds={[]}- onSeek={vi.fn()}- onAddTrimRange={vi.fn()}- onRemoveTrimRange={vi.fn()}- onSetWordText={vi.fn()}- onInsertWord={vi.fn()}- onRemoveWords={vi.fn()}- onTranscribe={vi.fn()}- canTranscribe- isTranscribing={false}- />- </I18nProvider>,- );-}--describe("clip headers", () => {- it("fronts a split clip with one header covering the whole run", () => {- const view = renderClips(SPLIT_CLIPS);- const headers = view.container.querySelectorAll("[data-clip-header]");- expect(headers).toHaveLength(1);- // The run's range, not the first piece's — and not the freeze's 0:06.0—0:06.0.- expect(headers[0].textContent).toContain("0:00.0—0:12.0");- });-- it("still gives two headers to one media placed twice", () => {- const view = renderClips(CLIPS);- expect(view.container.querySelectorAll("[data-clip-header]")).toHaveLength(2);- });-});diff --git a/src/lib/ai-edition/captions/captions.test.ts b/src/lib/ai-edition/captions/captions.test.tsindex 4d86af1ef..ce3d4a961 100644--- a/src/lib/ai-edition/captions/captions.test.ts+++ b/src/lib/ai-edition/captions/captions.test.ts@@ -650,118 +650,3 @@ describe("translated caption layout", () => {);});});--// ─── Captions across an inserted word's pause ────────────────────-// Inserting a word SPLITS the clip it lands in — [before · freeze · after] — and a caption-// line straddling the split was ventilated once per half, each half carrying the whole-// line. On screen: the caption played, blinked out for the pause, then played again from-// the top — dark over the one moment the pause exists for.--describe("a caption line over a freeze", () => {- /** `clip-1` split at 1.2s, with 0.5s of held frame carrying an inserted word. */- function splitDoc(): AxcutDocument {- const withInsert = transcript();- withInsert.segments[0] = {- ...withInsert.segments[0],- text: "hello there really friend",- wordIds: ["w1", "w2", "synth_1", "w3"],- };- withInsert.words = [- ...withInsert.words,- {- id: "synth_1",- segmentId: "seg_1",- startSec: 1.2,- endSec: 1.2,- text: "really",- source: "synth",- },- ];- return doc({- transcripts: [withInsert],- timeline: {- ...doc().timeline,- clips: [- {- id: "clip-1_fzA",- assetId: "asset-1",- sourceStartSec: 0,- sourceEndSec: 1.2,- timelineStartSec: 0,- timelineEndSec: 1.2,- wordRefs: [],- origin: "user",- reason: "",- },- {- id: "clip-1_fz",- assetId: "asset-1",- sourceStartSec: 1.2,- sourceEndSec: 1.2,- timelineStartSec: 1.2,- timelineEndSec: 1.7,- wordRefs: [],- origin: "user",- reason: "Inserted word — held frame",- frozenSec: 0.5,- },- {- id: "clip-1_fzB",- assetId: "asset-1",- sourceStartSec: 1.2,- sourceEndSec: 10,- timelineStartSec: 1.7,- timelineEndSec: 10.5,- wordRefs: [],- origin: "user",- reason: "",- },- ],- },- });- }-- it("plays the line once, straight through the pause", () => {- const cues = deriveCaptionCues(splitDoc(), ON, {});- const first = cues.filter((cue) => cue.text.includes("really"));- expect(first).toHaveLength(1);- // It starts before the freeze and is still up after it — no dark stretch.- expect(first[0].startMs).toBeLessThan(1200);- expect(first[0].endMs).toBeGreaterThan(1700);- });-- it("still plays a line twice when one media is genuinely placed twice", () => {- // The spans do not touch on the ruler there, so the coalescing must leave them apart.- const twice = doc({- timeline: {- ...doc().timeline,- clips: [- {- id: "clip-1",- assetId: "asset-1",- sourceStartSec: 0,- sourceEndSec: 10,- timelineStartSec: 0,- timelineEndSec: 10,- wordRefs: [],- origin: "user",- reason: "",- },- {- id: "clip-2",- assetId: "asset-1",- sourceStartSec: 0,- sourceEndSec: 10,- timelineStartSec: 20,- timelineEndSec: 30,- wordRefs: [],- origin: "user",- reason: "",- },- ],- },- });- const cues = deriveCaptionCues(twice, ON, {});- expect(cues.filter((cue) => cue.text.includes("hello"))).toHaveLength(2);- });-});diff --git a/src/lib/ai-edition/captions/cues.ts b/src/lib/ai-edition/captions/cues.tsindex 8154788a1..c3287ebcb 100644--- a/src/lib/ai-edition/captions/cues.ts+++ b/src/lib/ai-edition/captions/cues.ts@@ -161,17 +161,6 @@ export function sourceSpanToTimelineSpans(const out: Array<{ startSec: number; endSec: number }> = [];for (const clip of clips) {if (clip.assetId !== assetId) continue;- // A FREEZE clip holds one source moment for created timeline time — an inserted- // word's pause. Its source window is that single point, so the overlap test below- // can never match it, and the line the pause exists for went DARK for its whole- // duration. A line covering the held moment covers the pause too.- if (clip.frozenSec !== undefined) {- const held = clip.sourceStartSec;- if (held >= startSec && held < endSec) {- out.push({ startSec: clip.timelineStartSec, endSec: clip.timelineEndSec });- }- continue;- }const clipSourceEnd = clip.sourceEndSec ?? Number.POSITIVE_INFINITY;const s = Math.max(startSec, clip.sourceStartSec);const e = Math.min(endSec, clipSourceEnd);@@ -181,24 +170,7 @@ export function sourceSpanToTimelineSpans(endSec: clip.timelineStartSec + (e - clip.sourceStartSec),});}-- // Coalesce what meets on the ruler. Splitting a clip to make room for an inserted word- // leaves the line straddling [before · freeze · after]: three spans back to back, each- // carrying the WHOLE line's text, so the caption played, blinked out over the pause,- // then played again from the top. They are one appearance. A line genuinely played- // twice — two clips over one media — does not touch on the ruler and stays two.- const EPSILON_SEC = 0.001;- const ordered = [...out].sort((a, b) => a.startSec - b.startSec);- const merged: Array<{ startSec: number; endSec: number }> = [];- for (const span of ordered) {- const last = merged[merged.length - 1];- if (last && span.startSec <= last.endSec + EPSILON_SEC) {- last.endSec = Math.max(last.endSec, span.endSec);- continue;- }- merged.push({ ...span });- }- return merged;+ return out;}/**diff --git a/src/lib/ai-edition/document/timeline.ts b/src/lib/ai-edition/document/timeline.tsindex 43acfe40a..987e91dc2 100644--- a/src/lib/ai-edition/document/timeline.ts+++ b/src/lib/ai-edition/document/timeline.ts@@ -128,73 +128,6 @@ export function resequenceClips(clips: AxcutClip[]): AxcutClip[] {});}-/**- * Split the clip covering `atSec` (source time, `assetId`'s media) into- * [before · FREEZE · after], where the freeze holds the frame at `atSec` for- * `frozenSec` of timeline time. The pause an inserted word creates: without it the- * word only borrows free silence, and a word dropped between two words that run into- * each other has no time at all. With it the timeline grows, everything downstream- * shifts, and a future TTS voice has a slot to speak in.- *- * No clip covers `atSec` (gap between clips, boundary of the asset) → unchanged, the- * caller decides whether that is acceptable. Trims anchored to the split clip stay on- * their id; `trimAppliesToClip` matches by asset when a trim has no clipId, and both- * halves keep the asset, so a trim that straddles the freeze point still narrows both- * halves exactly as it narrowed the whole clip before.- */-export function insertFreezeInClips(- clips: AxcutClip[],- assetId: string,- atSec: number,- frozenSec: number,-): AxcutClip[] {- if (frozenSec <= 0) return clips;- const index = clips.findIndex(- (clip) =>- clip.assetId === assetId &&- (clip.frozenSec ?? 0) === 0 &&- (clip.sourceEndSec ?? -1) > atSec + 0.001 &&- atSec > clip.sourceStartSec,- );- if (index < 0) return clips;- const clip = clips[index];- // `resequenceClips` keeps each clip's OWN timeline length, so the halves must not- // inherit the un-split clip's — that would double the timeline. Lengths here are- // derived from the new source windows; resequence then only relays them.- const beforeLen = atSec - clip.sourceStartSec;- const afterLen = (clip.sourceEndSec ?? 0) - atSec;- const before: AxcutClip = {- ...clip,- id: `${clip.id}_fzA`,- sourceEndSec: atSec,- timelineEndSec: clip.timelineStartSec + beforeLen,- };- const freeze: AxcutClip = {- id: `${clip.id}_fz`,- assetId: clip.assetId,- sourceStartSec: atSec,- sourceEndSec: atSec,- timelineStartSec: 0,- timelineEndSec: frozenSec,- wordRefs: [],- origin: "user",- reason: "Inserted word — held frame",- frozenSec,- };- const after: AxcutClip | null =- afterLen > 0.001- ? {- ...clip,- id: `${clip.id}_fzB`,- sourceStartSec: atSec,- timelineStartSec: 0,- timelineEndSec: afterLen,- }- : null;- const replaced = after ? [before, freeze, after] : [before, freeze];- return resequenceClips([...clips.slice(0, index), ...replaced, ...clips.slice(index + 1)]);-}-export function subtractInterval(intervals: Interval[], cut: Interval): Interval[] {const output: Interval[] = [];for (const interval of intervals) {@@ -238,10 +171,7 @@ export function resolvePlaybackSegments(for (const clip of ordered) {const sourceEnd = clip.sourceEndSec ?? clip.sourceStartSec;if (sourceEnd <= clip.sourceStartSec) {- // Either not probed yet, or a FREEZE clip (source window is the point it- // holds; `frozenSec` carries its real length). Both pass through as one- // segment at their timeline length — for a freeze that KEEPS the created- // pause in the compressed stream, which is the whole point.+ // Duration not probed yet — pass through as a single segment, unchanged.const dur = clip.timelineEndSec - clip.timelineStartSec;result.push({...clip,diff --git a/src/lib/ai-edition/document/transcript.test.ts b/src/lib/ai-edition/document/transcript.test.tsindex 03f9e5aae..9e8ace067 100644--- a/src/lib/ai-edition/document/transcript.test.ts+++ b/src/lib/ai-edition/document/transcript.test.ts@@ -615,65 +615,6 @@ describe("insertDocumentWord / removeDocumentWords", () => {});});-describe("insertDocumentWord freeze", () => {- /** One clip covering the whole fixture recording — what the editor starts from. */- function makeDocWithClip() {- const doc = makeDoc();- return {- ...doc,- timeline: {- ...doc.timeline,- clips: [- {- id: "clip_1",- assetId: "asset_1",- sourceStartSec: 0,- sourceEndSec: 10,- timelineStartSec: 0,- timelineEndSec: 10,- wordRefs: [],- origin: "user" as const,- reason: "",- },- ],- },- };- }-- it("splits the clip and creates held-frame time when the silence is insufficient", () => {- // "really" after word_2: word_3 starts exactly where word_2 ends, so the word- // gets no silence at all and needs max(0.4, 6/15) = 0.4 s of created time.- const result = insertDocumentWord(makeDocWithClip(), "asset_1", "word_2", "after", "really");- const clips = result.timeline.clips;- expect(clips).toHaveLength(3);- expect(clips[0]).toMatchObject({ id: "clip_1_fzA", sourceStartSec: 0, sourceEndSec: 3 });- expect(clips[1]).toMatchObject({- id: "clip_1_fz",- sourceStartSec: 3,- sourceEndSec: 3,- frozenSec: 0.4,- });- expect(clips[2]).toMatchObject({ id: "clip_1_fzB", sourceStartSec: 3, sourceEndSec: 10 });- // The timeline grew by exactly the freeze, laid back-to-back.- expect(clips[1].timelineStartSec).toBe(3);- expect(clips[1].timelineEndSec).toBeCloseTo(3.4, 5);- expect(clips[2].timelineEndSec).toBeCloseTo(10.4, 5);- });-- it("does not touch the clips when free silence covers the word", () => {- // word_3 ends at 4, word_4 starts at 5: a full second of silence.- const result = insertDocumentWord(makeDocWithClip(), "asset_1", "word_3", "after", "really");- expect(result.timeline.clips).toHaveLength(1);- expect(result.timeline.clips[0].id).toBe("clip_1");- });-- it("leaves the timeline alone when no clip covers the insertion point", () => {- // makeDoc has no clips at all — the word rides the caption line, as before.- const result = insertDocumentWord(makeDoc(), "asset_1", "word_2", "after", "really");- expect(result.timeline.clips).toHaveLength(0);- });-});-describe("carryOverWordEdits with inserted words", () => {const withInsert = () => insertWord(fixture(), "word_2", "after", "really");diff --git a/src/lib/ai-edition/document/transcript.ts b/src/lib/ai-edition/document/transcript.tsindex ae626ee69..dec291474 100644--- a/src/lib/ai-edition/document/transcript.ts+++ b/src/lib/ai-edition/document/transcript.ts@@ -1,5 +1,4 @@import type { AxcutDocument, AxcutTranscript, AxcutWord } from "../schema";-import { insertFreezeInClips } from "./timeline";const CJK_EDGE = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u;const CLOSING_PUNCTUATION = /^[,.;:!?%。,、;:!?…))\]}>》」』】〕]/u;@@ -303,15 +302,7 @@ export function removeWord(transcript: AxcutTranscript, wordId: string): AxcutTr}/** {@link insertWord}, addressed by asset. Goes through `withTranscript` for the same- * reason {@link setDocumentWordText} does.- *- * When the free silence the word can borrow is shorter than the text needs to be- * read, the deficit becomes a FREEZE on the timeline (`insertFreezeInClips`): the clip- * is split at the word's edge and a held-frame clip carries the missing time. The- * timeline grows, everything downstream shifts, and the word has a real slot a- * synthesized voice will later speak in. No document-layer gate on this: it is the- * correct document semantics for an inserted word — the product decision of whether- * the gesture exists at all lives in the transcript pane (`openInsertion`). */+ * reason {@link setDocumentWordText} does. */export function insertDocumentWord(document: AxcutDocument,assetId: string,@@ -323,28 +314,7 @@ export function insertDocumentWord(if (!transcript) {throw new Error(`Cannot insert a word into asset "${assetId}": it has no transcript`);}- const next = withTranscript(document, insertWord(transcript, anchorWordId, side, text));-- // The word `insertWord` just added — the one synth id the old transcript lacked.- const inserted = next.transcripts- .find((t) => t.assetId === assetId)- ?.words.find(- (word) => word.source === "synth" && !transcript.words.some((w) => w.id === word.id),- );- if (!inserted) return next;- const deficit = readingSeconds(inserted.text) - (inserted.endSec - inserted.startSec);- if (deficit <= 0.05) return next;- // The freeze continues the word's slot: after the word for "after" (silence, then- // held frame), before it for "before" (held frame, then silence) — one contiguous- // stretch of created time the future voice occupies.- const atSec = side === "after" ? inserted.endSec : inserted.startSec;- return {- ...next,- timeline: {- ...next.timeline,- clips: insertFreezeInClips(next.timeline.clips, assetId, atSec, deficit),- },- };+ return withTranscript(document, insertWord(transcript, anchorWordId, side, text));}/** {@link removeWord}, addressed by asset and taking the whole set at once: a Backspacediff --git a/src/lib/ai-edition/schema/index.ts b/src/lib/ai-edition/schema/index.tsindex 0a6f80ab7..bbf1d6820 100644--- a/src/lib/ai-edition/schema/index.ts+++ b/src/lib/ai-edition/schema/index.ts@@ -220,14 +220,6 @@ export const clipSchema = z// that as the identity region {x:0,y:0,width:1,height:1} rather than// storing the identity explicitly, so untouched clips stay lean.cropRegion: clipCropRegionSchema.optional(),- // A FREEZE clip: holds the frame at `sourceStartSec` (source window is the- // zero-width point [sourceStartSec, sourceStartSec]) for `frozenSec` of- // TIMELINE time. The pause an inserted word creates so a future TTS voice has- // a slot to speak in — screen and webcam freeze together because both tracks- // are derived from the same asset source clock. Absent on every ordinary clip;- // `resolvePlaybackSegments`'s un-probed passthrough branch must not be confused- // with it (a frozen clip is pushed through unchanged too, see its comment).- frozenSec: z.number().positive().optional(),}).refine((data) => data.timelineEndSec >= data.timelineStartSec, {message: "timelineEndSec must be greater than or equal to timelineStartSec",diff --git a/src/lib/ai-edition/timeline/aggregated-transcript.test.ts b/src/lib/ai-edition/timeline/aggregated-transcript.test.tsindex 60f1fdea6..adc70b6cb 100644--- a/src/lib/ai-edition/timeline/aggregated-transcript.test.ts+++ b/src/lib/ai-edition/timeline/aggregated-transcript.test.ts@@ -474,94 +474,3 @@ describe("clipWordId", () => {expect(new Set(scopedIds).size).toBe(scopedIds.length);});});--// ─── Freeze clips in the pane ────────────────────────────────────-// An inserted word SPLITS the clip it lands in — [before · freeze · after] — and the word-// sits exactly on the split. Both the freeze and the half that starts there matched it, so-// the pane showed the same word twice, in two blocks.--describe("the section a freeze clip projects", () => {- const TRANSCRIPT: AxcutTranscript = {- assetId: "a1",- language: "fr",- segments: [- { id: "s1", kind: "speech", startSec: 0, endSec: 4, text: "un deux", wordIds: ["w1", "w2"] },- ],- words: [- { id: "w1", segmentId: "s1", startSec: 0, endSec: 2, text: "un" },- { id: "w2", segmentId: "s1", startSec: 2, endSec: 4, text: "deux" },- { id: "synth_1", segmentId: "s1", startSec: 2, endSec: 2, text: "vraiment", source: "synth" },- ],- };- const ASSET: AxcutAsset = {- id: "a1",- kind: "video",- label: "rec.mp4",- originalPath: "/r.mp4",- durationSec: 4,- cameraTrack: null,- };- const CLIPS: AxcutClip[] = [- {- id: "c_fzA",- assetId: "a1",- sourceStartSec: 0,- sourceEndSec: 2,- timelineStartSec: 0,- timelineEndSec: 2,- wordRefs: [],- origin: "user",- reason: "",- },- {- id: "c_fz",- assetId: "a1",- sourceStartSec: 2,- sourceEndSec: 2,- timelineStartSec: 2,- timelineEndSec: 2.5,- wordRefs: [],- origin: "user",- reason: "",- frozenSec: 0.5,- },- {- id: "c_fzB",- assetId: "a1",- sourceStartSec: 2,- sourceEndSec: 4,- timelineStartSec: 2.5,- timelineEndSec: 4.5,- wordRefs: [],- origin: "user",- reason: "",- },- ];-- it("shows the inserted word the freeze exists for", () => {- const sections = buildAggregatedSections(CLIPS, [TRANSCRIPT], [ASSET], []);- expect(sections[1].words.map((cw) => cw.word.text)).toEqual(["vraiment"]);- });-- it("shows it exactly once across the whole pane", () => {- const sections = buildAggregatedSections(CLIPS, [TRANSCRIPT], [ASSET], []);- const everywhere = sections.flatMap((section) =>- section.words.filter((cw) => cw.word.id === "synth_1"),- );- expect(everywhere).toHaveLength(1);- });-- it("leaves the spoken words where they were", () => {- const sections = buildAggregatedSections(CLIPS, [TRANSCRIPT], [ASSET], []);- expect(sections[0].words.map((cw) => cw.word.text)).toEqual(["un"]);- expect(sections[2].words.map((cw) => cw.word.text)).toEqual(["deux"]);- });-- // The claim is scoped to freezes: with no freeze in the timeline, a word with no- // duration is shown by whichever clip its moment falls in, as before.- it("does not withhold an inserted word when no freeze claims it", () => {- const whole: AxcutClip[] = [{ ...CLIPS[0], id: "c1", sourceEndSec: 4, timelineEndSec: 4 }];- const sections = buildAggregatedSections(whole, [TRANSCRIPT], [ASSET], []);- expect(sections[0].words.map((cw) => cw.word.text)).toContain("vraiment");- });-});diff --git a/src/lib/ai-edition/timeline/aggregated-transcript.ts b/src/lib/ai-edition/timeline/aggregated-transcript.tsindex d008867ad..9b59f2bd6 100644--- a/src/lib/ai-edition/timeline/aggregated-transcript.ts+++ b/src/lib/ai-edition/timeline/aggregated-transcript.ts@@ -197,32 +197,6 @@ export function buildClipSection(asset: AxcutAsset | null,trimRanges: AxcutTrimRange[],): ClipSection {- // A FREEZE clip is the created time behind an inserted word: its source window is- // the single point it holds, so the ordinary range filter matches nothing — and it- // must not. The words it shows are the SYNTH words touching that point: the word- // the freeze exists for. While the playhead runs through the freeze the cue- // resolves against this section and lights the amber word through the whole pause.- if (clip.frozenSec !== undefined) {- const atSec = clip.sourceStartSec;- const words = transcript- ? transcript.words.filter(- (word) => word.source === "synth" && word.startSec <= atSec && word.endSec >= atSec,- )- : [];- return {- clip,- asset,- transcript,- words: words.map((word) => ({- id: clipWordId(clip.id, word.id),- word,- kept: true,- trimId: null,- })),- trimRuns: [],- };- }-// `trimAppliesToClip` — not a bare `assetId` match — is what keeps a cut on the// second of two clips over the same media from also greying out the first one's// words. Same media, same source range: only the clip anchor tells them apart.@@ -307,7 +281,7 @@ export function buildAggregatedSections(): ClipSection[] {const transcriptById = new Map(transcripts.map((t) => [t.assetId, t]));const assetById = new Map(assets.map((a) => [a.id, a]));- const sections = clips.map((clip) =>+ return clips.map((clip) =>buildClipSection(clip,transcriptById.get(clip.assetId) ?? null,@@ -315,23 +289,6 @@ export function buildAggregatedSections(trimRanges,),);-- // A freeze clip claims the inserted word it was created for, and the clip after the- // split starts at the very moment that word sits on — so the word matched BOTH and the- // pane showed it twice, in two blocks. The freeze owns it: it is the section the- // playhead is inside while the pause plays, and the one whose whole reason to exist is- // that word.- const claimed = new Set(- sections- .filter((section) => section.clip.frozenSec !== undefined)- .flatMap((section) => section.words.map((cw) => cw.word.id)),- );- if (claimed.size === 0) return sections;- return sections.map((section) =>- section.clip.frozenSec !== undefined- ? section- : { ...section, words: section.words.filter((cw) => !claimed.has(cw.word.id)) },- );}/**diff --git a/src/lib/ai-edition/timeline/timelineMap.test.ts b/src/lib/ai-edition/timeline/timelineMap.test.tsindex ecc81a2d0..ea3f6c61b 100644--- a/src/lib/ai-edition/timeline/timelineMap.test.ts+++ b/src/lib/ai-edition/timeline/timelineMap.test.ts@@ -17,7 +17,6 @@ import {replacePillSpan,resolveNativePosition,resolvePillIds,- segmentRawSpanSec,} from "./timelineMap";function clip(overrides: Partial<AxcutClip> & Pick<AxcutClip, "id" | "assetId">): AxcutClip {@@ -806,63 +805,3 @@ describe("legacy groupId must never affect identity (regression: test 1)", () =>expect(out[0]).not.toHaveProperty("groupId");});});--// ─── Freeze clips ────────────────────────────────────────────────-// The pause an inserted word creates. Its source window is the single point it holds, so-// every reader that derives a length from `sourceEndSec - sourceStartSec` gets zero for it-// — and zero is the one answer that makes the playhead skip the pause entirely.--describe("a freeze clip", () => {- const clips = [- clip({ id: "a", assetId: "m", sourceStartSec: 0, sourceEndSec: 3 }),- clip({- id: "fz",- assetId: "m",- sourceStartSec: 3,- sourceEndSec: 3,- timelineStartSec: 3,- timelineEndSec: 3.5,- frozenSec: 0.5,- }),- clip({- id: "b",- assetId: "m",- sourceStartSec: 3,- sourceEndSec: 6,- timelineStartSec: 3.5,- timelineEndSec: 6.5,- }),- ];-- it("keeps its created time in the playback segments", () => {- // It carries no source range to compress, so a naive reader drops it and the pause- // vanishes from playback while the ruler still counts it.- const segments = resolvePlaybackSegments(clips, []);- const freeze = segments.find((segment) => segment.id === "fz");- expect(freeze).toBeDefined();- expect((freeze?.timelineEndSec ?? 0) - (freeze?.timelineStartSec ?? 0)).toBeCloseTo(0.5, 5);- });-- it("spans its frozen time on the raw ruler, not its (zero) source length", () => {- const span = segmentRawSpanSec(clips[1], clips);- expect(span.endSec - span.startSec).toBeCloseTo(0.5, 5);- });-- it("holds the source clock still while the playhead runs through it", () => {- // The raw playhead DOES advance through the pause. Letting that delta reach the- // decoder would push it past the held frame into the content that belongs after.- const segments = resolvePlaybackSegments(clips, []);- for (const rawSec of [3.05, 3.25, 3.45]) {- const position = resolveNativePosition(rawSec, segments, clips);- expect(position?.clip.id).toBe("fz");- expect(position?.sourceTimeSec).toBe(3);- }- });-- it("hands the clip after the pause its own source moment again", () => {- const segments = resolvePlaybackSegments(clips, []);- const position = resolveNativePosition(4, segments, clips);- expect(position?.clip.id).toBe("b");- expect(position?.sourceTimeSec).toBeCloseTo(3.5, 5);- });-});diff --git a/src/lib/ai-edition/timeline/timelineMap.ts b/src/lib/ai-edition/timeline/timelineMap.tsindex 081ede4d7..b98601a03 100644--- a/src/lib/ai-edition/timeline/timelineMap.ts+++ b/src/lib/ai-edition/timeline/timelineMap.ts@@ -403,13 +403,7 @@ export function segmentRawSpanSec(rawClips: AxcutClip[],): { startSec: number; endSec: number } {const startSec = getRawVirtualStartTime(segment, rawClips);- // A freeze clip's source window is the point it holds — its RAW span is its created- // timeline time, not the (zero) source length, or the playhead could never be- // "inside" it and would skip the pause entirely.- const lenSec =- segment.frozenSec !== undefined- ? segment.frozenSec- : (segment.sourceEndSec ?? segment.sourceStartSec) - segment.sourceStartSec;+ const lenSec = (segment.sourceEndSec ?? segment.sourceStartSec) - segment.sourceStartSec;return { startSec, endSec: startSec + lenSec };}@@ -696,20 +690,6 @@ export function resolveNativePosition(const seg = visibleSegments[index];const segSourceEnd = seg.sourceEndSec ?? seg.sourceStartSec;- // Inside a freeze: the source clock does not advance. The whole point of the clip- // is created timeline time over one held frame — clamp the offset to zero rather- // than letting the raw-playhead delta (which DOES advance through the freeze) push- // the decoder past the held frame into content that belongs after the pause.- if (seg.frozenSec !== undefined) {- return {- clip: seg,- clipIndex: index,- sourceTimeSec: seg.sourceStartSec,- };- }- // No `clampToSegmentStart` any more: this branch used to snap the playhead to the- // next kept segment, and main now returns `positionUnderCut` before reaching here- // (issue #216), so the flag could never be true.const unclamped = seg.sourceStartSec + (rawSec - spans[index].startSec);const maxSource = Math.max(seg.sourceStartSec, segSourceEnd - NATIVE_EOF_MARGIN_SEC);return {diff --git a/src/native/useNativePlaybackSync.ts b/src/native/useNativePlaybackSync.tsindex abe2f1c1a..64e877b63 100644--- a/src/native/useNativePlaybackSync.ts+++ b/src/native/useNativePlaybackSync.ts@@ -41,13 +41,6 @@ export function useNativePlaybackSync();const activeClipId = activePosition?.clip.id ?? null;const sourceTimeSec = activePosition?.sourceTimeSec ?? null;- // A freeze clip holds ONE frame for `frozenSec` of app-clock time. Free-running the- // decoder through it would play the frames after the pause instead; the app clock- // (which does traverse the freeze) then re-seeks on drift and stutters. Pausing the- // decoder for the duration of the freeze is what makes the pause a pause — the- // webcam track freezes with the screen track because both derive from the same- // asset source clock the freeze stops advancing.- const frozen = activePosition?.clip.frozenSec !== undefined;// Reactive "is a native view active?" so activation mid-session re-pushes the// current transport/playhead (time & playing aren't memoised in the store).@@ -56,15 +49,13 @@ export function useNativePlaybackSync(() => getCurrentNativeViewId() !== null,);- // Play/pause → native free-run. Inside a freeze the native side is PAUSED however- // the transport is set — the app clock advances through the created time while the- // decoder holds the frame.+ // Play/pause → native free-run.useEffect(() => {if (!active) {return;}- setNativePlaying(playing && !frozen);- }, [active, playing, frozen]);+ setNativePlaying(playing);+ }, [active, playing]);// Scrub/step while paused OR periodic resync during playback when drift > 100msconst lastSyncedSourceTimeRef = useRef<number | null>(null);@@ -77,17 +68,6 @@ export function useNativePlaybackSync(}const now = performance.now();- // Inside a freeze while playing: the decoder is paused (see the transport- // effect) and parked on the held frame. Refresh the drift refs every run so the- // drift check never sees the (correctly) frozen source clock as divergence and- // fights itself with repeated seeks.- if (playing && frozen) {- setNativeTime(sourceTimeSec);- lastSyncedSourceTimeRef.current = sourceTimeSec;- lastSyncedWallTimeRef.current = now;- return;- }-// When clip changes, let setActiveClip handle the atomic clip-switch-and-seek.if (lastActiveClipIdRef.current !== activeClipId) {lastActiveClipIdRef.current = activeClipId;@@ -115,5 +95,5 @@ export function useNativePlaybackSync(lastSyncedSourceTimeRef.current = sourceTimeSec;lastSyncedWallTimeRef.current = now;}- }, [active, playing, frozen, activeClipId, sourceTimeSec]);+ }, [active, playing, activeClipId, sourceTimeSec]);}