Skip to content

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

fix(meeting): scope the prompt countdown to its own window and keep listener state

Gabriel Stein2cb2b2bd58ba
diff --git a/src/components/UpdateNotificationOverlay.tsx b/src/components/UpdateNotificationOverlay.tsx
index 8e85b238d..762a7032b 100644
--- a/src/components/UpdateNotificationOverlay.tsx
+++ b/src/components/UpdateNotificationOverlay.tsx
@@ -49,16 +49,6 @@ export default function UpdateNotificationOverlay() {
[data]
);
- const handleMouseEnter = useCallback(() => {
- setIsHovered(true);
- window.electronAPI?.setNotificationInteractivity?.(true);
- }, []);
-
- const handleMouseLeave = useCallback(() => {
- setIsHovered(false);
- window.electronAPI?.setNotificationInteractivity?.(false);
- }, []);
-
return (
<div className="meeting-notification-window w-full h-full bg-transparent p-3">
<div
@@ -72,8 +62,8 @@ export default function UpdateNotificationOverlay() {
? "translate-x-0 opacity-100 scale-100"
: "translate-x-[120%] opacity-0 scale-95",
].join(" ")}
- onMouseEnter={handleMouseEnter}
- onMouseLeave={handleMouseLeave}
+ onMouseEnter={() => setIsHovered(true)}
+ onMouseLeave={() => setIsHovered(false)}
>
<button
onClick={() => respond("dismiss")}
diff --git a/src/helpers/audioActivityDetector.js b/src/helpers/audioActivityDetector.js
index fd3bd9dbd..3fd7189ff 100644
--- a/src/helpers/audioActivityDetector.js
+++ b/src/helpers/audioActivityDetector.js
@@ -96,8 +96,7 @@ class AudioActivityDetector extends EventEmitter {
this._killListenerProcess();
this._clearSustainedTimer();
this._clearResetTimer();
- this._clearCooldownReevalTimer();
- this._lastKnownMicState = false;
+ this._resetListenerState();
if (this.checkInterval) {
clearInterval(this.checkInterval);
this.checkInterval = null;
@@ -135,9 +134,18 @@ class AudioActivityDetector extends EventEmitter {
this.consecutiveChecks = 0;
this.audioActiveStart = null;
this.hasPrompted = false;
+ this._clearResetTimer();
+ }
+
+ // The pid set and source count mirror what the OS told us is open, not our
+ // own detection state — only losing the listener invalidates them. Clearing
+ // them on dismissal would desync the reference count, so an unrelated app's
+ // mic session ending would report the still-running call as gone.
+ _resetListenerState() {
this._activeMicPids.clear();
this._activeSources = 0;
- this._clearResetTimer();
+ this._lastKnownMicState = false;
+ this._clearCooldownReevalTimer();
}
_clearSustainedTimer() {
@@ -257,8 +265,7 @@ class AudioActivityDetector extends EventEmitter {
this._listenerProcess = null;
if (this._running && this._eventDriven) {
this._eventDriven = false;
- this._clearCooldownReevalTimer();
- this._lastKnownMicState = false;
+ this._resetListenerState();
this._startPolling();
}
};
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 99e2004e1..bcbaae131 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -1051,7 +1051,7 @@ class IPCHandlers {
});
ipcMain.handle("set-notification-interactivity", (event, interactive) => {
- this.windowManager.setNotificationInteractivity(Boolean(interactive));
+ this.windowManager.setNotificationInteractivity(event.sender, Boolean(interactive));
return { success: true };
});
diff --git a/src/helpers/windowManager.js b/src/helpers/windowManager.js
index 9838e700b..2c1efdf2d 100644
--- a/src/helpers/windowManager.js
+++ b/src/helpers/windowManager.js
@@ -133,17 +133,21 @@ class WindowManager {
}
}
- setNotificationInteractivity(interactive) {
- if (!this.notificationWindow || this.notificationWindow.isDestroyed()) {
+ // Only the meeting prompt owns this: another overlay reporting its own hover
+ // must not pause a countdown it cannot resume — it may be destroyed before
+ // its pointer ever leaves.
+ setNotificationInteractivity(sender, interactive) {
+ const win = this.notificationWindow;
+ if (!win || win.isDestroyed() || sender !== win.webContents) {
return;
}
// Hovering means the user is reading or about to click — the auto-dismiss
// countdown must not close the card under their pointer.
if (interactive) {
- this.notificationWindow.setIgnoreMouseEvents(false);
+ win.setIgnoreMouseEvents(false);
this._notificationDismissTimer.pause();
} else {
- this.notificationWindow.setIgnoreMouseEvents(true, { forward: true });
+ win.setIgnoreMouseEvents(true, { forward: true });
this._notificationDismissTimer.resume();
}
}
@@ -1230,38 +1234,40 @@ class WindowManager {
this.notificationWindow = win;
// Keep the prompt visible to the user but out of screen shares and recordings.
- this.notificationWindow.setContentProtection(true);
+ win.setContentProtection(true);
if (process.platform === "darwin") {
- this.notificationWindow.setIgnoreMouseEvents(true, { forward: true });
+ win.setIgnoreMouseEvents(true, { forward: true });
}
- WindowPositionUtil.setupAlwaysOnTop(this.notificationWindow);
+ WindowPositionUtil.setupAlwaysOnTop(win);
this._pendingNotificationData = promptData;
+ // Everything past the load addresses `win` directly: a replacement taking
+ // over mid-load must not have this prompt's data, countdown or force-show
+ // applied to its window.
if (process.env.NODE_ENV === "development") {
await DevServerManager.waitForDevServer();
- await this.notificationWindow.loadURL(
- `${DevServerManager.DEV_SERVER_URL}?meeting-notification=true`
- );
+ await win.loadURL(`${DevServerManager.DEV_SERVER_URL}?meeting-notification=true`);
} else {
const fileInfo = DevServerManager.getAppFilePath(false);
- await this.notificationWindow.loadFile(fileInfo.path, {
+ await win.loadFile(fileInfo.path, {
query: { ...fileInfo.query, "meeting-notification": "true" },
});
}
+ if (this.notificationWindow !== win) return;
this._notificationReadyFallback = setTimeout(() => {
this._notificationReadyFallback = null;
- if (this.notificationWindow && !this.notificationWindow.isDestroyed()) {
+ if (!win.isDestroyed()) {
debugLogger.warn(
"Notification renderer did not signal ready, force-showing",
{},
"meeting"
);
- this.notificationWindow.webContents.send("meeting-notification-data", promptData);
- this.notificationWindow.showInactive();
+ win.webContents.send("meeting-notification-data", promptData);
+ win.showInactive();
}
}, 3000);
diff --git a/test/helpers/audioActivityDetector.test.js b/test/helpers/audioActivityDetector.test.js
index 988e64366..87a91bef7 100644
--- a/test/helpers/audioActivityDetector.test.js
+++ b/test/helpers/audioActivityDetector.test.js
@@ -348,3 +348,25 @@ test("darwin: a warm-hold that releases cleanly does not produce a stale prompt"
assert.equal(emitted.length, 0, "the release edge must cancel the pending re-evaluation");
detector.stop();
});
+
+test("win32: an unrelated app's mic session ending does not hide an ongoing dismissed call", async (t) => {
+ t.mock.timers.enable({ apis: ["setTimeout", "Date"], now: 10_000 });
+ const { detector, children } = createDetector("win32");
+ const emitted = [];
+ detector.on("sustained-audio-detected", (data) => emitted.push(data));
+
+ await detector.start();
+ children[0].stdout.emit("data", "MIC_START 11\n");
+ t.mock.timers.tick(SUSTAINED_MS);
+ assert.equal(emitted.length, 1);
+ detector.dismiss();
+
+ // pid 11 never stopped, so the reference count must still hold it — otherwise
+ // pid 22's stop reads as "every mic closed" and cancels the re-evaluation.
+ children[0].stdout.emit("data", "MIC_START 22\nMIC_STOP 22\n");
+ t.mock.timers.tick(COOLDOWN_MS);
+ t.mock.timers.tick(SUSTAINED_MS);
+
+ assert.equal(emitted.length, 2, "the still-running call must re-prompt after the cooldown");
+ detector.stop();
+});