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(notes): preserve attendee identities and speaker corrections (#2587)
Joshua21b750f1742d
diff --git a/src/utils/llmTranscript.ts b/src/utils/llmTranscript.tsindex e53c6666c..10b021faa 100644--- a/src/utils/llmTranscript.ts+++ b/src/utils/llmTranscript.ts@@ -15,10 +15,8 @@ const isSelfParticipant = (participant: CalendarAttendee, identity: MeetingIdentparticipant.self || (!!identity.selfEmail && participant.email === identity.selfEmail);/**- * Speaker label for the LLM payload. Mirrors the precedence the exporter- * applies in transcriptFormatter.js: explicit name → cluster mapping →- * "Speaker N" → source fallback. The mic track is the note owner, so it- * carries their real name instead of an anonymous "You" whenever it is known.+ * Speaker label for the LLM payload. An unnamed mic track falls back to the+ * note owner's real name instead of an anonymous "You" whenever it is known.*/export function resolveLlmSpeakerLabel(segment: TranscriptSegment,@@ -26,9 +24,13 @@ export function resolveLlmSpeakerLabel(selfLabel: string,t: Translate): string {- if (segment.source === "mic" || segment.speaker === "you") return selfLabel;const resolved = resolveSegmentSpeakerName(segment, speakerMappings);- if (resolved) return resolved;+ if (resolved) {+ return resolved.trim().toLowerCase() === t("notes.speaker.you").toLowerCase()+ ? selfLabel+ : resolved;+ }+ if (segment.source === "mic" || segment.speaker === "you") return selfLabel;if (segment.speaker) {const num = Number.parseInt(segment.speaker.replace("speaker_", ""), 10);if (!Number.isNaN(num)) return t("notes.speaker.label", { n: num + 1 });@@ -75,7 +77,8 @@ export function buildMeetingContext(identity: MeetingIdentity, selfLabel: string/*** Everyone we can name around a note — the note owner, calendar participants,- * mapped speaker clusters, and named segments — deduplicated by display name.+ * mapped speaker clusters, and named segments. Same-name attendees with+ * different emails stay distinct so tagging can detect ambiguous owners.* Feeds the editor's @mention suggestions and action-item owner tagging.*/export function collectKnownPeople(@@ -84,14 +87,21 @@ export function collectKnownPeople(segments: TranscriptSegment[]): MentionPerson[] {const people: MentionPerson[] = [];- const seen = new Set<string>();+ const byName = new Map<string, MentionPerson[]>();const push = (name: string | null | undefined, email: string | null | undefined) => {const trimmed = name?.trim();if (!trimmed) return;- const key = trimmed.toLowerCase();- if (seen.has(key)) return;- seen.add(key);- people.push({ name: trimmed, email: email?.trim() || null });+ const key = trimmed.replace(/\s+/g, " ").toLowerCase();+ const address = email?.trim() || null;+ const existing = byName.get(key) ?? [];+ if (existing.length > 0) {+ if (!address || existing.some((p) => p.email?.toLowerCase() === address.toLowerCase()))+ return;+ }+ const person = { name: trimmed, email: address };+ existing.push(person);+ byName.set(key, existing);+ people.push(person);};push(identity.selfName, identity.selfEmail);diff --git a/src/utils/mentionMarkdown.ts b/src/utils/mentionMarkdown.tsindex f8de295a6..24a88ef35 100644--- a/src/utils/mentionMarkdown.ts+++ b/src/utils/mentionMarkdown.ts@@ -36,15 +36,24 @@ const TASK_OWNER_LINE = /^(\s*[-*]\s*\[[ xX]\]\s+\S.*?)(\s+[—–-]\s+)(\S.*?)\const OWNER_SPLIT = /\s*(?:,|&|\/|\band\b)\s*/i;interface NameIndex {- byFullName: Map<string, MentionPerson>;+ byFullName: Map<string, MentionPerson | null>;byFirstName: Map<string, MentionPerson | null>;}function buildNameIndex(people: MentionPerson[]): NameIndex {- const byFullName = new Map<string, MentionPerson>();+ const byFullName = new Map<string, MentionPerson | null>();for (const person of people) {const name = sanitizeLabel(person.name).toLowerCase();- if (name && !byFullName.has(name)) byFullName.set(name, person);+ if (!name) continue;+ if (!byFullName.has(name)) {+ byFullName.set(name, person);+ continue;+ }+ const existing = byFullName.get(name);+ if (!existing) continue;+ if (existing.email?.trim().toLowerCase() !== person.email?.trim().toLowerCase()) {+ byFullName.set(name, null);+ }}// First names resolve only when unambiguous across all known people.const byFirstName = new Map<string, MentionPerson | null>();@@ -58,7 +67,10 @@ function buildNameIndex(people: MentionPerson[]): NameIndex {function matchOwner(raw: string, index: NameIndex): MentionPerson | null {const owner = raw.trim().replace(/^@/, "").replace(/[.:]$/, "").toLowerCase();if (!owner) return null;- return index.byFullName.get(owner) ?? index.byFirstName.get(owner) ?? null;+ return (+ (index.byFullName.has(owner) ? index.byFullName.get(owner) : index.byFirstName.get(owner)) ??+ null+ );}/**diff --git a/test/utils/llmTranscript.test.js b/test/utils/llmTranscript.test.jsindex b26cd8c60..54c0693a3 100644--- a/test/utils/llmTranscript.test.js+++ b/test/utils/llmTranscript.test.js@@ -19,11 +19,61 @@ const attendee = (email, displayName, self = false) => ({test("mic segments carry the note owner's label", async () => {const { resolveLlmSpeakerLabel } = await load();- assert.equal(resolveLlmSpeakerLabel({ source: "mic", text: "hi" }, {}, "Gabriel Stein", t), "Gabriel Stein");assert.equal(- resolveLlmSpeakerLabel({ source: "system", speaker: "you", text: "hi" }, {}, "Gabriel Stein", t),+ resolveLlmSpeakerLabel({ source: "mic", text: "hi" }, {}, "Gabriel Stein", t),"Gabriel Stein");+ assert.equal(+ resolveLlmSpeakerLabel(+ { source: "system", speaker: "you", text: "hi" },+ {},+ "Gabriel Stein",+ t+ ),+ "Gabriel Stein"+ );+});++test("manual speaker corrections override the microphone's assumed note owner", async () => {+ const { resolveLlmSpeakerLabel } = await load();+ for (const speaker of ["speaker_0", "you"]) {+ const segment = {+ source: "mic",+ speaker,+ speakerName: "Ravi Patel",+ speakerLocked: true,+ speakerStatus: "locked",+ speakerLockSource: "user",+ speakerIsPlaceholder: false,+ text: "I will send the proposal.",+ };+ assert.equal(+ resolveLlmSpeakerLabel(segment, { [speaker]: "Old name" }, "Casey", t),+ "Ravi Patel"+ );+ }+});++test("a renamed microphone cluster reaches note generation without per-segment names", async () => {+ const { buildLlmTranscript } = await load();+ const segment = {+ source: "mic",+ speaker: "speaker_0",+ timestamp: 123,+ speakerStatus: "confirmed",+ speakerIsPlaceholder: false,+ speakerLocked: false,+ text: "I will send the proposal.",+ };+ assert.equal(+ buildLlmTranscript([segment], { speaker_0: "Ravi Patel" }, "Casey", t),+ "Ravi Patel: I will send the proposal."+ );+ assert.equal(buildLlmTranscript([segment], {}, "Casey", t), "Casey: I will send the proposal.");+ assert.equal(+ buildLlmTranscript([segment], { speaker_0: " you " }, "Casey", t),+ "Casey: I will send the proposal."+ );});test("system segments resolve name → mapping → Speaker N → Them", async () => {@@ -37,7 +87,12 @@ test("system segments resolve name → mapping → Speaker N → Them", async ()};assert.equal(resolveLlmSpeakerLabel(locked, { speaker_0: "Wrong" }, "You", t), "Michael");assert.equal(- resolveLlmSpeakerLabel({ source: "system", speaker: "speaker_1", text: "hi" }, { speaker_1: "Sean" }, "You", t),+ resolveLlmSpeakerLabel(+ { source: "system", speaker: "speaker_1", text: "hi" },+ { speaker_1: "Sean" },+ "You",+ t+ ),"Sean");assert.equal(@@ -82,7 +137,10 @@ test("buildMeetingContext names the owner and invited participants", async () =>test("buildMeetingContext omits what it does not know", async () => {const { buildMeetingContext } = await load();- assert.equal(buildMeetingContext({ selfName: null, selfEmail: null, participants: [] }, "You"), "");+ assert.equal(+ buildMeetingContext({ selfName: null, selfEmail: null, participants: [] }, "You"),+ ""+ );assert.equal(buildMeetingContext({ selfName: null, selfEmail: null, participants: [attendee("[email protected]", "Ada")] },@@ -115,3 +173,66 @@ test("collectKnownPeople merges owner, participants, mappings, and named segment{ name: "Ada", email: null },]);});++test("collectKnownPeople keeps same-name attendees with different email identities", async () => {+ const { collectKnownPeople } = await load();+ const participants = [+ attendee("[email protected]", "Alex Morgan"),+ attendee("[email protected]", "Alex Morgan"),+ attendee("[email protected]", "Alex Morgan"),+ ];+ const people = collectKnownPeople(+ { selfName: "Casey", selfEmail: "[email protected]", participants },+ { speaker_0: "Alex Morgan" },+ [{ source: "system", speakerName: "Alex Morgan", text: "I will send the proposal." }]+ );+ assert.deepEqual(people, [+ { name: "Casey", email: "[email protected]" },+ { name: "Alex Morgan", email: "[email protected]" },+ { name: "Alex Morgan", email: "[email protected]" },+ ]);+});++test("first-name owners resolve to a unique attendee while explicit short labels retain their identity", async () => {+ const { collectKnownPeople } = await load();+ const { tagActionItemOwners } = await import("../../src/utils/mentionMarkdown.ts");+ const identity = {+ selfName: null,+ selfEmail: null,+ participants: [attendee("[email protected]", "Ravi Patel")],+ };+ const line = "- [ ] Send the proposal — Ravi";+ assert.equal(+ tagActionItemOwners(line, collectKnownPeople(identity, { speaker_0: "Ravi Patel" }, [])),+ "- [ ] Send the proposal — [@Ravi Patel](mention:ravi%40example.test)"+ );+ assert.equal(+ tagActionItemOwners(line, collectKnownPeople(identity, { speaker_0: " Ravi Patel " }, [])),+ "- [ ] Send the proposal — [@Ravi Patel](mention:ravi%40example.test)"+ );+ // A name-only label is not evidence that it belongs to the similarly named invitee.+ assert.equal(+ tagActionItemOwners(line, collectKnownPeople(identity, { speaker_0: "Ravi" }, [])),+ "- [ ] Send the proposal — [@Ravi](mention:Ravi)"+ );+});++test("an owner without an email stays distinct from a same-name invitee", async () => {+ const { collectKnownPeople } = await load();+ const { tagActionItemOwners } = await import("../../src/utils/mentionMarkdown.ts");+ const people = collectKnownPeople(+ {+ selfName: "Alex Morgan",+ selfEmail: null,+ participants: [attendee("[email protected]", "Alex Morgan")],+ },+ {},+ []+ );+ assert.deepEqual(people, [+ { name: "Alex Morgan", email: null },+ { name: "Alex Morgan", email: "[email protected]" },+ ]);+ const line = "- [ ] Send the proposal — Alex Morgan";+ assert.equal(tagActionItemOwners(line, people), line);+});diff --git a/test/utils/mentionMarkdown.test.js b/test/utils/mentionMarkdown.test.jsindex 8640af118..a79100c5e 100644--- a/test/utils/mentionMarkdown.test.js+++ b/test/utils/mentionMarkdown.test.js@@ -66,6 +66,62 @@ test("leaves ambiguous first names untouched", async () => {assert.equal(tagActionItemOwners(line, people), line);});+test("does not choose between attendees with the same full name", async () => {+ const { tagActionItemOwners } = await load();+ const people = [+ { name: "Alex Morgan", email: "[email protected]" },+ { name: "Alex Morgan", email: "[email protected]" },+ ];+ for (const roster of [people, [...people].reverse()]) {+ for (const owner of ["Alex Morgan", "Alex", "Sean and Alex Morgan"]) {+ const line = `- [ ] Send the proposal — ${owner}`;+ assert.equal(tagActionItemOwners(line, [...roster, PEOPLE[2]]), line);+ }+ }+});++test("normalizing a display name must not hide conflicting attendee emails", async () => {+ const { tagActionItemOwners } = await load();+ const line = "- [ ] Send the proposal — Alex Morgan";+ assert.equal(+ tagActionItemOwners(line, [+ { name: "Alex Morgan", email: "[email protected]" },+ { name: "ALEX MORGAN", email: "[email protected]" },+ ]),+ line+ );+});++test("duplicate records retain the known attendee email", async () => {+ const { tagActionItemOwners } = await load();+ const attendee = { name: "Alex Morgan", email: "[email protected]" };+ for (const people of [+ [attendee, { ...attendee }],+ [attendee, { ...attendee, email: "[email protected]" }],+ ]) {+ assert.equal(+ tagActionItemOwners("- [ ] Send the proposal — Alex", people),+ "- [ ] Send the proposal — [@Alex Morgan](mention:alex%40example.test)"+ );+ }+});++test("a name-only identity does not inherit a same-name person's email", async () => {+ const { tagActionItemOwners } = await load();+ const attendee = { name: "Alex Morgan", email: "[email protected]" };+ const unnamedAddress = { ...attendee, email: null };+ for (const people of [+ [unnamedAddress, attendee],+ [attendee, unnamedAddress],+ [attendee, unnamedAddress, attendee],+ ]) {+ for (const owner of ["Alex Morgan", "Alex"]) {+ const line = `- [ ] Send the proposal — ${owner}`;+ assert.equal(tagActionItemOwners(line, people), line);+ }+ }+});+test("tags multiple owners only when every owner is known", async () => {const { tagActionItemOwners } = await load();assert.equal(