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(macos): report the Dock before reopening the control panel (#2467)
Joshua2fbd90d6cf68
diff --git a/CLAUDE.md b/CLAUDE.mdindex 0b97345a0..104cdb694 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -71,7 +71,10 @@ OpenWhispr is an Electron-based desktop dictation application that uses whisper.- **devServerManager.js**: Vite dev server integration- **dockManager.js**: Single owner of the macOS Dock icon- The icon follows the control panel: it appears when the panel opens and goes away when the panel closes to the tray, so no other caller (in particular the dictation panel's hide path) can resurrect it- - Every path that surfaces or hides the control panel (tray, app menu, deep links, `activate`, `ready-to-show`, `hideControlPanelToTray`) reports that state explicitly+ - Every path that surfaces or hides the control panel reports that state explicitly: openers (tray, app menu, deep links, `activate`, second instance, first show) go through `windowManager.showControlPanel()`, hiding through `hideControlPanelToTray()`+ - `showControlPanel()` reports the Dock before restoring, showing and focusing the window: on an active app `dock.show()` activates the Dock and then re-activates the app, which macOS does not honour, so a window surfaced first is left behind the previously frontmost app+ - `showControlPanel()` calls `show()` even on an open panel, since on macOS that activates the app and `focus()` does not; openers that send the user to another app (meeting-prompt Join, the meeting hotkey, Upcoming Meetings' Join & transcribe) pass `{ activate: false }`, so an open panel updates behind the meeting instead of covering it. A hidden panel is still shown+ - `app.dock.show()`/`hide()` run only when the requested state differs from `app.dock.isVisible()`, so reopening an already open panel never triggers that Dock hand-off- Never derive that state from the window's `show`/`hide` events: on macOS those are occlusion events, so they also fire when the panel is merely covered by another window, minimized, or on another Space, and the icon flickers as the user switches windows- Decision logic lives in `dockPolicy.js` (pure, unit-tested in `test/helpers/dockPolicy.test.js`)- **dragManager.js**: Window dragging functionalitydiff --git a/main.js b/main.jsindex cd6416b91..8eb2a8147 100644--- a/main.js+++ b/main.js@@ -779,11 +779,7 @@ app.on("open-url", (event, url) => {void handleOAuthDeepLink(url);- if (windowManager && isLiveWindow(windowManager.controlPanelWindow)) {- windowManager.controlPanelWindow.show();- windowManager.controlPanelWindow.focus();- dockManager.setControlPanelVisible(true);- }+ windowManager?.showControlPanel();});function isInvitationDeepLink(url) {@@ -883,9 +879,7 @@ function handleInvitationDeepLink(deepLinkUrl) {pendingInvitationDeepLinkToken = token;if (!windowManager) return;if (isLiveWindow(windowManager.controlPanelWindow)) {- windowManager.controlPanelWindow.show();- windowManager.controlPanelWindow.focus();- dockManager.setControlPanelVisible(true);+ windowManager.showControlPanel();// Best-effort fast path — the get-pending-invitation-token pull is the reliable path.windowManager.controlPanelWindow.webContents.send("workspace-invitation-token", token);} else {@@ -994,9 +988,7 @@ async function applySessionTokenAndRefresh(token) {oauthProtocol: OAUTH_PROTOCOL,});}- windowManager.controlPanelWindow.show();- windowManager.controlPanelWindow.focus();- dockManager.setControlPanelVisible(true);+ windowManager.showControlPanel();}async function handleOAuthDeepLink(deepLinkUrl) {@@ -1021,9 +1013,7 @@ function handleUpgradeDeepLink() {windowManager.controlPanelWindow.webContents.executeJavaScript('window.dispatchEvent(new Event("upgrade-success"))');- windowManager.controlPanelWindow.show();- windowManager.controlPanelWindow.focus();- dockManager.setControlPanelVisible(true);+ windowManager.showControlPanel();}}@@ -1328,7 +1318,8 @@ async function startApp() {const meetingHotkeyCallback = () => {if (!isMeetingPress()) return;debugLogger.info("Meeting hotkey triggered", {}, "meeting");- windowManager.startManualMeeting();+ // Usually pressed mid-call: an open panel updates behind the meeting app.+ windowManager.startManualMeeting({ activate: false });};const savedMeetingKey = environmentManager.getMeetingKey?.() || "";@@ -1869,7 +1860,7 @@ async function startApp() {} else if (hotkeyManager.slotHasHotkey("translation", key)) {windowManager.sendToggleTranslation();} else if (hotkeyManager.slotHasHotkey("meeting", key)) {- windowManager.startManualMeeting();+ windowManager.startManualMeeting({ activate: false });}};@@ -1976,12 +1967,7 @@ if (gotSingleInstanceLock) {}if (isLiveWindow(windowManager.controlPanelWindow)) {- if (windowManager.controlPanelWindow.isMinimized()) {- windowManager.controlPanelWindow.restore();- }- windowManager.controlPanelWindow.show();- windowManager.controlPanelWindow.focus();- dockManager.setControlPanelVisible(true);+ windowManager.showControlPanel();if (windowManager.controlPanelWindow.webContents.isCrashed()) {windowManager.loadControlPanel();}@@ -2082,12 +2068,7 @@ if (gotSingleInstanceLock) {} else {// Show control panel when dock icon is clicked (most common user action)if (windowManager && isLiveWindow(windowManager.controlPanelWindow)) {- if (windowManager.controlPanelWindow.isMinimized()) {- windowManager.controlPanelWindow.restore();- }- windowManager.controlPanelWindow.show();- windowManager.controlPanelWindow.focus();- dockManager.setControlPanelVisible(true);+ windowManager.showControlPanel();} else if (windowManager) {// If control panel doesn't exist, create itwindowManager.createControlPanelWindow();diff --git a/src/helpers/dockManager.js b/src/helpers/dockManager.jsindex fcb091bc9..07ff6af75 100644--- a/src/helpers/dockManager.js+++ b/src/helpers/dockManager.js@@ -33,7 +33,10 @@ class DockManager {platform: process.platform,controlPanelVisible: this._controlPanelVisible,});- if (visible === null || !app.dock) return;+ // Only act on a change. On an active app dock.show() hands activation to+ // the Dock even when the icon is already up (see DockShow in+ // browser_mac.mm), so reopening an open panel must not call it.+ if (visible === null || !app.dock || visible === app.dock.isVisible()) return;if (visible) {app.dock.show();diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex c44572044..66b29326b 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -12176,7 +12176,11 @@ class IPCHandlers {ipcMain.handle("join-calendar-meeting", async (_event, eventId) => {try {- await this.meetingDetectionEngine.joinCalendarMeeting(eventId);+ // Sent from the open panel, which may have just opened the meeting+ // link: leave the meeting in front rather than pulling the panel back.+ await this.meetingDetectionEngine.joinCalendarMeeting(eventId, "calendar-join", {+ activate: false,+ });return { success: true };} catch (error) {return { success: false, error: error.message };diff --git a/src/helpers/meetingDetectionEngine.js b/src/helpers/meetingDetectionEngine.jsindex 2cbb45d0f..3509f5ab8 100644--- a/src/helpers/meetingDetectionEngine.js+++ b/src/helpers/meetingDetectionEngine.js@@ -518,9 +518,11 @@ class MeetingDetectionEngine {// Entered before navigation so a detection arriving meanwhile cannot// replace this prompt and cancel the Start after its note is saved.this._meetingModeActive = true;+ // Join leaves the meeting it just opened in front: an open panel updates+ // behind it instead of covering the call.const navigation = await this.windowManager.queueMeetingNoteNavigation({ ...owner.authorizedNote, navigationId: randomUUID() },- { owner }+ { owner, activate: action !== "join" });if (!navigation.success) {this._meetingModeActive = false;@@ -532,7 +534,7 @@ class MeetingDetectionEngine {return { success: true, value: null };}- async startManualMeeting() {+ async startManualMeeting(options) {debugLogger.info("Starting manual meeting", {}, "meeting");// A live meeting already owns a note: a second start would leave the recording@@ -540,13 +542,13 @@ class MeetingDetectionEngine {if (this._recordingSession) {const { noteId } = this._recordingSession;debugLogger.info("Manual meeting ignored — a recording is live", { noteId }, "meeting");- if (noteId != null) await this.windowManager.queueNoteNavigation({ noteId });+ if (noteId != null) await this.windowManager.queueNoteNavigation({ noteId }, options);return;}const activeEvents = this.databaseManager.getActiveEvents();if (activeEvents?.length > 0) {- return this.joinCalendarMeeting(activeEvents[0].id, "hotkey");+ return this.joinCalendarMeeting(activeEvents[0].id, "hotkey", options);}this._meetingModeActive = true;@@ -568,16 +570,19 @@ class MeetingDetectionEngine {broadcastToWindows("note-added", noteResult.note);- await this.windowManager.queueMeetingNoteNavigation({- noteId: noteResult.note.id,- folderId: meetingsFolder.id,- event,- trigger: "hotkey",- });+ await this.windowManager.queueMeetingNoteNavigation(+ {+ noteId: noteResult.note.id,+ folderId: meetingsFolder.id,+ event,+ trigger: "hotkey",+ },+ options+ );}/** Navigates to the user's own note already linked to a calendar event, if any. */- async _resumeExistingEventNote(event, trigger) {+ async _resumeExistingEventNote(event, trigger, options) {const existingNote = this.databaseManager.getOwnNoteByCalendarEventId(event.id);if (!existingNote?.id) return false;debugLogger.info(@@ -585,16 +590,19 @@ class MeetingDetectionEngine {{ eventId: event.id, noteId: existingNote.id, trigger },"meeting");- await this.windowManager.queueMeetingNoteNavigation({- noteId: existingNote.id,- folderId: existingNote.folder_id ?? this.databaseManager.getMeetingsFolder()?.id,- event,- trigger,- });+ await this.windowManager.queueMeetingNoteNavigation(+ {+ noteId: existingNote.id,+ folderId: existingNote.folder_id ?? this.databaseManager.getMeetingsFolder()?.id,+ event,+ trigger,+ },+ options+ );return true;}- async joinCalendarMeeting(eventId, trigger = "calendar-join") {+ async joinCalendarMeeting(eventId, trigger = "calendar-join", options) {this._meetingModeActive = true;debugLogger.info("Joining calendar meeting", { eventId, trigger }, "meeting");@@ -606,7 +614,7 @@ class MeetingDetectionEngine {}// Joining the same event twice resumes its note instead of creating a duplicate.- if (await this._resumeExistingEventNote(calEvent, trigger)) {+ if (await this._resumeExistingEventNote(calEvent, trigger, options)) {return;}@@ -631,12 +639,15 @@ class MeetingDetectionEngine {broadcastToWindows("note-added", updateResult?.note || noteResult.note);- await this.windowManager.queueMeetingNoteNavigation({- noteId: noteResult.note.id,- folderId: meetingsFolder.id,- event: calEvent,- trigger,- });+ await this.windowManager.queueMeetingNoteNavigation(+ {+ noteId: noteResult.note.id,+ folderId: meetingsFolder.id,+ event: calEvent,+ trigger,+ },+ options+ );}// A card can vanish without a response — a compositor kill, a load failure,diff --git a/src/helpers/tray.js b/src/helpers/tray.jsindex d9cc77196..aca04b738 100644--- a/src/helpers/tray.js+++ b/src/helpers/tray.js@@ -2,7 +2,6 @@ const { Tray, Menu, nativeImage, app, systemPreferences } = require("electron");const path = require("path");const fs = require("fs");const debugLogger = require("./debugLogger");-const dockManager = require("./dockManager");const { i18nMain } = require("./i18nMain");const { windowsTrayIdentity } = require("../../package.json");@@ -110,14 +109,7 @@ class TrayManager {this.syncControlPanelWindow();if (this.controlPanelWindow && !this.controlPanelWindow.isDestroyed()) {- if (this.controlPanelWindow.isMinimized()) {- this.controlPanelWindow.restore();- }- if (!this.controlPanelWindow.isVisible()) {- this.controlPanelWindow.show();- }- this.controlPanelWindow.focus();- dockManager.setControlPanelVisible(true);+ this.windowManager.showControlPanel();if (this.controlPanelWindow.webContents.isCrashed()) {this.controlPanelWindow.webContents.reload();}@@ -127,12 +119,7 @@ class TrayManager {if (this.createControlPanelCallback) {await this.createControlPanelCallback();this.syncControlPanelWindow();-- if (this.controlPanelWindow && !this.controlPanelWindow.isDestroyed()) {- this.controlPanelWindow.show();- this.controlPanelWindow.focus();- dockManager.setControlPanelVisible(true);- }+ this.windowManager.showControlPanel();return;}diff --git a/src/helpers/windowManager.js b/src/helpers/windowManager.jsindex 954341e4a..5564d8989 100644--- a/src/helpers/windowManager.js+++ b/src/helpers/windowManager.js@@ -1005,10 +1005,10 @@ class WindowManager {// The one entry for starting a meeting by hand: the meeting hotkey, the pill's// command menu, and the tray. Fails closed during onboarding and while a// hotkey is being captured, like every hotkey slot.- async startManualMeeting() {+ async startManualMeeting(options) {if (this.hotkeyManager.isInListeningMode() || !this.isMeetingInputAllowed()) return;try {- await this.meetingDetectionEngine?.startManualMeeting();+ await this.meetingDetectionEngine?.startManualMeeting(options);} catch (error) {debugLogger.error("Failed to start manual meeting", { error: error.message }, "meeting");}@@ -1451,16 +1451,9 @@ class WindowManager {});}- async createControlPanelWindow() {+ async createControlPanelWindow(options) {if (this.controlPanelWindow && !this.controlPanelWindow.isDestroyed()) {- if (this.controlPanelWindow.isMinimized()) {- this.controlPanelWindow.restore();- }- if (!this.controlPanelWindow.isVisible()) {- this.controlPanelWindow.show();- }- this.controlPanelWindow.focus();- dockManager.setControlPanelVisible(true);+ this.showControlPanel(options);return;}@@ -1804,9 +1797,25 @@ class WindowManager {// a later timer firing could pull it back out of the tray.this._clearControlPanelVisibilityTimer();if (win.isVisible()) return;- win.show();- win.focus();+ this.showControlPanel();+ }++ // Every path that opens the control panel comes through here. The Dock is+ // reported first: on an active app dock.show() activates the Dock and then+ // re-activates the app, which macOS does not honour, so a window surfaced+ // before it is left behind the previously frontmost app. show() runs even+ // for a visible window, since on macOS it activates the app while another+ // app is active and focus() does not. `activate: false` skips that for an+ // open panel, for openers that send the user to another app (joining a+ // meeting, the meeting hotkey mid-call): the panel updates behind it.+ showControlPanel({ activate = true } = {}) {+ const win = this.controlPanelWindow;+ if (!win || win.isDestroyed()) return;+ this._clearControlPanelVisibilityTimer();dockManager.setControlPanelVisible(true);+ if (win.isMinimized()) win.restore();+ if (activate || !win.isVisible()) win.show();+ win.focus();}// Compact onboarding starts at smaller bounds, but both modes expose the@@ -2400,7 +2409,7 @@ class WindowManager {async queueMeetingNoteNavigation(payload, options) {if (!payload.navigationId) {this._pendingMeetingNoteNavigation = payload;- await this.createControlPanelWindow();+ await this.createControlPanelWindow(options);this.sendToControlPanel("meeting-note-navigation-pending");return;}@@ -2426,7 +2435,7 @@ class WindowManager {);void (async () => {try {- await this.createControlPanelWindow();+ await this.createControlPanelWindow({ activate: options.activate });if (this._meetingNavigationOperation !== operation) return;const panel = this.controlPanelWindow;if (!panel || panel.isDestroyed()) throw new Error("Panel unavailable");@@ -2537,9 +2546,9 @@ class WindowManager {return result;}- async queueNoteNavigation(payload) {+ async queueNoteNavigation(payload, options) {this._pendingNoteNavigation = payload;- await this.createControlPanelWindow();+ await this.createControlPanelWindow(options);this.sendToControlPanel("note-navigation-pending");}diff --git a/test/helpers/controlPanelReopen.test.js b/test/helpers/controlPanelReopen.test.jsnew file mode 100644index 000000000..1f8a0fe2e--- /dev/null+++ b/test/helpers/controlPanelReopen.test.js@@ -0,0 +1,219 @@+const test = require("node:test");+const assert = require("node:assert/strict");+const Module = require("node:module");++// Every Dock report and window call lands in one sequence, so the tests can+// assert their relative order. app.dock.show() on an active app hands+// activation to the Dock, and macOS does not give it back: a panel shown+// before the report ends up behind the previously frontmost app's window.+let sequence = [];++const originalLoad = Module._load;+Module._load = function loadWithStubs(request, parent, isMain) {+ if (request === "electron")+ return {+ app: { on: () => undefined },+ screen: { on: () => undefined },+ BrowserWindow: class {},+ Tray: class {},+ Menu: {},+ nativeImage: {},+ systemPreferences: {},+ };+ if (request === "./debugLogger")+ return { debug() {}, info() {}, warn() {}, error() {}, log() {} };+ if (request === "./hotkeyManager") return class {};+ if (request === "./dragManager") return class {};+ if (request === "./menuManager") return {};+ if (request === "./devServerManager") return {};+ if (request === "./dockManager")+ return {+ setControlPanelVisible: (visible) => sequence.push(visible ? "dock:visible" : "dock:hidden"),+ };+ if (request === "./i18nMain") return { i18nMain: { t: (key) => key } };+ if (request === "./windowConfig")+ return {+ MAIN_WINDOW_CONFIG: {},+ CONTROL_PANEL_CONFIG: {},+ NOTIFICATION_WINDOW_CONFIG: {},+ WINDOW_SIZES: { BASE: { width: 96, height: 96 } },+ ONBOARDING_WINDOW_SIZES: { COMPACT: {}, EXPANDED: {} },+ WindowPositionUtil: {},+ };+ return originalLoad.call(this, request, parent, isMain);+};+const WindowManager = require("../../src/helpers/windowManager");+const TrayManager = require("../../src/helpers/tray");+Module._load = originalLoad;++// A control panel that is hidden to the tray, minimized, or open. Restoring a+// minimized window also shows it, as it does in Electron.+function createControlPanel({+ visible: initiallyVisible = false,+ minimized = false,+ destroyed = false,+} = {}) {+ let visible = initiallyVisible;+ let isMinimized = minimized;+ return {+ isDestroyed: () => destroyed,+ isVisible: () => visible,+ isMinimized: () => isMinimized,+ restore() {+ sequence.push("restore");+ isMinimized = false;+ visible = true;+ },+ show() {+ sequence.push("show");+ visible = true;+ },+ focus() {+ sequence.push("focus");+ },+ on: () => undefined,+ webContents: { isCrashed: () => false },+ };+}++function createManagers() {+ sequence = [];+ const windowManager = new WindowManager();+ const trayManager = new TrayManager();+ trayManager.setWindowManager(windowManager);+ return { windowManager, trayManager };+}++test("reopening a hidden control panel reports the Dock before showing the window", async () => {+ const { windowManager } = createManagers();+ windowManager.controlPanelWindow = createControlPanel();++ await windowManager.createControlPanelWindow();++ assert.deepEqual(sequence, ["dock:visible", "show", "focus"]);+});++test("restoring a minimized control panel reports the Dock before restoring the window", () => {+ const { windowManager } = createManagers();+ windowManager.controlPanelWindow = createControlPanel({ minimized: true });++ windowManager.showControlPanel();++ assert.deepEqual(sequence, ["dock:visible", "restore", "show", "focus"]);+});++test("a control panel open behind another app is shown again, not only focused", () => {+ // On macOS show() activates the app even while another app is active, and+ // focus() does not: a deep link arrives while the browser is frontmost.+ const { windowManager } = createManagers();+ windowManager.controlPanelWindow = createControlPanel({ visible: true });++ windowManager.showControlPanel();++ assert.deepEqual(sequence, ["dock:visible", "show", "focus"]);+});++test("the first show of a new control panel reports the Dock before showing the window", () => {+ const { windowManager } = createManagers();+ windowManager.controlPanelWindow = createControlPanel();++ windowManager._showControlPanel();++ assert.deepEqual(sequence, ["dock:visible", "show", "focus"]);+});++test("opening a hidden control panel from the tray reports the Dock before showing the window", async () => {+ const { windowManager, trayManager } = createManagers();+ windowManager.controlPanelWindow = createControlPanel();++ await trayManager.toggleControlPanelFromTray();++ assert.deepEqual(sequence, ["dock:visible", "show", "focus"]);+});++test("opening a minimized control panel from the tray reports the Dock before restoring the window", async () => {+ const { windowManager, trayManager } = createManagers();+ windowManager.controlPanelWindow = createControlPanel({ minimized: true });++ await trayManager.toggleControlPanelFromTray();++ assert.deepEqual(sequence, ["dock:visible", "restore", "show", "focus"]);+});++test("opening the tray after the control panel was destroyed reports the Dock before showing the new window", async () => {+ const { windowManager, trayManager } = createManagers();+ trayManager.setCreateControlPanelCallback(async () => {+ windowManager.controlPanelWindow = createControlPanel();+ });++ await trayManager.toggleControlPanelFromTray();++ assert.deepEqual(sequence, ["dock:visible", "show", "focus"]);+});++test("an open control panel stays behind the frontmost app when the opener does not activate", () => {+ // Joining a meeting or the meeting hotkey mid-call: focus() leaves the+ // meeting app in front, show() would pull the panel over it.+ const { windowManager } = createManagers();+ windowManager.controlPanelWindow = createControlPanel({ visible: true });++ windowManager.showControlPanel({ activate: false });++ assert.deepEqual(sequence, ["dock:visible", "focus"]);+});++test("a hidden control panel is still shown when the opener does not activate", async () => {+ const { windowManager } = createManagers();+ windowManager.controlPanelWindow = createControlPanel();++ await windowManager.createControlPanelWindow({ activate: false });++ assert.deepEqual(sequence, ["dock:visible", "show", "focus"]);+});++test("a minimized control panel is restored without show() when the opener does not activate", () => {+ const { windowManager } = createManagers();+ windowManager.controlPanelWindow = createControlPanel({ minimized: true });++ windowManager.showControlPanel({ activate: false });++ assert.deepEqual(sequence, ["dock:visible", "restore", "focus"]);+});++test("showing the control panel without a live window touches neither the Dock nor a window", async () => {+ // open-url and the tray's create path rely on this instead of their own checks.+ const { windowManager, trayManager } = createManagers();++ windowManager.showControlPanel();+ windowManager.controlPanelWindow = createControlPanel({ destroyed: true });+ windowManager.showControlPanel();+ windowManager.controlPanelWindow = null;+ trayManager.setCreateControlPanelCallback(async () => {});+ await trayManager.toggleControlPanelFromTray();++ assert.deepEqual(sequence, []);+});++test("the first show leaves an already visible control panel where it is", () => {+ // It runs on every onboarding window-mode change; showing again would pull+ // the panel over System Settings during the permission steps.+ const { windowManager } = createManagers();+ windowManager.controlPanelWindow = createControlPanel({ visible: true });++ windowManager._showControlPanel();++ assert.deepEqual(sequence, []);+});++test("showing the control panel cancels the visibility backstop", () => {+ // A backstop left armed would restore the panel after the user minimized it.+ const { windowManager } = createManagers();+ windowManager.controlPanelWindow = createControlPanel();+ windowManager._controlPanelVisibilityTimer = setTimeout(() => {+ sequence.push("backstop");+ }, 0);++ windowManager.showControlPanel();++ assert.equal(windowManager._controlPanelVisibilityTimer, null);+});diff --git a/test/helpers/dockManager.test.js b/test/helpers/dockManager.test.jsnew file mode 100644index 000000000..64f8b60bf--- /dev/null+++ b/test/helpers/dockManager.test.js@@ -0,0 +1,68 @@+const test = require("node:test");+const assert = require("node:assert/strict");+const Module = require("node:module");++// Mirrors app.dock: the icon starts visible, as OpenWhispr's does+// (LSUIElement is false), and isVisible() reports what show()/hide() did.+const dock = {+ visible: true,+ calls: [],+ isVisible() {+ return this.visible;+ },+ show() {+ this.calls.push("show");+ this.visible = true;+ },+ hide() {+ this.calls.push("hide");+ this.visible = false;+ },+};++const originalLoad = Module._load;+Module._load = function loadDockManagerWithStubs(request, parent, isMain) {+ if (request === "electron") return { app: { dock } };+ return originalLoad.call(this, request, parent, isMain);+};+const dockManager = require("../../src/helpers/dockManager");+Module._load = originalLoad;++function onPlatform(platform, run) {+ const originalPlatform = process.platform;+ Object.defineProperty(process, "platform", { value: platform });+ dock.visible = true;+ dock.calls = [];+ try {+ run();+ } finally {+ Object.defineProperty(process, "platform", { value: originalPlatform });+ }+}++test("the Dock icon is only shown or hidden when the control panel changes state", () => {+ onPlatform("darwin", () => {+ dockManager.init();+ dockManager.setControlPanelVisible(true);+ // A second open (Dock-icon click, deep link, Cmd+,) while the panel is up+ // must not show the icon again: on an active app that hands activation to+ // the Dock.+ dockManager.setControlPanelVisible(true);+ dockManager.setControlPanelVisible(false);+ dockManager.setControlPanelVisible(true);++ assert.deepEqual(dock.calls, ["hide", "show", "hide", "show"]);+ });+});++test("the Dock icon is left alone outside macOS", () => {+ for (const platform of ["win32", "linux"]) {+ onPlatform(platform, () => {+ dockManager.init();+ dockManager.setControlPanelVisible(true);+ dockManager.setControlPanelVisible(false);++ assert.deepEqual(dock.calls, []);+ });+ }+});diff --git a/test/helpers/meetingDetectionEngine.test.js b/test/helpers/meetingDetectionEngine.test.jsindex 9ca0cb69d..854de2656 100644--- a/test/helpers/meetingDetectionEngine.test.js+++ b/test/helpers/meetingDetectionEngine.test.js@@ -213,6 +213,32 @@ test("joining a calendar meeting with no note of the user's own creates one", asassert.equal(meetingNavigations[0].folderId, 7);});+test("a manual meeting passes its options to whichever note it opens", async () => {+ // The meeting hotkey asks for an open panel to stay behind the call.+ const { engine, windowManager } = createEngine();+ const options = { activate: false };+ const received = [];+ windowManager.queueNoteNavigation = async (_payload, opts) => received.push(opts);+ windowManager.queueMeetingNoteNavigation = async (_payload, opts) => received.push(opts);++ engine._recordingSession = { sessionId: "s1", noteId: 42 };+ await engine.startManualMeeting(options);+ engine._recordingSession = null;++ const db = createJoinDatabase({ id: 5, folder_id: 3 });+ engine.databaseManager = { ...db.databaseManager, getActiveEvents: () => [{ id: "event-1" }] };+ await engine.startManualMeeting(options);+ engine.databaseManager = createJoinDatabase(null).databaseManager;+ await engine.joinCalendarMeeting("event-1", "hotkey", options);+ engine.databaseManager = {+ ...createJoinDatabase(null).databaseManager,+ getActiveEvents: () => [],+ };+ await engine.startManualMeeting(options);++ assert.deepEqual(received, [options, options, options, options]);+});+// The IPC adapter derives detector preferences through this policy; the engine// only has to honour whatever it is handed (adapter coverage lives in// meetingDetectionPreferencesIpc.test.js).@@ -331,14 +357,17 @@ test("notification Start saves directly in selected folder and duplicate clicksconst folder = c.db.createFolder("Chosen").folder;c.owner.selectedDestination = { folderId: folder.id, spaceId: folder.space_id };let finish;- c.windowManager.queueMeetingNoteNavigation = (payload) => {+ let navigationOptions;+ c.windowManager.queueMeetingNoteNavigation = (payload, options) => {c.meetingNavigations.push(payload);+ navigationOptions = options;return new Promise((r) => (finish = r));};const one = c.respond();const two = c.respond();await new Promise(setImmediate);assert.equal(c.meetingNavigations.length, 1);+ assert.equal(navigationOptions.activate, true, "Start brings the panel forward");const note = c.db.getNote(c.meetingNavigations[0].noteId);assert.equal(note.folder_id, folder.id);assert.equal(note.space_id, folder.space_id);@@ -417,10 +446,15 @@ test("Join opens the link and suppresses new prompts while navigation is pendingopenedUrls.length = 0;c.owner.detection.event.hangout_link = "https://meet.example/join?pwd=1";let finish;- c.windowManager.queueMeetingNoteNavigation = () => new Promise((r) => (finish = r));+ let navigationOptions;+ c.windowManager.queueMeetingNoteNavigation = (_payload, options) => {+ navigationOptions = options;+ return new Promise((r) => (finish = r));+ };const joining = c.engine.handleNotificationResponse("calendar:event", "join", {}, c.owner);await new Promise(setImmediate);assert.deepEqual(openedUrls, ["https://meet.example/join?pwd=1"]);+ assert.equal(navigationOptions.activate, false, "the meeting just opened stays in front");c.engine.handleCalendarReminder({ id: "next" });assert.equal(c.shown.length, 0);finish({ success: true });diff --git a/test/helpers/windowManagerMeetingNotification.test.js b/test/helpers/windowManagerMeetingNotification.test.jsindex b5de0536f..f7941e645 100644--- a/test/helpers/windowManagerMeetingNotification.test.js+++ b/test/helpers/windowManagerMeetingNotification.test.js@@ -1031,6 +1031,26 @@ test("a Start that creates the panel delivers once it loads, past the onboarding}});+test("a Join navigation leaves an open panel behind the meeting it opened", async () => {+ const f = await navigationFixture();+ try {+ const opened = [];+ f.manager.createControlPanelWindow = async (options) => opened.push(options);+ const pending = f.manager.queueMeetingNoteNavigation(f.payload, {+ owner: f.owner,+ activate: false,+ });+ await new Promise(setImmediate);+ f.manager.consumePendingMeetingNoteNavigation(f.panel.webContents);+ f.manager.confirmMeetingNoteNavigation(f.panel.webContents, "navigate-one");+ assert.equal((await pending).success, true);+ await f.manager.queueMeetingNoteNavigation({ noteId: 9 }, { activate: false });+ assert.deepEqual(opened, [{ activate: false }, { activate: false }]);+ } finally {+ f.manager.dismissMeetingNotification();+ }+});+test("replacing an audio prompt retires only its captured detection", async () => {const manager = createNormalWindowManager();try {