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
fix(annotations): start text annotations empty, with a placeholder
Etienne Lescot0d3f9d1c3360
diff --git a/src/components/ai-edition/v4/FloatingInspector.tsx b/src/components/ai-edition/v4/FloatingInspector.tsxindex d9ad854fc..4910562c5 100644--- a/src/components/ai-edition/v4/FloatingInspector.tsx+++ b/src/components/ai-edition/v4/FloatingInspector.tsx@@ -398,6 +398,7 @@ function SelectionPane({ tl, onClose }: { tl: TimelineApi; onClose: () => void }</span><textareavalue={region.content ?? ""}+ placeholder={ts("annotation.textPlaceholder")}onChange={(e) => tl.updateAnnotationLive(region.id, { content: e.target.value })}onBlur={() => void tl.commitAnnotationChange()}rows={2}diff --git a/src/lib/ai-edition/store/useTimeline.test.ts b/src/lib/ai-edition/store/useTimeline.test.tsindex c5bd8cf73..b6388bdf3 100644--- a/src/lib/ai-edition/store/useTimeline.test.ts+++ b/src/lib/ai-edition/store/useTimeline.test.ts@@ -471,3 +471,45 @@ describe("useTimeline.updateClipSourceRange (Edit-clip modal)", () => {});});});++describe("useTimeline.addAnnotation", () => {+ beforeEach(() => {+ useProjectStore.getState().clear();+ for (const mock of Object.values(bridgeMocks)) mock.mockReset();+ bridgeMocks.save.mockImplementation(async (doc: typeof sampleDoc) => ({+ success: true,+ document: doc,+ }));+ useProjectStore.setState({+ projectId: "proj_test",+ document: sampleDoc,+ currentTimeSec: 1,+ revision: 1,+ status: "ready",+ error: null,+ });+ });++ afterEach(() => {+ vi.clearAllMocks();+ });++ it("creates an empty text annotation and selects it so the placeholder shows", async () => {+ const { result } = renderHook(() => useTimeline());+ await act(async () => {+ await result.current.addAnnotation();+ });+ const annotations = useProjectStore.getState().document?.annotations ?? [];+ expect(annotations).toHaveLength(1);+ // Empty content is what lets the inspector's placeholder show, instead of a+ // baked-in default the user has to select and clear before typing.+ expect(annotations[0]).toMatchObject({ type: "text", content: "" });+ // The new (empty) annotation is auto-selected so its inspector opens and it+ // draws a selection box on the canvas — an empty text annotation renders+ // nothing, so without selection it would be invisible and unclickable.+ expect(result.current.selection).toEqual({+ kind: "annotation",+ id: (annotations[0] as { id: string }).id,+ });+ });+});diff --git a/src/lib/ai-edition/store/useTimeline.ts b/src/lib/ai-edition/store/useTimeline.tsindex 27eb593ec..6733295b4 100644--- a/src/lib/ai-edition/store/useTimeline.ts+++ b/src/lib/ai-edition/store/useTimeline.ts@@ -256,8 +256,10 @@ export function useTimeline() {startMs: timeMs,endMs: timeMs + 2000,type: "text" as AnnotationType,- content: "New annotation",- textContent: "New annotation",+ // Start empty so the inspector's placeholder shows and typing goes into an+ // empty field, instead of a baked-in default the user must select and clear.+ content: "",+ textContent: "",position: { x: 50, y: 50 },size: { width: 30, height: 20 },style: {@@ -273,14 +275,20 @@ export function useTimeline() {},zIndex: document.annotations.length + 1,};+ const created = anchorRegionsWithDerivedMs([ann], document.timeline.clips, () =>+ createId("ann"),+ );const next: AxcutDocument = {...document,- annotations: [- ...document.annotations,- ...anchorRegionsWithDerivedMs([ann], document.timeline.clips, () => createId("ann")),- ] as unknown as AxcutDocument["annotations"],+ annotations: [...document.annotations, ...created] as unknown as AxcutDocument["annotations"],};await saveDocument(next);+ // Select the freshly added (empty) annotation so its inspector opens and it+ // shows a selection box on the canvas — an empty text annotation renders+ // nothing, so without this it would be invisible and impossible to click.+ const newId = created[0]?.id ?? ann.id;+ setMultiSelection([{ kind: "annotation", id: newId }]);+ setSelection({ kind: "annotation", id: newId });}, [document, currentTimeSec, saveDocument]);const addSpeed = useCallback(async () => {