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
feat(timeline): widen Clear zooms into Clear timeline
EtienneLescote46850bd27a3
diff --git a/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx b/src/components/ai-edition/v4/V4Timeline.geometry.test.tsxindex 3589029a5..d6d3345e5 100644--- a/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx+++ b/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx@@ -86,13 +86,22 @@ function clip(startSec: number, endSec: number) {* which is what the Full Camera button is gated on. */const NO_CAMERA_ASSET = { id: "a1", label: "rec", durationSec: TOTAL_SEC };-/** By default one 30-minute clip carrying a single one-second annotation. */+/** The five edit lanes, by the `tl` member that feeds each. */+type EditLanes = Partial<+ Record<+ "annotationRegions" | "speedRegions" | "cameraFullscreenRegions" | "zoomRegions" | "trimRanges",+ Array<Record<string, unknown>>+ >+>;++/** By default one 30-minute clip carrying a single one-second annotation; `lanes` replaces+ * what any of the five edit lanes holds (an empty `annotationRegions` clears the default). */function renderTimeline(clips = [clip(0, TOTAL_SEC)],annotation = { id: "ann1", startMs: 10_000, endMs: 11_000 },assets: Array<Record<string, unknown>> = [NO_CAMERA_ASSET],onRender?: ProfilerOnRenderCallback,- zoomRegions: Array<Record<string, unknown>> = [],+ lanes: EditLanes = {},) {const tl = {clips,@@ -103,8 +112,9 @@ function renderTimeline(annotationRegions: [annotation],speedRegions: [],cameraFullscreenRegions: [],- zoomRegions,+ zoomRegions: [],trimRanges: [],+ ...lanes,selection: null,multiSelection: [],clipSelection: null,@@ -120,7 +130,7 @@ function renderTimeline(addZoom: vi.fn(async () => {/* the toolbar only awaits it */}),- clearZooms: vi.fn(async () => {+ clearTimeline: vi.fn(async () => {/* the toolbar only awaits it */}),};@@ -149,7 +159,11 @@ function renderTimeline(),);return {- pill: screen.getByTitle("toolbar.newAnnotation"),+ // A getter: a test that empties `annotationRegions` renders no such pill, and an eager+ // lookup would throw before its own assertions ran.+ get pill() {+ return screen.getByTitle("toolbar.newAnnotation");+ },clipEls: Array.from(document.querySelectorAll<HTMLElement>("[data-clip-id]")),tl,setCurrentTime,@@ -407,19 +421,30 @@ describe("V4Timeline create-from-toolbar", () => {expect(durationOf(tl)).toBeCloseTo(0.25, 3);});- // Clear zooms (#723) exists only while there is something to clear: absent, never greyed out.- it("shows no Clear zooms button while the project has no zoom", () => {- renderTimeline();- expect(screen.queryByLabelText("buttons.clearZooms")).not.toBeInTheDocument();+ // Clear timeline (#723) exists only while one of the five edit lanes holds a region:+ // absent, never greyed out.+ const REGION_IN_LANE: Record<keyof EditLanes, Record<string, unknown>> = {+ annotationRegions: { id: "r1", startMs: 1000, endMs: 3000 },+ zoomRegions: { id: "r1", startMs: 1000, endMs: 3000, depth: 3 },+ speedRegions: { id: "r1", startMs: 1000, endMs: 3000, speed: 1.5 },+ cameraFullscreenRegions: { id: "r1", startMs: 1000, endMs: 3000 },+ trimRanges: { id: "r1", assetId: "a1", clipId: "c@0", startSec: 1, endSec: 3 },+ };++ it("shows no Clear timeline button while every edit lane is empty", () => {+ renderTimeline(undefined, undefined, undefined, undefined, { annotationRegions: [] });+ expect(screen.queryByLabelText("buttons.clearTimeline")).not.toBeInTheDocument();});- it("shows Clear zooms once a zoom exists, and one click asks the store to clear them all", () => {- const { tl } = renderTimeline(undefined, undefined, undefined, undefined, [- { id: "z1", startMs: 1000, endMs: 3000, depth: 3 },- { id: "z2", startMs: 9000, endMs: 11_000, depth: 3 },- ]);- fireEvent.click(screen.getByLabelText("buttons.clearZooms"));- expect(tl.clearZooms).toHaveBeenCalledTimes(1);+ it.each(+ Object.keys(REGION_IN_LANE) as Array<keyof EditLanes>,+ )("shows Clear timeline for a %s region alone, and one click asks the store to clear", (lane) => {+ const { tl } = renderTimeline(undefined, undefined, undefined, undefined, {+ annotationRegions: [],+ [lane]: [REGION_IN_LANE[lane]],+ });+ fireEvent.click(screen.getByLabelText("buttons.clearTimeline"));+ expect(tl.clearTimeline).toHaveBeenCalledTimes(1);});// #353. A camera-fullscreen region grows the webcam overlay, so with no webcam on the@@ -660,6 +685,11 @@ describe("V4Timeline audio lane drag", () => {// 900px / 1800s = 0.5 px per second, so +90px is +180s.const secForPx = (px: number) => (px / VIEWPORT_PX) * TOTAL_SEC;+ it("does not offer Clear timeline for an audio track alone: it is content, not an edit", () => {+ renderAudio();+ expect(screen.queryByLabelText("buttons.clearTimeline")).not.toBeInTheDocument();+ });+it("offers both audio paths behind one toolbar button", () => {// A mic and a music note side by side both just said "audio"; one button// with a named menu is what tells a first-time user the two paths apart.diff --git a/src/components/ai-edition/v4/V4Timeline.tsx b/src/components/ai-edition/v4/V4Timeline.tsxindex b02a366cd..20bbf87db 100644--- a/src/components/ai-edition/v4/V4Timeline.tsx+++ b/src/components/ai-edition/v4/V4Timeline.tsx@@ -2,6 +2,7 @@ import {AudioLines,Clock,Crosshair,+ Eraser,Loader2,Maximize2,MessageSquare,@@ -786,6 +787,16 @@ export function V4Timeline({sourceIds: g.ids,}));+ // "Clear timeline" is there while any of the five edit lanes holds a pill, and only then.+ // The audio lane is not one of them: a track is content the user added, and it stays.+ const hasEditRegions =+ annPills.length ++ speedPills.length ++ trimPills.length ++ zoomPills.length ++ cameraFullscreenPills.length >+ 0;+// Ruler ticks are chosen from what is actually ON SCREEN, not from the clip// length: the canvas is widened by 1/navSpan, so the same recording shows one// label per 30s zoomed out and one per tenth of a second zoomed in. The step@@ -1987,16 +1998,16 @@ export function V4Timeline({</button></Tooltip>{/* Absent, not greyed out, when there is nothing to clear. One write in the- store, so one Ctrl+Z restores every zoom. */}- {tl.zoomRegions.length > 0 ? (- <Tooltip content={t("buttons.clearZooms")}>+ store, so one Ctrl+Z restores every region. */}+ {hasEditRegions ? (+ <Tooltip content={t("buttons.clearTimeline")}><buttontype="button"className={styles.tlToolBtn}- aria-label={t("buttons.clearZooms")}- onClick={() => void tl.clearZooms()}+ aria-label={t("buttons.clearTimeline")}+ onClick={() => void tl.clearTimeline()}>- <Trash2 size={16} />+ <Eraser size={16} /></button></Tooltip>) : null}diff --git a/src/i18n/locales/ar/timeline.json b/src/i18n/locales/ar/timeline.jsonindex 391d5f602..4b63494c3 100644--- a/src/i18n/locales/ar/timeline.json+++ b/src/i18n/locales/ar/timeline.json@@ -6,7 +6,7 @@"autoZoomOff": "اقتراحات التكبير التلقائي معطّلة — انقر لاقتراح تكبيرات من المؤشر","autoFocusAllOn": "التركيز التلقائي مفعّل لجميع التكبيرات — انقر للتبديل إلى يدوي للجميع","autoFocusAllOff": "تفعيل التركيز التلقائي لجميع التكبيرات (الكاميرا تتبع المؤشر)",- "clearZooms": "مسح التكبيرات",+ "clearTimeline": "مسح المخطط الزمني","addTrim": "إضافة قص (T)","addAnnotation": "إضافة شرح (A)","addSpeed": "إضافة سرعة (S)",diff --git a/src/i18n/locales/cs/timeline.json b/src/i18n/locales/cs/timeline.jsonindex ec4869b27..0a08fa905 100644--- a/src/i18n/locales/cs/timeline.json+++ b/src/i18n/locales/cs/timeline.json@@ -6,7 +6,7 @@"autoZoomOff": "Automatické návrhy přiblížení vypnuty, klikněte pro návrh přiblížení podle kurzoru","autoFocusAllOn": "Automatické zaostření zapnuto pro všechna přiblížení, klikněte pro přepnutí všech na ruční","autoFocusAllOff": "Automaticky zaostřit všechna přiblížení (kamera sleduje kurzor)",- "clearZooms": "Vymazat přiblížení",+ "clearTimeline": "Vymazat časovou osu","addTrim": "Přidat oříznutí (T)","addAnnotation": "Přidat anotaci (A)","addSpeed": "Přidat rychlost (S)",diff --git a/src/i18n/locales/de/timeline.json b/src/i18n/locales/de/timeline.jsonindex b13cec5b7..51fd44c81 100644--- a/src/i18n/locales/de/timeline.json+++ b/src/i18n/locales/de/timeline.json@@ -6,7 +6,7 @@"autoZoomOff": "Zoom-Vorschläge aus — klicken, um Zooms aus der Cursorbewegung vorzuschlagen","autoFocusAllOn": "Auto-Fokus für alle Zooms an — klicken, um alle auf manuell umzustellen","autoFocusAllOff": "Auto-Fokus für alle Zooms (Kamera folgt dem Cursor)",- "clearZooms": "Zooms löschen",+ "clearTimeline": "Timeline leeren","addTrim": "Trim hinzufügen (T)","addAnnotation": "Anmerkung hinzufügen (A)","addSpeed": "Tempo hinzufügen (S)",diff --git a/src/i18n/locales/en/timeline.json b/src/i18n/locales/en/timeline.jsonindex 76cce42f4..a1ed0c963 100644--- a/src/i18n/locales/en/timeline.json+++ b/src/i18n/locales/en/timeline.json@@ -6,7 +6,7 @@"autoZoomOff": "Auto zoom suggestions off — click to suggest zooms from cursor","autoFocusAllOn": "Auto-Focus on for all zooms — click to switch all to manual","autoFocusAllOff": "Auto-Focus all zooms (camera follows the cursor)",- "clearZooms": "Clear zooms",+ "clearTimeline": "Clear timeline","addTrim": "Add trim (T)","addAnnotation": "Add annotation (A)","addSpeed": "Add speed (S)",diff --git a/src/i18n/locales/es/timeline.json b/src/i18n/locales/es/timeline.jsonindex 7ed5d92e1..fbc674fa9 100644--- a/src/i18n/locales/es/timeline.json+++ b/src/i18n/locales/es/timeline.json@@ -6,7 +6,7 @@"autoZoomOff": "Sugerencias de zoom automático desactivadas — haz clic para sugerir zooms desde el cursor","autoFocusAllOn": "Enfoque automático activado para todos los zooms — haz clic para pasar todos a manual","autoFocusAllOff": "Activar enfoque automático para todos los zooms (la cámara sigue el cursor)",- "clearZooms": "Borrar zooms",+ "clearTimeline": "Borrar la línea de tiempo","addTrim": "Agregar recorte (T)","addAnnotation": "Agregar anotación (A)","addSpeed": "Agregar velocidad (S)",diff --git a/src/i18n/locales/fr/timeline.json b/src/i18n/locales/fr/timeline.jsonindex 9fdf817a1..a872f5788 100644--- a/src/i18n/locales/fr/timeline.json+++ b/src/i18n/locales/fr/timeline.json@@ -6,7 +6,7 @@"autoZoomOff": "Suggestions de zoom automatique désactivées — cliquez pour suggérer des zooms depuis le curseur","autoFocusAllOn": "Mise au point automatique activée pour tous les zooms — cliquez pour tout passer en manuel","autoFocusAllOff": "Activer la mise au point automatique pour tous les zooms (la caméra suit le curseur)",- "clearZooms": "Effacer les zooms",+ "clearTimeline": "Effacer la timeline","addTrim": "Ajouter une coupe (T)","addAnnotation": "Ajouter une annotation (A)","addSpeed": "Ajouter une vitesse (S)",diff --git a/src/i18n/locales/it/timeline.json b/src/i18n/locales/it/timeline.jsonindex c98f4038c..a74b782b7 100644--- a/src/i18n/locales/it/timeline.json+++ b/src/i18n/locales/it/timeline.json@@ -6,7 +6,7 @@"autoZoomOff": "Suggerimenti di zoom automatico disattivi — clicca per suggerire zoom dal cursore","autoFocusAllOn": "Messa a fuoco automatica attiva per tutti gli zoom — clicca per passare tutti a manuale","autoFocusAllOff": "Attiva la messa a fuoco automatica per tutti gli zoom (la fotocamera segue il cursore)",- "clearZooms": "Cancella zoom",+ "clearTimeline": "Cancella la timeline","addTrim": "Aggiungi taglio (T)","addAnnotation": "Aggiungi annotazione (A)","addSpeed": "Aggiungi velocità (S)",diff --git a/src/i18n/locales/ja-JP/timeline.json b/src/i18n/locales/ja-JP/timeline.jsonindex a7debcfbe..6797f05e4 100644--- a/src/i18n/locales/ja-JP/timeline.json+++ b/src/i18n/locales/ja-JP/timeline.json@@ -6,7 +6,7 @@"autoZoomOff": "自動ズーム提案がオフ — クリックするとカーソル位置からズームを提案します","autoFocusAllOn": "すべてのズームでオートフォーカスがオン — クリックするとすべて手動に切り替わります","autoFocusAllOff": "すべてのズームでオートフォーカスをオンにする(カメラがカーソルに追従)",- "clearZooms": "ズームをクリア",+ "clearTimeline": "タイムラインをクリア","addTrim": "トリムを追加 (T)","addAnnotation": "注釈を追加 (A)","addSpeed": "再生速度を追加 (S)",diff --git a/src/i18n/locales/ko-KR/timeline.json b/src/i18n/locales/ko-KR/timeline.jsonindex a601f888e..1eddfe7df 100644--- a/src/i18n/locales/ko-KR/timeline.json+++ b/src/i18n/locales/ko-KR/timeline.json@@ -6,7 +6,7 @@"autoZoomOff": "자동 줌 제안 꺼짐 — 클릭하면 커서 기반으로 줌을 제안합니다","autoFocusAllOn": "모든 줌에 자동 초점 켜짐 — 클릭하면 모두 수동으로 전환합니다","autoFocusAllOff": "모든 줌에 자동 초점 켜기 (카메라가 커서를 따라갑니다)",- "clearZooms": "줌 지우기",+ "clearTimeline": "타임라인 지우기","addTrim": "트림 추가 (T)","addAnnotation": "주석 추가 (A)","addSpeed": "속도 추가 (S)",diff --git a/src/i18n/locales/pt-BR/timeline.json b/src/i18n/locales/pt-BR/timeline.jsonindex 739bf30d4..3ed3d8d1b 100644--- a/src/i18n/locales/pt-BR/timeline.json+++ b/src/i18n/locales/pt-BR/timeline.json@@ -6,7 +6,7 @@"autoZoomOff": "Sugestões de zoom automático desativadas — clique para sugerir zooms a partir do cursor","autoFocusAllOn": "Foco automático ativado para todos os zooms — clique para mudar todos para manual","autoFocusAllOff": "Ativar foco automático para todos os zooms (a câmera segue o cursor)",- "clearZooms": "Limpar zooms",+ "clearTimeline": "Limpar a linha do tempo","addTrim": "Adicionar Recorte (T)","addAnnotation": "Adicionar Anotação (A)","addSpeed": "Adicionar Velocidade (S)",diff --git a/src/i18n/locales/ru/timeline.json b/src/i18n/locales/ru/timeline.jsonindex 404fad1c1..59ddff515 100644--- a/src/i18n/locales/ru/timeline.json+++ b/src/i18n/locales/ru/timeline.json@@ -6,7 +6,7 @@"autoZoomOff": "Автоматические предложения масштабирования выключены — нажмите, чтобы предложить зумы по курсору","autoFocusAllOn": "Автофокус включён для всех зумов — нажмите, чтобы переключить все в ручной режим","autoFocusAllOff": "Включить автофокус для всех зумов (камера следует за курсором)",- "clearZooms": "Очистить зумы",+ "clearTimeline": "Очистить таймлайн","addTrim": "Добавить обрезку (T)","addAnnotation": "Добавить аннотацию (A)","addSpeed": "Изменить скорость (S)",diff --git a/src/i18n/locales/tr/timeline.json b/src/i18n/locales/tr/timeline.jsonindex dfdfc1229..40c8b402f 100644--- a/src/i18n/locales/tr/timeline.json+++ b/src/i18n/locales/tr/timeline.json@@ -6,7 +6,7 @@"autoZoomOff": "Otomatik yakınlaştırma önerileri kapalı — imleçten yakınlaştırma önermek için tıklayın","autoFocusAllOn": "Tüm yakınlaştırmalarda Otomatik Odak açık — hepsini manuel yapmak için tıklayın","autoFocusAllOff": "Tüm yakınlaştırmalarda Otomatik Odağı aç (kamera imleci takip eder)",- "clearZooms": "Yakınlaştırmaları Temizle",+ "clearTimeline": "Zaman çizelgesini temizle","addTrim": "Kırpma Ekle (T)","addAnnotation": "Açıklama Ekle (A)","addSpeed": "Hız Ekle (S)",diff --git a/src/i18n/locales/vi/timeline.json b/src/i18n/locales/vi/timeline.jsonindex eeb85ea5d..6602ce939 100644--- a/src/i18n/locales/vi/timeline.json+++ b/src/i18n/locales/vi/timeline.json@@ -6,7 +6,7 @@"autoZoomOff": "Đề xuất thu phóng tự động đang tắt — nhấp để đề xuất thu phóng từ con trỏ","autoFocusAllOn": "Lấy nét tự động đang bật cho tất cả các thu phóng — nhấp để chuyển tất cả sang thủ công","autoFocusAllOff": "Bật lấy nét tự động cho tất cả các thu phóng (máy ảnh theo dõi con trỏ)",- "clearZooms": "Xóa thu phóng",+ "clearTimeline": "Xóa dòng thời gian","addTrim": "Thêm Cắt (T)","addAnnotation": "Thêm Chú thích (A)","addSpeed": "Thêm Tốc độ (S)",diff --git a/src/i18n/locales/zh-CN/timeline.json b/src/i18n/locales/zh-CN/timeline.jsonindex 4bb4a8ac1..3182dba9f 100644--- a/src/i18n/locales/zh-CN/timeline.json+++ b/src/i18n/locales/zh-CN/timeline.json@@ -6,7 +6,7 @@"autoZoomOff": "自动缩放建议已关闭 — 点击可根据光标建议缩放","autoFocusAllOn": "所有缩放的自动对焦已开启 — 点击可将全部切换为手动","autoFocusAllOff": "为所有缩放开启自动对焦(摄像头跟随光标)",- "clearZooms": "清除缩放",+ "clearTimeline": "清除时间轴","addTrim": "添加剪辑 (T)","addAnnotation": "添加标注 (A)","addSpeed": "添加速度 (S)",diff --git a/src/i18n/locales/zh-TW/timeline.json b/src/i18n/locales/zh-TW/timeline.jsonindex 16eae1ee9..5414690a4 100644--- a/src/i18n/locales/zh-TW/timeline.json+++ b/src/i18n/locales/zh-TW/timeline.json@@ -6,7 +6,7 @@"autoZoomOff": "自動縮放建議已關閉 — 點擊可根據游標建議縮放","autoFocusAllOn": "所有縮放的自動對焦已開啟 — 點擊可將全部切換為手動","autoFocusAllOff": "為所有縮放開啟自動對焦(攝影機跟隨游標)",- "clearZooms": "清除縮放",+ "clearTimeline": "清除時間軸","addTrim": "新增剪輯 (T)","addAnnotation": "新增標註 (A)","addSpeed": "新增速度 (S)",diff --git a/src/lib/ai-edition/document/timeline.ts b/src/lib/ai-edition/document/timeline.tsindex aebf57fca..12fe026e1 100644--- a/src/lib/ai-edition/document/timeline.ts+++ b/src/lib/ai-edition/document/timeline.ts@@ -1129,6 +1129,53 @@ export function removeRegion(document: AxcutDocument, kind: RegionKind, id: stri}}+const legacyRegionCount = (document: AxcutDocument, key: string): number => {+ const stored = (document.legacyEditor as Record<string, unknown> | null)?.[key];+ return Array.isArray(stored) ? stored.length : 0;+};+const withLegacyRegionsCleared = (document: AxcutDocument, key: string): AxcutDocument =>+ document.legacyEditor+ ? { ...document, legacyEditor: { ...document.legacyEditor, [key]: [] } }+ : document;++/**+ * The edit regions "Clear timeline" empties: one entry per `RegionKind` but `audio`. A Record+ * rather than a list, so a new kind is a compile error here until someone decides whether it+ * is an edit. `audio` is deliberately absent, like everything that is not a region at all:+ * clips, media, transcripts, captions and the pauses added words made are content the user+ * put there on purpose. (`timeline.speedRanges` is not the speed lane's store; the lane and+ * the export read `legacyEditor.speedRegions`.)+ */+const EDIT_REGIONS: Record<+ Exclude<RegionKind, "audio">,+ { count: (d: AxcutDocument) => number; clear: (d: AxcutDocument) => AxcutDocument }+> = {+ zoom: { count: (d) => d.zoomRanges.length, clear: (d) => ({ ...d, zoomRanges: [] }) },+ annotation: { count: (d) => d.annotations.length, clear: (d) => ({ ...d, annotations: [] }) },+ trim: {+ count: (d) => d.timeline.trimRanges.length,+ clear: (d) => ({ ...d, timeline: { ...d.timeline, trimRanges: [] } }),+ },+ speed: {+ count: (d) => legacyRegionCount(d, "speedRegions"),+ clear: (d) => withLegacyRegionsCleared(d, "speedRegions"),+ },+ cameraFullscreen: {+ count: (d) => legacyRegionCount(d, "cameraFullscreenRegions"),+ clear: (d) => withLegacyRegionsCleared(d, "cameraFullscreenRegions"),+ },+};++/** How many edit regions the document holds, stored rows and not pills. Pure. */+export function countEditRegions(document: AxcutDocument): number {+ return Object.values(EDIT_REGIONS).reduce((sum, kind) => sum + kind.count(document), 0);+}++/** The document with every edit region gone (see {@link EDIT_REGIONS}). Pure. */+export function clearEditRegions(document: AxcutDocument): AxcutDocument {+ return Object.values(EDIT_REGIONS).reduce((doc, kind) => kind.clear(doc), document);+}+/*** The document, with its clip list changed to this one.*diff --git a/src/lib/ai-edition/store/documentWriteAudit.test.ts b/src/lib/ai-edition/store/documentWriteAudit.test.tsindex c0f3ac84b..82268bc82 100644--- a/src/lib/ai-edition/store/documentWriteAudit.test.ts+++ b/src/lib/ai-edition/store/documentWriteAudit.test.ts@@ -254,8 +254,8 @@ const DECLARED: WritePath[] = [w("src/lib/ai-edition/store/useTimeline.ts", "addTrim", "save", "gesture"),w("src/lib/ai-edition/store/useTimeline.ts", "addZoom", "save", "gesture"),w("src/lib/ai-edition/store/useTimeline.ts", "addZoomsBulk", "save", "gesture"),- // The Clear zooms button: every zoom in one write, so one undo step.- w("src/lib/ai-edition/store/useTimeline.ts", "clearZooms", "save", "gesture"),+ // The Clear timeline button: every edit region in one write, so one undo step.+ w("src/lib/ai-edition/store/useTimeline.ts", "clearTimeline", "save", "gesture"),// The two drag commits. One undo step per gesture, recorded on release and only// if the write lands — `historyBase` carries the pre-drag document.w("src/lib/ai-edition/store/useTimeline.ts", "commitAnnotationChange", "save", "gesture"),diff --git a/src/lib/ai-edition/store/useTimeline.test.ts b/src/lib/ai-edition/store/useTimeline.test.tsindex 74e5de7b8..6b3ac5302 100644--- a/src/lib/ai-edition/store/useTimeline.test.ts+++ b/src/lib/ai-edition/store/useTimeline.test.ts@@ -3,6 +3,7 @@ import { act, renderHook, waitFor } from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { I18nProvider } from "@/contexts/I18nContext";import { DEFAULT_TEXT_PLATE } from "../annotations/background";+import { type RegionKind, readSpeedRegions } from "../document/timeline";import type { AxcutDocument } from "../schema";import { axcutSchemaVersion } from "../schema";import { useProjectStore } from "./projectStore";@@ -734,39 +735,104 @@ describe("useTimeline.addAnnotation", () => {});});-// The Clear zooms button. Zooms only, every clip, one write.-describe("useTimeline.clearZooms", () => {- const zoom = (- id: string,- clipId: string,- timelineSec: number,- sourceSec: number,- ): AxcutDocument["zoomRanges"][number] => ({- id,- startMs: timelineSec * 1000,- endMs: (timelineSec + 2) * 1000,- depth: 3,- focus: { cx: 0.5, cy: 0.5 },- focusMode: "manual",- clipId,- sourceStartSec: sourceSec,- sourceEndSec: sourceSec + 2,- });- const twoClipsTwoZooms: AxcutDocument = {+// The Clear timeline button. Every edit region on every clip, one write; the content stays.+describe("useTimeline.clearTimeline", () => {+ type Timeline = ReturnType<typeof useTimeline>;+ type EditKind = Exclude<RegionKind, "audio">;++ // A Record rather than a list: a new region kind fails to compile here until this suite+ // decides whether "Clear timeline" takes it. Each adder goes through the real hook, so+ // every region is schema-valid by construction.+ const addOf: Record<EditKind, (tl: Timeline) => Promise<unknown>> = {+ zoom: (tl) => tl.addZoom(),+ trim: (tl) => tl.addTrim(),+ annotation: (tl) => tl.addAnnotation(),+ speed: (tl) => tl.addSpeed(),+ cameraFullscreen: (tl) => tl.addCameraFullscreen(),+ };+ const editKinds = Object.keys(addOf) as EditKind[];++ const regionCounts = (doc: AxcutDocument | null | undefined): Record<EditKind, number> => {+ const legacy = (doc?.legacyEditor ?? {}) as { cameraFullscreenRegions?: unknown[] };+ return {+ zoom: doc?.zoomRanges.length ?? 0,+ trim: doc?.timeline.trimRanges.length ?? 0,+ annotation: doc?.annotations.length ?? 0,+ speed: doc ? readSpeedRegions(doc).length : 0,+ cameraFullscreen: legacy.cameraFullscreenRegions?.length ?? 0,+ };+ };+ const noRegions: Record<EditKind, number> = {+ zoom: 0,+ trim: 0,+ annotation: 0,+ speed: 0,+ cameraFullscreen: 0,+ };++ // A project holding everything that is NOT an edit: two clips, a webcam, an imported+ // audio track, a transcript, captions, a pause, and settings in the legacy envelope.+ const clipA = sampleDoc.timeline.clips[0];+ const contentDoc: AxcutDocument = {...sampleDoc,+ assets: [+ {+ ...sampleDoc.assets[0],+ // Dimensions filled in so the hook's backfill probe has nothing to do.+ cameraTrack: {+ sourcePath: "/tmp/camera.webm",+ startMs: 0,+ offsetMs: 0,+ visible: true,+ width: 1280,+ height: 720,+ },+ },+ {+ id: "audio_1",+ kind: "audio",+ label: "vo.mp3",+ originalPath: "/tmp/vo.mp3",+ durationSec: 30,+ cameraTrack: null,+ },+ ],+ transcripts: [{ assetId: "asset_1", language: "en", segments: [], words: [] }],timeline: {...sampleDoc.timeline,clips: [- ...sampleDoc.timeline.clips,+ clipA,{- ...sampleDoc.timeline.clips[0],+ ...clipA,id: "clip_b",+ sourceStartSec: 10,+ sourceEndSec: 20,timelineStartSec: 10,timelineEndSec: 20,},],+ muteRanges: [{ startSec: 3, endSec: 4, reason: "pause" }],+ captionRanges: [{ startSec: 1, endSec: 2, reason: "caption" }],},- zoomRanges: [zoom("zoom_a", "clip_a", 1, 1), zoom("zoom_b", "clip_b", 12, 2)],+ audioTracks: [+ {+ id: "trk_1",+ assetId: "audio_1",+ kind: "voiceover",+ startMs: 0,+ endMs: 5000,+ durationSec: 30,+ offsetMs: 0,+ gainDb: 0,+ loop: false,+ fadeInMs: 0,+ fadeOutMs: 0,+ muted: false,+ label: "vo.mp3",+ origin: "user",+ },+ ],+ legacyEditor: { aspectRatio: "16:9" },};beforeEach(() => {@@ -778,7 +844,7 @@ describe("useTimeline.clearZooms", () => {}));useProjectStore.setState({projectId: "proj_test",- document: twoClipsTwoZooms,+ document: contentDoc,currentTimeSec: 1,revision: 1,status: "ready",@@ -790,72 +856,106 @@ describe("useTimeline.clearZooms", () => {vi.clearAllMocks();});- it("removes the zooms of every clip and nothing else", async () => {+ const addEveryKind = async (result: { current: Timeline }) => {+ for (const kind of editKinds) {+ await act(async () => {+ await addOf[kind](result.current);+ });+ }+ };++ it.each(editKinds)("clears a timeline holding only a %s region", async (kind) => {const { result } = renderTimeline();await act(async () => {- await result.current.addAnnotation();+ await addOf[kind](result.current);});+ expect(regionCounts(useProjectStore.getState().document)).toEqual({+ ...noRegions,+ [kind]: 1,+ });+await act(async () => {- await result.current.clearZooms();+ await result.current.clearTimeline();});- const doc = useProjectStore.getState().document;- expect(doc?.zoomRanges).toEqual([]);- expect(doc?.annotations).toHaveLength(1);- expect(doc?.timeline.clips).toHaveLength(2);+ expect(regionCounts(useProjectStore.getState().document)).toEqual(noRegions);});- it("is one undo step: a single Ctrl+Z restores every zoom, redo clears them again", async () => {+ it("clears every region kind at once and keeps clips, media, audio, captions and transcript", async () => {const { result } = renderTimeline();+ await addEveryKind(result);+ const before = useProjectStore.getState().document;+ expect(regionCounts(before)).toEqual({+ zoom: 1,+ trim: 1,+ annotation: 1,+ speed: 1,+ cameraFullscreen: 1,+ });+await act(async () => {- await result.current.clearZooms();+ await result.current.clearTimeline();});- expect(past).toHaveLength(1);+ const after = useProjectStore.getState().document;+ expect(regionCounts(after)).toEqual(noRegions);+ expect(after?.timeline.clips).toEqual(before?.timeline.clips);+ expect(after?.timeline.clips).toHaveLength(2);+ expect(after?.assets).toEqual(before?.assets);+ expect(after?.audioTracks).toEqual(before?.audioTracks);+ expect(after?.audioTracks).toHaveLength(1);+ expect(after?.transcripts).toEqual(before?.transcripts);+ expect(after?.timeline.captionRanges).toEqual(before?.timeline.captionRanges);+ expect(after?.timeline.muteRanges).toEqual(before?.timeline.muteRanges);+ expect((after?.legacyEditor as { aspectRatio?: string }).aspectRatio).toBe("16:9");+ });++ it("is one undo step: a single Ctrl+Z restores every region, redo clears them again", async () => {+ const { result } = renderTimeline();+ await addEveryKind(result);+ const before = useProjectStore.getState().document;+ const stepsBefore = past.length;++ await act(async () => {+ await result.current.clearTimeline();+ });+ expect(past).toHaveLength(stepsBefore + 1);act(() => {expect(undo()).toBe(true);});- expect(useProjectStore.getState().document?.zoomRanges.map((z) => z.id)).toEqual([- "zoom_a",- "zoom_b",- ]);+ expect(useProjectStore.getState().document).toEqual(before);+ expect(regionCounts(useProjectStore.getState().document)).toEqual({+ zoom: 1,+ trim: 1,+ annotation: 1,+ speed: 1,+ cameraFullscreen: 1,+ });act(() => {expect(redo()).toBe(true);});- expect(useProjectStore.getState().document?.zoomRanges).toEqual([]);+ expect(regionCounts(useProjectStore.getState().document)).toEqual(noRegions);});- it("lets go of a selected zoom, which no longer exists", async () => {- const { result } = renderTimeline();- act(() => result.current.selectRegion("zoom", "zoom_a"));- expect(result.current.selection).toEqual({ kind: "zoom", id: "zoom_a" });-- await act(async () => {- await result.current.clearZooms();- });- expect(result.current.selection).toBeNull();- expect(result.current.multiSelection).toEqual([]);- });-- it("keeps an annotation selected", async () => {+ it("lets go of a selection that pointed at a region it just removed", async () => {const { result } = renderTimeline();+ // A fresh annotation is auto-selected.await act(async () => {await result.current.addAnnotation();});- const selected = result.current.selection;- expect(selected?.kind).toBe("annotation");+ expect(result.current.selection?.kind).toBe("annotation");await act(async () => {- await result.current.clearZooms();+ await result.current.clearTimeline();});- expect(result.current.selection).toEqual(selected);+ expect(result.current.selection).toBeNull();+ expect(result.current.multiSelection).toEqual([]);});- it("writes nothing when there is no zoom", async () => {- useProjectStore.setState({ document: { ...twoClipsTwoZooms, zoomRanges: [] } });+ it("writes nothing when the timeline holds no edit region, whatever else it holds", async () => {const { result } = renderTimeline();await act(async () => {- await result.current.clearZooms();+ await result.current.clearTimeline();});expect(bridgeMocks.save).not.toHaveBeenCalled();expect(past).toHaveLength(0);diff --git a/src/lib/ai-edition/store/useTimeline.ts b/src/lib/ai-edition/store/useTimeline.tsindex 8c41cc59f..f4e9b1125 100644--- a/src/lib/ai-edition/store/useTimeline.ts+++ b/src/lib/ai-edition/store/useTimeline.ts@@ -24,6 +24,8 @@ import {import { createId } from "../document/ids";import { resolveAspectRatioValue } from "../document/outputFormat";import {+ clearEditRegions,+ countEditRegions,duplicateClip as duplicateClipInDocument,moveClip as moveClipInDocument,PLACEHOLDER_DURATION_SEC,@@ -1135,13 +1137,15 @@ export function useTimeline() {[document, saveDocument],);- // Every zoom region, across all clips, in one write: one undo step brings them all- // back. Zooms only — trims, speeds, annotations and camera segments are untouched.- const clearZooms = useCallback(async () => {- if (!document || document.zoomRanges.length === 0) return;- if (!(await saveDocument({ ...document, zoomRanges: [] }, { history: true }))) return;- if (selection?.kind === "zoom") setSelection(null);- setMultiSelection((prev) => prev.filter((h) => h.kind !== "zoom"));+ // Every edit region (zoom, speed, trim, annotation, Full Camera), on every clip, in one+ // write: one undo step brings them all back. Clips, media, audio tracks, captions and the+ // transcript are content, not edits, and stay (see `clearEditRegions`).+ const clearTimeline = useCallback(async () => {+ if (!document || countEditRegions(document) === 0) return;+ if (!(await saveDocument(clearEditRegions(document), { history: true }))) return;+ // Every region a selection can point at is gone. An audio track is not one of them.+ if (selection && selection.kind !== "audio") setSelection(null);+ setMultiSelection((prev) => prev.filter((h) => h.kind === "audio"));}, [document, selection, saveDocument]);// Selecting a pill and selecting a clip are the SAME act — "this is the thing@@ -1643,7 +1647,7 @@ export function useTimeline() {addCameraFullscreen,removeRegion,removeRegions,- clearZooms,+ clearTimeline,addAudioTrack,addAudio,removeAudioTrack,diff --git a/technical-documentation/testing/manual-e2e-checklist.md b/technical-documentation/testing/manual-e2e-checklist.mdindex ded9493d7..55ff689de 100644--- a/technical-documentation/testing/manual-e2e-checklist.md+++ b/technical-documentation/testing/manual-e2e-checklist.md@@ -295,7 +295,7 @@ The timeline toolbar adds each kind: *Add zoom (Z)*, *Add trim (T)*, *Add speed- [ ] Set a zoom region's *Focus mode* to Auto and confirm its focus follows cursor telemetry across the whole region.- [ ] Use *Auto-enhance* → *Automatic zooms* and confirm it adds suggested zoom regions when cursor telemetry supports suggestions, or says why not ("No room for automatic zooms" on a take whose zooms were already placed after recording).- [ ] Select a zoom region and activate *Delete zoom* in the inspector; confirm it disappears from the lane.-- [ ] With two or more zooms on the timeline, activate *Clear zooms* (the trash button after *Auto-Focus all zooms*, absent while no zoom exists) and confirm every zoom disappears in one step and one `Ctrl+Z` brings them all back.+- [ ] With a zoom, a speed, a trim, an annotation and a Full Camera region on the timeline, plus an imported audio track and captions, activate *Clear timeline* (the eraser button after *Auto-Focus all zooms*, absent while no region exists) and confirm every region disappears in one step while the clips, the audio track and the captions stay, and one `Ctrl+Z` brings all the regions back.- [ ] Activate *Add speed (S)* and confirm a speed region appears.- [ ] Pick each speed in the *Playback speed* row (0.5×, 1×, 1.5×, 2×, 4×) and confirm the lane label and preview timing change.- [ ] Enter a custom speed in the *Custom speed* field, commit it, and confirm the value is kept, with no preset pressed.