Skip to content

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

fix(notes): draw in-person mic speakers on the other side of the transcript (#2783)

Chad Piha391095a77a7f
diff --git a/src/components/notes/MeetingTranscriptChat.tsx b/src/components/notes/MeetingTranscriptChat.tsx
index 21ed45851..b8a806db5 100644
--- a/src/components/notes/MeetingTranscriptChat.tsx
+++ b/src/components/notes/MeetingTranscriptChat.tsx
@@ -9,6 +9,7 @@ import { cn } from "../lib/utils";
import { MAX_SPEAKER_COUNT } from "../../constants/speakerDetection.json";
import type { TranscriptSegment } from "../../stores/meetingRecordingStore";
import {
+ isSelfSideSegment,
isTranscriptSpeakerLocked,
resolveSegmentSpeakerName,
type TranscriptSpeakerStatus,
@@ -812,13 +813,15 @@ export function MeetingTranscriptChat({
// Per-segment derivations hoisted out of the row map: rows receive them as
// stable props, so partial ticks (which change neither input) skip every row.
+ const youLabel = t("notes.speaker.you");
const rowMeta = useMemo(
() =>
segments.map((segment) => ({
key: getEffectiveSpeakerKey(segment, speakerMappings),
activeName: resolveSegmentSpeakerName(segment, speakerMappings),
+ selfSide: isSelfSideSegment(segment, speakerMappings, youLabel),
})),
- [segments, speakerMappings]
+ [segments, speakerMappings, youLabel]
);
const colorByKey = useMemo(() => {
@@ -826,7 +829,8 @@ export function MeetingTranscriptChat({
let nextIdx = 0;
segments.forEach((segment, i) => {
if (segment.source === "mic" && !segment.speaker) return;
- if (segment.speaker === "you") return;
+ // Bubbles on the user's side aren't colored, so they take no slot.
+ if (rowMeta[i].selfSide) return;
const key = rowMeta[i].key;
if (!map.has(key)) {
map.set(key, nextIdx % SPEAKER_COLORS.length);
@@ -859,14 +863,6 @@ export function MeetingTranscriptChat({
);
}
- const isSelfSide = (segment: TranscriptSegment): boolean => {
- const mapped = segment.speaker ? speakerMappings?.[segment.speaker] : undefined;
- if (mapped) return mapped.trim().toLowerCase() === t("notes.speaker.you").toLowerCase();
- if (segment.speaker === "you") return true;
- if (segment.speakerName) return false;
- return segment.source === "mic";
- };
-
const showAssumedHint =
!isDiarizing &&
sessionDiarizationEnabled &&
@@ -969,9 +965,8 @@ export function MeetingTranscriptChat({
{virtualizer.getVirtualItems().map((virtualItem) => {
const i = virtualItem.index;
const segment = segments[i];
- const selfSide = isSelfSide(segment);
+ const { key, activeName, selfSide } = rowMeta[i];
const isSystemSpeaker = !!segment.speaker && !selfSide;
- const { key, activeName } = rowMeta[i];
return (
<div
key={segment.id}
@@ -989,7 +984,9 @@ export function MeetingTranscriptChat({
<SegmentRow
segment={segment}
selfSide={selfSide}
- sameSpeaker={i > 0 && rowMeta[i - 1].key === key}
+ sameSpeaker={
+ i > 0 && rowMeta[i - 1].key === key && rowMeta[i - 1].selfSide === selfSide
+ }
isFirst={i === 0}
isNewest={i === segments.length - 1}
colorIdx={isSystemSpeaker ? (colorByKey.get(key) ?? 0) : 0}
diff --git a/src/utils/llmTranscript.ts b/src/utils/llmTranscript.ts
index 626fdfcb9..c0ca402c4 100644
--- a/src/utils/llmTranscript.ts
+++ b/src/utils/llmTranscript.ts
@@ -1,6 +1,6 @@
import type { TranscriptSegment } from "../stores/meetingRecordingStore";
import type { CalendarAttendee } from "../types/calendar";
-import { resolveSegmentSpeakerName } from "./transcriptSpeakerState";
+import { isYouSpeakerName, resolveSegmentSpeakerName } from "./transcriptSpeakerState";
import type { MentionPerson } from "./mentionMarkdown";
type Translate = (key: string, options?: Record<string, unknown>) => string;
@@ -28,11 +28,7 @@ export function resolveLlmSpeakerLabel(
t: Translate
): string {
const resolved = resolveSegmentSpeakerName(segment, speakerMappings);
- if (resolved) {
- return resolved.trim().toLowerCase() === t("notes.speaker.you").toLowerCase()
- ? selfLabel
- : resolved;
- }
+ if (resolved) return isYouSpeakerName(resolved, t("notes.speaker.you")) ? selfLabel : resolved;
if (segment.speaker === "you") return selfLabel;
if (segment.speaker) {
const num = Number.parseInt(segment.speaker.replace("speaker_", ""), 10);
diff --git a/src/utils/transcriptEvidence.ts b/src/utils/transcriptEvidence.ts
index 58578cbab..94398fbe7 100644
--- a/src/utils/transcriptEvidence.ts
+++ b/src/utils/transcriptEvidence.ts
@@ -1,6 +1,6 @@
import { parseTranscriptSegments } from "./parseTranscriptSegments";
import { withoutAttendeesFence } from "./noteAttendees";
-import { resolveSegmentSpeakerName } from "./transcriptSpeakerState";
+import { isYouSpeakerName, resolveSegmentSpeakerName } from "./transcriptSpeakerState";
import { buildMeetingContext, type MeetingIdentity } from "./llmTranscript";
import i18n from "../i18n";
import type { TranscriptSegment } from "../stores/meetingRecordingStore";
@@ -43,11 +43,7 @@ function speakerLabel(segment: TranscriptSegment, speakerMappings: Record<string
// Stored JSON is untrusted: a malformed name must not block the transcript.
const resolved: unknown = resolveSegmentSpeakerName(segment, speakerMappings);
if (typeof resolved === "string" && resolved) {
- // A speaker mapped to "You" is stored in the UI language.
- const name = resolved.trim().toLowerCase();
- return name === "you" || name === i18n.t("notes.speaker.you").toLowerCase()
- ? NOTE_TAKER_LABEL
- : resolved;
+ return isYouSpeakerName(resolved, i18n.t("notes.speaker.you")) ? NOTE_TAKER_LABEL : resolved;
}
if (segment.speaker === "you") return NOTE_TAKER_LABEL;
// Numbered from 1, as the note shows speakers. An in-person meeting is
diff --git a/src/utils/transcriptSpeakerState.ts b/src/utils/transcriptSpeakerState.ts
index d58b35e9e..7e66b77aa 100644
--- a/src/utils/transcriptSpeakerState.ts
+++ b/src/utils/transcriptSpeakerState.ts
@@ -219,3 +219,42 @@ export const resolveSegmentSpeakerName = (
const mapped = segment.speaker ? speakerMappings?.[segment.speaker] : undefined;
return mapped || segment.speakerName;
};
+
+// Naming a speaker "You" is how the user marks their own voice. The name is
+// stored in the UI language it was saved in, so English "You" counts in every
+// language alongside the current one.
+export const isYouSpeakerName = (name: string, youLabel: string): boolean => {
+ const normalized = name.trim().toLowerCase();
+ return normalized === "you" || normalized === youLabel.toLowerCase();
+};
+
+// Which side of the transcript a bubble sits on follows the name its chip shows,
+// so a stretch the user reassigned moves with its new name. An in-person meeting
+// is diarized on the mic without knowing which voice is the note taker, so its
+// numbered clusters, the user's own included, sit with the other speakers until
+// one is named "You". A remote call stores the mic as "you". An unconfirmed
+// "You?" suggestion on the mic sits where confirming it would put it.
+export const isSelfSideSegment = (
+ segment: TranscriptSegment,
+ speakerMappings: Record<string, string> | undefined,
+ youLabel: string
+): boolean => {
+ const name = resolveSegmentSpeakerName(segment, speakerMappings);
+ if (name) {
+ // On a call the user is the mic, so a remote voice that recording matched to
+ // their voice profile is a misidentification; only a name the user set, which
+ // locks its rows, moves it across. Mappings also hold automatic matches.
+ const autoNamedRemote = segment.source === "system" && !isTranscriptSpeakerLocked(segment);
+ return !autoNamedRemote && isYouSpeakerName(name, youLabel);
+ }
+ if (
+ segment.source === "mic" &&
+ segment.suggestedName &&
+ isYouSpeakerName(segment.suggestedName, youLabel)
+ ) {
+ return true;
+ }
+ if (segment.speaker === "you") return true;
+ if (segment.speaker) return false;
+ return segment.source === "mic";
+};
diff --git a/test/components/meetingTranscriptChat.test.js b/test/components/meetingTranscriptChat.test.js
index 0d9f10e8a..d46e6b36e 100644
--- a/test/components/meetingTranscriptChat.test.js
+++ b/test/components/meetingTranscriptChat.test.js
@@ -88,3 +88,44 @@ test("live partials render alongside the settled rows", async () => {
assert.ok(html.includes("still talking"));
assert.ok(html.includes("hello from mic"));
});
+
+test("an in-person meeting draws numbered mic speakers on the other side", async () => {
+ const html = await renderChat({
+ segments: [
+ { id: "p1", text: "first person", source: "mic", timestamp: 1, speaker: "speaker_0" },
+ { id: "p2", text: "second person", source: "mic", timestamp: 2, speaker: "speaker_1" },
+ { id: "p3", text: "not diarized", source: "mic", timestamp: 3 },
+ ],
+ });
+ const otherSide = html.split("bg-surface-2 border border-border/70 text-foreground").length - 1;
+ const selfSide = html.split("bg-primary/90 text-primary-foreground").length - 1;
+ assert.equal(otherSide, 2, "both numbered speakers sit on the other side");
+ assert.equal(selfSide, 1, "a mic line without a speaker stays on the user's side");
+ assert.ok(html.includes("Speaker 1") && html.includes("Speaker 2"));
+});
+
+test("a stretch of the user's lines reassigned to someone gets its own colour", async () => {
+ const html = await renderChat({
+ segments: [
+ { id: "y1", text: "my own line", source: "mic", timestamp: 1, speaker: "you" },
+ { id: "r1", text: "remote line", source: "system", timestamp: 2, speaker: "speaker_0" },
+ {
+ id: "y2",
+ text: "actually bob",
+ source: "mic",
+ timestamp: 3,
+ speaker: "you",
+ speakerName: "Bob",
+ speakerLocked: true,
+ speakerLockSource: "user",
+ speakerStatus: "locked",
+ },
+ ],
+ });
+ assert.equal(
+ html.split("border-s-blue-400/50").length - 1,
+ 1,
+ "Speaker 1 keeps the first colour"
+ );
+ assert.equal(html.split("border-s-green-400/50").length - 1, 1, "Bob gets the next one");
+});
diff --git a/test/utils/llmTranscript.test.js b/test/utils/llmTranscript.test.js
index 3b0870682..e88639ebf 100644
--- a/test/utils/llmTranscript.test.js
+++ b/test/utils/llmTranscript.test.js
@@ -262,3 +262,11 @@ test("an owner without an email stays distinct from a same-name invitee", async
const line = "- [ ] Send the proposal — Alex Morgan";
assert.equal(tagActionItemOwners(line, people), line);
});
+
+test("a You saved in another UI language still labels the note owner", async () => {
+ const { resolveLlmSpeakerLabel } = await load();
+ const german = (key, options) => (key === "notes.speaker.you" ? "Du" : t(key, options));
+ const segment = { source: "mic", speaker: "speaker_0", text: "hi" };
+ assert.equal(resolveLlmSpeakerLabel(segment, { speaker_0: "You" }, "Casey", german), "Casey");
+ assert.equal(resolveLlmSpeakerLabel(segment, { speaker_0: "Du" }, "Casey", german), "Casey");
+});
diff --git a/test/utils/transcriptSelfSide.test.js b/test/utils/transcriptSelfSide.test.js
new file mode 100644
index 000000000..bf8b914cc
--- /dev/null
+++ b/test/utils/transcriptSelfSide.test.js
@@ -0,0 +1,106 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+
+const load = () => import("../../src/utils/transcriptSpeakerState.ts");
+
+const YOU = "You";
+
+const userLocked = (segment, speakerName) => ({
+ ...segment,
+ speakerName,
+ speakerLocked: true,
+ speakerLockSource: "user",
+ speakerStatus: "locked",
+});
+
+test("a remote call keeps the mic on the user's side", async () => {
+ const { isSelfSideSegment } = await load();
+ assert.equal(isSelfSideSegment({ source: "mic", speaker: "you" }, {}, YOU), true);
+ assert.equal(isSelfSideSegment({ source: "system", speaker: "speaker_0" }, {}, YOU), false);
+});
+
+test("an in-person meeting puts numbered mic clusters on the other side", async () => {
+ const { isSelfSideSegment } = await load();
+ assert.equal(isSelfSideSegment({ source: "mic", speaker: "speaker_0" }, {}, YOU), false);
+ assert.equal(isSelfSideSegment({ source: "mic", speaker: "speaker_1" }, {}, YOU), false);
+});
+
+test("an undiarized mic stays on the user's side", async () => {
+ const { isSelfSideSegment } = await load();
+ assert.equal(isSelfSideSegment({ source: "mic" }, undefined, YOU), true);
+ assert.equal(isSelfSideSegment({ source: "system" }, undefined, YOU), false);
+});
+
+test("naming a cluster You moves it to the user's side, any other name moves it off", async () => {
+ const { isSelfSideSegment } = await load();
+ assert.equal(
+ isSelfSideSegment({ source: "mic", speaker: "speaker_1" }, { speaker_1: " you " }, YOU),
+ true
+ );
+ assert.equal(isSelfSideSegment({ source: "mic", speaker: "you" }, { you: "Alice" }, YOU), false);
+});
+
+test("a recognized name decides the side like the chip does", async () => {
+ const { isSelfSideSegment } = await load();
+ assert.equal(isSelfSideSegment({ source: "mic", speakerName: "Alice" }, {}, YOU), false);
+ // A voice profile named You recognizes the user without writing a mapping.
+ assert.equal(
+ isSelfSideSegment({ source: "mic", speaker: "speaker_0", speakerName: "You" }, {}, YOU),
+ true
+ );
+ assert.equal(
+ isSelfSideSegment(
+ { source: "mic", speaker: "speaker_0", speakerName: "You" },
+ { speaker_0: "Alice" },
+ YOU
+ ),
+ false
+ );
+});
+
+test("a reassigned stretch follows its new name over the cluster mapping", async () => {
+ const { isSelfSideSegment } = await load();
+ const cluster = { source: "mic", speaker: "speaker_0" };
+ assert.equal(isSelfSideSegment(userLocked(cluster, "Bob"), { speaker_0: "You" }, YOU), false);
+ assert.equal(isSelfSideSegment(userLocked(cluster, "You"), { speaker_0: "Alice" }, YOU), true);
+ assert.equal(isSelfSideSegment(userLocked(cluster, "You"), {}, YOU), true);
+});
+
+test("a You suggestion sits on the user's side until it is confirmed or dismissed", async () => {
+ const { isSelfSideSegment } = await load();
+ assert.equal(
+ isSelfSideSegment({ source: "mic", speaker: "speaker_0", suggestedName: "You" }, {}, YOU),
+ true
+ );
+ assert.equal(
+ isSelfSideSegment({ source: "mic", speaker: "speaker_0", suggestedName: "Alice" }, {}, YOU),
+ false
+ );
+ // A confirmed or mapped name outranks the suggestion, as it does on the chip.
+ assert.equal(
+ isSelfSideSegment(
+ { source: "mic", speaker: "speaker_0", suggestedName: "You" },
+ { speaker_0: "Alice" },
+ YOU
+ ),
+ false
+ );
+});
+
+test("a You saved in another UI language still counts as the user", async () => {
+ const { isSelfSideSegment } = await load();
+ const cluster = { source: "mic", speaker: "speaker_0" };
+ assert.equal(isSelfSideSegment(cluster, { speaker_0: "You" }, "Du"), true);
+ assert.equal(isSelfSideSegment(cluster, { speaker_0: "Du" }, "Du"), true);
+ assert.equal(isSelfSideSegment(cluster, { speaker_0: "Youssef" }, "Du"), false);
+});
+
+test("a remote voice matched to the user's voice profile stays on the other side", async () => {
+ const { isSelfSideSegment } = await load();
+ const remote = { source: "system", speaker: "speaker_0" };
+ assert.equal(isSelfSideSegment({ ...remote, suggestedName: "You" }, {}, YOU), false);
+ assert.equal(isSelfSideSegment({ ...remote, speakerName: "You" }, {}, YOU), false);
+ // An automatic match can write a mapping too, so only the user's lock moves it.
+ assert.equal(isSelfSideSegment(remote, { speaker_0: "You" }, YOU), false);
+ assert.equal(isSelfSideSegment(userLocked(remote, "You"), {}, YOU), true);
+});