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
feat(notes): add a "This is me" option to the speaker picker (#2782)
Chad Piha2b4706f28381
diff --git a/src/components/notes/MeetingTranscriptChat.tsx b/src/components/notes/MeetingTranscriptChat.tsxindex b8a806db5..6681d1373 100644--- a/src/components/notes/MeetingTranscriptChat.tsx+++ b/src/components/notes/MeetingTranscriptChat.tsx@@ -11,6 +11,7 @@ import type { TranscriptSegment } from "../../stores/meetingRecordingStore";import {isSelfSideSegment,isTranscriptSpeakerLocked,+ isYouSpeakerName,resolveSegmentSpeakerName,type TranscriptSpeakerStatus,} from "../../utils/transcriptSpeakerState";@@ -153,6 +154,10 @@ interface SpeakerPickerProps {speakerProfiles?: SpeakerProfileLite[];participants?: Array<{ email: string; displayName: string | null }>;onSelectName: (name: string, email?: string | null, profileId?: number) => void;+ // "offer": a voice that may be the user's gets a "This is me" row, which the+ // user's own voice profile folds into. "exclude": a call's remote voice is+ // never the user, so it can't be named after them.+ self?: "offer" | "exclude";t: (key: string, opts?: Record<string, unknown>) => string;}@@ -245,12 +250,40 @@ function AddContactButton({);}-function SpeakerPicker({ speakerProfiles, participants, onSelectName, t }: SpeakerPickerProps) {+function SpeakerPicker({+ speakerProfiles,+ participants,+ onSelectName,+ self,+ t,+}: SpeakerPickerProps) {const [search, setSearch] = useState("");const lower = search.toLowerCase();const trimmed = search.trim();const trimmedLower = trimmed.toLowerCase();+ const youLabel = t("notes.speaker.you");+ const youLower = youLabel.trim().toLowerCase();+ const thisIsMe = t("notes.speaker.thisIsMe");+ const selfProfiles = self+ ? (speakerProfiles || []).filter((p) => isYouSpeakerName(p.display_name, youLabel))+ : [];+ // Naming the speaker after the existing profile adds this voice to it rather+ // than to a second "You" profile.+ const selfProfile = selfProfiles.find((p) => p.id != null) ?? selfProfiles[0];+ const matchesSelf =+ !!self &&+ !!trimmed &&+ (isYouSpeakerName(trimmed, youLabel) ||+ selfProfiles.some((p) => p.email?.toLowerCase() === trimmedLower));+ const showSelf =+ self === "offer" &&+ (!trimmed ||+ matchesSelf ||+ youLower.includes(trimmedLower) ||+ thisIsMe.toLowerCase().includes(trimmedLower) ||+ !!selfProfile?.email?.toLowerCase().includes(trimmedLower));+const filteredParticipants = (participants || []).filter((p) =>!search ||@@ -259,12 +292,14 @@ function SpeakerPicker({ speakerProfiles, participants, onSelectName, t }: Speak);const filteredProfiles = (speakerProfiles || []).filter((p) =>- !search ||- p.display_name.toLowerCase().includes(lower) ||- (p.email && p.email.toLowerCase().includes(lower))+ !selfProfiles.includes(p) &&+ (!search ||+ p.display_name.toLowerCase().includes(lower) ||+ (p.email && p.email.toLowerCase().includes(lower))));const hasExactMatch =+ matchesSelf ||filteredParticipants.some((p) =>(p.displayName || "").toLowerCase() === trimmedLower ||@@ -289,14 +324,26 @@ function SpeakerPicker({ speakerProfiles, participants, onSelectName, t }: SpeaksetSearch("");};+ const selectSelf = () =>+ onSelectName(+ selfProfile?.display_name ?? youLabel,+ selfProfile?.email ?? null,+ selfProfile?.id+ );+const handleKeyDown = (e: React.KeyboardEvent) => {- if (e.key === "Enter" && canCreate) {+ if (e.key !== "Enter") return;+ if (showSelf && matchesSelf) {+ e.preventDefault();+ selectSelf();+ } else if (canCreate) {e.preventDefault();submitCreate();}};- const isEmpty = !filteredParticipants.length && !filteredProfiles.length && !canCreate;+ const isEmpty =+ !showSelf && !filteredParticipants.length && !filteredProfiles.length && !canCreate;return (<>@@ -312,6 +359,18 @@ function SpeakerPicker({ speakerProfiles, participants, onSelectName, t }: Speak/></div><div className="max-h-52 overflow-y-auto">+ {showSelf && (+ <div className="p-1 border-b border-border/70">+ <button+ onClick={selectSelf}+ className="flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-xs text-foreground/70 hover:bg-foreground/5 transition-colors cursor-pointer"+ >+ <span dir="auto" className="truncate flex-1 text-start">+ {thisIsMe}+ </span>+ </button>+ </div>+ )}{filteredParticipants.length > 0 && (<div className="p-1 border-b border-border/70"><div className="px-2 py-1 text-[11px] font-medium text-muted-foreground">@@ -402,6 +461,7 @@ function SpeakerLabel({participants,colorIdx,isOriginallyYou,+ self,onMap,onConfirm,onDismiss,@@ -414,6 +474,7 @@ function SpeakerLabel({participants?: Array<{ email: string; displayName: string | null }>;colorIdx: number;isOriginallyYou: boolean;+ self?: "offer" | "exclude";onMap?: (speakerId: string, name: string, email?: string | null, profileId?: number) => void;onConfirm?: (speakerId: string, name: string, profileId: number) => void;onDismiss?: (speakerId: string) => void;@@ -491,6 +552,7 @@ function SpeakerLabel({onMap?.(speakerId, name, email, profileId);setOpen(false);}}+ self={self}t={t}/></PopoverContent>@@ -528,28 +590,33 @@ function SelectCheckbox({}export function SelectionBar({- count,onClear,speakerProfiles,participants,onAssignName,+ selectedSegments,+ speakerMappings,t,}: {- count: number;onClear: () => void;speakerProfiles?: SpeakerProfileLite[];participants?: Array<{ email: string; displayName: string | null }>;onAssignName: (name: string, email?: string | null, profileId?: number) => void;+ selectedSegments: TranscriptSegment[];+ speakerMappings?: Record<string, string>;t: (key: string, opts?: Record<string, unknown>) => string;}) {const [open, setOpen] = useState(false);+ const offerSelf = selectedSegments.some(+ (segment) => !isSelfSideSegment(segment, speakerMappings, t("notes.speaker.you"))+ );return (<divclassName="flex items-center gap-3 rounded-md border border-border/70 bg-surface-2/95 backdrop-blur px-3 py-1.5 text-xs shadow-lg"style={{ animation: "agent-message-in 150ms ease-out both" }}><span className="text-foreground/70 tabular-nums">- {t("notes.speaker.selected", { n: count })}+ {t("notes.speaker.selected", { n: selectedSegments.length })}</span><Popover open={open} onOpenChange={setOpen}><PopoverTrigger asChild>@@ -566,6 +633,7 @@ export function SelectionBar({onAssignName(name, email, profileId);setOpen(false);}}+ self={offerSelf ? "offer" : undefined}t={t}/></PopoverContent>@@ -632,12 +700,19 @@ const SegmentRow = memo(function SegmentRow({const hasSpeaker = !!segment.speaker;const isOriginallyYou = segment.speaker === "you";const isSystemSpeaker = hasSpeaker && !selfSide;+ // Only an in-person mic cluster may be the user: diarization can't tell which+ // voice is theirs. A call's remote voices never are, and its mic is already+ // "you", where naming one line remaps every line of the mic.+ const self =+ segment.source === "system" ? "exclude" : !selfSide && !isOriginallyYou ? "offer" : undefined;const selectable = !!onToggleSelect;+ // The user's own voice profile isn't a contact.const canAddContact =!!matchedProfile &&matchedProfile.id != null &&!matchedProfile.email &&+ !isYouSpeakerName(matchedProfile.display_name, t("notes.speaker.you")) &&!!onAttachSpeakerEmail;const labelElement = hasSpeaker && (@@ -650,6 +725,7 @@ const SegmentRow = memo(function SegmentRow({participants={participants}colorIdx={colorIdx}isOriginallyYou={isOriginallyYou}+ self={self}onMap={onMapSpeaker}onConfirm={onConfirmSuggestion}onDismiss={onDismissSuggestion}diff --git a/src/components/notes/NoteEditor.tsx b/src/components/notes/NoteEditor.tsxindex 8d98e3a71..e962723ee 100644--- a/src/components/notes/NoteEditor.tsx+++ b/src/components/notes/NoteEditor.tsx@@ -1471,11 +1471,14 @@ export default function NoteEditor({{!isRecording && selectedSegmentIds.size > 0 && (<div className="absolute bottom-20 left-1/2 -translate-x-1/2 z-20 pointer-events-auto"><SelectionBar- count={selectedSegmentIds.size}onClear={handleClearSelection}speakerProfiles={knownSpeakers}participants={parsedParticipants}onAssignName={handleBulkAssignName}+ selectedSegments={displaySegments.filter((segment) =>+ selectedSegmentIds.has(segment.id)+ )}+ speakerMappings={speakerMappings}t={t}/></div>diff --git a/src/locales/ar/translation.json b/src/locales/ar/translation.jsonindex 5a55b5e4a..d8d72ab45 100644--- a/src/locales/ar/translation.json+++ b/src/locales/ar/translation.json@@ -2522,6 +2522,7 @@"typeNamePlaceholder": "اكتب اسمًا","nameOrEmailPlaceholder": "اكتب اسمًا أو بريدًا إلكترونيًا","knownSpeakers": "متحدثون معروفون",+ "thisIsMe": "هذا أنا","meetingAttendees": "حاضرو الاجتماع","createNewPrefix": "إنشاء","addContact": "إضافة جهة اتصال",diff --git a/src/locales/de/translation.json b/src/locales/de/translation.jsonindex decf40ee3..ac081bcfd 100644--- a/src/locales/de/translation.json+++ b/src/locales/de/translation.json@@ -3748,6 +3748,7 @@"typeNamePlaceholder": "Namen eingeben","nameOrEmailPlaceholder": "Name oder E-Mail eingeben","knownSpeakers": "Bekannte Sprecher",+ "thisIsMe": "Das bin ich","meetingAttendees": "Meeting-Teilnehmer","createNewPrefix": "Erstellen","addContact": "Kontakt hinzufügen",diff --git a/src/locales/en/translation.json b/src/locales/en/translation.jsonindex d34aa46e4..738a02ce1 100644--- a/src/locales/en/translation.json+++ b/src/locales/en/translation.json@@ -3748,6 +3748,7 @@"typeNamePlaceholder": "Type a name","nameOrEmailPlaceholder": "Type a name or email","knownSpeakers": "Known speakers",+ "thisIsMe": "This is me","meetingAttendees": "Meeting attendees","createNewPrefix": "Create","addContact": "Add contact",diff --git a/src/locales/es/translation.json b/src/locales/es/translation.jsonindex 47ad22e87..a52efbfbd 100644--- a/src/locales/es/translation.json+++ b/src/locales/es/translation.json@@ -3448,6 +3448,7 @@"speakersIdentified": "Participantes identificados","typeNamePlaceholder": "Escribe un nombre","knownSpeakers": "Hablantes conocidos",+ "thisIsMe": "Soy yo","meetingAttendees": "Asistentes de la reunión","assignName": "Asignar nombre","isThisPerson": "¿Es {{name}}?",diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.jsonindex 6d25d37ca..b6361b35e 100644--- a/src/locales/fr/translation.json+++ b/src/locales/fr/translation.json@@ -3748,6 +3748,7 @@"typeNamePlaceholder": "Saisir un nom","nameOrEmailPlaceholder": "Tapez un nom ou un e-mail","knownSpeakers": "Interlocuteurs connus",+ "thisIsMe": "C'est moi","meetingAttendees": "Participants à la réunion","createNewPrefix": "Créer","addContact": "Ajouter un contact",diff --git a/src/locales/it/translation.json b/src/locales/it/translation.jsonindex 0ca753fda..d50306966 100644--- a/src/locales/it/translation.json+++ b/src/locales/it/translation.json@@ -3396,6 +3396,7 @@"speakersIdentified": "Partecipanti identificati","typeNamePlaceholder": "Digita un nome","knownSpeakers": "Parlanti noti",+ "thisIsMe": "Sono io","meetingAttendees": "Partecipanti alla riunione","assignName": "Assegna nome","isThisPerson": "È {{name}}?",diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.jsonindex 2238ba898..b0dee395a 100644--- a/src/locales/ja/translation.json+++ b/src/locales/ja/translation.json@@ -3324,6 +3324,7 @@"speakersIdentified": "話者を識別しました","typeNamePlaceholder": "名前を入力","knownSpeakers": "登録済みの話者",+ "thisIsMe": "これは自分です","meetingAttendees": "会議の参加者","assignName": "名前を割り当て","isThisPerson": "{{name}}さんですか?",diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.jsonindex bb58e7a55..d222175bf 100644--- a/src/locales/pt/translation.json+++ b/src/locales/pt/translation.json@@ -3396,6 +3396,7 @@"speakersIdentified": "Participantes identificados","typeNamePlaceholder": "Digite um nome","knownSpeakers": "Falantes conhecidos",+ "thisIsMe": "Sou eu","meetingAttendees": "Participantes da reunião","assignName": "Atribuir nome","isThisPerson": "É {{name}}?",diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.jsonindex 3c8796e1a..fca8df4fb 100644--- a/src/locales/ru/translation.json+++ b/src/locales/ru/translation.json@@ -3416,6 +3416,7 @@"speakersIdentified": "Участники определены","typeNamePlaceholder": "Введите имя","knownSpeakers": "Известные собеседники",+ "thisIsMe": "Это я","meetingAttendees": "Участники встречи","assignName": "Назначить имя","isThisPerson": "Это {{name}}?",diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.jsonindex c3e71985b..18cddaec7 100644--- a/src/locales/zh-CN/translation.json+++ b/src/locales/zh-CN/translation.json@@ -3396,6 +3396,7 @@"speakersIdentified": "已识别发言者","typeNamePlaceholder": "输入姓名","knownSpeakers": "已知说话者",+ "thisIsMe": "这是我","meetingAttendees": "会议参与者","assignName": "分配姓名","isThisPerson": "这是{{name}}吗?",diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.jsonindex 960ba9a93..b5be35914 100644--- a/src/locales/zh-TW/translation.json+++ b/src/locales/zh-TW/translation.json@@ -3396,6 +3396,7 @@"speakersIdentified": "已辨識發言者","typeNamePlaceholder": "輸入姓名","knownSpeakers": "已知發言者",+ "thisIsMe": "這是我","meetingAttendees": "會議參與者","assignName": "指派姓名","isThisPerson": "這是{{name}}嗎?",diff --git a/test/components/meetingTranscriptSpeakerPicker.test.js b/test/components/meetingTranscriptSpeakerPicker.test.jsnew file mode 100644index 000000000..4266e8ddc--- /dev/null+++ b/test/components/meetingTranscriptSpeakerPicker.test.js@@ -0,0 +1,324 @@+const test = require("node:test");+const assert = require("node:assert/strict");+const { createRendererServer } = require("../lib/rendererTestHarness");++// Opens the real speaker popovers in happy-dom. Without an i18next instance,+// t() returns the key, so "You" reads as notes.speaker.you.++const DOM_GLOBALS = [+ "document",+ "navigator",+ "Node",+ "Element",+ "HTMLElement",+ "MutationObserver",+ "getComputedStyle",+ "Event",+ "CustomEvent",+ "MouseEvent",+ "PointerEvent",+ "FocusEvent",+ "KeyboardEvent",+ "HTMLInputElement",+ "ResizeObserver",+ "DOMRect",+];+const YOU = "notes.speaker.you";+const THIS_IS_ME = "notes.speaker.thisIsMe";++let happyWindow;++test.before(async () => {+ const { Window } = await import("happy-dom");+ happyWindow = new Window();+ const define = (name, value) =>+ Object.defineProperty(globalThis, name, { value, configurable: true, writable: true });+ define("window", happyWindow);+ for (const name of DOM_GLOBALS) define(name, happyWindow[name]);+ for (const name of ["requestAnimationFrame", "cancelAnimationFrame"]) {+ define(name, happyWindow[name].bind(happyWindow));+ }+ // happy-dom has no layout; the virtualized list renders nothing in a 0×0 box.+ for (const [name, value] of [+ ["offsetWidth", 400],+ ["offsetHeight", 600],+ ]) {+ Object.defineProperty(happyWindow.HTMLElement.prototype, name, {+ configurable: true,+ get: () => value,+ });+ }+});++test.after(async () => {+ await happyWindow.happyDOM.close();+});++async function mount(t, element) {+ globalThis.IS_REACT_ACT_ENVIRONMENT = true;+ const React = require("react");+ const { createRoot } = require("react-dom/client");+ const vite = await createRendererServer(t);+ const mod = await vite.ssrLoadModule("/components/notes/MeetingTranscriptChat.tsx");+ const host = happyWindow.document.createElement("div");+ happyWindow.document.body.appendChild(host);+ const root = createRoot(host);+ t.after(async () => {+ await React.act(async () => root.unmount());+ host.remove();+ });+ const act = (callback) =>+ React.act(async () => {+ await callback();+ await new Promise((resolve) => setTimeout(resolve, 30));+ });+ await act(() => root.render(element(React, mod)));+ return { act };+}++const buttonWithText = (text) =>+ [...happyWindow.document.querySelectorAll("button")].find((b) => b.textContent.trim() === text);+// Booleans, never the element: printing a happy-dom element in a failed assert+// runs the test process out of memory.+const hasButton = (text) => !!buttonWithText(text);+const pickerInput = () =>+ happyWindow.document.querySelector('input[placeholder="notes.speaker.nameOrEmailPlaceholder"]');+const pickerOpen = () => !!pickerInput();+const typeInPicker = (text) => {+ const input = pickerInput();+ Object.getOwnPropertyDescriptor(happyWindow.HTMLInputElement.prototype, "value").set.call(+ input,+ text+ );+ input.dispatchEvent(new happyWindow.Event("input", { bubbles: true }));+};+const pressEnter = () =>+ pickerInput().dispatchEvent(+ new happyWindow.KeyboardEvent("keydown", { key: "Enter", bubbles: true })+ );+const createsAny = () =>+ [...happyWindow.document.querySelectorAll("button")].some((b) =>+ b.textContent.includes("notes.speaker.createNewPrefix")+ );++const chat = (segments, extra) => (React, mod) =>+ React.createElement(mod.MeetingTranscriptChat, { segments, speakerMappings: {}, ...extra });++test("This is me names an in-person cluster You", async (t) => {+ const calls = [];+ const { act } = await mount(+ t,+ chat([{ id: "a", text: "hello", source: "mic", timestamp: 1, speaker: "speaker_1" }], {+ onMapSpeaker: (...args) => calls.push(args),+ })+ );+ await act(() => buttonWithText("notes.speaker.label").click());+ assert.ok(hasButton(THIS_IS_ME), "the picker offers This is me");+ await act(() => buttonWithText(THIS_IS_ME).click());+ assert.deepEqual(calls, [["speaker_1", YOU, null, undefined]]);+});++test("a call's remote speaker can't be named after the user", async (t) => {+ const { act } = await mount(+ t,+ chat([{ id: "a", text: "remote", source: "system", timestamp: 1, speaker: "speaker_0" }], {+ onMapSpeaker: () => {},+ speakerProfiles: [+ { id: 1, display_name: YOU, email: null },+ { id: 2, display_name: "Alice", email: null },+ ],+ })+ );+ await act(() => buttonWithText("notes.speaker.label").click());+ assert.ok(pickerOpen());+ assert.ok(!hasButton(THIS_IS_ME));+ assert.ok(hasButton("Alice"));+ assert.ok(!hasButton(YOU), "the user's voice profile isn't offered for a remote voice");+});++test("typing You on a call's remote speaker offers nothing to create", async (t) => {+ const { act } = await mount(+ t,+ chat([{ id: "a", text: "remote", source: "system", timestamp: 1, speaker: "speaker_0" }], {+ onMapSpeaker: () => {},+ })+ );+ await act(() => buttonWithText("notes.speaker.label").click());+ await act(() => typeInPicker(YOU));+ assert.ok(pickerOpen());+ assert.ok(!createsAny());+});++test("a reassigned line of a call's mic doesn't offer This is me", async (t) => {+ const { act } = await mount(+ t,+ chat([+ {+ id: "a",+ text: "me",+ source: "mic",+ timestamp: 1,+ speaker: "you",+ speakerName: "Bob",+ speakerLocked: true,+ speakerLockSource: "user",+ speakerStatus: "locked",+ },+ ])+ );+ await act(() => buttonWithText("Bob").click());+ assert.ok(pickerOpen());+ assert.ok(!hasButton(THIS_IS_ME), "naming it would remap every line of the mic");+});++test("typing You and pressing Enter picks This is me", async (t) => {+ const calls = [];+ const { act } = await mount(+ t,+ chat([{ id: "a", text: "hello", source: "mic", timestamp: 1, speaker: "speaker_1" }], {+ onMapSpeaker: (...args) => calls.push(args),+ })+ );+ await act(() => buttonWithText("notes.speaker.label").click());+ await act(() => typeInPicker(` ${YOU} `));+ assert.ok(hasButton(THIS_IS_ME));+ assert.ok(!createsAny());+ await act(() => pressEnter());+ assert.deepEqual(calls, [["speaker_1", YOU, null, undefined]]);+});++test("Enter still creates any other typed name", async (t) => {+ const calls = [];+ const { act } = await mount(+ t,+ chat([{ id: "a", text: "hello", source: "mic", timestamp: 1, speaker: "speaker_1" }], {+ onMapSpeaker: (...args) => calls.push(args),+ })+ );+ await act(() => buttonWithText("notes.speaker.label").click());+ await act(() => typeInPicker("Bob"));+ await act(() => pressEnter());+ assert.deepEqual(calls, [["speaker_1", "Bob", null, undefined]]);+});++test("a row already on the user's side doesn't offer This is me", async (t) => {+ const { act } = await mount(+ t,+ chat([{ id: "a", text: "me", source: "mic", timestamp: 1, speaker: "you" }])+ );+ await act(() => buttonWithText(YOU).click());+ assert.ok(pickerOpen());+ assert.ok(!hasButton(THIS_IS_ME));+});++test("the voice profile saved as You is folded into This is me", async (t) => {+ const { act } = await mount(+ t,+ chat([{ id: "a", text: "hello", source: "mic", timestamp: 1, speaker: "speaker_0" }], {+ onMapSpeaker: () => {},+ speakerProfiles: [+ { id: 1, display_name: YOU, email: null },+ { id: 2, display_name: "Alice", email: null },+ ],+ })+ );+ await act(() => buttonWithText("notes.speaker.label").click());+ assert.ok(hasButton(THIS_IS_ME));+ assert.ok(hasButton("Alice"));+ assert.ok(!hasButton(YOU), "the You profile isn't listed twice");+});++test("This is me adds the voice to the user's existing profile", async (t) => {+ const calls = [];+ const { act } = await mount(+ t,+ chat([{ id: "a", text: "hello", source: "mic", timestamp: 1, speaker: "speaker_0" }], {+ onMapSpeaker: (...args) => calls.push(args),+ // Saved in English or with other casing: still the user's profile, and+ // picked over the label used as a name in this note.+ speakerProfiles: [+ { id: 7, display_name: "you", email: "[email protected]" },+ { display_name: YOU, email: null },+ ],+ })+ );+ await act(() => buttonWithText("notes.speaker.label").click());+ assert.ok(!hasButton("you"));+ // Its email finds the row instead of offering to create a contact from it.+ await act(() => typeInPicker("[email protected]"));+ assert.ok(hasButton(THIS_IS_ME));+ assert.ok(!createsAny());+ await act(() => buttonWithText(THIS_IS_ME).click());+ assert.deepEqual(calls, [["speaker_0", "you", "[email protected]", 7]]);+});++test("the user's own chip doesn't offer Add contact", async (t) => {+ const { act } = await mount(+ t,+ chat(+ [+ { id: "a", text: "me", source: "mic", timestamp: 1, speaker: "speaker_0" },+ { id: "b", text: "them", source: "mic", timestamp: 2, speaker: "speaker_1" },+ // A remote voice that recording matched to the user's profile.+ {+ id: "c",+ text: "remote",+ source: "system",+ timestamp: 3,+ speaker: "speaker_2",+ speakerName: YOU,+ },+ ],+ {+ speakerMappings: { speaker_0: YOU, speaker_1: "Alice" },+ speakerProfiles: [+ { id: 1, display_name: YOU, email: null },+ { id: 2, display_name: "Alice", email: null },+ ],+ onAttachSpeakerEmail: () => {},+ }+ )+ );+ await act(() => {});+ const addContacts = [...happyWindow.document.querySelectorAll("button")].filter(+ (b) => b.textContent.trim() === "notes.speaker.addContact"+ );+ assert.equal(addContacts.length, 1, "only Alice's chip offers it");+});++test("Assign to offers This is me for a selection", async (t) => {+ const calls = [];+ const { act } = await mount(t, (React, mod) =>+ React.createElement(mod.SelectionBar, {+ onClear: () => {},+ onAssignName: (...args) => calls.push(args),+ selectedSegments: [+ { id: "a", text: "me", source: "mic", timestamp: 1, speaker: "speaker_0" },+ { id: "b", text: "them", source: "mic", timestamp: 2, speaker: "speaker_1" },+ ],+ speakerMappings: { speaker_0: YOU },+ t: (key) => key,+ })+ );+ await act(() => buttonWithText("notes.speaker.assignTo").click());+ await act(() => buttonWithText(THIS_IS_ME).click());+ assert.deepEqual(calls, [[YOU, null, undefined]]);+});++test("Assign to leaves This is me out when every selected line is the user's", async (t) => {+ const { act } = await mount(t, (React, mod) =>+ React.createElement(mod.SelectionBar, {+ onClear: () => {},+ onAssignName: () => {},+ selectedSegments: [+ { id: "a", text: "me", source: "mic", timestamp: 1, speaker: "speaker_0" },+ { id: "b", text: "me too", source: "mic", timestamp: 2, speaker: "you" },+ ],+ speakerMappings: { speaker_0: YOU },+ t: (key) => key,+ })+ );+ await act(() => buttonWithText("notes.speaker.assignTo").click());+ assert.ok(pickerOpen());+ assert.ok(!hasButton(THIS_IS_ME));+});