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(ai): the chat cannot rewrite a word nobody said
EtienneLescotc991976ae332
diff --git a/electron/ai-edition/agent-tools.test.ts b/electron/ai-edition/agent-tools.test.tsindex f39510487..20d345298 100644--- a/electron/ai-edition/agent-tools.test.ts+++ b/electron/ai-edition/agent-tools.test.ts@@ -2301,6 +2301,41 @@ describe("setWordText", () => {expect(next.transcripts[0].segments[0].text).toBe("I use Kubernetes");});+ // The editor gates word INSERTION on a dev-only flag, and that gate lives in the renderer.+ // The chat runs in the main process, so an ungated path here would let a release rewrite+ // generated media through the agent — the one door the flag cannot see.+ it("refuses a word that was added rather than heard", () => {+ const base = documentWithWords();+ const withInsertion: AxcutDocument = {+ ...base,+ transcripts: [+ ...base.transcripts,+ {+ assetId: "ext:synth_1",+ language: "en",+ segments: [],+ words: [+ {+ id: "synth_1",+ segmentId: "seg_1",+ startSec: 0,+ endSec: 0.15,+ text: "added",+ source: "synth",+ },+ ],+ },+ ],+ };+ const result = run(withInsertion, "setWordText", {+ assetId: "ext:synth_1",+ wordId: "synth_1",+ text: "much longer",+ });+ expect(result.ok).toBe(false);+ expect(result.document).toBeUndefined();+ });+// The document carries the transcript twice; a write that reaches only one leaves the// legacy mirror serving the old text forever.it("writes the legacy mirror too", () => {diff --git a/electron/ai-edition/agent-tools.ts b/electron/ai-edition/agent-tools.tsindex 469b5d313..958658f85 100644--- a/electron/ai-edition/agent-tools.ts+++ b/electron/ai-edition/agent-tools.ts@@ -35,6 +35,7 @@ import {import { setDocumentWordText } from "../../src/lib/ai-edition/document/transcript";import type { AxcutDocument } from "../../src/lib/ai-edition/schema";import { hasAnyClipWithCamera } from "../../src/lib/ai-edition/timeline/camera";+import { isGeneratedAssetId } from "../../src/lib/ai-edition/timeline/clip-parts";import {buildCursorTrack,type CursorTrackSample,@@ -1341,6 +1342,17 @@ export function executeAgentTool(if (before.text === text) {return failure(`Word ${wordId} already reads "${text}" — nothing to change.`);}+ // This tool exists to fix a name the transcriber misheard. An INSERTED word was+ // never heard: retyping it resizes the clip it plays on and asks for generated+ // media of a new length, which is the gesture the editor gates on `insertionsEnabled`+ // — and that gate lives in the renderer, where the chat does not run. Refused here+ // unconditionally rather than mirrored, because the agent has no business authoring+ // generated media at all.+ if (isGeneratedAssetId(assetId)) {+ return failure(+ `Word ${wordId} was added to the transcript, not heard — the chat cannot rewrite it.`,+ );+ }let next: AxcutDocument;try {next = setDocumentWordText(document, assetId, wordId, text);