Skip to content

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

fix(meetings): make the roster-driven speaker cap raise-only

Gabriel Stein3bd66e620ae0
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 9e8521498..7d01dc6fd 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -762,13 +762,18 @@ class IPCHandlers {
// Participants added mid-meeting must raise the speaker cap that was derived
// from the note at recording start. A count the user set via the stepper
// (explicit) is never overridden.
+ //
+ // Raise-only: lowering the cap below the clusters already discovered would make
+ // _assignOrForceCluster fold every later voice onto an existing speaker — the
+ // exact identity collapse this refresh exists to prevent. A roster that shrinks
+ // (or empties) mid-meeting therefore leaves the cap where it is.
_refreshMeetingSpeakerConfigFromNote(noteId, note) {
const config = this.activeMeetingSpeakerConfig;
if (!config || config.explicit) return;
if (noteId == null || this._activeMeetingNoteId !== noteId) return;
- const expectedCount = this._resolveNoteExpectedSpeakerCount(note);
- if (expectedCount === config.expectedCount) return;
+ const expectedCount = this._noteExpectedSpeakerCountOrNull(note);
+ if (expectedCount == null || expectedCount <= config.expectedCount) return;
this.activeMeetingSpeakerConfig = { ...config, expectedCount };
liveSpeakerIdentifier.setMaxSpeakers(Math.max(1, expectedCount - 1));
@@ -9823,7 +9828,9 @@ class IPCHandlers {
return { numSpeakers, cap: numSpeakers };
}
- return { numSpeakers: -1, cap: DEFAULT_EXPECTED_SPEAKER_COUNT };
+ // Only system audio reaches the diarizer (the mic track is "you"), so the cap
+ // counts other speakers — same total - 1 basis as the branches above.
+ return { numSpeakers: -1, cap: Math.max(1, DEFAULT_EXPECTED_SPEAKER_COUNT - 1) };
}
_startOrSkipDiarization(
diff --git a/src/helpers/liveSpeakerIdentifier.js b/src/helpers/liveSpeakerIdentifier.js
index 9252b1141..4a02fb237 100644
--- a/src/helpers/liveSpeakerIdentifier.js
+++ b/src/helpers/liveSpeakerIdentifier.js
@@ -342,11 +342,15 @@ class LiveSpeakerIdentifier {
mapSpeaker(liveId, profileId, displayName, noteId) {
if (!liveId || !this.transientEmbeddings.has(liveId)) {
- debugLogger.warn("Live speaker mapping dropped: unknown speaker id", {
- liveId,
- hasDisplayName: !!displayName,
- knownSpeakers: [...this.transientEmbeddings.keys()],
- });
+ // Labeling a speaker in a past note routes here with no live session, so
+ // only an active session losing a mapping is worth flagging.
+ if (this.running) {
+ debugLogger.warn("Live speaker mapping dropped: unknown speaker id", {
+ liveId,
+ hasDisplayName: !!displayName,
+ knownSpeakers: [...this.transientEmbeddings.keys()],
+ });
+ }
return false;
}
diff --git a/src/utils/participants.ts b/src/utils/participants.ts
index 5c166a244..07e8c9a75 100644
--- a/src/utils/participants.ts
+++ b/src/utils/participants.ts
@@ -15,6 +15,9 @@ export const resolveParticipantExpectedSpeakerCount = (
return others > 0 ? others + 1 : null;
};
+// Raise-only, mirroring _refreshMeetingSpeakerConfigFromNote in main: a roster
+// that shrinks mid-recording must not pull the cap below the speakers already
+// discovered, and main would not broadcast the lower value back anyway.
export const resolveParticipantSpeakerCountSync = ({
recordingNoteId,
noteId,
@@ -25,7 +28,7 @@ export const resolveParticipantSpeakerCountSync = ({
if (recordingNoteId !== noteId || userTouchedStepper) return null;
const expectedCount = resolveParticipantExpectedSpeakerCount(participants);
- return expectedCount != null && expectedCount !== currentExpectedCount ? expectedCount : null;
+ return expectedCount != null && expectedCount > currentExpectedCount ? expectedCount : null;
};
export const resolveInitialSpeakerCountOverride = (
diff --git a/test/helpers/liveSpeakerIdentifier.test.js b/test/helpers/liveSpeakerIdentifier.test.js
index 58822eb44..0b4ef762d 100644
--- a/test/helpers/liveSpeakerIdentifier.test.js
+++ b/test/helpers/liveSpeakerIdentifier.test.js
@@ -122,12 +122,13 @@ test("stop() state keys match the resolved speaker ids", async () => {
);
});
-test("mapSpeaker on an unknown id fails loudly", () => {
+test("mapSpeaker on an unknown id fails loudly during a live session", () => {
const { LiveSpeakerIdentifier, warnings } = loadIdentifier();
const identifier = new LiveSpeakerIdentifier();
identifier.setMaxSpeakers(3);
identifier._resolveSpeakerForEmbedding(voiceA, { updateCentroid: true });
+ identifier.running = true;
const mapped = identifier.mapSpeaker("speaker_9", 1, "Alice", null);
assert.equal(mapped, false);
@@ -139,6 +140,17 @@ test("mapSpeaker on an unknown id fails loudly", () => {
);
});
+// Labeling a speaker in a past note, or editing that note's participants, routes
+// through mapSpeaker with no live session and no transient clusters. Nothing was
+// dropped, so warning there would put noise in every user's production log file.
+test("mapSpeaker stays quiet when no session is running", () => {
+ const { LiveSpeakerIdentifier, warnings } = loadIdentifier();
+ const identifier = new LiveSpeakerIdentifier();
+
+ assert.equal(identifier.mapSpeaker("speaker_0", 1, "Alice", 42), false);
+ assert.deepEqual(warnings, []);
+});
+
// Plants exactly two clusters ~0.70 similar (above the 0.65 recluster
// threshold) — creating them via resolution would just match them together.
function seedSimilarIdentifiedPair(identifier) {
diff --git a/test/helpers/meetingSpeakerReconcile.test.js b/test/helpers/meetingSpeakerReconcile.test.js
index 3ec68ba5d..263456f27 100644
--- a/test/helpers/meetingSpeakerReconcile.test.js
+++ b/test/helpers/meetingSpeakerReconcile.test.js
@@ -133,20 +133,20 @@ test("reconciliation migrates the mapping when the offline id differs", () => {
assert.deepEqual(calls.remove, [{ noteId: NOTE_ID, speakerId: "speaker_3" }]);
});
-function refreshConfig(explicit) {
+const THREE_ATTENDEES = [
+ { email: "[email protected]" },
+ { email: "[email protected]" },
+ { email: "[email protected]" },
+];
+
+function refreshConfig(explicit, { expectedCount = 2, attendees = THREE_ATTENDEES } = {}) {
const { IPCHandlers, liveSpeakerIdentifier, broadcasts } = loadHandlers();
const fakeThis = Object.assign(Object.create(IPCHandlers.prototype), {
- activeMeetingSpeakerConfig: { enabled: true, expectedCount: 2, explicit },
+ activeMeetingSpeakerConfig: { enabled: true, expectedCount, explicit },
_activeMeetingNoteId: NOTE_ID,
databaseManager: { getGoogleAccounts: () => [] },
});
- const note = {
- participants: JSON.stringify([
- { email: "[email protected]" },
- { email: "[email protected]" },
- { email: "[email protected]" },
- ]),
- };
+ const note = { participants: JSON.stringify(attendees) };
IPCHandlers.prototype._refreshMeetingSpeakerConfigFromNote.call(fakeThis, NOTE_ID, note);
return { fakeThis, liveSpeakerIdentifier, broadcasts };
@@ -168,3 +168,60 @@ test("an explicit stepper count is never overridden by roster changes", () => {
assert.equal(fakeThis.activeMeetingSpeakerConfig.expectedCount, 2);
assert.deepEqual(broadcasts, []);
});
+
+// Lowering the cap below the clusters already discovered makes the identifier
+// fold every later voice onto an existing speaker — the collapse this refresh
+// exists to prevent. A shrinking or emptied roster must be ignored.
+test("a shrinking roster leaves the speaker cap untouched", () => {
+ const shrunk = refreshConfig(false, {
+ expectedCount: 4,
+ attendees: [{ email: "[email protected]" }],
+ });
+
+ assert.equal(shrunk.fakeThis.activeMeetingSpeakerConfig.expectedCount, 4);
+ assert.deepEqual(shrunk.broadcasts, []);
+
+ const emptied = refreshConfig(false, { expectedCount: 4, attendees: [] });
+
+ assert.equal(emptied.fakeThis.activeMeetingSpeakerConfig.expectedCount, 4);
+ assert.deepEqual(emptied.broadcasts, []);
+});
+
+// Only system audio reaches the diarizer, so every branch must report `cap` as a
+// count of other speakers (total - 1). The no-signal fallback used to return the
+// total itself, which let one remote voice split across two labels.
+test("speaker expectation reports cap as other-speaker count in every branch", () => {
+ const { IPCHandlers } = loadHandlers();
+ const resolve = (args) =>
+ IPCHandlers.prototype._resolveSpeakerExpectation.call(
+ Object.assign(Object.create(IPCHandlers.prototype), {
+ databaseManager: { getNote: () => args.note ?? null },
+ }),
+ {
+ sessionConfig: args.sessionConfig ?? null,
+ noteId: args.noteId ?? null,
+ observedSpeakerIds: args.observedSpeakerIds ?? new Set(),
+ }
+ );
+
+ assert.deepEqual(
+ resolve({ sessionConfig: { expectedCount: 3, explicit: true } }),
+ { numSpeakers: 2, cap: 2 },
+ "an explicit count of 3 means 2 other speakers"
+ );
+ assert.deepEqual(
+ resolve({ noteId: NOTE_ID, note: { expected_speaker_count: 4 } }),
+ { numSpeakers: 3, cap: 3 },
+ "a note count outranks a non-explicit session config"
+ );
+ assert.deepEqual(
+ resolve({ observedSpeakerIds: new Set(["speaker_0", "speaker_1"]) }),
+ { numSpeakers: 2, cap: 2 },
+ "observed ids are already other-speaker ids"
+ );
+ assert.deepEqual(
+ resolve({}),
+ { numSpeakers: -1, cap: 1 },
+ "the default total of 2 means a single other speaker, not 2"
+ );
+});
diff --git a/test/helpers/participants.test.js b/test/helpers/participants.test.js
index 8128f5d65..f3087b687 100644
--- a/test/helpers/participants.test.js
+++ b/test/helpers/participants.test.js
@@ -87,6 +87,26 @@ test("participant changes do not override another recording, a manual count, or
);
});
+// A roster that shrinks mid-recording must not pull the cap below the speakers
+// already discovered — that would fold later voices onto an existing speaker.
+test("a shrinking roster never lowers the session count", async () => {
+ const { resolveParticipantSpeakerCountSync } = await load();
+ const base = { recordingNoteId: 42, noteId: 42, userTouchedStepper: false };
+
+ assert.equal(
+ resolveParticipantSpeakerCountSync({
+ ...base,
+ currentExpectedCount: 4,
+ participants: [{ email: "[email protected]", self: false }],
+ }),
+ null
+ );
+ assert.equal(
+ resolveParticipantSpeakerCountSync({ ...base, currentExpectedCount: 4, participants: [] }),
+ null
+ );
+});
+
test("participant-derived startup counts remain eligible for roster synchronization", async () => {
const { resolveInitialSpeakerCountOverride } = await load();