Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix: give Audio Upload its own self-hosted transcription URL (#2051)

Hill Patela114ddb7e917
diff --git a/src/components/notes/UploadAudioView.tsx b/src/components/notes/UploadAudioView.tsx
index 588033ae5..162255b3e 100644
--- a/src/components/notes/UploadAudioView.tsx
+++ b/src/components/notes/UploadAudioView.tsx
@@ -293,6 +293,8 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa
cloudTranscriptionBaseUrl,
cloudTranscriptionMode,
transcriptionMode,
+ remoteTranscriptionUrl,
+ remoteTranscriptionModel,
} = useSettingsStore(
useShallow((settings) =>
selectResolvedUploadTranscription(selectPolicyEffectiveSettings(settings, policyState))
@@ -300,9 +302,6 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa
);
const uploadAllowedByPolicy = useTranscriptionContextAllowed("upload");
- const remoteTranscriptionUrl = useSettingsStore((s) => s.remoteTranscriptionUrl);
- const remoteTranscriptionModel = useSettingsStore((s) => s.remoteTranscriptionModel);
-
const setUploadTranscriptionMode = useSettingsStore((s) => s.setUploadTranscriptionMode);
const setUploadCloudTranscriptionMode = useSettingsStore(
(s) => s.setUploadCloudTranscriptionMode
diff --git a/src/components/settings/UploadSettings.tsx b/src/components/settings/UploadSettings.tsx
index 237c889d3..295bc0df2 100644
--- a/src/components/settings/UploadSettings.tsx
+++ b/src/components/settings/UploadSettings.tsx
@@ -40,10 +40,10 @@ export function UploadTranscriptionPanel() {
setUploadCloudTranscriptionBaseUrl,
setUploadCloudTranscriptionMode,
setEnterpriseTranscriptionSetupMode,
- remoteTranscriptionUrl,
- setRemoteTranscriptionUrl,
- remoteTranscriptionModel,
- setRemoteTranscriptionModel,
+ uploadRemoteTranscriptionUrl,
+ setUploadRemoteTranscriptionUrl,
+ uploadRemoteTranscriptionModel,
+ setUploadRemoteTranscriptionModel,
} = useSettingsStore();
const {
modes: transcriptionModes,
@@ -166,10 +166,10 @@ export function UploadTranscriptionPanel() {
{effectiveTranscriptionMode === "self-hosted" && (
<SelfHostedPanel
service="transcription"
- url={remoteTranscriptionUrl}
- onUrlChange={setRemoteTranscriptionUrl}
- model={remoteTranscriptionModel}
- onModelChange={setRemoteTranscriptionModel}
+ url={uploadRemoteTranscriptionUrl}
+ onUrlChange={setUploadRemoteTranscriptionUrl}
+ model={uploadRemoteTranscriptionModel}
+ onModelChange={setUploadRemoteTranscriptionModel}
/>
)}
</div>
diff --git a/src/stores/settingsStore.ts b/src/stores/settingsStore.ts
index 56abf7e9e..7f0104d87 100644
--- a/src/stores/settingsStore.ts
+++ b/src/stores/settingsStore.ts
@@ -509,6 +509,29 @@ function migrateUploadTranscription() {
migrateUploadTranscription();
+// One-time seed of the upload self-hosted server. These keys arrived after
+// migrateUploadTranscription() had latched (1.7.3), and until then the Upload
+// tab edited dictation's server (#2049), so copy the values a profile has been
+// uploading with; the tab then shows the server it actually uses. Fresh installs
+// have nothing to copy, and an upload key the user already set is kept.
+const UPLOAD_SELF_HOSTED_PAIRS: ReadonlyArray<[string, string]> = [
+ ["remoteTranscriptionUrl", "uploadRemoteTranscriptionUrl"],
+ ["remoteTranscriptionModel", "uploadRemoteTranscriptionModel"],
+];
+
+function migrateUploadSelfHosted() {
+ if (!isBrowser) return;
+ if (localStorage.getItem("uploadSelfHostedMigrated") === "true") return;
+ for (const [src, dst] of UPLOAD_SELF_HOSTED_PAIRS) {
+ if (localStorage.getItem(dst) !== null) continue;
+ const v = localStorage.getItem(src);
+ if (v !== null) localStorage.setItem(dst, v);
+ }
+ localStorage.setItem("uploadSelfHostedMigrated", "true");
+}
+
+migrateUploadSelfHosted();
+
// Dictation and upload render `*TranscriptionMode` in their picker but route on
// `*UseLocalWhisper` (audioManager, fileTranscription) and `*CloudTranscriptionMode`
// (the `isOpenWhisprCloud` test), so routing can disagree with what the user sees
@@ -921,6 +944,8 @@ export interface SettingsState
uploadCloudTranscriptionModel: string;
uploadCloudTranscriptionBaseUrl: string;
uploadCloudTranscriptionMode: string;
+ uploadRemoteTranscriptionUrl: string;
+ uploadRemoteTranscriptionModel: string;
/** Last model used per scope+provider (`"<context>:<providerId>"`), so switching providers restores it. */
transcriptionModelByProvider: Record<string, string>;
@@ -1024,6 +1049,8 @@ export interface SettingsState
setUploadCloudTranscriptionModel: (value: string) => void;
setUploadCloudTranscriptionBaseUrl: (value: string) => void;
setUploadCloudTranscriptionMode: (value: string) => void;
+ setUploadRemoteTranscriptionUrl: (value: string) => void;
+ setUploadRemoteTranscriptionModel: (value: string) => void;
setNoteFormattingMode: (mode: InferenceMode) => void;
setNoteFormattingProvider: (value: string) => void;
@@ -1725,6 +1752,8 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({
uploadCloudTranscriptionModel: readString("uploadCloudTranscriptionModel", ""),
uploadCloudTranscriptionBaseUrl: readString("uploadCloudTranscriptionBaseUrl", ""),
uploadCloudTranscriptionMode: readString("uploadCloudTranscriptionMode", ""),
+ uploadRemoteTranscriptionUrl: readString("uploadRemoteTranscriptionUrl", ""),
+ uploadRemoteTranscriptionModel: readString("uploadRemoteTranscriptionModel", ""),
noteFormattingMode: (() => {
const v = readString("noteFormattingMode", "openwhispr");
@@ -1819,6 +1848,8 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({
setUploadCloudTranscriptionModel: createStringSetter("uploadCloudTranscriptionModel"),
setUploadCloudTranscriptionBaseUrl: createStringSetter("uploadCloudTranscriptionBaseUrl"),
setUploadCloudTranscriptionMode: createStringSetter("uploadCloudTranscriptionMode"),
+ setUploadRemoteTranscriptionUrl: createStringSetter("uploadRemoteTranscriptionUrl"),
+ setUploadRemoteTranscriptionModel: createStringSetter("uploadRemoteTranscriptionModel"),
setNoteFormattingMode: createStringSetter("noteFormattingMode") as (mode: InferenceMode) => void,
setNoteFormattingProvider: createStringSetter("noteFormattingProvider"),
@@ -2753,6 +2784,8 @@ export interface ResolvedUploadTranscription {
cloudTranscriptionBaseUrl: string;
cloudTranscriptionMode: string;
transcriptionMode: InferenceMode;
+ remoteTranscriptionUrl: string;
+ remoteTranscriptionModel: string;
}
// Audio upload is batch (not streaming), so unset values fall back to the base
@@ -2760,6 +2793,9 @@ export interface ResolvedUploadTranscription {
// A realtime-only dictation provider is the exception: it has no batch route, so
// inheriting it would fail every upload closed. Uploads take the default provider
// instead, and the dictation model stays behind with the provider it belongs to.
+// The self-hosted server is the exception the other way: it never inherits, so
+// uploads go only to the server the Upload tab shows (#2049).
+// migrateUploadSelfHosted() seeds it once for profiles from before the tab had its own.
export const selectResolvedUploadTranscription = (
state: SettingsState
): ResolvedUploadTranscription => {
@@ -2782,6 +2818,8 @@ export const selectResolvedUploadTranscription = (
state.uploadCloudTranscriptionBaseUrl || state.cloudTranscriptionBaseUrl || "",
cloudTranscriptionMode: state.uploadCloudTranscriptionMode || state.cloudTranscriptionMode,
transcriptionMode: state.uploadTranscriptionMode,
+ remoteTranscriptionUrl: state.uploadRemoteTranscriptionUrl,
+ remoteTranscriptionModel: state.uploadRemoteTranscriptionModel,
};
};
diff --git a/test/helpers/settingsStoreUploadTranscription.test.js b/test/helpers/settingsStoreUploadTranscription.test.js
index 4c8f7c0a5..8b7cbca8a 100644
--- a/test/helpers/settingsStoreUploadTranscription.test.js
+++ b/test/helpers/settingsStoreUploadTranscription.test.js
@@ -1,5 +1,8 @@
const test = require("node:test");
const assert = require("node:assert/strict");
+const path = require("node:path");
+const React = require("react");
+const { renderToStaticMarkup } = require("react-dom/server");
const { createRendererServer, installBrowserGlobals } = require("../lib/rendererTestHarness");
// Upload inherits unset values from dictation, but a realtime-only dictation
@@ -52,3 +55,107 @@ test("upload transcription never inherits a realtime-only dictation provider", a
assert.equal(inherited.cloudTranscriptionProvider, "groq");
assert.equal(inherited.cloudTranscriptionModel, "whisper-large-v3-turbo");
});
+
+const DICTATION_URL = "http://192.168.11.83:8090";
+const DICTATION_MODEL = "large-v3";
+const UPLOAD_URL = "http://192.168.11.84:8090";
+
+// A self-hosted dictation profile from before Audio Upload had its own server.
+const SELF_HOSTED_DICTATION = {
+ transcriptionMode: "self-hosted",
+ uploadTranscriptionMode: "self-hosted",
+ remoteTranscriptionUrl: DICTATION_URL,
+ remoteTranscriptionModel: DICTATION_MODEL,
+};
+// The same profile after ≥1.7.3: the upload copy latched before the upload
+// self-hosted keys existed, so migrateUploadTranscription() can never seed them.
+const LATCHED_SELF_HOSTED = { ...SELF_HOSTED_DICTATION, uploadTranscriptionMigrated: "true" };
+
+// #2049: the Upload tab's Server URL and Model wrote dictation's keys, so the
+// two tabs could not point at different servers.
+test("audio upload has its own self-hosted server", async (t) => {
+ const { storage } = installBrowserGlobals(t);
+ const vite = await createRendererServer(t, {
+ cachePrefix: "openwhispr-upload-self-hosted-test-",
+ resolveAlias: { "@": path.resolve(__dirname, "../../src") },
+ });
+ // Migrations run once per module evaluation, so every case re-evaluates the store.
+ const load = async (seed) => {
+ storage.clear();
+ for (const [key, value] of Object.entries(seed)) storage.setItem(key, value);
+ vite.moduleGraph.invalidateAll();
+ const mod = await vite.ssrLoadModule("/stores/settingsStore.ts");
+ return { mod, store: mod.useSettingsStore };
+ };
+ const resolved = (mod, store) => mod.selectResolvedUploadTranscription(store.getState());
+
+ await t.test(
+ "uploads use only the Upload tab's URL and model, and never write dictation's",
+ async () => {
+ const { mod, store } = await load({});
+ store.getState().setRemoteTranscriptionUrl(DICTATION_URL);
+ store.getState().setRemoteTranscriptionModel(DICTATION_MODEL);
+ // An empty Upload tab must not send uploads to dictation's server.
+ assert.equal(resolved(mod, store).remoteTranscriptionUrl, "");
+ assert.equal(resolved(mod, store).remoteTranscriptionModel, "");
+
+ store.getState().setUploadRemoteTranscriptionUrl(UPLOAD_URL);
+ store.getState().setUploadRemoteTranscriptionModel("whisper-diarize");
+ const state = store.getState();
+ assert.equal(state.remoteTranscriptionUrl, DICTATION_URL, "dictation URL untouched");
+ assert.equal(state.remoteTranscriptionModel, DICTATION_MODEL, "dictation model untouched");
+ assert.equal(resolved(mod, store).remoteTranscriptionUrl, UPLOAD_URL);
+ assert.equal(resolved(mod, store).remoteTranscriptionModel, "whisper-diarize");
+ }
+ );
+
+ await t.test("an existing self-hosted profile keeps its server on upgrade", async () => {
+ for (const [label, seed] of [
+ ["pre-1.7.3", SELF_HOSTED_DICTATION],
+ ["latched ≥1.7.3", LATCHED_SELF_HOSTED],
+ ]) {
+ const { mod, store } = await load(seed);
+ const state = store.getState();
+ assert.equal(state.uploadRemoteTranscriptionUrl, DICTATION_URL, `${label}: URL shown`);
+ assert.equal(state.uploadRemoteTranscriptionModel, DICTATION_MODEL, `${label}: model shown`);
+ assert.equal(
+ resolved(mod, store).remoteTranscriptionUrl,
+ DICTATION_URL,
+ `${label}: URL used`
+ );
+ assert.equal(storage.getItem("uploadSelfHostedMigrated"), "true", `${label}: latched`);
+ }
+ });
+
+ await t.test("the seed copies only keys the upload context lacks, and only once", async () => {
+ const kept = await load({ ...LATCHED_SELF_HOSTED, uploadRemoteTranscriptionUrl: UPLOAD_URL });
+ assert.equal(kept.store.getState().uploadRemoteTranscriptionUrl, UPLOAD_URL, "not overwritten");
+ assert.equal(kept.store.getState().uploadRemoteTranscriptionModel, DICTATION_MODEL);
+
+ const done = await load({ ...LATCHED_SELF_HOSTED, uploadSelfHostedMigrated: "true" });
+ assert.equal(storage.getItem("uploadRemoteTranscriptionUrl"), null, "no second copy");
+ assert.equal(storage.getItem("uploadRemoteTranscriptionModel"), null, "no second model copy");
+ assert.equal(done.store.getState().uploadRemoteTranscriptionUrl, "");
+
+ await load({});
+ assert.equal(storage.getItem("uploadSelfHostedMigrated"), "true", "fresh install latches");
+ assert.equal(storage.getItem("uploadRemoteTranscriptionUrl"), null, "nothing to copy");
+ });
+
+ await t.test("the Upload tab shows its own server, not dictation's", async () => {
+ await load({
+ ...LATCHED_SELF_HOSTED,
+ uploadRemoteTranscriptionUrl: UPLOAD_URL,
+ uploadRemoteTranscriptionModel: "whisper-diarize",
+ });
+ const { UploadTranscriptionPanel } = await vite.ssrLoadModule(
+ "/components/settings/UploadSettings.tsx"
+ );
+ const html = renderToStaticMarkup(React.createElement(UploadTranscriptionPanel));
+ assert.ok(html.includes(UPLOAD_URL) && html.includes("whisper-diarize"), "upload server shown");
+ assert.ok(
+ !html.includes(DICTATION_URL) && !html.includes(DICTATION_MODEL),
+ "dictation's server hidden"
+ );
+ });
+});