Skip to content

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

fix(dictation): stop restacking the pill on every live transcript chunk (#2185)

Gabriel Steinbc404ff1ed4c
diff --git a/src/helpers/windowManager.js b/src/helpers/windowManager.js
index 7a59697e6..1398d37f2 100644
--- a/src/helpers/windowManager.js
+++ b/src/helpers/windowManager.js
@@ -1400,8 +1400,12 @@ class WindowManager {
if (!this.mainWindow || this.mainWindow.isDestroyed()) return;
this.mainWindow.webContents.send("preview-text", text);
this._sendAgentDictationPreview("preview-text", text);
- this.mainWindow.showInactive();
- this.enforceMainWindowOnTop();
+ // Partials arrive several times a second; re-showing a visible window
+ // restacks it (and re-fires "show") on every chunk (#1262).
+ if (!this.mainWindow.isVisible()) {
+ this.mainWindow.showInactive();
+ this.enforceMainWindowOnTop();
+ }
}
appendTranscriptionPreview(text) {
diff --git a/test/helpers/windowManagerAssistantPanel.test.js b/test/helpers/windowManagerAssistantPanel.test.js
index 15fc7844d..15e7fecfc 100644
--- a/test/helpers/windowManagerAssistantPanel.test.js
+++ b/test/helpers/windowManagerAssistantPanel.test.js
@@ -36,25 +36,51 @@ Module._load = function loadWindowManagerWithStubs(request, parent, isMain) {
};
createdBrowserWindows.push(this);
}
- on(event, listener) { this.windowListeners.set(event, listener); }
- setContentProtection(value) { this.protectionCalls.push(value); }
+ on(event, listener) {
+ this.windowListeners.set(event, listener);
+ }
+ setContentProtection(value) {
+ this.protectionCalls.push(value);
+ }
setIgnoreMouseEvents() {}
- loadFile() { return Promise.resolve(); }
- loadURL() { return Promise.resolve(); }
- isDestroyed() { return false; }
- close() { this.closeCalls += 1; this.windowListeners.get("closed")?.(); }
- getBounds() { return this.bounds; }
- setBounds(nextBounds) { this.bounds = nextBounds; this.setBoundsCalls += 1; }
- isVisible() { return this.visible; }
- showInactive() { this.visible = true; }
- hide() { this.visible = false; }
+ loadFile() {
+ return Promise.resolve();
+ }
+ loadURL() {
+ return Promise.resolve();
+ }
+ isDestroyed() {
+ return false;
+ }
+ close() {
+ this.closeCalls += 1;
+ this.windowListeners.get("closed")?.();
+ }
+ getBounds() {
+ return this.bounds;
+ }
+ setBounds(nextBounds) {
+ this.bounds = nextBounds;
+ this.setBoundsCalls += 1;
+ }
+ isVisible() {
+ return this.visible;
+ }
+ showInactive() {
+ this.visible = true;
+ }
+ hide() {
+ this.visible = false;
+ }
moveTop() {}
},
Menu: {
buildFromTemplate: (template) => {
const menu = {
popupCalls: [],
- popup(options) { this.popupCalls.push(options); },
+ popup(options) {
+ this.popupCalls.push(options);
+ },
};
builtMenus.push({ template, menu });
return menu;
@@ -64,15 +90,36 @@ Module._load = function loadWindowManagerWithStubs(request, parent, isMain) {
dialog: {},
};
}
- if (request === "./debugLogger") return { warn: () => undefined, debug: () => undefined, log: () => undefined };
+ if (request === "./debugLogger")
+ return { warn: () => undefined, debug: () => undefined, log: () => undefined };
if (request === "./hotkeyManager") {
- const FakeHotkeyManager = class { unregisterAll() {} isInListeningMode() { return false; } };
+ const FakeHotkeyManager = class {
+ unregisterAll() {}
+ isInListeningMode() {
+ return false;
+ }
+ };
FakeHotkeyManager.isGlobeLikeHotkey = () => false;
return FakeHotkeyManager;
}
- if (request === "./dragManager") return class { cleanup() {} async startWindowDrag() { return { success: true }; } async stopWindowDrag() { return { success: true }; } };
+ if (request === "./dragManager")
+ return class {
+ cleanup() {}
+ async startWindowDrag() {
+ return { success: true };
+ }
+ async stopWindowDrag() {
+ return { success: true };
+ }
+ };
if (request === "./menuManager") return {};
- if (request === "./devServerManager") return { DEV_SERVER_PORT: 5173, DEV_SERVER_URL: "http://localhost:5173", getAppFilePath: () => ({ path: "/app/index.html", query: {} }), waitForDevServer: async () => undefined };
+ if (request === "./devServerManager")
+ return {
+ DEV_SERVER_PORT: 5173,
+ DEV_SERVER_URL: "http://localhost:5173",
+ getAppFilePath: () => ({ path: "/app/index.html", query: {} }),
+ waitForDevServer: async () => undefined,
+ };
if (request === "./dockManager") return {};
if (request === "./i18nMain") return { i18nMain: { t: (key) => key } };
if (request === "./windowConfig") {
@@ -117,9 +164,18 @@ function fakeWindow({ visible }) {
isDestroyed: () => false,
isVisible: () => isVisible,
isMinimized: () => false,
- showInactive: () => { isVisible = true; calls.push("showInactive"); },
- show: () => { isVisible = true; calls.push("show"); },
- hide: () => { isVisible = false; calls.push("hide"); },
+ showInactive: () => {
+ isVisible = true;
+ calls.push("showInactive");
+ },
+ show: () => {
+ isVisible = true;
+ calls.push("show");
+ },
+ hide: () => {
+ isVisible = false;
+ calls.push("hide");
+ },
focus: () => calls.push("focus"),
blur: () => calls.push("blur"),
setFocusable: (value) => calls.push(`focusable:${value}`),
@@ -321,6 +377,7 @@ test("live transcript events are mirrored to the companion only for plain dictat
manager._agentDictationPillReady = true;
manager.mainWindow = {
isDestroyed: () => false,
+ isVisible: () => true,
showInactive: () => undefined,
webContents: { send: (channel, payload) => mainMessages.push({ channel, payload }) },
};
@@ -344,6 +401,41 @@ test("live transcript events are mirrored to the companion only for plain dictat
assert.deepEqual(companionMessages, [{ channel: "preview-text", payload: "plain" }]);
});
+test("live transcript updates do not restack an already visible dictation window", async () => {
+ const manager = new WindowManager();
+ const calls = [];
+ manager.setOnboardingActive(false);
+ manager.mainWindow = {
+ isDestroyed: () => false,
+ isVisible: () => true,
+ showInactive: () => calls.push("showInactive"),
+ webContents: { send: () => undefined },
+ };
+ manager.enforceMainWindowOnTop = () => calls.push("onTop");
+
+ await manager.showTranscriptionPreview("one");
+ await manager.showTranscriptionPreview("two");
+
+ assert.deepEqual(calls, []);
+});
+
+test("the first live transcript update still surfaces a hidden dictation window", async () => {
+ const manager = new WindowManager();
+ const calls = [];
+ manager.setOnboardingActive(false);
+ manager.mainWindow = {
+ isDestroyed: () => false,
+ isVisible: () => false,
+ showInactive: () => calls.push("showInactive"),
+ webContents: { send: () => undefined },
+ };
+ manager.enforceMainWindowOnTop = () => calls.push("onTop");
+
+ await manager.showTranscriptionPreview("hello");
+
+ assert.deepEqual(calls, ["showInactive", "onTop"]);
+});
+
// Both platform paths run on every runner: branching the expectation on the
// host's own process.platform would leave whichever path CI is not running
// unverified — and darwin is the one that carries the contract.
@@ -676,15 +768,18 @@ test("display changes reposition the companion pill", () => {
pill.webContentsListeners.get("did-finish-load")();
const boundsCallsBefore = pill.setBoundsCalls;
- const metricsListener = screenListeners.find((entry) => entry.event === "display-metrics-changed");
+ const metricsListener = screenListeners.find(
+ (entry) => entry.event === "display-metrics-changed"
+ );
assert.ok(metricsListener, "display-metrics-changed listener registered");
metricsListener.listener();
assert.equal(pill.setBoundsCalls, boundsCallsBefore + 1);
- assert.deepEqual(
- screenListeners.map((entry) => entry.event).sort(),
- ["display-added", "display-metrics-changed", "display-removed"]
- );
+ assert.deepEqual(screenListeners.map((entry) => entry.event).sort(), [
+ "display-added",
+ "display-metrics-changed",
+ "display-removed",
+ ]);
});
test("onboarding suppresses the companion pill like every popup surface", () => {