Skip to content

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

fix(whisper): engage downloaded GPU packs without the env flag

Gabriel Steind4c207a29f78
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 00df09ea5..b9e73de24 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -1107,7 +1107,15 @@ class IPCHandlers {
set: Object.keys(setVars),
cleared: clearVars.filter((k) => !process.env[k]),
});
- this.environmentManager.saveAllKeysToEnvFile().catch(() => {});
+ // A swallowed .env write failure here left GPU enablement flags silently
+ // out of sync with the packs on disk (#1340) — log which keys were lost.
+ this.environmentManager.saveAllKeysToEnvFile().catch((err) => {
+ debugLogger.error("Failed to persist startup env vars to .env", {
+ set: Object.keys(setVars),
+ cleared: clearVars,
+ error: err.message,
+ });
+ });
}
}
diff --git a/src/helpers/whisper.js b/src/helpers/whisper.js
index 1709a5922..283dc0999 100644
--- a/src/helpers/whisper.js
+++ b/src/helpers/whisper.js
@@ -77,7 +77,11 @@ class WhisperManager {
// The GPU backend for every server start is resolved fresh from the current
// env + installed packs, so enabling or removing a pack applies immediately
- // instead of after an app restart. WHISPER_GPU_FAILED lists backends that
+ // instead of after an app restart. A pack on disk implies intent: the user
+ // downloaded it, so it engages unless WHISPER_*_ENABLED is explicitly set to
+ // "false" (an opt-out that survives without deleting the pack). Requiring
+ // the flag to be present stranded downloaded packs on silent CPU whenever
+ // the .env line was lost (#1340). WHISPER_GPU_FAILED lists backends that
// crashed on this machine (persisted by ipcHandlers when the server falls
// back to CPU); they stay off until the user retries or re-downloads, so a
// doomed backend isn't re-attempted — and its model reload re-paid — on
@@ -85,12 +89,12 @@ class WhisperManager {
resolveGpuStartOptions() {
const failed = resolveFailedGpuBackends(process.env.WHISPER_GPU_FAILED);
const useCuda =
- process.env.WHISPER_CUDA_ENABLED === "true" &&
+ process.env.WHISPER_CUDA_ENABLED !== "false" &&
!failed.includes("cuda") &&
!!this._cudaBinaryManager?.isDownloaded();
const useVulkan =
!useCuda &&
- process.env.WHISPER_VULKAN_ENABLED === "true" &&
+ process.env.WHISPER_VULKAN_ENABLED !== "false" &&
!failed.includes("vulkan") &&
!!this._vulkanBinaryManager?.isDownloaded();
return { useCuda, useVulkan };
diff --git a/test/helpers/whisperGpuResolve.test.js b/test/helpers/whisperGpuResolve.test.js
index 1c9297977..8cacc84d9 100644
--- a/test/helpers/whisperGpuResolve.test.js
+++ b/test/helpers/whisperGpuResolve.test.js
@@ -80,6 +80,32 @@ test("clearing the failure re-enables the backend (Retry)", () => {
assert.equal(manager.resolveGpuStartOptions().useCuda, true);
});
+test("a downloaded pack with a lost env flag still engages (#1340)", () => {
+ // A pack on disk implies intent: losing the WHISPER_*_ENABLED line from .env
+ // must not strand the pack on silent CPU.
+ const vulkanOnly = managerWith({ vulkanDownloaded: true });
+ assert.deepEqual(vulkanOnly.resolveGpuStartOptions(), { useCuda: false, useVulkan: true });
+
+ const cudaOnly = managerWith({ cudaDownloaded: true });
+ assert.deepEqual(cudaOnly.resolveGpuStartOptions(), { useCuda: true, useVulkan: false });
+});
+
+test("explicit 'false' opts a downloaded pack out", () => {
+ process.env.WHISPER_VULKAN_ENABLED = "false";
+ const vulkanOnly = managerWith({ vulkanDownloaded: true });
+ assert.deepEqual(vulkanOnly.resolveGpuStartOptions(), { useCuda: false, useVulkan: false });
+
+ process.env.WHISPER_CUDA_ENABLED = "false";
+ const cudaOnly = managerWith({ cudaDownloaded: true });
+ assert.deepEqual(cudaOnly.resolveGpuStartOptions(), { useCuda: false, useVulkan: false });
+});
+
+test("a remembered failure still gates a flag-less downloaded pack", () => {
+ process.env.WHISPER_GPU_FAILED = "vulkan";
+ const manager = managerWith({ vulkanDownloaded: true });
+ assert.deepEqual(manager.resolveGpuStartOptions(), { useCuda: false, useVulkan: false });
+});
+
test("without injected binary managers (macOS) everything resolves to CPU", () => {
process.env.WHISPER_CUDA_ENABLED = "true";
process.env.WHISPER_VULKAN_ENABLED = "true";