Skip to content

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

fix(autolearn): ignore redundant same-value auto-learn syncs (#1109)

Serhii Leniv6c84474a1ed8
diff --git a/src/helpers/autoLearnSetting.js b/src/helpers/autoLearnSetting.js
new file mode 100644
index 000000000..8119d621b
--- /dev/null
+++ b/src/helpers/autoLearnSetting.js
@@ -0,0 +1,9 @@
+// Pure resolver for the "auto-learn-changed" IPC sync. Coerces the raw IPC
+// value to boolean and reports whether it differs from the current state, so
+// the handler can ignore repeated same-value syncs (#1080).
+function applyAutoLearnSetting(current, incoming) {
+ const enabled = !!incoming;
+ return { changed: enabled !== !!current, enabled };
+}
+
+module.exports = { applyAutoLearnSetting };
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index cf0fb1d7b..eeb0d7034 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -26,6 +26,7 @@ const liveSpeakerIdentifier = require("./liveSpeakerIdentifier");
const MeetingEchoLeakDetector = require("./meetingEchoLeakDetector");
const { partitionPendingMicFinals, isWithinRetractWindow } = require("./meetingMicHoldback");
const { applySmartSpacing } = require("./smartSpacing");
+const { applyAutoLearnSetting } = require("./autoLearnSetting");
const {
transcriptsOverlap,
transcriptsLooselyOverlap,
@@ -965,7 +966,10 @@ class IPCHandlers {
// Dictionary handlers
ipcMain.on("auto-learn-changed", (_event, enabled) => {
- this._autoLearnEnabled = !!enabled;
+ // Both renderer windows re-sync this on mount — ignore same-value updates (#1080).
+ const { changed, enabled: next } = applyAutoLearnSetting(this._autoLearnEnabled, enabled);
+ if (!changed) return;
+ this._autoLearnEnabled = next;
if (!this._autoLearnEnabled) {
if (this._autoLearnDebounceTimer) {
clearTimeout(this._autoLearnDebounceTimer);
diff --git a/test/helpers/autoLearnSetting.test.js b/test/helpers/autoLearnSetting.test.js
new file mode 100644
index 000000000..68a768958
--- /dev/null
+++ b/test/helpers/autoLearnSetting.test.js
@@ -0,0 +1,41 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+
+const { applyAutoLearnSetting } = require("../../src/helpers/autoLearnSetting");
+
+test("reports a change when enabling from disabled", () => {
+ assert.deepEqual(applyAutoLearnSetting(false, true), {
+ changed: true,
+ enabled: true,
+ });
+});
+
+test("reports a change when disabling from enabled", () => {
+ assert.deepEqual(applyAutoLearnSetting(true, false), {
+ changed: true,
+ enabled: false,
+ });
+});
+
+test("is idempotent when the value is unchanged (enabled) — #1080 dual-window mount sync", () => {
+ assert.deepEqual(applyAutoLearnSetting(true, true), {
+ changed: false,
+ enabled: true,
+ });
+});
+
+test("is idempotent when the value is unchanged (disabled)", () => {
+ assert.deepEqual(applyAutoLearnSetting(false, false), {
+ changed: false,
+ enabled: false,
+ });
+});
+
+test("coerces truthy/falsy incoming values to boolean", () => {
+ assert.deepEqual(applyAutoLearnSetting(false, 1), { changed: true, enabled: true });
+ assert.deepEqual(applyAutoLearnSetting(true, 0), { changed: true, enabled: false });
+ assert.deepEqual(applyAutoLearnSetting(true, undefined), {
+ changed: true,
+ enabled: false,
+ });
+});