Skip to content

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

fix: auto-paste in Chromium-based apps on macOS (#668) (#823)

Gabriel Stein32825fe2aacc
diff --git a/src/components/notes/UploadAudioView.tsx b/src/components/notes/UploadAudioView.tsx
index f8bf05f5b..d241ed614 100644
--- a/src/components/notes/UploadAudioView.tsx
+++ b/src/components/notes/UploadAudioView.tsx
@@ -42,7 +42,7 @@ const TranscriptionModelPicker = React.lazy(() => import("../TranscriptionModelP
type UploadState = "idle" | "selected" | "transcribing" | "complete" | "error";
-const SUPPORTED_EXTENSIONS = ["mp3", "wav", "m4a", "webm", "ogg", "flac", "aac"];
+const SUPPORTED_EXTENSIONS = ["mp3", "wav", "m4a", "webm", "ogg", "oga", "flac", "aac"];
const BYOK_MAX_FILE_SIZE = 25 * 1024 * 1024; // 25 MB — hard limit for bring-your-own-key
const CLOUD_FREE_MAX_FILE_SIZE = 25 * 1024 * 1024; // 25 MB — free plan cloud limit
@@ -788,7 +788,7 @@ function IdleView({
<input
ref={fileInputRef}
type="file"
- accept=".mp3,.wav,.m4a,.webm,.ogg,.flac,.aac"
+ accept=".mp3,.wav,.m4a,.webm,.ogg,.oga,.flac,.aac"
onChange={handleFileInputChange}
className="sr-only"
tabIndex={-1}
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index ab5725d5f..795f93906 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -72,6 +72,7 @@ const AUDIO_MIME_TYPES = {
m4a: "audio/mp4",
webm: "audio/webm",
ogg: "audio/ogg",
+ oga: "audio/ogg",
flac: "audio/flac",
aac: "audio/aac",
};
@@ -1401,7 +1402,10 @@ class IPCHandlers {
const result = await dialog.showOpenDialog({
properties: ["openFile"],
filters: [
- { name: "Audio Files", extensions: ["mp3", "wav", "m4a", "webm", "ogg", "flac", "aac"] },
+ {
+ name: "Audio Files",
+ extensions: ["mp3", "wav", "m4a", "webm", "ogg", "oga", "flac", "aac"],
+ },
],
});
if (result.canceled || !result.filePaths.length) {
@@ -1441,13 +1445,18 @@ class IPCHandlers {
});
ipcMain.handle("paste-text", async (event, text, options) => {
- // If the floating dictation panel currently has focus, dismiss it so the
- // paste keystroke lands in the user's target app instead of the overlay.
const mainWindow = this.windowManager?.mainWindow;
- if (mainWindow && !mainWindow.isDestroyed() && mainWindow.isFocused()) {
+ const targetPid = this.textEditMonitor?.lastTargetPid || null;
+
+ // Activating the target by PID is more reliable than hide()'s implicit
+ // focus hand-off for Chromium apps like Claude desktop and Brave (#668).
+ let activated = false;
+ if (process.platform === "darwin" && this.textEditMonitor) {
+ activated = await this.textEditMonitor.activateTargetPid();
+ }
+
+ if (!activated && mainWindow && !mainWindow.isDestroyed() && mainWindow.isFocused()) {
if (process.platform === "darwin") {
- // hide() forces macOS to activate the previous app; showInactive()
- // restores the overlay without stealing focus.
mainWindow.hide();
await new Promise((resolve) => setTimeout(resolve, 120));
mainWindow.showInactive();
@@ -1460,7 +1469,6 @@ class IPCHandlers {
...options,
webContents: event.sender,
});
- const targetPid = this.textEditMonitor?.lastTargetPid || null;
debugLogger.debug("[AutoLearn] Paste completed", {
autoLearnEnabled: this._autoLearnEnabled,
hasMonitor: !!this.textEditMonitor,
diff --git a/src/helpers/textEditMonitor.js b/src/helpers/textEditMonitor.js
index 7ec28a3b0..cbcb75ece 100644
--- a/src/helpers/textEditMonitor.js
+++ b/src/helpers/textEditMonitor.js
@@ -76,6 +76,34 @@ class TextEditMonitor extends EventEmitter {
});
}
+ /**
+ * macOS: bring the captured target app to the front before pasting.
+ * More reliable than hide()'s implicit hand-off for Chromium apps (#668).
+ */
+ activateTargetPid() {
+ return new Promise((resolve) => {
+ if (process.platform !== "darwin" || !this.lastTargetPid) {
+ resolve(false);
+ return;
+ }
+ const pid = this.lastTargetPid;
+ const script =
+ `ObjC.import("AppKit"); ` +
+ `const app = $.NSRunningApplication.runningApplicationWithProcessIdentifier(${pid}); ` +
+ `if (app.isNil) { "not_found" } else { app.activateWithOptions(2); "ok" }`;
+ execFile(
+ "osascript",
+ ["-l", "JavaScript", "-e", script],
+ { timeout: 1000 },
+ (err, stdout) => {
+ const ok = !err && stdout.trim() === "ok";
+ debugLogger.debug("[TextEditMonitor] Activated target PID", { pid, ok });
+ resolve(ok);
+ }
+ );
+ });
+ }
+
/**
* Start monitoring the focused text field for edits after a paste.
* Kills any existing monitor before starting a new one.