Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
fix(gpu): gate the cleanup GPU banner on local inference (#1591)
Chad Pihafbd267a2affc
diff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsxindex 319abd313..93c448060 100644--- a/src/components/ControlPanel.tsx+++ b/src/components/ControlPanel.tsx@@ -1,5 +1,6 @@import React, { Suspense, useState, useEffect, useRef, useCallback } from "react";import { useTranslation } from "react-i18next";+import { useShallow } from "zustand/react/shallow";import { Button } from "./ui/button";import {Download,@@ -32,8 +33,13 @@ import {updateTranscription as updateInStore,clearTranscriptions as clearStore,} from "../stores/transcriptionStore";-import { getSettings, useSettingsStore } from "../stores/settingsStore";+import {+ getSettings,+ selectPolicyEffectiveSettings,+ useSettingsStore,+} from "../stores/settingsStore";import { usePolicyStore } from "../stores/policyStore";+import { usePolicySnapshot } from "../hooks/usePolicy";import {isAgentAllowed,isControlPanelViewAllowed,@@ -53,6 +59,7 @@ import WindowControls from "./WindowControls";import { getCachedPlatform } from "../utils/platform";import { isAccessibilitySkipped } from "../utils/permissions";+import { eligibleGpuOffers, type GpuOffers } from "../utils/gpuBannerPolicy";import {setActiveNoteId,setActiveFolderId,@@ -145,12 +152,9 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelProfolderId: number;event: any;} | null>(null);- const [gpuAccelAvailable, setGpuAccelAvailable] = useState<{- transcription: boolean;- intelligence: boolean;- }>({+ const [gpuAccelAvailable, setGpuAccelAvailable] = useState<GpuOffers>({transcription: false,- intelligence: false,+ intelligence: null,});const [gpuBannerDismissed, setGpuBannerDismissed] = useState(() => localStorage.getItem("gpuBannerDismissedUnified") === "true"@@ -160,13 +164,7 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelProconst updateErrorToastShown = useRef<Error | null>(null);const { hotkey } = useHotkey();const { toast } = useToast();- const {- useLocalWhisper,- localTranscriptionProvider,- useCleanupModel,- setUseLocalWhisper,- setCloudTranscriptionMode,- } = useSettings();+ const { useCleanupModel, setUseLocalWhisper, setCloudTranscriptionMode } = useSettings();const { isSignedIn, isLoaded: authLoaded, user } = useAuth();// Suppressed while a deep-linked invitation is open so the two never stack.const {@@ -202,6 +200,23 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelProconst updateRequiredByOrg = usePolicyStore(isUpdateRequiredByOrg);const policyMinAppVersion = usePolicyStore((s) => s.policy?.minAppVersion ?? null);+ // Policy-effective, because the settings pane the GPU banner links to renders+ // the clamped mode — see eligibleGpuOffers.+ const policySnapshot = usePolicySnapshot();+ const gpuBannerSettings = useSettingsStore(+ useShallow((settings) => {+ const effective = selectPolicyEffectiveSettings(settings, policySnapshot);+ return {+ useLocalWhisper: effective.useLocalWhisper,+ localTranscriptionProvider: effective.localTranscriptionProvider,+ useCleanupModel: effective.useCleanupModel,+ cleanupMode: effective.cleanupMode,+ useDictationAgent: effective.useDictationAgent,+ dictationAgentMode: effective.dictationAgentMode,+ };+ })+ );+const {confirmDialog,alertDialog,@@ -389,9 +404,14 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelProuseEffect(() => {if (platform === "darwin" || gpuBannerDismissed) return;+ const offers = eligibleGpuOffers({ ...gpuBannerSettings, agentAllowedByPolicy });+ // A run that loses its settings mid-probe must not publish: switching to a+ // cloud mode resolves with no IPC at all, so an older local-mode run would+ // otherwise land last and re-raise the banner for the rest of the session.+ let cancelled = false;const detect = async () => {- const results = { transcription: false, intelligence: false };- if (useLocalWhisper && localTranscriptionProvider === "whisper") {+ const results: GpuOffers = { transcription: false, intelligence: null };+ if (offers.transcription) {try {const status = await window.electronAPI?.getCudaWhisperStatus?.();if (status?.gpuInfo.hasNvidiaGpu && status.gpuInfo.cudaSupported) {@@ -402,19 +422,22 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro}} catch {}}- if (useCleanupModel) {+ if (offers.intelligence) {try {const [gpu, vulkan] = await Promise.all([window.electronAPI?.detectVulkanGpu?.(),window.electronAPI?.getLlamaVulkanStatus?.(),]);- if (gpu?.available && !vulkan?.downloaded) results.intelligence = true;+ if (gpu?.available && !vulkan?.downloaded) results.intelligence = offers.intelligence;} catch {}}- setGpuAccelAvailable(results);+ if (!cancelled) setGpuAccelAvailable(results);};detect();- }, [useLocalWhisper, localTranscriptionProvider, useCleanupModel, gpuBannerDismissed]);+ return () => {+ cancelled = true;+ };+ }, [gpuBannerSettings, agentAllowedByPolicy, gpuBannerDismissed]);useEffect(() => {const drain = async () => {@@ -1127,7 +1150,11 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelProclassName="h-7 text-xs"onClick={() => {setSettingsSection(- gpuAccelAvailable.transcription ? "transcription" : "intelligence"+ gpuAccelAvailable.transcription+ ? "transcription"+ : gpuAccelAvailable.intelligence === "dictationAgent"+ ? "dictationAgent"+ : "intelligence");setShowSettings(true);}}diff --git a/src/components/SettingsModal.tsx b/src/components/SettingsModal.tsxindex b6118783e..9afa0e429 100644--- a/src/components/SettingsModal.tsx+++ b/src/components/SettingsModal.tsx@@ -21,10 +21,12 @@ export type { SettingsSectionType };// The old AI Models sidebar had four items (transcription, meetings,// intelligence, agentMode) — they now collapse into two: speechToText + llms.// Legacy deep-links land on the matching sub-tab via LEGACY_SUB_TAB.+// "dictationAgent" is a live deep-link (the Home GPU banner), not a legacy alias.const SECTION_ALIASES: Record<string, SettingsSectionType> = {aiModels: "llms",agentConfig: "llms",agentMode: "llms",+ dictationAgent: "llms",intelligence: "llms",meetings: "llms",prompts: "llms",@@ -39,6 +41,7 @@ const SECTION_ALIASES: Record<string, SettingsSectionType> = {const LEGACY_SUB_TAB: Record<string, string> = {transcription: "dictation",uploadTranscription: "upload",+ dictationAgent: "dictationAgent",meetings: "noteFormatting",intelligence: "dictationCleanup",agentMode: "chatIntelligence",diff --git a/src/utils/gpuBannerPolicy.ts b/src/utils/gpuBannerPolicy.tsnew file mode 100644index 000000000..06ac46d7b--- /dev/null+++ b/src/utils/gpuBannerPolicy.ts@@ -0,0 +1,42 @@+import type { InferenceMode, LocalTranscriptionProvider } from "../types/electron";++export interface GpuOfferInputs {+ useLocalWhisper: boolean;+ localTranscriptionProvider: LocalTranscriptionProvider;+ useCleanupModel: boolean;+ cleanupMode: InferenceMode;+ useDictationAgent: boolean;+ dictationAgentMode: InferenceMode;+ agentAllowedByPolicy: boolean;+}++export type IntelligenceGpuTarget = "cleanup" | "dictationAgent";++export interface GpuOffers {+ transcription: boolean;+ intelligence: IntelligenceGpuTarget | null;+}++// The Home-screen GPU banner offers to install local acceleration binaries, so+// each branch must require an engine that actually runs locally — otherwise the+// Enable GPU button would land on a settings pane without the install control+// (#1509). Cleanup and the dictation agent share the local llama server (see+// resolveLocalServerNeeds), so either one running locally makes the Vulkan+// pack worth offering; the target names the settings tab that carries the+// install control. A policy-blocked agent gets no offer — its tab is hidden.+//+// Modes must be policy-effective (selectPolicyEffectiveSettings), not raw: the+// settings pane renders the clamped mode, so a managed profile that forbids+// local inference leaves the raw mode at "local" pointing at a pane that shows+// no install control — the same dead end #1509 reported.+export function eligibleGpuOffers(inputs: GpuOfferInputs): GpuOffers {+ const cleanupLocal = inputs.useCleanupModel && inputs.cleanupMode === "local";+ const agentLocal =+ inputs.useDictationAgent &&+ inputs.agentAllowedByPolicy &&+ inputs.dictationAgentMode === "local";+ return {+ transcription: inputs.useLocalWhisper && inputs.localTranscriptionProvider === "whisper",+ intelligence: cleanupLocal ? "cleanup" : agentLocal ? "dictationAgent" : null,+ };+}diff --git a/test/utils/gpuBannerPolicy.test.js b/test/utils/gpuBannerPolicy.test.jsnew file mode 100644index 000000000..a260aeca8--- /dev/null+++ b/test/utils/gpuBannerPolicy.test.js@@ -0,0 +1,102 @@+const test = require("node:test");+const assert = require("node:assert/strict");++const load = () => import("../../src/utils/gpuBannerPolicy.ts");++const offersWith = async (overrides) => {+ const { eligibleGpuOffers } = await load();+ return eligibleGpuOffers({+ useLocalWhisper: false,+ localTranscriptionProvider: "whisper",+ useCleanupModel: false,+ cleanupMode: "openwhispr",+ useDictationAgent: false,+ dictationAgentMode: "openwhispr",+ agentAllowedByPolicy: true,+ ...overrides,+ });+};++test("cloud cleanup (openwhispr default) is not eligible for the intelligence GPU offer", async () => {+ const offers = await offersWith({ useCleanupModel: true, cleanupMode: "openwhispr" });++ assert.equal(offers.intelligence, null);+});++test("cloud cleanup modes are never eligible even with cleanup enabled", async () => {+ for (const cleanupMode of ["openwhispr", "providers", "self-hosted", "enterprise"]) {+ const offers = await offersWith({ useCleanupModel: true, cleanupMode });+ assert.equal(offers.intelligence, null, `cleanupMode=${cleanupMode}`);+ }+});++test("local cleanup with the model enabled targets the cleanup tab", async () => {+ const offers = await offersWith({ useCleanupModel: true, cleanupMode: "local" });++ assert.equal(offers.intelligence, "cleanup");+});++test("local cleanup with the model disabled is not eligible", async () => {+ const offers = await offersWith({ useCleanupModel: false, cleanupMode: "local" });++ assert.equal(offers.intelligence, null);+});++test("a local dictation agent with cloud cleanup targets the agent tab", async () => {+ const offers = await offersWith({+ useCleanupModel: true,+ cleanupMode: "openwhispr",+ useDictationAgent: true,+ dictationAgentMode: "local",+ });++ assert.equal(offers.intelligence, "dictationAgent");+});++test("local cleanup wins the target when both scopes run locally", async () => {+ const offers = await offersWith({+ useCleanupModel: true,+ cleanupMode: "local",+ useDictationAgent: true,+ dictationAgentMode: "local",+ });++ assert.equal(offers.intelligence, "cleanup");+});++test("a disabled or cloud-mode dictation agent is not eligible", async () => {+ const disabled = await offersWith({ useDictationAgent: false, dictationAgentMode: "local" });+ assert.equal(disabled.intelligence, null);++ for (const dictationAgentMode of ["openwhispr", "providers", "self-hosted", "enterprise"]) {+ const cloud = await offersWith({ useDictationAgent: true, dictationAgentMode });+ assert.equal(cloud.intelligence, null, `dictationAgentMode=${dictationAgentMode}`);+ }+});++test("a policy-blocked agent gets no offer — its settings tab is hidden", async () => {+ const offers = await offersWith({+ useDictationAgent: true,+ dictationAgentMode: "local",+ agentAllowedByPolicy: false,+ });++ assert.equal(offers.intelligence, null);+});++test("local whisper transcription is eligible for the transcription GPU offer", async () => {+ const offers = await offersWith({ useLocalWhisper: true });++ assert.equal(offers.transcription, true);+});++test("cloud transcription and non-whisper local providers are not eligible", async () => {+ const cloud = await offersWith({ useLocalWhisper: false });+ assert.equal(cloud.transcription, false);++ const parakeet = await offersWith({+ useLocalWhisper: true,+ localTranscriptionProvider: "nvidia",+ });+ assert.equal(parakeet.transcription, false);+});