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(captions): re-clamp offsets on patch, and unambiguous Turkish labels
EtienneLescot8bd01e36c970
diff --git a/src/i18n/locales/tr/settings.json b/src/i18n/locales/tr/settings.jsonindex 091e6496c..278100998 100644--- a/src/i18n/locales/tr/settings.json+++ b/src/i18n/locales/tr/settings.json@@ -293,8 +293,8 @@"alignLeft": "Sol","alignCenter": "Orta","alignRight": "Sağ",- "verticalOffset": "Dikey kaydırma",- "horizontalOffset": "Yatay kaydırma",+ "verticalOffset": "Dikey ofset",+ "horizontalOffset": "Yatay ofset","width": "Genişlik","lineLength": "Satır uzunluğu","minWords": "Satır başına en az kelime",diff --git a/src/lib/ai-edition/captions/captions.test.ts b/src/lib/ai-edition/captions/captions.test.tsindex 61fd5ef4d..f253c0c8f 100644--- a/src/lib/ai-edition/captions/captions.test.ts+++ b/src/lib/ai-edition/captions/captions.test.ts@@ -1,6 +1,7 @@import { describe, expect, it } from "vitest";import type { AxcutDocument, AxcutTranscript } from "../schema";import { captionCuesToTextRegions, deriveCaptionCues } from "./cues";+import type { CaptionSettings } from "./settings";import {CAPTION_BAND_HEIGHT_PCT,captionBackgroundCss,@@ -178,6 +179,36 @@ describe("caption settings", () => {expect(large).toBeCloseTo(100 - CAPTION_BAND_HEIGHT_PCT - 75, 6);});+ it("re-clamps the offsets against the geometry a patch just created", () => {+ // A patch can move the reachable span itself — `width`, `fontSize`,+ // `backgroundEnabled` and `verticalPosition` all do. Clamping only on read+ // would leave the stored number outside the span until someone read it, and+ // the next patch would write that stale number straight back out.+ const wide = patchCaptionSettings(doc(), { enabled: true, width: 20 });+ const pushed = patchCaptionSettings(wide, {+ offsetX: captionOffsetRange(getCaptionSettings(wide)).x.max,+ });+ const narrowed = patchCaptionSettings(pushed, { width: 100 });++ const stored = (narrowed.legacyEditor as { captions: CaptionSettings }).captions;+ expect(stored.offsetX).toBeCloseTo(0, 6);+ expect(stored.offsetX).toBeCloseTo(getCaptionSettings(narrowed).offsetX, 6);+ });++ it("re-clamps when the anchor moves, not just when the width does", () => {+ const low = patchCaptionSettings(doc(), { enabled: true, verticalPosition: "bottom" });+ const pushed = patchCaptionSettings(low, {+ offsetY: captionOffsetRange(getCaptionSettings(low)).y.min,+ });+ const flipped = patchCaptionSettings(pushed, { verticalPosition: "top" });++ const stored = (flipped.legacyEditor as { captions: CaptionSettings }).captions;+ const range = captionOffsetRange(getCaptionSettings(flipped));+ expect(stored.offsetY).toBeGreaterThanOrEqual(range.y.min - 1e-9);+ expect(stored.offsetY).toBeLessThanOrEqual(range.y.max + 1e-9);+ expect(stored.offsetY).toBeCloseTo(getCaptionSettings(flipped).offsetY, 6);+ });+it("normalises an offset left over from another anchor on read", () => {// The stored value, the slider position and the drawn band stay the same number.const parked = patchCaptionSettings(doc(), { enabled: true, offsetY: 45 });diff --git a/src/lib/ai-edition/captions/settings.ts b/src/lib/ai-edition/captions/settings.tsindex 6440ec321..13cacdc94 100644--- a/src/lib/ai-edition/captions/settings.ts+++ b/src/lib/ai-edition/captions/settings.ts@@ -264,6 +264,15 @@ export function patchCaptionSettings(patch: CaptionSettingsPatch,): AxcutDocument {const next: CaptionSettings = { ...getCaptionSettings(doc), ...patch };+ // Re-clamp against the geometry the patch just produced, not the one it+ // replaced: `width`, `fontSize`, `backgroundEnabled` and `verticalPosition` all+ // move the reachable span, so a patch to any of them can strand an offset+ // outside it. `getCaptionSettings` would pull it back on the next read, but+ // until then the document would hold a number the band never draws — and the+ // next patch would write that stale number back out.+ const range = captionOffsetRange(next);+ next.offsetY = clamp(next.offsetY, range.y.min, range.y.max);+ next.offsetX = clamp(next.offsetX, range.x.min, range.x.max);return {...doc,legacyEditor: {diff --git a/technical-documentation/architecture/transcription-and-captions.md b/technical-documentation/architecture/transcription-and-captions.mdindex d11c1f3b4..afd9ada74 100644--- a/technical-documentation/architecture/transcription-and-captions.md+++ b/technical-documentation/architecture/transcription-and-captions.md@@ -493,7 +493,7 @@ unit falls back to the original words (`untranslatedUnits`,Caption appearance lives in `document.legacyEditor.captions`, accessedthrough `getCaptionSettings` / `patchCaptionSettings`-([`src/lib/ai-edition/captions/settings.ts:122,154`](../../src/lib/ai-edition/captions/settings.ts:122)).+([`src/lib/ai-edition/captions/settings.ts:217,262`](../../src/lib/ai-edition/captions/settings.ts:217)).| Field | Default | Notes ||---|---|---|@@ -576,7 +576,7 @@ sync.> the sole pixel source (see [preview.md](preview.md)).- **Preview and export** — `captionCuesToTextRegions`- ([`src/lib/ai-edition/captions/cues.ts:242`](../../src/lib/ai-edition/captions/cues.ts:242))+ ([`src/lib/ai-edition/captions/cues.ts:254`](../../src/lib/ai-edition/captions/cues.ts:254))converts the virtual-ms cue list into synthetic `CaptionTextRegion`s viathe `captionBandRect` + `captionBackgroundCss` helpers. Those regionsride the existing annotation path through the scene description and onto