Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

revert(captions): drop the preview guide, it had nothing left to explain

EtienneLescot7526c30d732a
diff --git a/src/components/ai-edition/CaptionGuideOverlay.test.tsx b/src/components/ai-edition/CaptionGuideOverlay.test.tsx
deleted file mode 100644
index 0030de548..000000000
--- a/src/components/ai-edition/CaptionGuideOverlay.test.tsx
+++ /dev/null
@@ -1,127 +0,0 @@
-// @vitest-environment jsdom
-// The caption guide is DOM, and the last DOM caption layer was deleted for good
-// reason (it painted the same text through a second wrapping engine and the two
-// disagreed). What these tests pin is the boundary that makes this one safe: it
-// draws no text, it only appears while the pane that explains it is open, and it
-// tracks the same geometry function the compositor is handed.
-
-import "@testing-library/jest-dom";
-import { cleanup, render } from "@testing-library/react";
-import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
-import { captionBoxRect, getCaptionSettings } from "@/lib/ai-edition/captions";
-import type { AxcutAsset, AxcutDocument } from "@/lib/ai-edition/schema";
-import { useProjectStore } from "@/lib/ai-edition/store/projectStore";
-import { useCaptionGuideBus } from "@/lib/ai-edition/store/useCaptionGuideBus";
-import { CaptionGuideOverlay } from "./CaptionGuideOverlay";
-
-vi.mock("@/native", () => ({ nativeBridgeClient: { aiEdition: {} } }));
-vi.mock("@/native/client", () => ({ nativeBridgeClient: { aiEdition: {} } }));
-
-const ASSET: AxcutAsset = {
- id: "asset_1",
- kind: "video",
- label: "recording.mp4",
- originalPath: "/rec.mp4",
- durationSec: 12,
- cameraTrack: null,
-};
-
-function documentWith(captions: Record<string, unknown>): AxcutDocument {
- return {
- schemaVersion: 7,
- project: {
- id: "proj_1",
- title: "Test",
- createdAt: "2026-06-25T10:00:00.000Z",
- updatedAt: "2026-06-25T10:00:00.000Z",
- primaryAssetId: ASSET.id,
- },
- assets: [ASSET],
- transcript: null,
- transcripts: [],
- timeline: {
- clips: [
- {
- id: "clip_1",
- assetId: ASSET.id,
- sourceStartSec: 0,
- sourceEndSec: 12,
- timelineStartSec: 0,
- timelineEndSec: 12,
- wordRefs: [],
- origin: "user",
- reason: "",
- },
- ],
- gaps: [],
- trimRanges: [],
- muteRanges: [],
- speedRanges: [],
- captionRanges: [],
- },
- annotations: [],
- zoomRanges: [],
- legacyEditor: { captions },
- } as unknown as AxcutDocument;
-}
-
-function show(captions: Record<string, unknown>, open: boolean) {
- const document = documentWith(captions);
- useProjectStore.setState({
- projectId: document.project.id,
- document,
- status: "ready",
- error: null,
- dirty: false,
- });
- useCaptionGuideBus.setState({ open });
- return { document, ...render(<CaptionGuideOverlay />) };
-}
-
-beforeEach(() => {
- useProjectStore.getState().clear();
- useCaptionGuideBus.setState({ open: false });
-});
-
-afterEach(() => {
- cleanup();
-});
-
-describe("caption guide overlay", () => {
- it("draws nothing while the captions pane is closed", () => {
- const { container } = show({ enabled: true }, false);
- expect(container).toBeEmptyDOMElement();
- });
-
- it("draws nothing when captions are off, even with the pane open", () => {
- const { container } = show({ enabled: false }, true);
- expect(container).toBeEmptyDOMElement();
- });
-
- it("puts the anchor line exactly where the compositor pins the caption", () => {
- const { container, document } = show({ enabled: true, anchorV: "bottom", insetY: 12 }, true);
- const line = container.querySelector('div[style*="height: 2px"]');
- expect(line).toBeInTheDocument();
- // 100 − insetY: the same number `captionBoxRect` puts the box's bottom edge at,
- // so the guide cannot drift from the thing it is drawing.
- expect((line as HTMLElement).style.top).toBe("88%");
-
- const box = captionBoxRect(getCaptionSettings(document, 16 / 9), 16 / 9);
- expect(box.y + box.height).toBeCloseTo(88, 6);
- });
-
- it("follows the anchor to the top edge", () => {
- const { container } = show({ enabled: true, anchorV: "top", insetY: 9 }, true);
- const line = container.querySelector('div[style*="height: 2px"]');
- expect((line as HTMLElement).style.top).toBe("9%");
- });
-
- it("carries no text — it is a guide, not a second caption painter", () => {
- const { container } = show({ enabled: true }, true);
- expect(container.textContent).toBe("");
- // And it is inert: it must never eat a click meant for the canvas beneath.
- const root = container.firstElementChild as HTMLElement;
- expect(root.style.pointerEvents).toBe("none");
- expect(root).toHaveAttribute("aria-hidden", "true");
- });
-});
diff --git a/src/components/ai-edition/CaptionGuideOverlay.tsx b/src/components/ai-edition/CaptionGuideOverlay.tsx
deleted file mode 100644
index a298b36dc..000000000
--- a/src/components/ai-edition/CaptionGuideOverlay.tsx
+++ /dev/null
@@ -1,95 +0,0 @@
-// The caption guide: the anchor line the user is actually setting, plus the edges of
-// the column captions wrap in. Shown only while the Captions pane is open.
-//
-// Why it exists: the pane's controls are all edge-referenced now, but two of those
-// edges (the column's) are derived from the output aspect rather than chosen, so
-// "why does Left stop there?" has no answer on screen without this. The anchor line
-// is the stronger reason — it IS the invariant the distance slider sets, and watching
-// it hold still while a caption grows is the fastest way to understand the model.
-//
-// This is NOT a second caption painter. `CaptionLayer.tsx` was deleted because it
-// drew the same TEXT through a second wrapping engine and the two disagreed on line
-// breaks; a rule and two hairlines have no glyphs to disagree about. The precedent is
-// `AnnotationOverlay` — the DOM painter went, the selection chrome stayed. A <div>
-// also has no route into `buildSceneDescription`, so it cannot reach an export.
-
-import { useMemo } from "react";
-import { captionBoxRect, getCaptionSettings } from "@/lib/ai-edition/captions";
-import { resolveAspectRatioValue } from "@/lib/ai-edition/document/outputFormat";
-import { useProjectStore } from "@/lib/ai-edition/store/projectStore";
-import { useCaptionGuideBus } from "@/lib/ai-edition/store/useCaptionGuideBus";
-import { useEditorSettings } from "@/lib/ai-edition/store/useEditorSettings";
-
-/**
- * Mounted as a direct child of `.previewFrame`, NOT of `.screenStage`.
- *
- * That is load-bearing: `.screenStage` is the screen rect, which shrinks as the
- * padding slider grows, while captions are measured against the output frame
- * (`space: "frame"`, issue #396). Drawing the guide on the screen rect would
- * reproduce that exact bug inside the guide meant to explain it. Inside
- * `.previewFrame`, frame-percent → CSS-percent is the identity, so there is no
- * letterbox arithmetic here and no second geometry to keep in sync.
- */
-export function CaptionGuideOverlay() {
- const open = useCaptionGuideBus((s) => s.open);
- const document = useProjectStore((s) => s.document);
- const { settings: editorSettings } = useEditorSettings();
-
- const guide = useMemo(() => {
- if (!document) return null;
- const aspect = resolveAspectRatioValue(document, editorSettings.aspectRatio);
- const captions = getCaptionSettings(document, aspect);
- if (!captions.enabled) return null;
- const box = captionBoxRect(captions, aspect);
- return {
- // The edge the caption is pinned to — the one number the distance slider sets,
- // and the one that must not move when the text wraps.
- anchorPct: captions.anchorV === "bottom" ? 100 - captions.insetY : captions.insetY,
- leftPct: box.x,
- rightPct: box.x + box.width,
- };
- }, [document, editorSettings.aspectRatio]);
-
- if (!open || !guide) return null;
-
- return (
- <div
- aria-hidden="true"
- style={{
- position: "absolute",
- inset: 0,
- pointerEvents: "none",
- zIndex: 3,
- }}
- >
- {/* The column's edges, faint: they answer "why does Left stop there?" and
- nothing else, so they must not compete with the anchor line. */}
- {[guide.leftPct, guide.rightPct].map((pct) => (
- <div
- key={pct}
- style={{
- position: "absolute",
- top: 0,
- bottom: 0,
- left: `${pct}%`,
- width: 1,
- background: "color-mix(in srgb, var(--accent) 35%, transparent)",
- }}
- />
- ))}
- {/* The anchor line. Deliberately the loudest thing here. */}
- <div
- style={{
- position: "absolute",
- left: `${guide.leftPct}%`,
- width: `${guide.rightPct - guide.leftPct}%`,
- top: `${guide.anchorPct}%`,
- height: 2,
- marginTop: -1,
- background: "var(--accent)",
- borderRadius: 1,
- }}
- />
- </div>
- );
-}
diff --git a/src/components/ai-edition/CaptionsPane.tsx b/src/components/ai-edition/CaptionsPane.tsx
index 13e0b1c8b..6d6a776c9 100644
--- a/src/components/ai-edition/CaptionsPane.tsx
+++ b/src/components/ai-edition/CaptionsPane.tsx
@@ -10,7 +10,7 @@
// "Original" goes straight back to the SSOT text.
import { Captions as CaptionsIcon, Languages, Loader2, Trash2 } from "lucide-react";
-import { useEffect, useMemo, useState } from "react";
+import { useMemo, useState } from "react";
import { useScopedT } from "@/contexts/I18nContext";
import type { CaptionAnchorH, CaptionAnchorV } from "@/lib/ai-edition/captions";
import {
@@ -23,7 +23,6 @@ import {
useTimelineTranscriptGate,
useTranscriptionStore,
} from "@/lib/ai-edition/store/transcriptionStore";
-import { useCaptionGuideBus } from "@/lib/ai-edition/store/useCaptionGuideBus";
import { useCaptions } from "@/lib/ai-edition/store/useCaptions";
import { nativeBridgeClient } from "@/native";
import { ColorField } from "./ColorField";
@@ -118,15 +117,6 @@ export function CaptionsPane() {
const disabled = !hasDocument;
const languageOptions = useMemo(() => Object.values(translations), [translations]);
- // The preview draws the anchor line and the column edges while this pane is open.
- // `FacetBody` mounts exactly one pane at a time, so mounting is the signal — no
- // prop to thread down through the inspector, and nothing to remember to turn off.
- const setGuideOpen = useCaptionGuideBus((s) => s.setOpen);
- useEffect(() => {
- setGuideOpen(true);
- return () => setGuideOpen(false);
- }, [setGuideOpen]);
-
const handleTranslate = async () => {
const doc = useProjectStore.getState().document;
if (!doc) return;
diff --git a/src/components/ai-edition/PreviewCanvas.tsx b/src/components/ai-edition/PreviewCanvas.tsx
index 70980fa33..6f59e066f 100644
--- a/src/components/ai-edition/PreviewCanvas.tsx
+++ b/src/components/ai-edition/PreviewCanvas.tsx
@@ -55,7 +55,6 @@ import { getCssClipPath } from "@/lib/webcamMaskShapes";
import { computeCameraFullscreenProgress } from "@/lib/zoomMath/cameraFullscreenUtils";
import { clamp, clamp01 } from "@/utils/math";
import { AnnotationLayer } from "./AnnotationLayer";
-import { CaptionGuideOverlay } from "./CaptionGuideOverlay";
import { NativeCompositorOverlay } from "./NativeCompositorOverlay";
import styles from "./NewEditorShell.module.css";
import { type VideoSource, VirtualPreview } from "./VirtualPreview";
@@ -406,11 +405,6 @@ export function PreviewCanvas(props: PreviewCanvasProps) {
hitbox) still render on top as normal DOM so they stay clickable. No more
dual preview path. */}
<NativeCompositorOverlay />
- {/* Sibling of `.screenStage`, never a child of it: captions are measured
- against the output FRAME, and `.screenStage` shrinks with the padding
- slider — so a guide mounted inside it would drift away from the thing
- it is drawing (issue #396, in the guide meant to explain it). */}
- <CaptionGuideOverlay />
{layout?.screenRect ? (
<div className={styles.screenStage} style={screenStyle}>
{(() => {
diff --git a/src/lib/ai-edition/store/useCaptionGuideBus.ts b/src/lib/ai-edition/store/useCaptionGuideBus.ts
deleted file mode 100644
index 8219b4c36..000000000
--- a/src/lib/ai-edition/store/useCaptionGuideBus.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { create } from "zustand";
-
-// Tiny decoupled bus so the preview can draw the caption guide while the Captions
-// pane is open, without the pane reaching across the layout to the canvas or the
-// canvas importing the inspector.
-//
-// Same shape and same reason as `useChatPromptBus`. The pane owns the signal because
-// it is the thing that knows it is open: `FacetBody` mounts exactly one pane at a
-// time, so mounting IS "the user is editing captions" and unmounting is the end of it.
-
-interface CaptionGuideBusState {
- /** True while the Captions pane is mounted. Nothing else may set it. */
- open: boolean;
- setOpen: (open: boolean) => void;
-}
-
-export const useCaptionGuideBus = create<CaptionGuideBusState>((set) => ({
- open: false,
- setOpen: (open) => set({ open }),
-}));
diff --git a/technical-documentation/architecture/transcription-and-captions.md b/technical-documentation/architecture/transcription-and-captions.md
index 389d0abce..245519ab5 100644
--- a/technical-documentation/architecture/transcription-and-captions.md
+++ b/technical-documentation/architecture/transcription-and-captions.md
@@ -621,21 +621,6 @@ two controls fighting over that one outcome — `offsetX` moved an invisible ban
`textAlign` moved the text inside it — and neither could be read without seeing the
band.
-#### The guide overlay
-
-`CaptionGuideOverlay`
-([`src/components/ai-edition/CaptionGuideOverlay.tsx`](../../src/components/ai-edition/CaptionGuideOverlay.tsx))
-draws the anchor line and the column's edges over the preview while the Captions
-pane is open, signalled by `useCaptionGuideBus`. It mounts as a child of
-`.previewFrame` and **not** of `.screenStage`: the latter is the screen rect, which
-shrinks with the padding slider, so a guide mounted there would reproduce #396
-inside the guide meant to explain it.
-
-This does not revive the deleted DOM caption painter described below. That one drew
-the same *text* through a second wrapping engine and the two disagreed on line
-breaks; a rule and two hairlines have no glyphs to disagree about, and a `<div>` has
-no route into `buildSceneDescription`, so it cannot reach an export.
-
The Captions pane itself
([`src/components/ai-edition/CaptionsPane.tsx`](../../src/components/ai-edition/CaptionsPane.tsx))
is the only place that runs `transcribe` from the editor shell, and