Skip to content

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

feat(reasoning): self-hosted OpenAI-compatible parity + thinking-mode toggle (#708)

Gabriel Steind693be677bd6
diff --git a/.github/workflows/build-and-notarize.yml b/.github/workflows/build-and-notarize.yml
index 93376cc9d..5953be7ca 100644
--- a/.github/workflows/build-and-notarize.yml
+++ b/.github/workflows/build-and-notarize.yml
@@ -223,7 +223,7 @@ jobs:
uses: actions/cache@v4
with:
path: resources/bin
- key: macos-${{ matrix.arch }}-bin-${{ hashFiles('scripts/download-*.js', 'scripts/build-globe-listener.js', 'resources/macos-globe-listener.swift', 'scripts/build-macos-fast-paste.js', 'resources/macos-fast-paste.swift', 'scripts/build-media-remote.js', 'resources/macos-media-remote.swift') }}
+ key: macos-${{ matrix.arch }}-bin-${{ hashFiles('scripts/download-*.js', 'scripts/build-globe-listener.js', 'resources/macos-globe-listener.swift', 'scripts/build-macos-fast-paste.js', 'resources/macos-fast-paste.swift', 'scripts/build-media-remote.js', 'resources/macos-media-remote.swift', 'scripts/build-macos-audio-tap.js', 'resources/macos-audio-tap.swift') }}
- name: Compile macos-globe-listener binary
run: npm run compile:globe -- --arch ${{ matrix.arch }}
@@ -234,6 +234,9 @@ jobs:
- name: Compile macos-media-remote binary
run: npm run compile:media-remote -- --arch ${{ matrix.arch }}
+ - name: Compile macos-audio-tap binary
+ run: npm run compile:audio-tap -- --arch ${{ matrix.arch }}
+
- name: Download whisper.cpp binaries
run: node scripts/download-whisper-cpp.js --current --platform darwin --arch ${{ matrix.arch }}
env:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 671f3c4fa..84a0d88ba 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -208,7 +208,7 @@ jobs:
uses: actions/cache@v4
with:
path: resources/bin
- key: macos-${{ matrix.arch }}-bin-${{ hashFiles('scripts/download-*.js', 'scripts/build-globe-listener.js', 'resources/macos-globe-listener.swift', 'scripts/build-macos-fast-paste.js', 'resources/macos-fast-paste.swift', 'scripts/build-media-remote.js', 'resources/macos-media-remote.swift') }}
+ key: macos-${{ matrix.arch }}-bin-${{ hashFiles('scripts/download-*.js', 'scripts/build-globe-listener.js', 'resources/macos-globe-listener.swift', 'scripts/build-macos-fast-paste.js', 'resources/macos-fast-paste.swift', 'scripts/build-media-remote.js', 'resources/macos-media-remote.swift', 'scripts/build-macos-audio-tap.js', 'resources/macos-audio-tap.swift') }}
- name: Compile macos-globe-listener binary
run: npm run compile:globe -- --arch ${{ matrix.arch }}
@@ -219,6 +219,9 @@ jobs:
- name: Compile macos-media-remote binary
run: npm run compile:media-remote -- --arch ${{ matrix.arch }}
+ - name: Compile macos-audio-tap binary
+ run: npm run compile:audio-tap -- --arch ${{ matrix.arch }}
+
- name: Download whisper.cpp binaries
run: node scripts/download-whisper-cpp.js --current --platform darwin --arch ${{ matrix.arch }}
env:
diff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsx
index 724980716..dd2dbb3f5 100644
--- a/src/components/ControlPanel.tsx
+++ b/src/components/ControlPanel.tsx
@@ -451,7 +451,7 @@ export default function ControlPanel() {
try {
const [
{ default: ReasoningService },
- { getEffectiveCleanupModel, isCloudCleanupMode },
+ { getEffectiveCleanupModel, isCloudCleanupMode, getSettings },
] = await Promise.all([
import("../services/ReasoningService"),
import("../stores/settingsStore"),
@@ -460,7 +460,9 @@ export default function ControlPanel() {
const isCloud = isCloudCleanupMode();
if (model || isCloud) {
const agentName = localStorage.getItem("agentName") || null;
- const reasonedText = await ReasoningService.processText(rawText, model, agentName);
+ const reasonedText = await ReasoningService.processText(rawText, model, agentName, {
+ disableThinking: getSettings().cleanupDisableThinking,
+ });
if (reasonedText && reasonedText !== rawText) {
const updated = await window.electronAPI.updateTranscriptionText(
id,
diff --git a/src/components/OpenAICompatiblePanel.tsx b/src/components/OpenAICompatiblePanel.tsx
new file mode 100644
index 000000000..a2eb0daed
--- /dev/null
+++ b/src/components/OpenAICompatiblePanel.tsx
@@ -0,0 +1,324 @@
+import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
+import { useTranslation } from "react-i18next";
+import { Button } from "./ui/button";
+import { Input } from "./ui/input";
+import ApiKeyInput from "./ui/ApiKeyInput";
+import ModelCardList from "./ui/ModelCardList";
+import { buildApiUrl, normalizeBaseUrl } from "../config/constants";
+import { isSecureEndpoint } from "../utils/urlUtils";
+
+interface ModelOption {
+ value: string;
+ label: string;
+ description?: string;
+ ownedBy?: string;
+}
+
+interface OpenAICompatiblePanelProps {
+ baseUrl: string;
+ setBaseUrl: (value: string) => void;
+ apiKey: string;
+ setApiKey: (value: string) => void;
+ model: string;
+ setModel: (value: string) => void;
+ defaultBaseUrl?: string;
+ baseUrlPlaceholder?: string;
+ helpExamples?: ReactNode;
+}
+
+export default function OpenAICompatiblePanel({
+ baseUrl,
+ setBaseUrl,
+ apiKey,
+ setApiKey,
+ model,
+ setModel,
+ defaultBaseUrl,
+ baseUrlPlaceholder = "https://api.openai.com/v1",
+ helpExamples,
+}: OpenAICompatiblePanelProps) {
+ const { t } = useTranslation();
+ const [draftBase, setDraftBase] = useState(baseUrl);
+ const [modelOptions, setModelOptions] = useState<ModelOption[]>([]);
+ const [modelsLoading, setModelsLoading] = useState(false);
+ const [modelsError, setModelsError] = useState<string | null>(null);
+ const isMountedRef = useRef(true);
+ const lastLoadedBaseRef = useRef<string | null>(null);
+ const pendingBaseRef = useRef<string | null>(null);
+ const latestBaseRef = useRef<string>(normalizeBaseUrl(baseUrl));
+
+ useEffect(() => {
+ isMountedRef.current = true;
+ return () => {
+ isMountedRef.current = false;
+ };
+ }, []);
+
+ useEffect(() => {
+ setDraftBase(baseUrl);
+ }, [baseUrl]);
+
+ const normalizedBase = useMemo(() => normalizeBaseUrl(baseUrl), [baseUrl]);
+
+ useEffect(() => {
+ latestBaseRef.current = normalizedBase;
+ }, [normalizedBase]);
+
+ const hasBase = normalizedBase !== "";
+ const trimmedDraft = draftBase.trim();
+ const hasSavedBase = Boolean((baseUrl || "").trim());
+ const isDraftDirty = trimmedDraft !== (baseUrl || "").trim();
+
+ const loadRemoteModels = useCallback(
+ async (baseOverride?: string, force = false) => {
+ const rawBase = (baseOverride ?? baseUrl) || "";
+ const normalized = normalizeBaseUrl(rawBase);
+
+ if (!normalized) {
+ if (isMountedRef.current) {
+ setModelsLoading(false);
+ setModelsError(null);
+ setModelOptions([]);
+ }
+ return;
+ }
+
+ if (!force && lastLoadedBaseRef.current === normalized) return;
+ if (!force && pendingBaseRef.current === normalized) return;
+
+ if (baseOverride !== undefined) {
+ latestBaseRef.current = normalized;
+ }
+
+ pendingBaseRef.current = normalized;
+
+ if (isMountedRef.current) {
+ setModelsLoading(true);
+ setModelsError(null);
+ setModelOptions([]);
+ }
+
+ const trimmedKey = apiKey?.trim();
+ const effectiveKey = trimmedKey && trimmedKey.length > 0 ? trimmedKey : undefined;
+
+ try {
+ if (!normalized.includes("://")) {
+ if (isMountedRef.current && latestBaseRef.current === normalized) {
+ setModelsError(t("reasoning.custom.endpointWithProtocol"));
+ setModelsLoading(false);
+ }
+ return;
+ }
+
+ if (!isSecureEndpoint(normalized)) {
+ if (isMountedRef.current && latestBaseRef.current === normalized) {
+ setModelsError(t("reasoning.custom.httpsRequired"));
+ setModelsLoading(false);
+ }
+ return;
+ }
+
+ const headers: Record<string, string> = {};
+ if (effectiveKey) {
+ headers.Authorization = `Bearer ${effectiveKey}`;
+ }
+
+ const modelsUrl = buildApiUrl(normalized, "/models");
+ const response = await fetch(modelsUrl, { method: "GET", headers });
+
+ if (!response.ok) {
+ const errorText = await response.text().catch(() => "");
+ const summary = errorText
+ ? `${response.status} ${errorText.slice(0, 200)}`
+ : `${response.status} ${response.statusText}`;
+ throw new Error(summary.trim());
+ }
+
+ const payload = await response.json().catch(() => ({}));
+ const rawModels = Array.isArray(payload?.data)
+ ? payload.data
+ : Array.isArray(payload?.models)
+ ? payload.models
+ : [];
+
+ const mapped = (rawModels as Array<Record<string, unknown>>)
+ .map((item) => {
+ const value = (item?.id || item?.name) as string | undefined;
+ if (!value) return null;
+ const ownedBy = typeof item?.owned_by === "string" ? item.owned_by : undefined;
+ return {
+ value,
+ label: (item?.id || item?.name || value) as string,
+ description:
+ (item?.description as string) ||
+ (ownedBy ? t("reasoning.custom.ownerLabel", { owner: ownedBy }) : undefined),
+ ownedBy,
+ } as ModelOption;
+ })
+ .filter(Boolean) as ModelOption[];
+
+ if (isMountedRef.current && latestBaseRef.current === normalized) {
+ setModelOptions(mapped);
+ if (model && mapped.length > 0 && !mapped.some((m) => m.value === model)) {
+ setModel("");
+ }
+ setModelsError(null);
+ lastLoadedBaseRef.current = normalized;
+ }
+ } catch (error) {
+ if (isMountedRef.current && latestBaseRef.current === normalized) {
+ const message = (error as Error).message || t("reasoning.custom.unableToLoadModels");
+ const unauthorized = /\b(401|403)\b/.test(message);
+ if (unauthorized && !effectiveKey) {
+ setModelsError(t("reasoning.custom.endpointUnauthorized"));
+ } else {
+ setModelsError(message);
+ }
+ setModelOptions([]);
+ }
+ } finally {
+ if (pendingBaseRef.current === normalized) {
+ pendingBaseRef.current = null;
+ }
+ if (isMountedRef.current && latestBaseRef.current === normalized) {
+ setModelsLoading(false);
+ }
+ }
+ },
+ [baseUrl, apiKey, model, setModel, t]
+ );
+
+ useEffect(() => {
+ if (!hasBase) {
+ setModelsError(null);
+ setModelOptions([]);
+ setModelsLoading(false);
+ lastLoadedBaseRef.current = null;
+ return;
+ }
+ if (!normalizedBase) return;
+ if (pendingBaseRef.current === normalizedBase) return;
+ if (lastLoadedBaseRef.current === normalizedBase) return;
+ loadRemoteModels();
+ }, [hasBase, normalizedBase, loadRemoteModels]);
+
+ const applyBase = useCallback(() => {
+ const normalized = trimmedDraft ? normalizeBaseUrl(trimmedDraft) : trimmedDraft;
+ setDraftBase(normalized);
+ setBaseUrl(normalized);
+ lastLoadedBaseRef.current = null;
+ loadRemoteModels(normalized, true);
+ }, [trimmedDraft, setBaseUrl, loadRemoteModels]);
+
+ const handleBlur = useCallback(() => {
+ if (!trimmedDraft) return;
+ if (trimmedDraft !== (baseUrl || "").trim()) {
+ applyBase();
+ }
+ }, [trimmedDraft, baseUrl, applyBase]);
+
+ const handleReset = useCallback(() => {
+ const target = defaultBaseUrl ?? "";
+ setDraftBase(target);
+ setBaseUrl(target);
+ lastLoadedBaseRef.current = null;
+ loadRemoteModels(target, true);
+ }, [defaultBaseUrl, setBaseUrl, loadRemoteModels]);
+
+ const handleRefresh = useCallback(() => {
+ if (isDraftDirty) {
+ applyBase();
+ return;
+ }
+ if (!trimmedDraft) return;
+ loadRemoteModels(undefined, true);
+ }, [applyBase, isDraftDirty, trimmedDraft, loadRemoteModels]);
+
+ const displayedModels = isDraftDirty ? [] : modelOptions;
+ const queryUrl = hasBase ? `${normalizedBase}/models` : `${baseUrlPlaceholder}/models`;
+
+ return (
+ <>
+ <div className="space-y-2">
+ <h4 className="font-medium text-foreground">{t("reasoning.custom.endpointTitle")}</h4>
+ <Input
+ value={draftBase}
+ onChange={(event) => setDraftBase(event.target.value)}
+ onBlur={handleBlur}
+ placeholder={baseUrlPlaceholder}
+ className="text-sm"
+ />
+ {helpExamples ?? (
+ <p className="text-xs text-muted-foreground">
+ {t("reasoning.custom.endpointExamples")}{" "}
+ <code className="text-primary">https://openrouter.ai/api/v1</code> (OpenRouter),{" "}
+ <code className="text-primary">https://api.together.xyz/v1</code> (Together).
+ </p>
+ )}
+ </div>
+
+ <div className="space-y-2 pt-3">
+ <h4 className="font-medium text-foreground">{t("reasoning.custom.apiKeyOptional")}</h4>
+ <ApiKeyInput
+ apiKey={apiKey}
+ setApiKey={setApiKey}
+ label=""
+ helpText={t("reasoning.custom.apiKeyHelp")}
+ />
+ </div>
+
+ <div className="space-y-2 pt-3">
+ <div className="flex items-center justify-between">
+ <h4 className="text-sm font-medium text-foreground">{t("reasoning.availableModels")}</h4>
+ <div className="flex gap-2">
+ {defaultBaseUrl !== undefined && (
+ <Button
+ type="button"
+ size="sm"
+ variant="outline"
+ onClick={handleReset}
+ className="text-xs"
+ >
+ {t("common.reset")}
+ </Button>
+ )}
+ <Button
+ type="button"
+ size="sm"
+ variant="outline"
+ onClick={handleRefresh}
+ disabled={modelsLoading || (!trimmedDraft && !hasSavedBase)}
+ className="text-xs"
+ >
+ {modelsLoading
+ ? t("common.loading")
+ : isDraftDirty
+ ? t("reasoning.custom.applyAndRefresh")
+ : t("common.refresh")}
+ </Button>
+ </div>
+ </div>
+ <p className="text-xs text-muted-foreground">
+ {t("reasoning.custom.queryPrefix")} <code className="break-all">{queryUrl}</code>{" "}
+ {t("reasoning.custom.querySuffix")}
+ </p>
+ {isDraftDirty && (
+ <p className="text-xs text-primary">{t("reasoning.custom.modelsReloadHint")}</p>
+ )}
+ {!hasBase && <p className="text-xs text-warning">{t("reasoning.custom.enterEndpoint")}</p>}
+ {hasBase && (
+ <>
+ {modelsLoading && (
+ <p className="text-xs text-primary">{t("reasoning.custom.fetchingModels")}</p>
+ )}
+ {modelsError && <p className="text-xs text-destructive">{modelsError}</p>}
+ {!modelsLoading && !modelsError && modelOptions.length === 0 && (
+ <p className="text-xs text-warning">{t("reasoning.custom.noModels")}</p>
+ )}
+ </>
+ )}
+ <ModelCardList models={displayedModels} selectedModel={model} onModelSelect={setModel} />
+ </div>
+ </>
+ );
+}
diff --git a/src/components/ReasoningModelSelector.tsx b/src/components/ReasoningModelSelector.tsx
index 7a2efabcd..bf8b51a96 100644
--- a/src/components/ReasoningModelSelector.tsx
+++ b/src/components/ReasoningModelSelector.tsx
@@ -1,4 +1,4 @@
-import { useState, useEffect, useCallback, useMemo, useRef } from "react";
+import { useState, useEffect, useCallback, useMemo } from "react";
import { useTranslation } from "react-i18next";
import type {
LlamaServerStatus,
@@ -8,18 +8,17 @@ import type {
InferenceMode,
} from "../types/electron";
import { Button } from "./ui/button";
-import { Input } from "./ui/input";
import { Cloud, Lock, Zap } from "lucide-react";
import ApiKeyInput from "./ui/ApiKeyInput";
import ModelCardList from "./ui/ModelCardList";
import LocalModelPicker, { type LocalProvider } from "./LocalModelPicker";
import { ProviderTabs } from "./ui/ProviderTabs";
-import { API_ENDPOINTS, buildApiUrl, normalizeBaseUrl } from "../config/constants";
+import OpenAICompatiblePanel from "./OpenAICompatiblePanel";
+import { API_ENDPOINTS } from "../config/constants";
import logger from "../utils/logger";
import { REASONING_PROVIDERS } from "../models/ModelRegistry";
import { modelRegistry } from "../models/ModelRegistry";
import { getProviderIcon, isMonochromeProvider } from "../utils/providerIcons";
-import { isSecureEndpoint } from "../utils/urlUtils";
import { createExternalLinkHandler } from "../utils/externalLinks";
import { getCachedPlatform } from "../utils/platform";
import { useSettingsStore } from "../stores/settingsStore";
@@ -324,173 +323,6 @@ export default function ReasoningModelSelector({
const [selectedMode, setSelectedMode] = useState<"cloud" | "local">(mode || "cloud");
const [selectedCloudProvider, setSelectedCloudProvider] = useState("openai");
const [selectedLocalProvider, setSelectedLocalProvider] = useState("qwen");
- const [customModelOptions, setCustomModelOptions] = useState<CloudModelOption[]>([]);
- const [customModelsLoading, setCustomModelsLoading] = useState(false);
- const [customModelsError, setCustomModelsError] = useState<string | null>(null);
- const [customBaseInput, setCustomBaseInput] = useState(cloudReasoningBaseUrl);
- const lastLoadedBaseRef = useRef<string | null>(null);
- const pendingBaseRef = useRef<string | null>(null);
- const isMountedRef = useRef(true);
-
- useEffect(() => {
- isMountedRef.current = true;
- return () => {
- isMountedRef.current = false;
- };
- }, []);
-
- useEffect(() => {
- setCustomBaseInput(cloudReasoningBaseUrl);
- }, [cloudReasoningBaseUrl]);
-
- const defaultOpenAIBase = useMemo(() => normalizeBaseUrl(API_ENDPOINTS.OPENAI_BASE), []);
- const normalizedCustomReasoningBase = useMemo(
- () => normalizeBaseUrl(cloudReasoningBaseUrl),
- [cloudReasoningBaseUrl]
- );
- const latestReasoningBaseRef = useRef(normalizedCustomReasoningBase);
-
- useEffect(() => {
- latestReasoningBaseRef.current = normalizedCustomReasoningBase;
- }, [normalizedCustomReasoningBase]);
-
- const hasCustomBase = normalizedCustomReasoningBase !== "";
- const effectiveReasoningBase = hasCustomBase ? normalizedCustomReasoningBase : defaultOpenAIBase;
-
- const loadRemoteModels = useCallback(
- async (baseOverride?: string, force = false) => {
- const rawBase = (baseOverride ?? cloudReasoningBaseUrl) || "";
- const normalizedBase = normalizeBaseUrl(rawBase);
-
- if (!normalizedBase) {
- if (isMountedRef.current) {
- setCustomModelsLoading(false);
- setCustomModelsError(null);
- setCustomModelOptions([]);
- }
- return;
- }
-
- if (!force && lastLoadedBaseRef.current === normalizedBase) return;
- if (!force && pendingBaseRef.current === normalizedBase) return;
-
- if (baseOverride !== undefined) {
- latestReasoningBaseRef.current = normalizedBase;
- }
-
- pendingBaseRef.current = normalizedBase;
-
- if (isMountedRef.current) {
- setCustomModelsLoading(true);
- setCustomModelsError(null);
- setCustomModelOptions([]);
- }
-
- let apiKey: string | undefined;
-
- try {
- // Use the custom reasoning API key for custom endpoints
- const keyFromState = customReasoningApiKey?.trim();
- apiKey = keyFromState && keyFromState.length > 0 ? keyFromState : undefined;
-
- if (!normalizedBase.includes("://")) {
- if (isMountedRef.current && latestReasoningBaseRef.current === normalizedBase) {
- setCustomModelsError(t("reasoning.custom.endpointWithProtocol"));
- setCustomModelsLoading(false);
- }
- return;
- }
-
- if (!isSecureEndpoint(normalizedBase)) {
- if (isMountedRef.current && latestReasoningBaseRef.current === normalizedBase) {
- setCustomModelsError(t("reasoning.custom.httpsRequired"));
- setCustomModelsLoading(false);
- }
- return;
- }
-
- const headers: Record<string, string> = {};
- if (apiKey) {
- headers.Authorization = `Bearer ${apiKey}`;
- }
-
- const modelsUrl = buildApiUrl(normalizedBase, "/models");
- const response = await fetch(modelsUrl, { method: "GET", headers });
-
- if (!response.ok) {
- const errorText = await response.text().catch(() => "");
- const summary = errorText
- ? `${response.status} ${errorText.slice(0, 200)}`
- : `${response.status} ${response.statusText}`;
- throw new Error(summary.trim());
- }
-
- const payload = await response.json().catch(() => ({}));
- const rawModels = Array.isArray(payload?.data)
- ? payload.data
- : Array.isArray(payload?.models)
- ? payload.models
- : [];
-
- const mappedModels = (rawModels as Array<Record<string, unknown>>)
- .map((item) => {
- const value = (item?.id || item?.name) as string | undefined;
- if (!value) return null;
- const ownedBy = typeof item?.owned_by === "string" ? item.owned_by : undefined;
- return {
- value,
- label: (item?.id || item?.name || value) as string,
- description:
- (item?.description as string) ||
- (ownedBy ? t("reasoning.custom.ownerLabel", { owner: ownedBy }) : undefined),
- ownedBy,
- } as CloudModelOption;
- })
- .filter(Boolean) as CloudModelOption[];
-
- if (isMountedRef.current && latestReasoningBaseRef.current === normalizedBase) {
- setCustomModelOptions(mappedModels);
- if (
- reasoningModel &&
- mappedModels.length > 0 &&
- !mappedModels.some((model) => model.value === reasoningModel)
- ) {
- setReasoningModel("");
- }
- setCustomModelsError(null);
- lastLoadedBaseRef.current = normalizedBase;
- }
- } catch (error) {
- if (isMountedRef.current && latestReasoningBaseRef.current === normalizedBase) {
- const message = (error as Error).message || t("reasoning.custom.unableToLoadModels");
- const unauthorized = /\b(401|403)\b/.test(message);
- if (unauthorized && !apiKey) {
- setCustomModelsError(t("reasoning.custom.endpointUnauthorized"));
- } else {
- setCustomModelsError(message);
- }
- setCustomModelOptions([]);
- }
- } finally {
- if (pendingBaseRef.current === normalizedBase) {
- pendingBaseRef.current = null;
- }
- if (isMountedRef.current && latestReasoningBaseRef.current === normalizedBase) {
- setCustomModelsLoading(false);
- }
- }
- },
- [cloudReasoningBaseUrl, customReasoningApiKey, reasoningModel, setReasoningModel, t]
- );
-
- const trimmedCustomBase = customBaseInput.trim();
- const hasSavedCustomBase = Boolean((cloudReasoningBaseUrl || "").trim());
- const isCustomBaseDirty = trimmedCustomBase !== (cloudReasoningBaseUrl || "").trim();
-
- const displayedCustomModels = useMemo<CloudModelOption[]>(() => {
- if (isCustomBaseDirty) return [];
- return customModelOptions;
- }, [isCustomBaseDirty, customModelOptions]);
const effectiveMode = mode || selectedMode;
@@ -533,7 +365,7 @@ export default function ReasoningModelSelector({
const selectedCloudModels = useMemo<CloudModelOption[]>(() => {
if (selectedCloudProvider === "openai") return openaiModelOptions;
- if (selectedCloudProvider === "custom") return displayedCustomModels;
+ if (selectedCloudProvider === "custom") return [];
const provider = REASONING_PROVIDERS[selectedCloudProvider as keyof typeof REASONING_PROVIDERS];
if (!provider?.models) return [];
@@ -548,43 +380,7 @@ export default function ReasoningModelSelector({
icon: iconUrl,
invertInDark,
}));
- }, [selectedCloudProvider, openaiModelOptions, displayedCustomModels, t]);
-
- const handleApplyCustomBase = useCallback(() => {
- const trimmedBase = customBaseInput.trim();
- const normalized = trimmedBase ? normalizeBaseUrl(trimmedBase) : trimmedBase;
- setCustomBaseInput(normalized);
- setCloudReasoningBaseUrl(normalized);
- lastLoadedBaseRef.current = null;
- loadRemoteModels(normalized, true);
- }, [customBaseInput, setCloudReasoningBaseUrl, loadRemoteModels]);
-
- const handleBaseUrlBlur = useCallback(() => {
- const trimmedBase = customBaseInput.trim();
- if (!trimmedBase) return;
-
- // Auto-apply on blur if changed
- if (trimmedBase !== (cloudReasoningBaseUrl || "").trim()) {
- handleApplyCustomBase();
- }
- }, [customBaseInput, cloudReasoningBaseUrl, handleApplyCustomBase]);
-
- const handleResetCustomBase = useCallback(() => {
- const defaultBase = API_ENDPOINTS.OPENAI_BASE;
- setCustomBaseInput(defaultBase);
- setCloudReasoningBaseUrl(defaultBase);
- lastLoadedBaseRef.current = null;
- loadRemoteModels(defaultBase, true);
- }, [setCloudReasoningBaseUrl, loadRemoteModels]);
-
- const handleRefreshCustomModels = useCallback(() => {
- if (isCustomBaseDirty) {
- handleApplyCustomBase();
- return;
- }
- if (!trimmedCustomBase) return;
- loadRemoteModels(undefined, true);
- }, [handleApplyCustomBase, isCustomBaseDirty, trimmedCustomBase, loadRemoteModels]);
+ }, [selectedCloudProvider, openaiModelOptions, t]);
useEffect(() => {
const localProviderIds = localProviders.map((p) => p.id);
@@ -597,24 +393,6 @@ export default function ReasoningModelSelector({
}
}, [localProviders, localReasoningProvider]);
- useEffect(() => {
- if (selectedCloudProvider !== "custom") return;
- if (!hasCustomBase) {
- setCustomModelsError(null);
- setCustomModelOptions([]);
- setCustomModelsLoading(false);
- lastLoadedBaseRef.current = null;
- return;
- }
-
- const normalizedBase = normalizedCustomReasoningBase;
- if (!normalizedBase) return;
- if (pendingBaseRef.current === normalizedBase || lastLoadedBaseRef.current === normalizedBase)
- return;
-
- loadRemoteModels();
- }, [selectedCloudProvider, hasCustomBase, normalizedCustomReasoningBase, loadRemoteModels]);
-
const [downloadedModels, setDownloadedModels] = useState<Set<string>>(new Set());
const loadDownloadedModels = useCallback(async () => {
@@ -647,18 +425,7 @@ export default function ReasoningModelSelector({
window.electronAPI?.llamaServerStop?.();
setLocalReasoningProvider(selectedCloudProvider);
- if (selectedCloudProvider === "custom") {
- setCustomBaseInput(cloudReasoningBaseUrl);
- lastLoadedBaseRef.current = null;
- pendingBaseRef.current = null;
-
- if (customModelOptions.length > 0) {
- setReasoningModel(customModelOptions[0].value);
- } else if (hasCustomBase) {
- loadRemoteModels();
- }
- return;
- }
+ if (selectedCloudProvider === "custom") return;
const provider =
REASONING_PROVIDERS[selectedCloudProvider as keyof typeof REASONING_PROVIDERS];
@@ -685,18 +452,7 @@ export default function ReasoningModelSelector({
setSelectedCloudProvider(provider);
setLocalReasoningProvider(provider);
- if (provider === "custom") {
- setCustomBaseInput(cloudReasoningBaseUrl);
- lastLoadedBaseRef.current = null;
- pendingBaseRef.current = null;
-
- if (customModelOptions.length > 0) {
- setReasoningModel(customModelOptions[0].value);
- } else if (hasCustomBase) {
- loadRemoteModels();
- }
- return;
- }
+ if (provider === "custom") return;
const providerData = REASONING_PROVIDERS[provider as keyof typeof REASONING_PROVIDERS];
if (providerData?.models?.length > 0) {
@@ -760,111 +516,15 @@ export default function ReasoningModelSelector({
<div>
{selectedCloudProvider === "custom" ? (
- <>
- <div className="space-y-2">
- <h4 className="font-medium text-foreground">
- {t("reasoning.custom.endpointTitle")}
- </h4>
- <Input
- value={customBaseInput}
- onChange={(event) => setCustomBaseInput(event.target.value)}
- onBlur={handleBaseUrlBlur}
- placeholder="https://api.openai.com/v1"
- className="text-sm"
- />
- <p className="text-xs text-muted-foreground">
- {t("reasoning.custom.endpointExamples")}{" "}
- <code className="text-primary">http://localhost:11434/v1</code>{" "}
- {t("reasoning.custom.ollama")},{" "}
- <code className="text-primary">http://localhost:8080/v1</code>{" "}
- {t("reasoning.custom.localAi")}.
- </p>
- </div>
-
- <div className="space-y-2 pt-3">
- <h4 className="font-medium text-foreground">
- {t("reasoning.custom.apiKeyOptional")}
- </h4>
- <ApiKeyInput
- apiKey={customReasoningApiKey}
- setApiKey={setCustomReasoningApiKey || (() => {})}
- label=""
- helpText={t("reasoning.custom.apiKeyHelp")}
- />
- </div>
-
- <div className="space-y-2 pt-3">
- <div className="flex items-center justify-between">
- <h4 className="text-sm font-medium text-foreground">
- {t("reasoning.availableModels")}
- </h4>
- <div className="flex gap-2">
- <Button
- type="button"
- size="sm"
- variant="outline"
- onClick={handleResetCustomBase}
- className="text-xs"
- >
- {t("common.reset")}
- </Button>
- <Button
- type="button"
- size="sm"
- variant="outline"
- onClick={handleRefreshCustomModels}
- disabled={
- customModelsLoading || (!trimmedCustomBase && !hasSavedCustomBase)
- }
- className="text-xs"
- >
- {customModelsLoading
- ? t("common.loading")
- : isCustomBaseDirty
- ? t("reasoning.custom.applyAndRefresh")
- : t("common.refresh")}
- </Button>
- </div>
- </div>
- <p className="text-xs text-muted-foreground">
- {t("reasoning.custom.queryPrefix")}{" "}
- <code className="break-all">
- {hasCustomBase
- ? `${effectiveReasoningBase}/models`
- : `${defaultOpenAIBase}/models`}
- </code>{" "}
- {t("reasoning.custom.querySuffix")}
- </p>
- {isCustomBaseDirty && (
- <p className="text-xs text-primary">{t("reasoning.custom.modelsReloadHint")}</p>
- )}
- {!hasCustomBase && (
- <p className="text-xs text-warning">{t("reasoning.custom.enterEndpoint")}</p>
- )}
- {hasCustomBase && (
- <>
- {customModelsLoading && (
- <p className="text-xs text-primary">
- {t("reasoning.custom.fetchingModels")}
- </p>
- )}
- {customModelsError && (
- <p className="text-xs text-destructive">{customModelsError}</p>
- )}
- {!customModelsLoading &&
- !customModelsError &&
- customModelOptions.length === 0 && (
- <p className="text-xs text-warning">{t("reasoning.custom.noModels")}</p>
- )}
- </>
- )}
- <ModelCardList
- models={selectedCloudModels}
- selectedModel={reasoningModel}
- onModelSelect={setReasoningModel}
- />
- </div>
- </>
+ <OpenAICompatiblePanel
+ baseUrl={cloudReasoningBaseUrl}
+ setBaseUrl={setCloudReasoningBaseUrl}
+ apiKey={customReasoningApiKey}
+ setApiKey={setCustomReasoningApiKey || (() => {})}
+ model={reasoningModel}
+ setModel={setReasoningModel}
+ defaultBaseUrl={API_ENDPOINTS.OPENAI_BASE}
+ />
) : (
<>
{selectedCloudProvider === "openai" && (
diff --git a/src/components/chat/useChatStreaming.ts b/src/components/chat/useChatStreaming.ts
index 9ae322c3c..0b3420103 100644
--- a/src/components/chat/useChatStreaming.ts
+++ b/src/components/chat/useChatStreaming.ts
@@ -196,6 +196,7 @@ export function useChatStreaming({
lanUrl: isLanAgent ? settings.chatAgentRemoteUrl : undefined,
baseUrl: isCustomAgent ? settings.chatAgentCloudBaseUrl || undefined : undefined,
customApiKey: isCustomAgent ? settings.chatAgentCustomApiKey || undefined : undefined,
+ disableThinking: settings.chatAgentDisableThinking,
},
aiTools
);
diff --git a/src/components/settings/InferenceConfigEditor.tsx b/src/components/settings/InferenceConfigEditor.tsx
index 360d972c8..ddbf29343 100644
--- a/src/components/settings/InferenceConfigEditor.tsx
+++ b/src/components/settings/InferenceConfigEditor.tsx
@@ -10,10 +10,16 @@ import { InferenceModeSelector } from "../ui/SettingsSection";
import type { InferenceModeOption } from "../ui/SettingsSection";
import ReasoningModelSelector from "../ReasoningModelSelector";
import EnterpriseSection from "../EnterpriseSection";
-import SelfHostedPanel from "../SelfHostedPanel";
+import OpenAICompatiblePanel from "../OpenAICompatiblePanel";
+import { Toggle } from "../ui/toggle";
import type { InferenceMode } from "../../types/electron";
import type { InferenceScope } from "../../config/inferenceScopes";
-import { modelRegistry, isEnterpriseProvider } from "../../models/ModelRegistry";
+import {
+ modelRegistry,
+ isEnterpriseProvider,
+ getCloudModel,
+ getLocalModel,
+} from "../../models/ModelRegistry";
function isProviderValidForMode(provider: string, mode: InferenceMode): boolean {
switch (mode) {
@@ -142,6 +148,12 @@ export default function InferenceConfigEditor({ scope, onModeChange }: Inference
/>
);
+ const showThinkingToggle =
+ config.mode === "self-hosted" ||
+ (config.mode === "providers" &&
+ (config.provider === "custom" || !!getCloudModel(config.model)?.supportsThinking)) ||
+ (config.mode === "local" && !!getLocalModel(config.model)?.supportsThinking);
+
return (
<div className="space-y-3">
<InferenceModeSelector modes={modes} activeMode={config.mode} onSelect={handleModeSelect} />
@@ -150,13 +162,34 @@ export default function InferenceConfigEditor({ scope, onModeChange }: Inference
{config.mode === "local" && renderModelSelector("local")}
{config.mode === "self-hosted" && (
- <SelfHostedPanel
- service="reasoning"
- url={config.remoteUrl ?? ""}
- onUrlChange={setField("remoteUrl")}
+ <OpenAICompatiblePanel
+ baseUrl={config.remoteUrl ?? ""}
+ setBaseUrl={setField("remoteUrl")}
+ apiKey={config.customApiKey ?? ""}
+ setApiKey={setField("customApiKey")}
+ model={config.model}
+ setModel={setModel}
+ baseUrlPlaceholder="http://192.168.1.126:11434/v1"
+ helpExamples={
+ <p className="text-xs text-muted-foreground">
+ {t("reasoning.selfHosted.endpointHelp")}
+ </p>
+ }
/>
)}
+ {showThinkingToggle && (
+ <div className="flex items-start justify-between gap-3 pt-1">
+ <div className="flex-1 min-w-0">
+ <h4 className="text-sm font-medium text-foreground">
+ {t("reasoning.disableThinking.label")}
+ </h4>
+ <p className="text-xs text-muted-foreground">{t("reasoning.disableThinking.help")}</p>
+ </div>
+ <Toggle checked={config.disableThinking} onChange={setField("disableThinking")} />
+ </div>
+ )}
+
{config.mode === "enterprise" && (
<EnterpriseSection
currentProvider={config.provider}
diff --git a/src/components/ui/PromptStudio.tsx b/src/components/ui/PromptStudio.tsx
index e5956778d..d04f839ba 100644
--- a/src/components/ui/PromptStudio.tsx
+++ b/src/components/ui/PromptStudio.tsx
@@ -153,7 +153,9 @@ export default function PromptStudio({ className = "", kind = "cleanup" }: Promp
const previous = customPrompt;
setCustomPrompt(kind, editedPrompt);
try {
- const result = await ReasoningService.processText(testText, modelToUse, agentName, {});
+ const result = await ReasoningService.processText(testText, modelToUse, agentName, {
+ disableThinking: useSettingsStore.getState().cleanupDisableThinking,
+ });
setTestResult(result);
} finally {
setCustomPrompt(kind, previous);
diff --git a/src/config/inferenceScopes.ts b/src/config/inferenceScopes.ts
index 9e8be511c..fa38fb0b2 100644
--- a/src/config/inferenceScopes.ts
+++ b/src/config/inferenceScopes.ts
@@ -8,6 +8,7 @@ export interface InferenceScopeStoreKeys {
cloudBaseUrl?: keyof SettingsState;
remoteUrl?: keyof SettingsState;
customApiKey?: keyof SettingsState;
+ disableThinking?: keyof SettingsState;
}
export interface InferenceScopeDefinition {
@@ -25,6 +26,7 @@ export const INFERENCE_SCOPES = {
cloudBaseUrl: "cleanupCloudBaseUrl",
remoteUrl: "cleanupRemoteUrl",
customApiKey: "cleanupCustomApiKey",
+ disableThinking: "cleanupDisableThinking",
},
},
dictationAgent: {
@@ -36,6 +38,7 @@ export const INFERENCE_SCOPES = {
cloudBaseUrl: "dictationAgentCloudBaseUrl",
remoteUrl: "dictationAgentRemoteUrl",
customApiKey: "dictationAgentCustomApiKey",
+ disableThinking: "dictationAgentDisableThinking",
},
},
noteFormatting: {
@@ -47,6 +50,7 @@ export const INFERENCE_SCOPES = {
cloudBaseUrl: "noteFormattingCloudBaseUrl",
remoteUrl: "noteFormattingRemoteUrl",
customApiKey: "noteFormattingCustomApiKey",
+ disableThinking: "noteFormattingDisableThinking",
},
fallbackScope: "dictationCleanup",
},
@@ -59,6 +63,7 @@ export const INFERENCE_SCOPES = {
cloudBaseUrl: "chatAgentCloudBaseUrl",
remoteUrl: "chatAgentRemoteUrl",
customApiKey: "chatAgentCustomApiKey",
+ disableThinking: "chatAgentDisableThinking",
},
},
} as const satisfies Record<string, InferenceScopeDefinition>;
diff --git a/src/hooks/useActionProcessing.ts b/src/hooks/useActionProcessing.ts
index a20fd7c5f..cc04d5895 100644
--- a/src/hooks/useActionProcessing.ts
+++ b/src/hooks/useActionProcessing.ts
@@ -2,7 +2,7 @@ import { useState, useEffect, useRef, useCallback } from "react";
import { useTranslation } from "react-i18next";
import reasoningService from "../services/ReasoningService";
import type { ActionItem } from "../types/electron";
-import { getEffectiveCleanupModel } from "../stores/settingsStore";
+import { getEffectiveCleanupModel, getSettings } from "../stores/settingsStore";
import { generateNoteTitle } from "../utils/generateTitle";
export type ActionProcessingState = "idle" | "processing" | "success";
@@ -83,6 +83,7 @@ export function useActionProcessing({ onSuccess, onError }: UseActionProcessingO
const enhanced = await reasoningService.processText(noteContent, modelId, null, {
systemPrompt,
temperature: 0.3,
+ disableThinking: getSettings().noteFormattingDisableThinking,
});
if (cancelledRef.current) return;
diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json
index 2fbad74a7..4370875df 100644
--- a/src/locales/de/translation.json
+++ b/src/locales/de/translation.json
@@ -355,6 +355,13 @@
"getApiKey": "API-Schlüssel holen ->",
"selectModel": "Modell auswählen",
"availableModels": "Verfügbare Modelle",
+ "disableThinking": {
+ "label": "Denkausgabe deaktivieren",
+ "help": "Überspringt Reasoning-Token für eine sauberere Ausgabe. Empfohlen für Bereinigung. Einige Server ignorieren diesen Hinweis."
+ },
+ "selfHosted": {
+ "endpointHelp": "Zeige auf einen OpenAI-kompatiblen Server in deinem lokalen Netzwerk (z. B. Ollama, LM Studio, vLLM oder llama-server)."
+ },
"enterprise": {
"title": "Enterprise-Anbieter",
"description": "Verbinden Sie sich mit Cloud-Anbietern über die Zugangsdaten Ihrer Organisation.",
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index 9b1be1798..c78ae9c0c 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -355,6 +355,13 @@
"getApiKey": "Get your API key ->",
"selectModel": "Select Model",
"availableModels": "Available Models",
+ "disableThinking": {
+ "label": "Disable thinking output",
+ "help": "Skips reasoning tokens for cleaner output. Recommended for cleanup. Some servers ignore this hint."
+ },
+ "selfHosted": {
+ "endpointHelp": "Point to an OpenAI-compatible server on your local network (e.g. Ollama, LM Studio, vLLM, or llama-server)."
+ },
"enterprise": {
"title": "Enterprise Providers",
"description": "Connect to cloud providers using your organization's credentials.",
diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json
index c7f96a680..f77a36c4a 100644
--- a/src/locales/es/translation.json
+++ b/src/locales/es/translation.json
@@ -355,6 +355,13 @@
"getApiKey": "Obtener clave API ->",
"selectModel": "Seleccionar modelo",
"availableModels": "Modelos disponibles",
+ "disableThinking": {
+ "label": "Desactivar salida de razonamiento",
+ "help": "Omite los tokens de razonamiento para una salida más limpia. Recomendado para limpieza. Algunos servidores ignoran esta indicación."
+ },
+ "selfHosted": {
+ "endpointHelp": "Apunta a un servidor compatible con OpenAI en tu red local (p. ej. Ollama, LM Studio, vLLM o llama-server)."
+ },
"enterprise": {
"title": "Proveedores empresariales",
"description": "Conecta con proveedores de nube usando las credenciales de tu organización.",
diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json
index c8c8fefbc..276b8c15f 100644
--- a/src/locales/fr/translation.json
+++ b/src/locales/fr/translation.json
@@ -355,6 +355,13 @@
"getApiKey": "Obtenir la clé API ->",
"selectModel": "Sélectionner un modèle",
"availableModels": "Modèles disponibles",
+ "disableThinking": {
+ "label": "Désactiver la sortie de raisonnement",
+ "help": "Ignore les jetons de raisonnement pour une sortie plus propre. Recommandé pour le nettoyage. Certains serveurs ignorent cette indication."
+ },
+ "selfHosted": {
+ "endpointHelp": "Pointez vers un serveur compatible OpenAI sur votre réseau local (par ex. Ollama, LM Studio, vLLM ou llama-server)."
+ },
"enterprise": {
"title": "Fournisseurs Enterprise",
"description": "Connectez-vous aux fournisseurs cloud avec les identifiants de votre organisation.",
diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json
index caaf208e3..744c6b839 100644
--- a/src/locales/it/translation.json
+++ b/src/locales/it/translation.json
@@ -355,6 +355,13 @@
"getApiKey": "Ottieni la chiave API ->",
"selectModel": "Seleziona modello",
"availableModels": "Modelli disponibili",
+ "disableThinking": {
+ "label": "Disattiva output di ragionamento",
+ "help": "Salta i token di ragionamento per un output più pulito. Consigliato per la pulizia. Alcuni server ignorano questo suggerimento."
+ },
+ "selfHosted": {
+ "endpointHelp": "Punta a un server compatibile con OpenAI sulla tua rete locale (es. Ollama, LM Studio, vLLM o llama-server)."
+ },
"enterprise": {
"title": "Provider Enterprise",
"description": "Connettiti ai provider cloud usando le credenziali della tua organizzazione.",
diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json
index 42caad07d..2a48f29a1 100644
--- a/src/locales/ja/translation.json
+++ b/src/locales/ja/translation.json
@@ -355,6 +355,13 @@
"getApiKey": "API キーを取得 ->",
"selectModel": "モデルを選択",
"availableModels": "利用可能なモデル",
+ "disableThinking": {
+ "label": "思考出力を無効にする",
+ "help": "推論トークンをスキップして出力をクリーンに保ちます。クリーンアップに推奨。一部のサーバーはこのヒントを無視します。"
+ },
+ "selfHosted": {
+ "endpointHelp": "ローカルネットワーク上の OpenAI 互換サーバーを指定します(例: Ollama、LM Studio、vLLM、llama-server)。"
+ },
"enterprise": {
"title": "エンタープライズプロバイダー",
"description": "組織のクラウドプロバイダー認証情報を使用して接続します。",
diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json
index a1448ae39..b16a61531 100644
--- a/src/locales/pt/translation.json
+++ b/src/locales/pt/translation.json
@@ -327,6 +327,13 @@
"getApiKey": "Obter chave API ->",
"selectModel": "Selecionar modelo",
"availableModels": "Modelos disponíveis",
+ "disableThinking": {
+ "label": "Desativar saída de raciocínio",
+ "help": "Ignora tokens de raciocínio para uma saída mais limpa. Recomendado para limpeza. Alguns servidores ignoram esta dica."
+ },
+ "selfHosted": {
+ "endpointHelp": "Aponte para um servidor compatível com OpenAI na sua rede local (ex.: Ollama, LM Studio, vLLM ou llama-server)."
+ },
"enterprise": {
"title": "Provedores corporativos",
"description": "Conecte-se a provedores de nuvem usando as credenciais da sua organização.",
diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json
index 43c47312b..fae6b3a02 100644
--- a/src/locales/ru/translation.json
+++ b/src/locales/ru/translation.json
@@ -355,6 +355,13 @@
"getApiKey": "Получить API-ключ ->",
"selectModel": "Выберите модель",
"availableModels": "Доступные модели",
+ "disableThinking": {
+ "label": "Отключить вывод рассуждений",
+ "help": "Пропускает токены рассуждения для более чистого вывода. Рекомендуется для очистки. Некоторые серверы игнорируют эту подсказку."
+ },
+ "selfHosted": {
+ "endpointHelp": "Укажите OpenAI-совместимый сервер в вашей локальной сети (например, Ollama, LM Studio, vLLM или llama-server)."
+ },
"enterprise": {
"title": "Корпоративные провайдеры",
"description": "Подключайтесь к облачным провайдерам с учётными данными вашей организации.",
diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json
index cb3f4ec28..a0b60aee1 100644
--- a/src/locales/zh-CN/translation.json
+++ b/src/locales/zh-CN/translation.json
@@ -355,6 +355,13 @@
"getApiKey": "获取你的 API Key ->",
"selectModel": "选择模型",
"availableModels": "可用模型",
+ "disableThinking": {
+ "label": "禁用思考输出",
+ "help": "跳过推理令牌以获得更清晰的输出。推荐用于清理。某些服务器会忽略此提示。"
+ },
+ "selfHosted": {
+ "endpointHelp": "指向本地网络中兼容 OpenAI 的服务器(例如 Ollama、LM Studio、vLLM 或 llama-server)。"
+ },
"enterprise": {
"title": "企业级提供商",
"description": "使用你组织的凭据连接云端提供商。",
diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json
index 77f40f7f3..22603d44e 100644
--- a/src/locales/zh-TW/translation.json
+++ b/src/locales/zh-TW/translation.json
@@ -355,6 +355,13 @@
"getApiKey": "取得 API Key ->",
"selectModel": "選擇模型",
"availableModels": "可用模型",
+ "disableThinking": {
+ "label": "停用思考輸出",
+ "help": "略過推理權杖以獲得更乾淨的輸出。建議用於清理。某些伺服器會忽略此提示。"
+ },
+ "selfHosted": {
+ "endpointHelp": "指向本地網路中相容 OpenAI 的伺服器(例如 Ollama、LM Studio、vLLM 或 llama-server)。"
+ },
"enterprise": {
"title": "企業級提供商",
"description": "使用你組織的憑證連線到雲端提供商。",
diff --git a/src/models/ModelRegistry.ts b/src/models/ModelRegistry.ts
index 4a2ca8c4f..4dd73fc28 100644
--- a/src/models/ModelRegistry.ts
+++ b/src/models/ModelRegistry.ts
@@ -13,6 +13,7 @@ export interface ModelDefinition {
contextLength: number;
hfRepo: string;
recommended?: boolean;
+ supportsThinking?: boolean;
}
export interface LocalProviderData {
@@ -38,6 +39,7 @@ export interface CloudModelDefinition {
description: string;
descriptionKey?: string;
disableThinking?: boolean;
+ supportsThinking?: boolean;
tokenParam?: "max_tokens" | "max_completion_tokens";
supportsTemperature?: boolean;
}
@@ -374,6 +376,10 @@ export function getCloudModel(modelId: string): CloudModelDefinition | undefined
return undefined;
}
+export function getLocalModel(modelId: string): ModelDefinition | undefined {
+ return modelRegistry.getModel(modelId)?.model;
+}
+
export interface OpenAiApiConfig {
tokenParam: "max_tokens" | "max_completion_tokens";
supportsTemperature: boolean;
diff --git a/src/models/modelRegistryData.json b/src/models/modelRegistryData.json
index d7b15c3c9..840335ec9 100644
--- a/src/models/modelRegistryData.json
+++ b/src/models/modelRegistryData.json
@@ -320,18 +320,21 @@
"name": "Qwen3 32B",
"description": "Powerful reasoning model, 131K context",
"disableThinking": true,
+ "supportsThinking": true,
"descriptionKey": "models.descriptions.cloud.groq_qwen_qwen3_32b"
},
{
"id": "openai/gpt-oss-120b",
"name": "GPT-OSS 120B",
"description": "OpenAI's open-source flagship, 500 T/sec",
+ "supportsThinking": true,
"descriptionKey": "models.descriptions.cloud.groq_openai_gpt_oss_120b"
},
{
"id": "openai/gpt-oss-20b",
"name": "GPT-OSS 20B",
"description": "Fast open-source model, 1000 T/sec",
+ "supportsThinking": true,
"descriptionKey": "models.descriptions.cloud.groq_openai_gpt_oss_20b"
},
{
@@ -449,6 +452,7 @@
"contextLength": 262144,
"hfRepo": "bartowski/Qwen_Qwen3.5-9B-GGUF",
"recommended": true,
+ "supportsThinking": true,
"descriptionKey": "models.descriptions.local.qwen_qwen3_5_9b_q4_k_m"
},
{
@@ -461,6 +465,7 @@
"quantization": "q4_k_m",
"contextLength": 262144,
"hfRepo": "bartowski/Qwen_Qwen3.5-4B-GGUF",
+ "supportsThinking": true,
"descriptionKey": "models.descriptions.local.qwen_qwen3_5_4b_q4_k_m"
},
{
@@ -473,6 +478,7 @@
"quantization": "q4_k_m",
"contextLength": 262144,
"hfRepo": "bartowski/Qwen_Qwen3.5-2B-GGUF",
+ "supportsThinking": true,
"descriptionKey": "models.descriptions.local.qwen_qwen3_5_2b_q4_k_m"
},
{
@@ -485,6 +491,7 @@
"quantization": "q4_k_m",
"contextLength": 131072,
"hfRepo": "Qwen/Qwen3-8B-GGUF",
+ "supportsThinking": true,
"descriptionKey": "models.descriptions.local.qwen_qwen3_8b_q4_k_m"
},
{
@@ -497,6 +504,7 @@
"quantization": "q5_k_m",
"contextLength": 131072,
"hfRepo": "Qwen/Qwen3-8B-GGUF",
+ "supportsThinking": true,
"descriptionKey": "models.descriptions.local.qwen_qwen3_8b_q5_k_m"
},
{
@@ -509,6 +517,7 @@
"quantization": "q4_k_m",
"contextLength": 131072,
"hfRepo": "Qwen/Qwen3-4B-GGUF",
+ "supportsThinking": true,
"descriptionKey": "models.descriptions.local.qwen_qwen3_4b_q4_k_m"
},
{
@@ -521,6 +530,7 @@
"quantization": "q8_0",
"contextLength": 131072,
"hfRepo": "Qwen/Qwen3-1.7B-GGUF",
+ "supportsThinking": true,
"descriptionKey": "models.descriptions.local.qwen_qwen3_1_7b_q8_0"
},
{
@@ -533,6 +543,7 @@
"quantization": "q4_k_m",
"contextLength": 131072,
"hfRepo": "Qwen/Qwen3-32B-GGUF",
+ "supportsThinking": true,
"descriptionKey": "models.descriptions.local.qwen_qwen3_32b_q4_k_m"
},
{
@@ -692,6 +703,7 @@
"contextLength": 128000,
"hfRepo": "ggml-org/gpt-oss-20b-GGUF",
"recommended": true,
+ "supportsThinking": true,
"descriptionKey": "models.descriptions.local.openai_oss_gpt_oss_20b_mxfp4"
}
]
diff --git a/src/services/BaseReasoningService.ts b/src/services/BaseReasoningService.ts
index 3eda21b4b..31981032a 100644
--- a/src/services/BaseReasoningService.ts
+++ b/src/services/BaseReasoningService.ts
@@ -10,6 +10,7 @@ export interface ReasoningConfig {
baseUrl?: string;
customApiKey?: string;
provider?: string;
+ disableThinking?: boolean;
}
export abstract class BaseReasoningService {
diff --git a/src/services/ReasoningService.ts b/src/services/ReasoningService.ts
index 698d65566..ed1193190 100644
--- a/src/services/ReasoningService.ts
+++ b/src/services/ReasoningService.ts
@@ -14,6 +14,7 @@ import { streamText, stepCountIs } from "ai";
import { getAIModel } from "./ai/providers";
import { PROVIDER_REGISTRY, type ProviderContext } from "./ai/inferenceProviders";
import { getConfiguredOpenAIBase } from "./ai/openaiBase";
+import { applyThinkingSuppression } from "./ai/thinkingSuppression";
export type AgentStreamChunk =
| { type: "content"; text: string }
@@ -166,11 +167,7 @@ class ReasoningService extends BaseReasoningService {
),
};
- // Disable thinking for Groq Qwen models
- const modelDef = getCloudModel(model);
- if (modelDef?.disableThinking && providerName.toLowerCase() === "groq") {
- requestBody.reasoning_effort = "none";
- }
+ applyThinkingSuppression(requestBody, model, providerName, config);
logger.logReasoning(`${providerName.toUpperCase()}_REQUEST`, {
endpoint,
@@ -404,6 +401,8 @@ class ReasoningService extends BaseReasoningService {
}
}
+ applyThinkingSuppression(requestBody, model, provider, config);
+
logger.logReasoning("AGENT_STREAM_REQUEST", {
endpoint,
model,
@@ -485,8 +484,9 @@ class ReasoningService extends BaseReasoningService {
let content = parsed.choices?.[0]?.delta?.content;
if (!content) continue;
- // Strip Qwen3 <think> blocks from streamed output
- if (isLocalProvider || isLanCleanup) {
+ const stripThinking =
+ (isLocalProvider || isLanCleanup) && config.disableThinking !== false;
+ if (stripThinking) {
if (insideThinkBlock) {
const endIdx = content.indexOf("</think>");
if (endIdx !== -1) {
@@ -582,7 +582,9 @@ class ReasoningService extends BaseReasoningService {
const aiModel = getAIModel(aiProvider, model, apiKey, baseURL);
const modelDef = getCloudModel(model);
- const needsDisableThinking = provider === "groq" && modelDef?.disableThinking;
+ const userSuppressesThinking = config.disableThinking === true && !!modelDef?.supportsThinking;
+ const needsDisableThinking =
+ provider === "groq" && (modelDef?.disableThinking || userSuppressesThinking);
logger.logReasoning("AGENT_AI_SDK_STREAM_REQUEST", {
model,
diff --git a/src/services/ai/inferenceProviders/lan.ts b/src/services/ai/inferenceProviders/lan.ts
index d5a40b2a0..be347cf60 100644
--- a/src/services/ai/inferenceProviders/lan.ts
+++ b/src/services/ai/inferenceProviders/lan.ts
@@ -5,17 +5,19 @@ import logger from "../../../utils/logger";
export const lanProvider: InferenceProvider = {
id: "lan",
- async call({ text, agentName, config, ctx }) {
+ async call({ text, model, agentName, config, ctx }) {
const lanUrl = (config.lanUrl || getSettings().cleanupRemoteUrl).trim();
- logger.logReasoning("LAN_START", { url: lanUrl, agentName });
+ logger.logReasoning("LAN_START", { url: lanUrl, agentName, model });
try {
const baseUrl = normalizeBaseUrl(lanUrl) || lanUrl;
const endpoint = buildApiUrl(baseUrl, "/v1/chat/completions");
+ const apiKey = config.customApiKey?.trim() || getSettings().cleanupCustomApiKey?.trim() || "";
+ const resolvedModel = model?.trim() || "default";
return await ctx.callChatCompletionsApi(
endpoint,
- "",
- "default",
+ apiKey,
+ resolvedModel,
text,
agentName,
config,
diff --git a/src/services/ai/inferenceProviders/openai.ts b/src/services/ai/inferenceProviders/openai.ts
index a7ad5b703..2834442b0 100644
--- a/src/services/ai/inferenceProviders/openai.ts
+++ b/src/services/ai/inferenceProviders/openai.ts
@@ -5,6 +5,7 @@ import { getSettings } from "../../../stores/settingsStore";
import { withRetry, createApiRetryStrategy } from "../../../utils/retry";
import logger from "../../../utils/logger";
import { getConfiguredOpenAIBase } from "../openaiBase";
+import { applyThinkingSuppression } from "../thinkingSuppression";
const OPENAI_ENDPOINT_PREF_STORAGE_KEY = "openAiEndpointPreference";
const REQUEST_TIMEOUT_MS = 30_000;
@@ -194,6 +195,7 @@ export const openaiProvider: InferenceProvider = {
} else {
requestBody.messages = messages;
requestBody[apiConfig.tokenParam] = maxTokens;
+ applyThinkingSuppression(requestBody, model, resolvedProvider, config);
}
if (apiConfig.supportsTemperature) {
diff --git a/src/services/ai/thinkingSuppression.ts b/src/services/ai/thinkingSuppression.ts
new file mode 100644
index 000000000..76965eedb
--- /dev/null
+++ b/src/services/ai/thinkingSuppression.ts
@@ -0,0 +1,31 @@
+import type { ReasoningConfig } from "../BaseReasoningService";
+import { getCloudModel, getLocalModel } from "../../models/ModelRegistry";
+
+// Sends both `reasoning_effort` (OpenAI/Groq dialect) and `think` (Ollama
+// dialect); servers ignore unknown fields. Skips known non-thinking models
+// to avoid suppressing reasoning on models like gpt-5 where the user toggle
+// is hidden but the default value still applies.
+export function applyThinkingSuppression(
+ requestBody: Record<string, unknown>,
+ model: string,
+ provider: string,
+ config: ReasoningConfig
+): void {
+ const cloudModel = getCloudModel(model);
+ const curatedGroqSuppress = !!cloudModel?.disableThinking && provider.toLowerCase() === "groq";
+
+ if (curatedGroqSuppress) {
+ requestBody.reasoning_effort = "none";
+ requestBody.think = false;
+ return;
+ }
+
+ if (config.disableThinking !== true) return;
+
+ const localModel = getLocalModel(model);
+ const knownModel = cloudModel || localModel;
+ if (knownModel && !knownModel.supportsThinking) return;
+
+ requestBody.reasoning_effort = "none";
+ requestBody.think = false;
+}
diff --git a/src/services/localReasoningBridge.js b/src/services/localReasoningBridge.js
index 84a5bdf51..1ac603ea1 100644
--- a/src/services/localReasoningBridge.js
+++ b/src/services/localReasoningBridge.js
@@ -48,10 +48,13 @@ class LocalReasoningService {
});
const result = await modelManager.runInference(modelId, text, inferenceConfig);
- const cleanResult = result
- .replace(/<think>[\s\S]*?<\/think>/g, "")
- .replace(/<think>[\s\S]*$/, "")
- .trim();
+ const stripThinking = config.disableThinking !== false;
+ const cleanResult = stripThinking
+ ? result
+ .replace(/<think>[\s\S]*?<\/think>/g, "")
+ .replace(/<think>[\s\S]*$/, "")
+ .trim()
+ : result.trim();
const processingTime = Date.now() - startTime;
diff --git a/src/stores/settingsStore.ts b/src/stores/settingsStore.ts
index e2d274e33..9460d9a06 100644
--- a/src/stores/settingsStore.ts
+++ b/src/stores/settingsStore.ts
@@ -124,6 +124,10 @@ const BOOLEAN_SETTINGS = new Set([
"dataRetentionEnabled",
"noteFilesEnabled",
"showTranscriptionPreview",
+ "cleanupDisableThinking",
+ "dictationAgentDisableThinking",
+ "noteFormattingDisableThinking",
+ "chatAgentDisableThinking",
]);
const ARRAY_SETTINGS = new Set(["customDictionary", "gcalAccounts"]);
@@ -364,6 +368,11 @@ export interface SettingsState
dictationAgentRemoteUrl: string;
dictationAgentCustomApiKey: string;
+ cleanupDisableThinking: boolean;
+ dictationAgentDisableThinking: boolean;
+ noteFormattingDisableThinking: boolean;
+ chatAgentDisableThinking: boolean;
+
customPrompts: Record<PromptKind, string>;
setCustomPrompt: (kind: PromptKind, value: string) => void;
@@ -401,6 +410,11 @@ export interface SettingsState
setNoteFormattingRemoteUrl: (url: string) => void;
setNoteFormattingCustomApiKey: (key: string) => void;
+ setCleanupDisableThinking: (value: boolean) => void;
+ setDictationAgentDisableThinking: (value: boolean) => void;
+ setNoteFormattingDisableThinking: (value: boolean) => void;
+ setChatAgentDisableThinking: (value: boolean) => void;
+
setUseLocalWhisper: (value: boolean) => void;
setWhisperModel: (value: string) => void;
setLocalTranscriptionProvider: (value: LocalTranscriptionProvider) => void;
@@ -857,6 +871,11 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({
dictationAgentRemoteUrl: readString("dictationAgentRemoteUrl", ""),
dictationAgentCustomApiKey: readString("dictationAgentCustomApiKey", ""),
+ cleanupDisableThinking: readBoolean("cleanupDisableThinking", true),
+ dictationAgentDisableThinking: readBoolean("dictationAgentDisableThinking", true),
+ noteFormattingDisableThinking: readBoolean("noteFormattingDisableThinking", true),
+ chatAgentDisableThinking: readBoolean("chatAgentDisableThinking", true),
+
customPrompts: PROMPT_KIND_LIST.reduce(
(acc, kind) => ({ ...acc, [kind]: readString(`customPrompt.${kind}`, "") }),
{} as Record<PromptKind, string>
@@ -876,6 +895,11 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({
setDictationAgentRemoteUrl: createStringSetter("dictationAgentRemoteUrl"),
setDictationAgentCustomApiKey: createStringSetter("dictationAgentCustomApiKey"),
+ setCleanupDisableThinking: createBooleanSetter("cleanupDisableThinking"),
+ setDictationAgentDisableThinking: createBooleanSetter("dictationAgentDisableThinking"),
+ setNoteFormattingDisableThinking: createBooleanSetter("noteFormattingDisableThinking"),
+ setChatAgentDisableThinking: createBooleanSetter("chatAgentDisableThinking"),
+
setUseLocalWhisper: createBooleanSetter("useLocalWhisper"),
setWhisperModel: createStringSetter("whisperModel"),
setLocalTranscriptionProvider: (value: LocalTranscriptionProvider) => {
@@ -1339,6 +1363,7 @@ export interface ResolvedLLMConfig {
cloudBaseUrl?: string;
remoteUrl?: string;
customApiKey?: string;
+ disableThinking: boolean;
}
export const selectResolvedLLMConfig = (
@@ -1356,6 +1381,9 @@ export const selectResolvedLLMConfig = (
return (state[key] as string | undefined) || undefined;
};
+ const disableThinkingKey = def.storeKeys.disableThinking;
+ const disableThinking = disableThinkingKey ? (state[disableThinkingKey] as boolean) : true;
+
return {
scope,
mode: state[def.storeKeys.mode] as InferenceMode,
@@ -1365,6 +1393,7 @@ export const selectResolvedLLMConfig = (
cloudBaseUrl: read("cloudBaseUrl") || fallback?.cloudBaseUrl,
remoteUrl: read("remoteUrl") || fallback?.remoteUrl,
customApiKey: read("customApiKey"),
+ disableThinking,
};
};
@@ -1378,7 +1407,12 @@ export function setResolvedLLMConfig(
if (value === undefined) continue;
const storeKey = def.storeKeys[field as keyof InferenceScopeStoreKeys];
if (!storeKey) continue;
- if (isBrowser) localStorage.setItem(storeKey as string, value as string);
+ if (isBrowser) {
+ localStorage.setItem(
+ storeKey as string,
+ typeof value === "boolean" ? String(value) : (value as string)
+ );
+ }
(updates as Record<string, unknown>)[storeKey as string] = value;
}
if (Object.keys(updates).length > 0) useSettingsStore.setState(updates);
diff --git a/src/utils/generateTitle.ts b/src/utils/generateTitle.ts
index 39c2fc89d..c5dbb75a2 100644
--- a/src/utils/generateTitle.ts
+++ b/src/utils/generateTitle.ts
@@ -1,4 +1,5 @@
import reasoningService from "../services/ReasoningService";
+import { getSettings } from "../stores/settingsStore";
const TITLE_SYSTEM_PROMPT =
"Generate a concise 3-8 word title for these notes. Return ONLY the title text, nothing else — no quotes, no prefix, no explanation.";
@@ -8,6 +9,7 @@ export async function generateNoteTitle(text: string, modelId: string): Promise<
const raw = await reasoningService.processText(text.slice(0, 2000), modelId, null, {
systemPrompt: TITLE_SYSTEM_PROMPT,
temperature: 0.3,
+ disableThinking: getSettings().noteFormattingDisableThinking,
});
const cleaned = raw.trim().replace(/^["']|["']$/g, "");
return cleaned.length > 0 && cleaned.length < 100 ? cleaned : "";