From 7e9c7645e3b3874573d643d19f28afeee8809370 Mon Sep 17 00:00:00 2001 From: Christian Bager Bach Houmann Date: Fri, 20 Nov 2026 22:24:33 +0100 Subject: [PATCH 1/3] test(transcription): run from audio offline with the user's own server Fails until the command follows the Transcript panel's offline rule. --- src/commands.test.ts | 52 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/src/commands.test.ts b/src/commands.test.ts index 71bd29c9..98e065e6 100644 --- a/src/commands.test.ts +++ b/src/commands.test.ts @@ -1206,18 +1206,50 @@ describe("Reorder Queue", () => { }); describe("Transcribe", () => { + /** Loads the plugin online, and returns a check and a run for each command id. */ + async function transcribeCommands(data: Record) { + const online = vi.spyOn(navigator, "onLine", "get").mockReturnValue(true); + const { commands } = await loadPlugin(data); + const command = (id: string) => commands.find((each) => each.id === id)!; + return { + available: (id: string) => command(id).checkCallback!(true), + run: (id: string) => command(id).checkCallback!(false), + goOffline: () => { + online.mockReturnValue(false); + window.dispatchEvent(new Event("offline")); + }, + }; + } + it.each(["podnotes-transcribe", "podnotes-transcribe-audio"])( - "%s is available for an audio episode only while online", + "%s is available for an audio episode only while online with a hosted provider", async (id) => { - const online = vi.spyOn(navigator, "onLine", "get").mockReturnValue(true); - const { commands } = await loadPlugin(playing); - const available = () => - commands.find((command) => command.id === id)!.checkCallback!(true); - - expect(available()).toBe(true); - online.mockReturnValue(false); - window.dispatchEvent(new Event("offline")); - expect(available()).toBe(false); + const { available, goOffline } = await transcribeCommands(playing); + + expect(available(id)).toBe(true); + goOffline(); + expect(available(id)).toBe(false); }, ); + + it("runs from audio offline with the user's own server, as the Transcript panel does", async () => { + // No model yet, so the run stops at its Notice before any request. + const { available, run, goOffline } = await transcribeCommands({ + ...playing, + transcript: { + provider: "openai-compatible", + serverUrl: "http://192.168.1.20:8000/v1", + model: "", + }, + }); + goOffline(); + + // The plain command looks for the feed's published transcript first, which needs the network. + expect(available("podnotes-transcribe")).toBe(false); + expect(available("podnotes-transcribe-audio")).toBe(true); + run("podnotes-transcribe-audio"); + expect(said()).toEqual([ + "Enter a model for your OpenAI-compatible server in the transcript settings.", + ]); + }); }); From e060f81858b5122b056031e7bc55d60aa9213b8c Mon Sep 17 00:00:00 2001 From: Christian Bager Bach Houmann Date: Fri, 20 Nov 2026 22:32:17 +0100 Subject: [PATCH 2/3] fix(transcription): offer "from audio" offline with the user's own server The Transcript panel's "Transcribe with your server" button stays enabled offline, but "Transcribe current episode from audio" was hidden, so a server on the same computer could transcribe from the panel but not from the command palette. The command runs the same audio transcription as the button, so it now follows the button's rule: available offline when the provider is the user's own server, whatever its address. "Transcribe current episode" stays online-only. It first looks up and fetches the feed's published transcript, which needs the network. --- src/commands.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index 5af55b07..d4eab554 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -8,6 +8,7 @@ import downloadEpisodeWithNotice from "src/downloadEpisode"; import getUniversalPodcastLink from "src/getUniversalPodcastLink"; import { getEpisodeMediaType } from "src/utility/mediaType"; import { TRANSCRIBE_FROM_AUDIO_COMMAND } from "src/services/TranscriptionService"; +import { transcriptionChoice } from "src/services/transcription"; import { notifyPrivateFeedUnavailable } from "src/services/privateFeeds"; import type PodNotes from "src/main"; @@ -280,10 +281,14 @@ export function registerCommands(plugin: PodNotes): void { }, }); - const canTranscribe = () => - get(plugin.online) && - !!plugin.api.podcast && - getEpisodeMediaType(plugin.api.podcast) === "audio"; + const playingAudio = () => + !!plugin.api.podcast && getEpisodeMediaType(plugin.api.podcast) === "audio"; + // The published transcript comes from the feed, so this command needs the network. + const canTranscribe = () => get(plugin.online) && playingAudio(); + // The user's own server can run on this computer, so offline it stays available, as the + // Transcript panel's button does. + const canTranscribeAudio = () => + (get(plugin.online) || !!transcriptionChoice(plugin.settings).server) && playingAudio(); plugin.addCommand({ id: "podnotes-transcribe", @@ -304,10 +309,10 @@ export function registerCommands(plugin: PodNotes): void { name: TRANSCRIBE_FROM_AUDIO_COMMAND, checkCallback: (checking) => { if (checking) { - return canTranscribe(); + return canTranscribeAudio(); } - if (canTranscribe()) { + if (canTranscribeAudio()) { plugin.getTranscriptionService().transcribeCurrentEpisodeFromAudio(); } }, From a91b15cdb10ddb75989368f1a5708c989597b965 Mon Sep 17 00:00:00 2001 From: Christian Bager Bach Houmann Date: Fri, 20 Nov 2026 22:32:34 +0100 Subject: [PATCH 3/3] build(size): raise both budgets by the 60 raw and 28 gzip bytes the offline audio command measures --- AGENTS.md | 2 +- scripts/size-baseline.md | 11 ++++++++++- scripts/size.mjs | 4 ++-- scripts/size.test.ts | 10 +++++----- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index ee4472f9..6706efba 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -63,7 +63,7 @@ svelte-check's native API path passes when a tsconfig matches no files, which `check:a11y` in temporary workspaces and requires it to fail on that case and when the native compiler cannot start. -After `npm run build`, `npm run size` enforces 334,091 raw bytes and 109,234 gzip bytes at level 9 for root `main.js` in the Test workflow's Build and sizes worker. `npm run size:data` reports a synthetic v2 stress library with 50 feeds, 2,000 history entries, and 200 saved episodes from frozen NPR metadata, including duplicated snapshots. Its 1.5 MB document goal is advisory. Pass an additive candidate JSON path to report optional-field overhead without changing existing data. In the isolated Obsidian instance, `npm run count:writes -- start`, `report`, and `stop` record writes to PodNotes' exact `data.json` path. Stop the recorder before stopping the instance, because recorder commands start a stopped instance; plugin reloads invalidate its counts. +After `npm run build`, `npm run size` enforces 334,151 raw bytes and 109,262 gzip bytes at level 9 for root `main.js` in the Test workflow's Build and sizes worker. `npm run size:data` reports a synthetic v2 stress library with 50 feeds, 2,000 history entries, and 200 saved episodes from frozen NPR metadata, including duplicated snapshots. Its 1.5 MB document goal is advisory. Pass an additive candidate JSON path to report optional-field overhead without changing existing data. In the isolated Obsidian instance, `npm run count:writes -- start`, `report`, and `stop` record writes to PodNotes' exact `data.json` path. Stop the recorder before stopping the instance, because recorder commands start a stopped instance; plugin reloads invalidate its counts. Before opening a PR or cutting a release, run the CI-equivalent checks locally: diff --git a/scripts/size-baseline.md b/scripts/size-baseline.md index 6fc18ca4..9d2bd799 100644 --- a/scripts/size-baseline.md +++ b/scripts/size-baseline.md @@ -12,7 +12,7 @@ main.js raw: 307131 bytes; budget 330000 bytes; 22869 bytes remaining main.js gzip (level 9): 97161 bytes; budget 100000 bytes; 2839 bytes remaining ``` -The gzip budget is now 109,234 bytes, and the raw budget 334,091. On 2026-10-14 it rose from 100,000 for +The gzip budget is now 109,262 bytes, and the raw budget 334,151. On 2026-10-14 it rose from 100,000 for the full player's Transcript panel, which the owner approved at about 1.9 KB and which measured 2,576 bytes. The coordinator set 103,000 to keep the panel's Find and Follow chip and to leave room for fixes in flight. The @@ -100,6 +100,15 @@ main.js raw: 334091 bytes; budget 334091 bytes; 0 bytes remaining main.js gzip (level 9): 109234 bytes; budget 109234 bytes; 0 bytes remaining ``` +On 2026-11-20 both rose for "Transcribe current episode from audio" offline with +the user's own server, as the Transcript panel's button already ran: from 334,091 +raw by 60 bytes, and from 109,234 gzip by 28 bytes. With it: + +```text +main.js raw: 334151 bytes; budget 334151 bytes; 0 bytes remaining +main.js gzip (level 9): 109262 bytes; budget 109262 bytes; 0 bytes remaining +``` + Gzip uses Node's `gzipSync` at level 9, without a filename or timestamp. Budgets use decimal bytes. The brief's 96,533-byte reference is unexplained. This report fixes the compressor instead of comparing compressed sizes across diff --git a/scripts/size.mjs b/scripts/size.mjs index c883ce78..101182c0 100644 --- a/scripts/size.mjs +++ b/scripts/size.mjs @@ -9,8 +9,8 @@ try { const bundle = readFileSync(path); if (!bundle.length) throw new Error(`${path} is empty. Run npm run build first.`); const measurements = [ - { name: "raw", bytes: bundle.length, budget: 334_091 }, - { name: "gzip (level 9)", bytes: gzipSync(bundle, { level: 9 }).length, budget: 109_234 }, + { name: "raw", bytes: bundle.length, budget: 334_151 }, + { name: "gzip (level 9)", bytes: gzipSync(bundle, { level: 9 }).length, budget: 109_262 }, ]; const rows = measurements.map(({ name, bytes, budget }) => { const overage = Math.max(0, bytes - budget); diff --git a/scripts/size.test.ts b/scripts/size.test.ts index 9ecc9e7f..944b7db3 100644 --- a/scripts/size.test.ts +++ b/scripts/size.test.ts @@ -20,19 +20,19 @@ function check(name: string, contents: string | Buffer) { describe("bundle budget CLI", () => { it("allows the raw budget boundary and rejects one extra byte", () => { - expect(check("boundary.js", "a".repeat(334_091)).status).toBe(0); - const result = check("over.js", "a".repeat(334_092)); + expect(check("boundary.js", "a".repeat(334_151)).status).toBe(0); + const result = check("over.js", "a".repeat(334_152)); expect(result.status).toBe(1); - expect(result.stdout).toContain("budget 334091 bytes; OVER by 1 bytes"); + expect(result.stdout).toContain("budget 334151 bytes; OVER by 1 bytes"); }); it("rejects gzip growth even when raw bytes fit", () => { const result = check("gzip.js", randomBytes(110_000)); expect(result.status).toBe(1); expect(result.stdout).toMatch( - /gzip \(level 9\): \d+ bytes; budget 109234 bytes; OVER by \d+ bytes/, + /gzip \(level 9\): \d+ bytes; budget 109262 bytes; OVER by \d+ bytes/, ); - expect(result.stdout).toContain("budget 334091 bytes; 224091 bytes remaining"); + expect(result.stdout).toContain("budget 334151 bytes; 224151 bytes remaining"); }); it("fails on absent or empty artifacts instead of reporting a small build", () => {