Skip to content

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

fix: bundle compiled Globe listener and surface mac hotkey errors

Gabriel Stein54cc8e0d90d0
diff --git a/.gitignore b/.gitignore
index 3b61a84ef..277baf931 100644
--- a/.gitignore
+++ b/.gitignore
@@ -188,6 +188,9 @@ build/
*.AppImage
*.snap
+# Generated Globe listener binary
+resources/bin/
+
# macOS
.DS_Store
.AppleDouble
@@ -269,4 +272,4 @@ $RECYCLE.BIN/
.Spotlight-V100
.Trashes
ehthumbs.db
-Thumbs.db
\ No newline at end of file
+Thumbs.db
diff --git a/electron-builder.json b/electron-builder.json
index 2b30f5cae..a63cf61d5 100644
--- a/electron-builder.json
+++ b/electron-builder.json
@@ -30,7 +30,8 @@
],
"extraResources": [
"src/assets/**/*",
- "resources/macos-globe-listener.swift"
+ "resources/macos-globe-listener.swift",
+ "resources/bin/macos-globe-listener"
],
"mac": {
"category": "public.app-category.productivity",
diff --git a/main.js b/main.js
index a5e0248ae..a59668893 100644
--- a/main.js
+++ b/main.js
@@ -1,4 +1,4 @@
-const { app, globalShortcut, BrowserWindow } = require("electron");
+const { app, globalShortcut, BrowserWindow, dialog } = require("electron");
// Ensure macOS menus use the proper casing for the app name
if (process.platform === "darwin" && app.getName() !== "OpenWhispr") {
@@ -69,6 +69,34 @@ const whisperManager = new WhisperManager();
const trayManager = new TrayManager();
const updateManager = new UpdateManager();
const globeKeyManager = new GlobeKeyManager();
+let globeKeyAlertShown = false;
+
+if (process.platform === "darwin") {
+ globeKeyManager.on("error", (error) => {
+ if (globeKeyAlertShown) {
+ return;
+ }
+ globeKeyAlertShown = true;
+
+ const detailLines = [
+ error?.message || "Unknown error occurred while starting the Globe listener.",
+ "The Globe key shortcut will remain disabled; existing keyboard shortcuts continue to work.",
+ ];
+
+ if (process.env.NODE_ENV === "development") {
+ detailLines.push("Run `npm run compile:globe` and rebuild the app to regenerate the listener binary.");
+ } else {
+ detailLines.push("Try reinstalling OpenWhispr or contact support if the issue persists.");
+ }
+
+ dialog.showMessageBox({
+ type: "warning",
+ title: "Globe Hotkey Unavailable",
+ message: "OpenWhispr could not activate the Globe key hotkey.",
+ detail: detailLines.join("\n\n"),
+ });
+ });
+}
// Initialize IPC handlers with all managers
const ipcHandlers = new IPCHandlers({
diff --git a/package-lock.json b/package-lock.json
index 97d0442aa..5a66ff1bf 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "open-whispr",
- "version": "1.0.9",
+ "version": "1.0.10",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "open-whispr",
- "version": "1.0.9",
+ "version": "1.0.10",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
diff --git a/package.json b/package.json
index b768ecd71..4f47f16e9 100644
--- a/package.json
+++ b/package.json
@@ -1,22 +1,32 @@
{
"name": "open-whispr",
- "version": "1.0.9",
+ "version": "1.0.10",
"description": "A desktop dictation application using OpenAI Whisper for speech-to-text transcription",
"main": "main.js",
"private": true,
"scripts": {
+ "compile:globe": "node scripts/build-globe-listener.js",
+ "prestart": "npm run compile:globe",
"start": "electron .",
+ "predev": "npm run compile:globe",
"dev": "concurrently -k -r \"npm:dev:renderer\" \"npm:dev:main\"",
+ "predev:main": "npm run compile:globe",
"dev:main": "cross-env NODE_ENV=development electron . --dev",
"dev:renderer": "cd src && vite",
+ "prebuild": "npm run compile:globe",
"build": "cd src && vite build && cd .. && electron-builder",
"postinstall": "electron-builder install-app-deps",
"build:renderer": "cd src && vite build",
+ "prebuild:mac": "npm run compile:globe",
"build:mac": "npm run build:renderer && electron-builder --mac",
+ "prebuild:win": "npm run compile:globe",
"build:win": "npm run build:renderer && electron-builder --win",
+ "prebuild:linux": "npm run compile:globe",
"build:linux": "npm run build:renderer && electron-builder --linux",
"setup": "node setup.js",
+ "prepack": "npm run compile:globe",
"pack": "npm run build:renderer && CSC_IDENTITY_AUTO_DISCOVERY=false electron-builder --dir",
+ "predist": "npm run compile:globe",
"dist": "npm run build:renderer && electron-builder",
"lint": "cd src && eslint .",
"preview": "cd src && vite preview",
diff --git a/scripts/build-globe-listener.js b/scripts/build-globe-listener.js
new file mode 100644
index 000000000..755b8720c
--- /dev/null
+++ b/scripts/build-globe-listener.js
@@ -0,0 +1,90 @@
+#!/usr/bin/env node
+
+const { spawnSync } = require("child_process");
+const fs = require("fs");
+const path = require("path");
+
+const isMac = process.platform === "darwin";
+if (!isMac) {
+ process.exit(0);
+}
+
+const projectRoot = path.resolve(__dirname, "..");
+const swiftSource = path.join(projectRoot, "resources", "macos-globe-listener.swift");
+const outputDir = path.join(projectRoot, "resources", "bin");
+const outputBinary = path.join(outputDir, "macos-globe-listener");
+const moduleCacheDir = path.join(outputDir, ".swift-module-cache");
+
+function log(message) {
+ console.log(`[globe-listener] ${message}`);
+}
+
+function ensureDir(dirPath) {
+ if (!fs.existsSync(dirPath)) {
+ fs.mkdirSync(dirPath, { recursive: true });
+ }
+}
+
+if (!fs.existsSync(swiftSource)) {
+ console.error(`[globe-listener] Swift source not found at ${swiftSource}`);
+ process.exit(1);
+}
+
+ensureDir(outputDir);
+ensureDir(moduleCacheDir);
+
+let needsBuild = true;
+if (fs.existsSync(outputBinary)) {
+ try {
+ const binaryStat = fs.statSync(outputBinary);
+ const sourceStat = fs.statSync(swiftSource);
+ if (binaryStat.mtimeMs >= sourceStat.mtimeMs) {
+ needsBuild = false;
+ }
+ } catch {
+ needsBuild = true;
+ }
+}
+
+if (!needsBuild) {
+ process.exit(0);
+}
+
+function attemptCompile(command, args) {
+ log(`Compiling with ${[command, ...args].join(" ")}`);
+ return spawnSync(command, args, {
+ stdio: "inherit",
+ env: {
+ ...process.env,
+ SWIFT_MODULE_CACHE_PATH: moduleCacheDir,
+ },
+ });
+}
+
+const compileArgs = [
+ swiftSource,
+ "-O",
+ "-module-cache-path",
+ moduleCacheDir,
+ "-o",
+ outputBinary,
+];
+
+let result = attemptCompile("xcrun", ["swiftc", ...compileArgs]);
+
+if (result.status !== 0) {
+ result = attemptCompile("swiftc", compileArgs);
+}
+
+if (result.status !== 0) {
+ console.error("[globe-listener] Failed to compile macOS Globe listener binary.");
+ process.exit(result.status ?? 1);
+}
+
+try {
+ fs.chmodSync(outputBinary, 0o755);
+} catch (error) {
+ console.warn(`[globe-listener] Unable to set executable permissions: ${error.message}`);
+}
+
+log("Successfully built macOS Globe listener binary.");
diff --git a/src/helpers/globeKeyManager.js b/src/helpers/globeKeyManager.js
index 97467a6f4..923340407 100644
--- a/src/helpers/globeKeyManager.js
+++ b/src/helpers/globeKeyManager.js
@@ -8,6 +8,7 @@ class GlobeKeyManager extends EventEmitter {
super();
this.process = null;
this.isSupported = process.platform === "darwin";
+ this.hasReportedError = false;
}
start() {
@@ -15,13 +16,27 @@ class GlobeKeyManager extends EventEmitter {
return;
}
- const scriptPath = this.resolveScriptPath();
- if (!scriptPath) {
- console.error("GlobeKeyManager: Swift listener script not found");
+ const listenerPath = this.resolveListenerBinary();
+ if (!listenerPath) {
+ this.reportError(
+ new Error(
+ "macOS Globe listener binary not found. Run `npm run compile:globe` before packaging."
+ )
+ );
return;
}
- this.process = spawn("swift", [scriptPath]);
+ try {
+ fs.accessSync(listenerPath, fs.constants.X_OK);
+ } catch (accessError) {
+ this.reportError(
+ new Error(`macOS Globe listener is not executable: ${listenerPath}`)
+ );
+ return;
+ }
+
+ this.hasReportedError = false;
+ this.process = spawn(listenerPath);
this.process.stdout.setEncoding("utf8");
this.process.stdout.on("data", (chunk) => {
@@ -40,21 +55,25 @@ class GlobeKeyManager extends EventEmitter {
this.process.stderr.setEncoding("utf8");
this.process.stderr.on("data", (data) => {
- console.error("GlobeKeyManager error:", data.trim());
+ const message = data.toString().trim();
+ if (message.length > 0) {
+ console.error("GlobeKeyManager stderr:", message);
+ this.reportError(new Error(message));
+ }
});
this.process.on("error", (error) => {
- console.error("GlobeKeyManager failed to start:", error);
+ this.reportError(error);
this.process = null;
- this.emit("error", error);
});
this.process.on("exit", (code, signal) => {
this.process = null;
if (code !== 0) {
- console.error(
- `GlobeKeyManager exited with code ${code ?? "null"} signal ${signal ?? "null"}`
+ const error = new Error(
+ `Globe key listener exited with code ${code ?? "null"} signal ${signal ?? "null"}`
);
+ this.reportError(error);
}
});
}
@@ -66,16 +85,64 @@ class GlobeKeyManager extends EventEmitter {
}
}
- resolveScriptPath() {
+ reportError(error) {
+ if (this.hasReportedError) {
+ return;
+ }
+ this.hasReportedError = true;
+ if (this.process) {
+ try {
+ this.process.kill();
+ } catch {
+ // ignore
+ } finally {
+ this.process = null;
+ }
+ }
+ console.error("GlobeKeyManager error:", error);
+ this.emit("error", error);
+ }
+
+ resolveListenerBinary() {
+ const candidates = new Set([
+ path.join(__dirname, "..", "..", "resources", "bin", "macos-globe-listener"),
+ path.join(__dirname, "..", "..", "resources", "macos-globe-listener"),
+ ]);
+
+ if (process.resourcesPath) {
+ [
+ path.join(process.resourcesPath, "macos-globe-listener"),
+ path.join(process.resourcesPath, "bin", "macos-globe-listener"),
+ path.join(process.resourcesPath, "resources", "macos-globe-listener"),
+ path.join(process.resourcesPath, "resources", "bin", "macos-globe-listener"),
+ path.join(
+ process.resourcesPath,
+ "app.asar.unpacked",
+ "resources",
+ "macos-globe-listener"
+ ),
+ path.join(
+ process.resourcesPath,
+ "app.asar.unpacked",
+ "resources",
+ "bin",
+ "macos-globe-listener"
+ ),
+ ].forEach((candidate) => candidates.add(candidate));
+ }
+
const candidatePaths = [
- path.join(__dirname, "..", "..", "resources", "macos-globe-listener.swift"),
- path.join(process.resourcesPath, "macos-globe-listener.swift"),
- path.join(process.resourcesPath, "app.asar.unpacked", "resources", "macos-globe-listener.swift"),
+ ...candidates,
];
for (const candidate of candidatePaths) {
- if (fs.existsSync(candidate)) {
- return candidate;
+ try {
+ const stats = fs.statSync(candidate);
+ if (stats.isFile()) {
+ return candidate;
+ }
+ } catch {
+ continue;
}
}