Skip to content

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

fix(meeting): stop diarization collapsing remote speakers into one (#1126)

Gabriel Steincae350aec415
diff --git a/src/components/notes/PersonalNotesView.tsx b/src/components/notes/PersonalNotesView.tsx
index 0f7a3e1ea..caf874e1c 100644
--- a/src/components/notes/PersonalNotesView.tsx
+++ b/src/components/notes/PersonalNotesView.tsx
@@ -58,6 +58,7 @@ import { MEETINGS_FOLDER_NAME, findDefaultFolder } from "./shared";
import logger from "../../utils/logger";
import { parseTranscriptSegments } from "../../utils/parseTranscriptSegments";
import { serializeTranscriptSegments } from "../../utils/transcriptSpeakerState";
+import { resolveExpectedSpeakerCount } from "../../utils/participants";
import {
useNotes,
useActiveNoteId,
@@ -232,7 +233,7 @@ export default function PersonalNotesView({
folderId: note?.folder_id ?? null,
seedSegments,
diarizationEnabled: note?.diarization_enabled == null ? null : note.diarization_enabled === 1,
- expectedCount: note?.expected_speaker_count ?? null,
+ expectedCount: resolveExpectedSpeakerCount(note),
});
}, [notes]);
@@ -521,7 +522,7 @@ export default function PersonalNotesView({
folderId: note?.folder_id ?? meetingRecordingRequest.folderId ?? null,
seedSegments,
diarizationEnabled: note?.diarization_enabled == null ? null : note.diarization_enabled === 1,
- expectedCount: note?.expected_speaker_count ?? null,
+ expectedCount: resolveExpectedSpeakerCount(note),
});
onMeetingRecordingRequestHandled?.();
}, [meetingRecordingRequest, activeNoteId, notes, onMeetingRecordingRequestHandled]);
diff --git a/src/helpers/database.js b/src/helpers/database.js
index c5413c492..6b980cf6f 100644
--- a/src/helpers/database.js
+++ b/src/helpers/database.js
@@ -1491,6 +1491,11 @@ class DatabaseManager {
}
}
if (fields.length === 0) return { success: false };
+ // Re-queue for cloud sync on any local edit, so post-sync field changes aren't
+ // left local-only and overwritten by a later pull.
+ if (!("sync_status" in updates)) {
+ fields.push("sync_status = 'pending'");
+ }
fields.push("updated_at = CURRENT_TIMESTAMP");
values.push(id);
const stmt = this.db.prepare(`UPDATE notes SET ${fields.join(", ")} WHERE id = ?`);
@@ -2685,10 +2690,10 @@ class DatabaseManager {
enhanced_at_content_hash = excluded.enhanced_at_content_hash,
transcript = excluded.transcript,
folder_id = excluded.folder_id,
- participants = excluded.participants,
- calendar_event_id = excluded.calendar_event_id,
- diarization_enabled = excluded.diarization_enabled,
- expected_speaker_count = excluded.expected_speaker_count,
+ participants = COALESCE(excluded.participants, participants),
+ calendar_event_id = COALESCE(excluded.calendar_event_id, calendar_event_id),
+ diarization_enabled = COALESCE(excluded.diarization_enabled, diarization_enabled),
+ expected_speaker_count = COALESCE(excluded.expected_speaker_count, expected_speaker_count),
sync_status = 'synced',
updated_at = excluded.updated_at
`);
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 6096c0913..6150be7d1 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -535,6 +535,34 @@ class IPCHandlers {
return { displayName, email };
}
+ _resolveNoteExpectedSpeakerCount(note) {
+ const stored = Number(note?.expected_speaker_count);
+ if (Number.isFinite(stored) && stored > 0) {
+ return Math.min(stored, MAX_SPEAKER_COUNT);
+ }
+ const others = this._parseNonSelfParticipants(note?.participants).length;
+ if (others > 0) {
+ return Math.min(others + 1, MAX_SPEAKER_COUNT);
+ }
+ return DEFAULT_EXPECTED_SPEAKER_COUNT;
+ }
+
+ _resolveInitialMeetingSpeakerConfig(noteId) {
+ let note = null;
+ if (noteId != null) {
+ try {
+ note = this.databaseManager.getNote(noteId);
+ } catch (_) {
+ note = null;
+ }
+ }
+ const enabled =
+ (note?.diarization_enabled == null
+ ? this.speakerDiarizationEnabled
+ : note.diarization_enabled !== 0) !== false;
+ return { enabled, expectedCount: this._resolveNoteExpectedSpeakerCount(note) };
+ }
+
_rebuildMirror(basePath) {
const markdownMirror = require("./markdownMirror");
if (basePath) markdownMirror.init(basePath);
@@ -5601,6 +5629,7 @@ class IPCHandlers {
await stopLiveSpeakerIdentification().catch(() => {});
resetMeetingLocalState();
await disconnectMeetingStreaming().catch(() => {});
+ this.activeMeetingSpeakerConfig = null;
};
const setupDictationCallbacks = (streaming, event) => {
@@ -5783,6 +5812,12 @@ class IPCHandlers {
meetingOneOnOneProfileBound = false;
meetingNoteId = options.noteId ?? null;
+ // Seed the speaker cap from the note/calendar participants up front so live
+ // identification isn't stuck at the default if the renderer never pushes a config.
+ if (!this.activeMeetingSpeakerConfig) {
+ this.activeMeetingSpeakerConfig = this._resolveInitialMeetingSpeakerConfig(meetingNoteId);
+ }
+
if (systemAudioMode === "unsupported" && this._meetingSystemStreaming?.isConnected) {
await this._meetingSystemStreaming.disconnect().catch(() => ({ text: "" }));
this._meetingSystemStreaming = null;
diff --git a/src/utils/participants.ts b/src/utils/participants.ts
new file mode 100644
index 000000000..c72d5a28a
--- /dev/null
+++ b/src/utils/participants.ts
@@ -0,0 +1,22 @@
+import type { CalendarAttendee } from "../types/calendar";
+
+// Expected total speaker count for a meeting note: the stored value, else derived from
+// calendar participants (non-self attendees + you), else null so callers use their default.
+export const resolveExpectedSpeakerCount = (note?: {
+ expected_speaker_count?: number | null;
+ participants?: string | null;
+}): number | null => {
+ if (note?.expected_speaker_count != null) return note.expected_speaker_count;
+ if (!note?.participants) return null;
+
+ let attendees: CalendarAttendee[];
+ try {
+ const parsed = JSON.parse(note.participants);
+ attendees = Array.isArray(parsed) ? parsed : [];
+ } catch {
+ return null;
+ }
+
+ const others = attendees.filter((attendee) => attendee?.self !== true).length;
+ return others > 0 ? others + 1 : null;
+};
diff --git a/src/utils/transcriptSpeakerState.ts b/src/utils/transcriptSpeakerState.ts
index 8a25928e8..9acd32c07 100644
--- a/src/utils/transcriptSpeakerState.ts
+++ b/src/utils/transcriptSpeakerState.ts
@@ -111,7 +111,10 @@ const mergeSpeakerFields = (existing: TranscriptSegment, incoming: TranscriptSeg
}
if (isTranscriptSpeakerLocked(existing)) {
+ // Keep the user's name/lock but let diarization refine the speaker cluster, so one
+ // locked label can't freeze a bucket diarization splits into multiple speakers.
for (const field of SPEAKER_STATE_FIELDS) {
+ if (field === "speaker" || field === "speakerIsPlaceholder") continue;
if (existingFields[field] !== undefined) {
mergedFields[field] = existingFields[field];
}