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(stt): log a startup death once, and name the sentence's real author
EtienneLescotad1854ded5b9
diff --git a/electron/stt/whisperServer.test.ts b/electron/stt/whisperServer.test.tsindex c3637c978..dc401a6d8 100644--- a/electron/stt/whisperServer.test.ts+++ b/electron/stt/whisperServer.test.ts@@ -498,6 +498,111 @@ describe("WhisperServerManager", () => {}});+ it("logs a startup death once, and keeps the more specific reason on status", async () => {+ // ponytail: the `exit` listener and the startup catch both answer for the+ // SAME death — the listener because the child died, the catch because the+ // promise that death rejects is the one `launch` awaits. Two `[stt]` lines+ // worded differently for one event teaches a reader to skim the log. The+ // field still takes the second, more specific message: that is what+ // `status.lastError` is for.+ const fs = await import("node:fs/promises");+ const { spawn } = await import("node:child_process");+ const dir = await mkdtemp(path.join(tmpdir(), "whisper-one-log-"));+ const errors = vi.spyOn(console, "error").mockImplementation(() => undefined);+ try {+ const modelPath = path.join(dir, "ggml-small-q8_0.bin");+ const fakeBinaryPath = path.join(+ dir,+ process.platform === "win32" ? "whisper-stt-server.exe" : "whisper-stt-server",+ );+ await fs.writeFile(modelPath, "dummy-ggml");+ await fs.writeFile(fakeBinaryPath, "x", { mode: 0o755 });++ const child = Object.assign(new EventEmitter(), {+ stdout: new EventEmitter(),+ stderr: new EventEmitter(),+ pid: 4321,+ kill: vi.fn(),+ });+ vi.mocked(spawn).mockImplementationOnce(() => {+ // No GPU vocabulary in the tail, so this death is NOT read as a GPU+ // startup failure and nothing retries on CPU — the throw is the result.+ queueMicrotask(() => {+ child.stderr.emit("data", Buffer.from("could not open model"));+ child.emit("exit", 3);+ });+ return child as never;+ });++ const mgr = new WhisperServerManager();+ await expect(+ mgr.start({ modelPath, binaryPath: fakeBinaryPath, backend: "whispercpp-cpu" }),+ ).rejects.toThrow(/exited during startup/);++ const stt = errors.mock.calls.map(String).filter((line) => line.startsWith("[stt] "));+ expect(stt, `lignes [stt] émises : ${JSON.stringify(stt)}`).toHaveLength(1);+ // The one that survives is the listener's — the catch is the second voice.+ expect(stt[0]).toMatch(/exited with code 3/);+ // …and the field keeps the more specific of the two.+ expect(mgr.status.lastError).toMatch(/exited during startup \(3\)/);+ } finally {+ errors.mockRestore();+ await rm(dir, { recursive: true, force: true });+ }+ });++ it("logs a readiness timeout, which no exit listener would ever see", async () => {+ // The other direction: nothing exits, so the startup catch is the ONLY voice+ // on this failure and must not be silenced by the de-duplication above. Same+ // fake-timer shape as the probe test further up — the helper is alive and+ // simply never answers ok.+ const fs = await import("node:fs/promises");+ const { spawn } = await import("node:child_process");+ const dir = await mkdtemp(path.join(tmpdir(), "whisper-timeout-log-"));+ const errors = vi.spyOn(console, "error").mockImplementation(() => undefined);+ try {+ const modelPath = path.join(dir, "ggml-small-q8_0.bin");+ const fakeBinaryPath = path.join(+ dir,+ process.platform === "win32" ? "whisper-stt-server.exe" : "whisper-stt-server",+ );+ await fs.writeFile(modelPath, "dummy-ggml");+ await fs.writeFile(fakeBinaryPath, "x", { mode: 0o755 });++ const child = Object.assign(new EventEmitter(), {+ stdout: new EventEmitter(),+ stderr: new EventEmitter(),+ pid: 4322,+ kill: vi.fn(() => {+ queueMicrotask(() => child.emit("exit", 0));+ return true;+ }),+ });+ vi.mocked(spawn).mockImplementationOnce(() => child as never);+ vi.stubGlobal("fetch", vi.fn().mockResolvedValue({ ok: false } as Response));+ vi.useFakeTimers();++ const mgr = new WhisperServerManager();+ const started = mgr.start({+ modelPath,+ binaryPath: fakeBinaryPath,+ backend: "whispercpp-cpu",+ });+ const assertion = expect(started).rejects.toThrow(/did not respond within/);+ await vi.advanceTimersByTimeAsync(31_000);+ await assertion;++ const stt = errors.mock.calls.map(String).filter((line) => line.startsWith("[stt] "));+ expect(stt, `lignes [stt] émises : ${JSON.stringify(stt)}`).toHaveLength(1);+ expect(stt[0]).toMatch(/did not respond within/);+ } finally {+ vi.useRealTimers();+ vi.unstubAllGlobals();+ errors.mockRestore();+ await rm(dir, { recursive: true, force: true });+ }+ });+it("refuses to start when the model file is missing", async () => {const fs = await import("node:fs/promises");const dir = await mkdtemp(path.join(tmpdir(), "whisper-no-model-"));diff --git a/electron/stt/whisperServer.ts b/electron/stt/whisperServer.tsindex 03a8f680b..132e60b91 100644--- a/electron/stt/whisperServer.ts+++ b/electron/stt/whisperServer.ts@@ -173,15 +173,27 @@ export class WhisperServerManager {throw new Error(`whisper-stt-server at ${baseUrl} did not respond within ${timeoutMs}ms`);}- private recordError(message: string): void {+ /**+ * Record a failure on `lastError`, and — unless `log` says otherwise — put it+ * in the main-process log.+ *+ * ponytail: to the log, not only to the field. `lastError` is read by the+ * `status` getter, which nothing on the transcribe path calls, so a missing or+ * non-executable helper used to leave no trace anywhere in the main process+ * and the only way to find out was to instrument the code. The renderer does+ * toast the failure; a packaged build still needs a line someone can point at+ * in a bug report.+ *+ * `log: false` exists because a death during startup reaches this method+ * TWICE — once from the `exit` listener, once from the startup catch that the+ * same exit rejects. Both writes are wanted (the second message is the more+ * specific of the two, and it is what `status` should end up holding), but two+ * differently-worded lines for one event is the kind of noise that makes a+ * reader doubt the log rather than trust it.+ */+ private recordError(message: string, { log = true }: { log?: boolean } = {}): void {this.lastError = message;- // ponytail: also to the log, not only to the field. `lastError` is read by- // the `status` getter, which nothing on the transcribe path calls — so a- // missing or non-executable helper used to leave no trace anywhere in the- // main process, and the only way to find out was to instrument the code.- // The renderer does toast the failure; a packaged build still needs a line- // someone can point at in a bug report.- console.error(`[stt] ${message}`);+ if (log) console.error(`[stt] ${message}`);}/** True when a process is alive and a model is loaded. */@@ -317,8 +329,14 @@ export class WhisperServerManager {]);} catch (err) {const message = err instanceof Error ? err.message : String(err);+ // ponytail: read BEFORE `stop()`, which nulls it either way. The `exit`+ // listener clears `this.process` as it records, so `!== child` here means+ // the death has already been logged and this catch is the second voice on+ // it. A readiness TIMEOUT leaves the child in place and is logged from+ // here, which is the only place that sees it at all.+ const alreadyLogged = this.process !== child;await this.stop();- this.recordError(message);+ this.recordError(message, { log: !alreadyLogged });throw new Error(message);}return { port, backend: activeBackend };diff --git a/technical-documentation/testing/manual-e2e-checklist.md b/technical-documentation/testing/manual-e2e-checklist.mdindex 94b8c92c8..4be4b4b0a 100644--- a/technical-documentation/testing/manual-e2e-checklist.md+++ b/technical-documentation/testing/manual-e2e-checklist.md@@ -194,7 +194,7 @@ Zoom, speed, annotation, and full-camera regions are stored against a clip in th### Local transcription and captions — v1.8.0- [ ] Confirm the transcript pane states that transcription runs locally and that no upload occurs when it is started.-- [ ] With the Whisper helper binary absent, activate the transcribe action and confirm the UI reports why nothing happened, and that the main-process log carries a matching `[stt]` line. The failure now reaches a toast (`transcriptionStore.ts`) and the log (`whisperServer.ts`), but the text it shows is the helper's own — a sentence about a build script, which is not an answer for someone running a packaged build. Verify against a build whose helper was deliberately not packaged, not only against a working one.+- [ ] With the Whisper helper binary absent, activate the transcribe action and confirm the UI reports why nothing happened, and that the main-process log carries exactly one matching `[stt]` line. The failure now reaches a toast (`transcriptionStore.ts`) and the log (`whisperServer.ts`), but the sentence shown is one the app writes for itself — `whisper-stt-server binary not found; build it via scripts/build-whisper-stt.sh`, produced before any helper process starts — so it points a packaged-build user at a script they do not have. Helper stderr is a separate source, and only ever for a helper that did start. Verify against a build whose helper was deliberately not packaged, not only against a working one.- [ ] Run transcription in the packaged build and confirm the model is fetched or reused without an error about a missing cache directory.- [ ] Confirm a second transcription reuses the cached model instead of downloading it again.- [ ] Confirm the completed transcript reports the detected language on the media asset card.diff --git a/workbench/l0/quality.wb.ts b/workbench/l0/quality.wb.tsindex 2810f9897..bc86390df 100644--- a/workbench/l0/quality.wb.ts+++ b/workbench/l0/quality.wb.ts@@ -435,6 +435,11 @@ describe("zoomPlacement — précision ET rappel, jamais une note unique", () =>// un défaut de placement.const placement = zoomPlacement(document, [{ startSec: 8, endSec: 15, label: "zone" }]);expect(placement.zoomSec).toBeCloseTo(7, 4);+ // Les deux termes séparément, pas seulement leur rapport : un rapport se lit+ // juste quand numérateur ET dénominateur double-comptent de concert. Ici+ // `zoomSec` suffirait à l'attraper, mais le lecteur ne devrait pas avoir à+ // le déduire d'un ratio pour savoir ce que l'oracle compte.+ expect(placement.onZoneSec).toBeCloseTo(7, 4);expect(placement.precision).toBeCloseTo(1, 4);});