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(window): keep a tray-hidden control panel hidden during auth refresh (#2632)
Chad Pihaec806dfcaad5
diff --git a/src/helpers/windowManager.js b/src/helpers/windowManager.jsindex 5564d8989..31610fa6f 100644--- a/src/helpers/windowManager.js+++ b/src/helpers/windowManager.js@@ -1790,9 +1790,12 @@ class WindowManager {this._controlPanelVisibilityTimer = null;}- _showControlPanel() {+ _showControlPanel({ onlyBeforeFirstShow = false } = {}) {const win = this.controlPanelWindow;if (!win || win.isDestroyed()) return;+ // onlyBeforeFirstShow reveals a new panel only while its visibility timer is pending;+ // after that, a hidden or minimized panel stays as the user left it.+ if (onlyBeforeFirstShow && this._controlPanelVisibilityTimer === null) return;// Cancel the backstop either way: once the window has been shown on purpose,// a later timer firing could pull it back out of the tray.this._clearControlPanelVisibilityTimer();@@ -1881,7 +1884,7 @@ class WindowManager {this._onboardingRestoreBounds = null;this._onboardingWindowMode = null;this._onboardingWindowState = null;- this._showControlPanel();+ this._showControlPanel({ onlyBeforeFirstShow: true });return true;}@@ -1900,7 +1903,7 @@ class WindowManager {this._applyOnboardingWindowChrome(win, mode);if (this._onboardingWindowMode === mode) {- this._showControlPanel();+ this._showControlPanel({ onlyBeforeFirstShow: true });return true;}@@ -1914,13 +1917,13 @@ class WindowManager {current.height === next.height) {this._onboardingWindowMode = mode;- this._showControlPanel();+ this._showControlPanel({ onlyBeforeFirstShow: true });return true;}win.setContentBounds(next, true);this._onboardingWindowMode = mode;- this._showControlPanel();+ this._showControlPanel({ onlyBeforeFirstShow: true });return true;}diff --git a/test/helpers/controlPanelReopen.test.js b/test/helpers/controlPanelReopen.test.jsindex 1f8a0fe2e..d9f37790b 100644--- a/test/helpers/controlPanelReopen.test.js+++ b/test/helpers/controlPanelReopen.test.js@@ -195,8 +195,8 @@ test("showing the control panel without a live window touches neither the Dock n});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.+ // A failed load runs it on an open panel too; showing again would pull the+ // panel over the app the user is working in.const { windowManager } = createManagers();windowManager.controlPanelWindow = createControlPanel({ visible: true });diff --git a/test/helpers/windowManagerControlPanel.test.js b/test/helpers/windowManagerControlPanel.test.jsnew file mode 100644index 000000000..692a973f8--- /dev/null+++ b/test/helpers/windowManagerControlPanel.test.js@@ -0,0 +1,166 @@+const test = require("node:test");+const assert = require("node:assert/strict");+const Module = require("node:module");++const dockVisibilityCalls = [];++const originalLoad = Module._load;+Module._load = function loadWindowManagerWithStubs(request, parent, isMain) {+ if (request === "electron") {+ return {+ app: { on: () => undefined },+ screen: {+ getDisplayMatching: () => ({+ workArea: { x: 0, y: 0, width: 1440, height: 900 },+ }),+ },+ };+ }+ if (request === "./debugLogger") return {};+ if (request === "./hotkeyManager") return class {};+ if (request === "./dragManager") return class {};+ if (request === "./menuManager") return {};+ if (request === "./devServerManager") return {};+ if (request === "./dockManager") {+ return {+ setControlPanelVisible: (visible) => dockVisibilityCalls.push(visible),+ };+ }+ if (request === "./i18nMain") return { i18nMain: {} };+ if (request === "./windowConfig") {+ return {+ NOTIFICATION_WINDOW_CONFIG: {},+ WINDOW_SIZES: { BASE: { width: 96, height: 96 } },+ ONBOARDING_WINDOW_SIZES: {+ COMPACT: { width: 480, height: 624 },+ EXPANDED: { width: 1000, height: 740 },+ },+ };+ }+ return originalLoad.call(this, request, parent, isMain);+};+const WindowManager = require("../../src/helpers/windowManager");+Module._load = originalLoad;++function createControlPanelWindow({+ visible,+ bounds = { x: 120, y: 90, width: 1200, height: 800 },+}) {+ const calls = [];+ let currentBounds = { ...bounds };+ let isVisible = visible;++ return {+ calls,+ isVisible: () => isVisible,+ window: {+ isDestroyed: () => false,+ isVisible: () => isVisible,+ isFullScreen: () => false,+ isMaximized: () => false,+ isMinimized: () => false,+ getBounds: () => ({ ...currentBounds }),+ getContentBounds: () => ({ ...currentBounds }),+ setContentBounds: (nextBounds) => {+ currentBounds = { ...nextBounds };+ calls.push("setContentBounds");+ },+ isResizable: () => true,+ isMinimizable: () => true,+ isMaximizable: () => true,+ isClosable: () => true,+ isFullScreenable: () => true,+ getMinimumSize: () => [400, 300],+ setResizable: () => undefined,+ setMinimizable: () => undefined,+ setMaximizable: () => undefined,+ setClosable: () => undefined,+ setFullScreenable: () => undefined,+ setMinimumSize: () => undefined,+ setWindowButtonVisibility: () => undefined,+ show: () => {+ isVisible = true;+ calls.push("show");+ },+ focus: () => calls.push("focus"),+ hide: () => {+ isVisible = false;+ calls.push("hide");+ },+ },+ };+}++function createManager(windowOptions) {+ const manager = new WindowManager();+ const fake = createControlPanelWindow(windowOptions);+ manager.controlPanelWindow = fake.window;+ return { manager, ...fake };+}++test.beforeEach(() => {+ dockVisibilityCalls.length = 0;+});++test("initial restore still reveals the renderer-sized control panel", () => {+ const { manager, calls, isVisible } = createManager({ visible: false });+ manager._controlPanelVisibilityTimer = 1;++ assert.equal(manager.setOnboardingWindowMode("restore"), true);++ assert.equal(isVisible(), true);+ assert.deepEqual(calls, ["show", "focus"]);+ assert.deepEqual(dockVisibilityCalls, [true]);+});++test("repeated restore preserves a control panel hidden to the tray", () => {+ const { manager, calls, isVisible } = createManager({ visible: true });+ manager._controlPanelVisibilityTimer = 1;+ manager.hideControlPanelToTray();+ calls.length = 0;+ dockVisibilityCalls.length = 0;++ assert.equal(manager.setOnboardingWindowMode("restore"), true);++ assert.equal(isVisible(), false);+ assert.deepEqual(calls, []);+ assert.deepEqual(dockVisibilityCalls, []);+});++test("compact reauthentication can resize a tray-hidden panel without surfacing it", () => {+ const { manager, calls, isVisible } = createManager({ visible: true });+ manager._controlPanelVisibilityTimer = 1;+ manager.hideControlPanelToTray();+ calls.length = 0;+ dockVisibilityCalls.length = 0;++ assert.equal(manager.setOnboardingWindowMode("compact"), true);++ assert.equal(isVisible(), false);+ assert.deepEqual(calls, ["setContentBounds"]);+ assert.deepEqual(dockVisibilityCalls, []);+});++test("repeated compact resends keep a tray-hidden panel hidden", () => {+ // Already at the centered compact bounds, so no resize is needed.+ const { manager, calls, isVisible } = createManager({+ visible: true,+ bounds: { x: 480, y: 138, width: 480, height: 624 },+ });+ manager._controlPanelVisibilityTimer = 1;+ manager.hideControlPanelToTray();+ calls.length = 0;+ dockVisibilityCalls.length = 0;++ // First resend: bounds already match the target.+ assert.equal(manager.setOnboardingWindowMode("compact"), true);+ assert.equal(isVisible(), false);+ assert.deepEqual(calls, []);+ assert.deepEqual(dockVisibilityCalls, []);++ // Second resend: the mode is already compact.+ assert.equal(manager.setOnboardingWindowMode("compact"), true);+ assert.equal(isVisible(), false);+ assert.deepEqual(calls, []);+ assert.deepEqual(dockVisibilityCalls, []);+});