Skip to content

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

fix(notes): route self-hosted note formatting to its endpoint (#1156)

Stanislav Ochotnickýaf96ab7ae862
diff --git a/src/components/notes/PersonalNotesView.tsx b/src/components/notes/PersonalNotesView.tsx
index caf874e1c..c02e549bc 100644
--- a/src/components/notes/PersonalNotesView.tsx
+++ b/src/components/notes/PersonalNotesView.tsx
@@ -80,6 +80,7 @@ import {
} from "../../stores/meetingRecordingStore";
import { useNotesOnboarding } from "../../hooks/useNotesOnboarding";
import NotesOnboarding from "./NotesOnboarding";
+import { isRegenerableNoteTitle } from "../../helpers/regenerableNoteTitle";
const FOLDER_INPUT_CLASS =
"w-full h-6 bg-foreground/5 dark:bg-white/5 rounded px-2 text-xs text-foreground outline-none border border-primary/30 focus:border-primary/50";
@@ -1017,9 +1018,15 @@ export default function PersonalNotesView({
isCloudMode,
modelId: effectiveModelId,
isMeetingNote,
- allowTitleGeneration:
- !editorNote.title.trim() ||
- editorNote.title === t("notes.list.untitledNote"),
+ allowTitleGeneration: isRegenerableNoteTitle(
+ editorNote.title,
+ [
+ t("notes.list.untitledNote"),
+ t("notes.list.newNote"),
+ t("notes.sidebar.newNote"),
+ ],
+ calendarEventName
+ ),
}
);
}}
diff --git a/src/helpers/noteFormattingOverrides.js b/src/helpers/noteFormattingOverrides.js
new file mode 100644
index 000000000..1b8e62edd
--- /dev/null
+++ b/src/helpers/noteFormattingOverrides.js
@@ -0,0 +1,33 @@
+// Provider overrides for note-formatting ReasoningService.processText calls.
+// Self-hosted must forward remoteUrl as lanUrl — without it, processText
+// guesses the provider from the model and can silently hit a cloud API.
+export function buildNoteFormattingOverrides(noteFormatting, isCloudMode, customApiKey) {
+ if (isCloudMode) {
+ return {
+ provider: "openwhispr",
+ baseUrl: undefined,
+ customApiKey: undefined,
+ lanUrl: undefined,
+ };
+ }
+
+ const mode = noteFormatting?.mode;
+
+ if (mode === "self-hosted") {
+ return {
+ provider: undefined,
+ baseUrl: undefined,
+ customApiKey: customApiKey || undefined,
+ lanUrl: noteFormatting?.remoteUrl || undefined,
+ };
+ }
+
+ const provider = mode === "providers" ? noteFormatting?.provider || undefined : undefined;
+ const isCustom = provider === "custom";
+ return {
+ provider,
+ baseUrl: isCustom ? noteFormatting?.cloudBaseUrl || undefined : undefined,
+ customApiKey: isCustom ? customApiKey || undefined : undefined,
+ lanUrl: undefined,
+ };
+}
diff --git a/src/helpers/regenerableNoteTitle.js b/src/helpers/regenerableNoteTitle.js
new file mode 100644
index 000000000..b22de23f1
--- /dev/null
+++ b/src/helpers/regenerableNoteTitle.js
@@ -0,0 +1,18 @@
+// A title may be (re)generated only while it is still a placeholder default
+// (localized labels plus the English literals meetingDetectionEngine.js stamps
+// regardless of locale) or the unedited calendar event summary — never after
+// the user typed their own.
+const BUILTIN_PLACEHOLDERS = ["untitled note", "untitled", "new note"];
+
+export function isRegenerableNoteTitle(title, placeholders = [], calendarEventName = null) {
+ const trimmed = typeof title === "string" ? title.trim() : "";
+ if (trimmed === "") return true;
+
+ const set = new Set(BUILTIN_PLACEHOLDERS);
+ for (const p of placeholders) {
+ if (typeof p === "string" && p.trim()) set.add(p.trim().toLowerCase());
+ }
+ if (set.has(trimmed.toLowerCase())) return true;
+
+ return typeof calendarEventName === "string" && calendarEventName.trim() === trimmed;
+}
diff --git a/src/helpers/stripThinking.js b/src/helpers/stripThinking.js
new file mode 100644
index 000000000..d108cc580
--- /dev/null
+++ b/src/helpers/stripThinking.js
@@ -0,0 +1,9 @@
+// Strip <think>...</think> blocks (including unterminated ones) emitted by
+// reasoning models. Mirrors the regex in localReasoningBridge.js.
+export function stripThinkingTags(text) {
+ if (typeof text !== "string") return text;
+ return text
+ .replace(/<think>[\s\S]*?<\/think>/g, "")
+ .replace(/<think>[\s\S]*$/, "")
+ .trim();
+}
diff --git a/src/hooks/useActionProcessing.ts b/src/hooks/useActionProcessing.ts
index 357461097..5de1b72e3 100644
--- a/src/hooks/useActionProcessing.ts
+++ b/src/hooks/useActionProcessing.ts
@@ -26,6 +26,7 @@ export function useActionProcessing(noteId: number | null) {
if (noteId == null) return;
runBackgroundAction(noteId, noteContent, contentHash, action, options, {
noModel: t("notes.actions.errors.noModel"),
+ noEndpoint: t("notes.actions.errors.noEndpoint"),
actionFailed: t("notes.actions.errors.actionFailed"),
});
},
diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json
index 100c2994e..a314f10ed 100644
--- a/src/locales/de/translation.json
+++ b/src/locales/de/translation.json
@@ -2219,6 +2219,7 @@
},
"errors": {
"noModel": "Kein KI-Modell ausgewählt. Konfigurieren Sie eins in den Einstellungen.",
+ "noEndpoint": "Keine URL für den selbst gehosteten Server festgelegt. Konfigurieren Sie eine in den Einstellungen.",
"actionFailed": "Aktion fehlgeschlagen"
}
},
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index 63b424acb..f68433c60 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -2434,6 +2434,7 @@
},
"errors": {
"noModel": "No AI model selected. Configure one in Settings.",
+ "noEndpoint": "No self-hosted server URL set. Configure one in Settings.",
"actionFailed": "Action failed"
}
},
diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json
index a29a39f96..a9a04defd 100644
--- a/src/locales/es/translation.json
+++ b/src/locales/es/translation.json
@@ -2267,6 +2267,7 @@
},
"errors": {
"noModel": "No hay modelo de IA seleccionado. Configura uno en Ajustes.",
+ "noEndpoint": "No hay URL del servidor autoalojado configurada. Configura una en Ajustes.",
"actionFailed": "La acción falló"
}
},
diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json
index e7238fe82..115f21d50 100644
--- a/src/locales/fr/translation.json
+++ b/src/locales/fr/translation.json
@@ -2346,6 +2346,7 @@
},
"errors": {
"noModel": "Aucun modèle IA sélectionné. Configurez-en un dans les Paramètres.",
+ "noEndpoint": "Aucune URL de serveur auto-hébergé définie. Configurez-en une dans les Paramètres.",
"actionFailed": "L'action a échoué"
}
},
diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json
index 382253a1e..8cb7a6a1a 100644
--- a/src/locales/it/translation.json
+++ b/src/locales/it/translation.json
@@ -2219,6 +2219,7 @@
},
"errors": {
"noModel": "Nessun modello IA selezionato. Configurane uno nelle Impostazioni.",
+ "noEndpoint": "Nessun URL del server self-hosted impostato. Configurane uno nelle Impostazioni.",
"actionFailed": "Azione non riuscita"
}
},
diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json
index c21cac917..ff74048dc 100644
--- a/src/locales/ja/translation.json
+++ b/src/locales/ja/translation.json
@@ -2073,6 +2073,7 @@
},
"errors": {
"noModel": "AIモデルが選択されていません。設定で構成してください。",
+ "noEndpoint": "セルフホストサーバーの URL が設定されていません。設定で構成してください。",
"actionFailed": "アクションに失敗しました"
}
},
diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json
index 7b66b6b59..ba0e3bc58 100644
--- a/src/locales/pt/translation.json
+++ b/src/locales/pt/translation.json
@@ -2219,6 +2219,7 @@
},
"errors": {
"noModel": "Nenhum modelo de IA selecionado. Configure um nas Configurações.",
+ "noEndpoint": "Nenhum URL de servidor auto-hospedado definido. Configure um nas Configurações.",
"actionFailed": "A ação falhou"
}
},
diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json
index 62d7d09f4..b3b08dcf0 100644
--- a/src/locales/ru/translation.json
+++ b/src/locales/ru/translation.json
@@ -2219,6 +2219,7 @@
},
"errors": {
"noModel": "Модель ИИ не выбрана. Настройте её в разделе Настройки.",
+ "noEndpoint": "URL собственного сервера не задан. Настройте его в разделе Настройки.",
"actionFailed": "Действие не выполнено"
}
},
diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json
index 94b2dfb2f..7dac49003 100644
--- a/src/locales/zh-CN/translation.json
+++ b/src/locales/zh-CN/translation.json
@@ -2214,6 +2214,7 @@
},
"errors": {
"noModel": "未选择 AI 模型。请在设置中配置。",
+ "noEndpoint": "未设置自托管服务器 URL。请在设置中配置。",
"actionFailed": "操作失败"
}
},
diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json
index 48f0d7ab3..a98dff946 100644
--- a/src/locales/zh-TW/translation.json
+++ b/src/locales/zh-TW/translation.json
@@ -2214,6 +2214,7 @@
},
"errors": {
"noModel": "未選擇 AI 模型。請在設定中進行配置。",
+ "noEndpoint": "未設定自架伺服器 URL。請在設定中進行配置。",
"actionFailed": "操作失敗"
}
},
diff --git a/src/services/ReasoningService.ts b/src/services/ReasoningService.ts
index 773fc4400..d87adbda7 100644
--- a/src/services/ReasoningService.ts
+++ b/src/services/ReasoningService.ts
@@ -13,6 +13,7 @@ import { API_ENDPOINTS, TOKEN_LIMITS, buildApiUrl, ensureV1Suffix } from "../con
import logger from "../utils/logger";
import { getSettings, isCloudCleanupMode } from "../stores/settingsStore";
import { wrapCleanupTranscript } from "../config/prompts";
+import { stripThinkingTags } from "../helpers/stripThinking.js";
import { streamText, stepCountIs } from "ai";
import { getAIModel } from "./ai/providers";
import { createEnterpriseChatModel } from "./ai/enterpriseChatModel";
@@ -276,7 +277,11 @@ class ReasoningService extends BaseReasoningService {
}
const choice = response.choices[0];
- const responseText = choice.message?.content?.trim() || "";
+ // Reasoning models leak <think> blocks into non-streamed output; strip them
+ // unless the user explicitly enabled thinking (same default as streaming).
+ const rawContent = choice.message?.content?.trim() || "";
+ const responseText =
+ config.disableThinking !== false ? stripThinkingTags(rawContent) : rawContent;
if (!responseText) {
logger.logReasoning(`${providerName.toUpperCase()}_EMPTY_RESPONSE`, {
diff --git a/src/stores/actionProcessingStore.ts b/src/stores/actionProcessingStore.ts
index b7a5f7847..b8d533571 100644
--- a/src/stores/actionProcessingStore.ts
+++ b/src/stores/actionProcessingStore.ts
@@ -3,6 +3,7 @@ import reasoningService from "../services/ReasoningService";
import { getSettings, selectResolvedNoteFormatting } from "./settingsStore";
import { appendDictionarySuffix } from "../config/prompts";
import { generateNoteTitle } from "../utils/generateTitle";
+import { buildNoteFormattingOverrides } from "../helpers/noteFormattingOverrides";
import type { ActionItem } from "../types/electron";
export type ActionProcessingStatus = "idle" | "processing" | "success";
@@ -94,6 +95,7 @@ export interface RunActionOptions {
export interface RunActionLabels {
noModel: string;
+ noEndpoint: string;
actionFailed: string;
}
@@ -117,6 +119,14 @@ export function runBackgroundAction(
return;
}
+ const settings = getSettings();
+ const noteFormatting = selectResolvedNoteFormatting(settings);
+ // A self-hosted config without a URL would fall through to a cloud provider.
+ if (!options.isCloudMode && noteFormatting.mode === "self-hosted" && !noteFormatting.remoteUrl) {
+ pushErrorEvent({ noteId, message: labels.noEndpoint });
+ return;
+ }
+
cancelledFlags.set(noteId, false);
processingFlags.set(noteId, true);
setNoteState(noteId, { status: "processing", actionName: action.name });
@@ -124,19 +134,11 @@ export function runBackgroundAction(
(async () => {
try {
const basePrompt = options.isMeetingNote ? MEETING_SYSTEM_PROMPT : BASE_SYSTEM_PROMPT;
- const settings = getSettings();
- const noteFormatting = selectResolvedNoteFormatting(settings);
- const provider = options.isCloudMode
- ? "openwhispr"
- : noteFormatting.mode === "providers"
- ? noteFormatting.provider || undefined
- : undefined;
- const isCustom = provider === "custom";
- const providerOverrides = {
- provider,
- baseUrl: isCustom ? noteFormatting.cloudBaseUrl || undefined : undefined,
- customApiKey: isCustom ? settings.noteFormattingCustomApiKey || undefined : undefined,
- };
+ const providerOverrides = buildNoteFormattingOverrides(
+ noteFormatting,
+ options.isCloudMode,
+ settings.noteFormattingCustomApiKey
+ );
const systemPrompt = appendDictionarySuffix(
basePrompt + action.prompt,
options.isMeetingNote ? settings.customDictionary : undefined,
diff --git a/src/utils/generateTitle.ts b/src/utils/generateTitle.ts
index b165dbb4d..f697e7a46 100644
--- a/src/utils/generateTitle.ts
+++ b/src/utils/generateTitle.ts
@@ -8,7 +8,7 @@ const TITLE_SYSTEM_PROMPT =
export async function generateNoteTitle(
text: string,
modelId: string,
- config?: Pick<ReasoningConfig, "provider" | "baseUrl" | "customApiKey">
+ config?: Pick<ReasoningConfig, "provider" | "baseUrl" | "customApiKey" | "lanUrl">
): Promise<string> {
try {
const raw = await reasoningService.processText(text.slice(0, 2000), modelId, null, {
diff --git a/test/helpers/noteFormattingOverrides.test.js b/test/helpers/noteFormattingOverrides.test.js
new file mode 100644
index 000000000..44067f4c3
--- /dev/null
+++ b/test/helpers/noteFormattingOverrides.test.js
@@ -0,0 +1,88 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+
+const load = () => import("../../src/helpers/noteFormattingOverrides.js");
+
+test("cloud mode routes to openwhispr and ignores self-hosted fields", async () => {
+ const { buildNoteFormattingOverrides } = await load();
+ const overrides = buildNoteFormattingOverrides(
+ { mode: "self-hosted", remoteUrl: "http://192.168.1.126:11434/v1" },
+ true,
+ "secret"
+ );
+ assert.deepEqual(overrides, {
+ provider: "openwhispr",
+ baseUrl: undefined,
+ customApiKey: undefined,
+ lanUrl: undefined,
+ });
+});
+
+test("self-hosted forwards remoteUrl as lanUrl and the api key (regression: was hitting OpenAI)", async () => {
+ const { buildNoteFormattingOverrides } = await load();
+ const overrides = buildNoteFormattingOverrides(
+ { mode: "self-hosted", remoteUrl: "http://192.168.1.126:11434/v1", model: "llama3" },
+ false,
+ "sk-local"
+ );
+ assert.equal(overrides.lanUrl, "http://192.168.1.126:11434/v1");
+ assert.equal(overrides.customApiKey, "sk-local");
+ assert.equal(overrides.provider, undefined);
+ assert.equal(overrides.baseUrl, undefined);
+});
+
+test("self-hosted with no key still routes via lanUrl", async () => {
+ const { buildNoteFormattingOverrides } = await load();
+ const overrides = buildNoteFormattingOverrides(
+ { mode: "self-hosted", remoteUrl: "http://host:8080/v1" },
+ false,
+ ""
+ );
+ assert.equal(overrides.lanUrl, "http://host:8080/v1");
+ assert.equal(overrides.customApiKey, undefined);
+});
+
+test("providers/custom forwards cloudBaseUrl as baseUrl and the key", async () => {
+ const { buildNoteFormattingOverrides } = await load();
+ const overrides = buildNoteFormattingOverrides(
+ { mode: "providers", provider: "custom", cloudBaseUrl: "https://api.example.com/v1" },
+ false,
+ "sk-custom"
+ );
+ assert.deepEqual(overrides, {
+ provider: "custom",
+ baseUrl: "https://api.example.com/v1",
+ customApiKey: "sk-custom",
+ lanUrl: undefined,
+ });
+});
+
+test("providers with a first-party cloud provider passes provider only, no key/baseUrl", async () => {
+ const { buildNoteFormattingOverrides } = await load();
+ const overrides = buildNoteFormattingOverrides(
+ { mode: "providers", provider: "anthropic" },
+ false,
+ "should-not-leak"
+ );
+ assert.deepEqual(overrides, {
+ provider: "anthropic",
+ baseUrl: undefined,
+ customApiKey: undefined,
+ lanUrl: undefined,
+ });
+});
+
+test("local mode passes no provider overrides (uses model-derived local provider)", async () => {
+ const { buildNoteFormattingOverrides } = await load();
+ const overrides = buildNoteFormattingOverrides(
+ { mode: "local", model: "qwen2.5-3b" },
+ false,
+ "irrelevant"
+ );
+ assert.deepEqual(overrides, {
+ provider: undefined,
+ baseUrl: undefined,
+ customApiKey: undefined,
+ lanUrl: undefined,
+ });
+});
diff --git a/test/helpers/regenerableNoteTitle.test.js b/test/helpers/regenerableNoteTitle.test.js
new file mode 100644
index 000000000..9b0280a67
--- /dev/null
+++ b/test/helpers/regenerableNoteTitle.test.js
@@ -0,0 +1,38 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+
+const load = () => import("../../src/helpers/regenerableNoteTitle.js");
+const LABELS = ["Untitled Note", "New note", "New note"]; // typical localized labels
+
+test("empty / whitespace title is regenerable", async () => {
+ const { isRegenerableNoteTitle } = await load();
+ assert.equal(isRegenerableNoteTitle("", LABELS), true);
+ assert.equal(isRegenerableNoteTitle(" ", LABELS), true);
+ assert.equal(isRegenerableNoteTitle(null, LABELS), true);
+});
+
+test("builtin English placeholders are regenerable regardless of locale labels", async () => {
+ const { isRegenerableNoteTitle } = await load();
+ assert.equal(isRegenerableNoteTitle("Untitled Note", []), true);
+ assert.equal(isRegenerableNoteTitle("New note", []), true);
+ assert.equal(isRegenerableNoteTitle("New Note", []), true); // case-insensitive
+ assert.equal(isRegenerableNoteTitle("untitled", []), true);
+});
+
+test("localized placeholder labels are regenerable", async () => {
+ const { isRegenerableNoteTitle } = await load();
+ assert.equal(isRegenerableNoteTitle("Nueva nota", ["Nueva nota", "Nota sin título"]), true);
+ assert.equal(isRegenerableNoteTitle("Neue Notiz", ["Neue Notiz"]), true);
+});
+
+test("unedited calendar event name is regenerable", async () => {
+ const { isRegenerableNoteTitle } = await load();
+ assert.equal(isRegenerableNoteTitle("Weekly Team Sync", LABELS, "Weekly Team Sync"), true);
+});
+
+test("a manually-typed title is preserved (not regenerable)", async () => {
+ const { isRegenerableNoteTitle } = await load();
+ assert.equal(isRegenerableNoteTitle("Q3 Roadmap Decisions", LABELS), false);
+ // even if a calendar event exists, a title that differs from it is user-set
+ assert.equal(isRegenerableNoteTitle("My own title", LABELS, "Weekly Team Sync"), false);
+});
diff --git a/test/helpers/stripThinking.test.js b/test/helpers/stripThinking.test.js
new file mode 100644
index 000000000..fdc3055b1
--- /dev/null
+++ b/test/helpers/stripThinking.test.js
@@ -0,0 +1,37 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+
+const load = () => import("../../src/helpers/stripThinking.js");
+
+test("removes a well-formed think block and keeps the answer", async () => {
+ const { stripThinkingTags } = await load();
+ assert.equal(
+ stripThinkingTags("<think>let me reason about this</think>Meeting Notes Summary"),
+ "Meeting Notes Summary"
+ );
+});
+
+test("removes an unterminated think block (streamed/cut off)", async () => {
+ const { stripThinkingTags } = await load();
+ assert.equal(stripThinkingTags("Title Here<think>reasoning that never closed"), "Title Here");
+});
+
+test("handles a title emitted before the think block", async () => {
+ const { stripThinkingTags } = await load();
+ assert.equal(stripThinkingTags("Quarterly Plan<think>...</think>"), "Quarterly Plan");
+});
+
+test("leaves plain text untouched", async () => {
+ const { stripThinkingTags } = await load();
+ assert.equal(stripThinkingTags("Project Kickoff Notes"), "Project Kickoff Notes");
+});
+
+test("a response that is only reasoning collapses to empty (title falls back)", async () => {
+ const { stripThinkingTags } = await load();
+ assert.equal(stripThinkingTags("<think>just thinking, no answer</think>"), "");
+});
+
+test("non-string input is returned as-is", async () => {
+ const { stripThinkingTags } = await load();
+ assert.equal(stripThinkingTags(undefined), undefined);
+});