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(mcp): run no Whisper for a project deleted while its transcription waited
EtienneLescot63acc0707d9f
diff --git a/electron/mcp/openscreen-mcp-server.ts b/electron/mcp/openscreen-mcp-server.tsindex 2e8ab44a5..7b0f3ec38 100644--- a/electron/mcp/openscreen-mcp-server.ts+++ b/electron/mcp/openscreen-mcp-server.ts@@ -687,7 +687,11 @@ export function createToolRunner(deps: McpToolDeps): McpToolRunner {const current = await deps.projects.getProjectForUpdate(targetId).then((read) => read.document)- .catch(() => document);+ .catch((error) => {+ // Deleted while it waited: no Whisper on a file nobody owns any more.+ if (error instanceof DocumentNotFoundError) throw error;+ return document;+ });const media = current.assets.find((a) => a.id === asset.id);if (!media) throw new Error(`Asset ${asset.id} was removed from the project.`);return whisper({@@ -701,6 +705,12 @@ export function createToolRunner(deps: McpToolDeps): McpToolRunner {try {response = await started;} catch (error) {+ if (error instanceof DocumentNotFoundError) {+ return textResult(+ `Project ${targetId} was deleted before its transcription started.`,+ true,+ );+ }const failure = classifyTranscriptionError(error);// Remembered on the asset as the editor remembers it: best effort, the answer stands.await landEdit(targetId, editsAllowed, async (current) => {diff --git a/electron/mcp/transcribe-tool.test.ts b/electron/mcp/transcribe-tool.test.tsindex d51803347..8f3b443c6 100644--- a/electron/mcp/transcribe-tool.test.ts+++ b/electron/mcp/transcribe-tool.test.ts@@ -191,6 +191,29 @@ describe("transcribe, on a project's file", () => {await second;});+ it("runs no Whisper for a project deleted while it waited", async () => {+ await projects.saveProject(fixtureDocument("proj_1"));+ await projects.saveProject(fixtureDocument("proj_2"));+ const running: Array<(response: SttTranscribeResponse) => void> = [];+ const { run, transcribe } = runnerWith(+ () =>+ new Promise((resolve) => {+ running.push(resolve);+ }),+ );+ const first = run(TRANSCRIBE_TOOL, { projectId: "proj_1" });+ await vi.waitFor(() => expect(running).toHaveLength(1));+ const second = run(TRANSCRIBE_TOOL, { projectId: "proj_2" });+ await projects.deleteProject("proj_2");+ running.shift()?.(SPEECH);+ await first;++ const result = await second;+ expect(result.isError).toBe(true);+ expect(result.content[0]).toMatchObject({ text: expect.stringContaining("deleted") });+ expect(transcribe).toHaveBeenCalledTimes(1);+ });+it("survives a restore to a checkpoint made before it", async () => {await projects.saveProject(fixtureDocument("proj_1"));const { run } = runnerWith(async () => SPEECH);