Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(transcription): remind to ask for consent when a recording starts
Elian Dorand65fb570b0c0
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex b185be1bdd..aa78a1351b 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -4607,7 +4607,9 @@"title_keeping_recordings": "{{title}} (keeps the audio for troubleshooting)","stop_no_audio": "Stop transcribing (no audio is arriving)","no_audio_microphone": "No audio has arrived from your microphone for 10 seconds, so what you say is not being transcribed. Stop the transcription and start it again.",- "no_audio_system": "No audio has arrived from the meeting for 10 seconds, so what the others say is not being transcribed. Stop the transcription and start it again."+ "no_audio_system": "No audio has arrived from the meeting for 10 seconds, so what the others say is not being transcribed. Stop the transcription and start it again.",+ "consent": "Let everyone in the meeting know that it is being transcribed, and ask for their consent.",+ "consent_keeping_recordings": "Let everyone in the meeting know that it is being transcribed and its audio kept, and ask for their consent."},"transcript": {"speaker_me": "Me",diff --git a/apps/client/src/widgets/launch_bar/RecordMeetingButton.css b/apps/client/src/widgets/launch_bar/RecordMeetingButton.cssindex 65b6bae7cc..c876c70327 100644--- a/apps/client/src/widgets/launch_bar/RecordMeetingButton.css+++ b/apps/client/src/widgets/launch_bar/RecordMeetingButton.css@@ -38,3 +38,30 @@}}}++.tn-popover.record-meeting-consent {+ --menu-background-color: color-mix(+ in srgb, var(--link-color) 18%,+ var(--menu-background-color-no-backdrop, var(--main-background-color))+ );+ --menu-text-color: var(--main-text-color);+ --dropdown-border-color: var(--link-color);+ max-width: 18rem;+ backdrop-filter: none;+ box-shadow: 0 2px 12px color-mix(in srgb, var(--link-color) 35%, transparent);++ .record-meeting-consent-body {+ display: flex;+ align-items: flex-start;+ gap: 0.5rem;+ padding: 0.6rem 0.75rem;+ font-size: 0.9em;+ cursor: pointer;++ .bx {+ flex-shrink: 0;+ font-size: 1.25em;+ color: var(--link-color);+ }+ }+}diff --git a/apps/client/src/widgets/launch_bar/RecordMeetingButton.spec.tsx b/apps/client/src/widgets/launch_bar/RecordMeetingButton.spec.tsxindex f1342a50f4..2188526d76 100644--- a/apps/client/src/widgets/launch_bar/RecordMeetingButton.spec.tsx+++ b/apps/client/src/widgets/launch_bar/RecordMeetingButton.spec.tsx@@ -51,7 +51,8 @@ vi.mock("./launch_bar_widgets", () => ({LaunchBarActionButton: ({ icon, text, disabled, onClick }: {icon: string; text: string; disabled?: boolean; onClick: () => void;}) => <button className={icon} disabled={disabled} onClick={onClick}>{text}</button>,- useLauncherIconAndTitle: () => ({ icon: "bx bx-microphone", title: "Record meeting" })+ useLauncherIconAndTitle: () => ({ icon: "bx bx-microphone", title: "Record meeting" }),+ useLaunchBarTitlePosition: () => "right"}));import RecordMeetingButton, {@@ -105,18 +106,18 @@ describe("toggleRecording", () => {it("starts recording into a new meeting note, and shows why it could not", async () => {transcription.start.mockResolvedValueOnce("");- await toggleRecording("idle");+ expect(await toggleRecording("idle")).toBe(true);expect(transcription.start).toHaveBeenCalledExactlyOnceWith("meeting");expect(mocks.showError).not.toHaveBeenCalled();transcription.start.mockResolvedValueOnce("No speech model");- await toggleRecording("idle");+ expect(await toggleRecording("idle")).toBe(false);expect(mocks.showError).toHaveBeenCalledExactlyOnceWith("No speech model");expect(mocks.createNote).toHaveBeenCalledTimes(2);});it("stops a running recording, and leaves one that is starting or stopping alone", async () => {- await toggleRecording("recording");+ expect(await toggleRecording("recording")).toBe(false);await toggleRecording("starting");await toggleRecording("stopping");@@ -338,6 +339,104 @@ describe("RecordMeetingButton", () => {window.electronApi = undefined;});+ it("reminds to ask for consent once its own click starts a recording", async () => {+ let onStateChanged: (state: TranscriptionState) => void = () => {};+ const report = (state: Partial<TranscriptionState>) => act(() => onStateChanged({+ status: "recording", noteId: "meeting", pendingSources: [], ...state+ }));+ const transcription = {+ isSupported: async () => true,+ getState: async () => ({ status: "idle", noteId: null, pendingSources: [] }),+ onStateChanged: (callback: typeof onStateChanged) => {+ onStateChanged = callback;+ return () => {};+ },+ start: vi.fn(async () => {+ onStateChanged({ status: "recording", noteId: "meeting", pendingSources: [] });+ return "";+ }),+ stop: vi.fn(async () => {})+ };+ window.electronApi = { transcription } as unknown as typeof window.electronApi;+ mocks.getInboxNote.mockResolvedValue({ noteId: "inbox", isProtected: false });+ mocks.createNote.mockResolvedValue({ note: { noteId: "meeting" } });+ mocks.requireResources.mockResolvedValue(true);+ let container: HTMLElement | null = null;+ await act(async () => {+ container = renderInto(<RecordMeetingButton launcherNote={{} as FNote} />);+ });+ const button = () => (container as HTMLElement | null)?.querySelector("button");+ const reminder = () => document.body.querySelector(".record-meeting-consent");+ const start = async () => {+ await vi.waitFor(() => expect(button()?.className).toBe("bx bx-microphone"));+ await act(async () => button()?.click());+ await vi.waitFor(() => expect(reminder()).not.toBeNull());+ };++ await report({ status: "idle", noteId: null });+ await report({});+ expect(reminder()).toBeNull();+ await report({ status: "idle", noteId: null });++ await start();+ expect(reminder()?.textContent).toContain("record_meeting.consent");+ expect(reminder()?.textContent).not.toContain("keeping");+ act(() => {+ document.body.dispatchEvent(new PointerEvent("pointerdown", { bubbles: true }));+ });+ expect(reminder()).not.toBeNull();+ act(() => reminder()?.querySelector<HTMLElement>(".record-meeting-consent-body")?.click());+ expect(reminder()).toBeNull();++ await report({ status: "idle", noteId: null });+ mocks.keepRecordings = true;+ await start();+ expect(reminder()?.textContent).toContain("record_meeting.consent_keeping_recordings");+ await report({ status: "stopping" });+ expect(reminder()).toBeNull();+ window.electronApi = undefined;+ });++ it("closes the consent reminder by itself after 10 seconds", async () => {+ vi.useFakeTimers({ toFake: [ "setTimeout", "clearTimeout", "Date" ] });+ let onStateChanged: (state: TranscriptionState) => void = () => {};+ window.electronApi = {+ transcription: {+ isSupported: async () => true,+ getState: async () => ({ status: "idle", noteId: null, pendingSources: [] }),+ onStateChanged: (callback: typeof onStateChanged) => {+ onStateChanged = callback;+ return () => {};+ },+ start: async () => {+ onStateChanged({ status: "recording", noteId: "meeting", pendingSources: [] });+ return "";+ }+ }+ } as unknown as typeof window.electronApi;+ mocks.getInboxNote.mockResolvedValue({ noteId: "inbox", isProtected: false });+ mocks.createNote.mockResolvedValue({ note: { noteId: "meeting" } });+ mocks.requireResources.mockResolvedValue(true);+ const advance = (ms: number) => act(async () => {+ await vi.advanceTimersByTimeAsync(ms);+ });+ let container: HTMLElement | null = null;+ await act(async () => {+ container = renderInto(<RecordMeetingButton launcherNote={{} as FNote} />);+ });+ await advance(50);+ const reminder = () => document.body.querySelector(".record-meeting-consent");++ await act(async () => (container as HTMLElement | null)?.querySelector("button")?.click());+ await advance(50);+ expect(reminder()).not.toBeNull();+ await advance(9_900);+ expect(reminder()).not.toBeNull();+ await advance(100);+ expect(reminder()).toBeNull();+ window.electronApi = undefined;+ });+it("shows the shared recording's state, and starts or stops it on a click", async () => {let onStateChanged: (state: TranscriptionState) => void = () => {};const report = (status: TranscriptionState["status"]) =>diff --git a/apps/client/src/widgets/launch_bar/RecordMeetingButton.tsx b/apps/client/src/widgets/launch_bar/RecordMeetingButton.tsxindex 59563bbb56..d9e9a6b6c3 100644--- a/apps/client/src/widgets/launch_bar/RecordMeetingButton.tsx+++ b/apps/client/src/widgets/launch_bar/RecordMeetingButton.tsx@@ -15,9 +15,12 @@ import options from "../../services/options";import toast from "../../services/toast";import { Badge } from "../react/Badge";import { useTriliumOptionBool } from "../react/hooks";+import Icon from "../react/Icon";+import Popover from "../react/Popover";import {LaunchBarActionButton,LauncherNoteProps,+ useLaunchBarTitlePosition,useLauncherIconAndTitle} from "./launch_bar_widgets";@@ -26,7 +29,8 @@ import {* recording, the second stops it. Desktop only, since the main process does the recording, and* shown only while `transcriptionEnabled` is on and the computer can transcribe. Its corner badge reads "Beta" while idle and the* time elapsed while recording, which turns red, with a message once, when a source stops- * delivering audio.+ * delivering audio. A recording started from this window opens a reminder beside the button, for+ * 10 s, to ask the people in the meeting for their consent.*/export default function RecordMeetingButton({ launcherNote }: LauncherNoteProps) {const { icon, title } = useLauncherIconAndTitle(launcherNote);@@ -35,9 +39,31 @@ export default function RecordMeetingButton({ launcherNote }: LauncherNoteProps)const isSupported = useTranscriptionSupported(isEnabled);const [ keepsRecordings ] = useTriliumOptionBool("transcriptionKeepRecordings");const [ now, setNow ] = useState(Date.now);+ const [ isRemindingConsent, setRemindingConsent ] = useState(false);+ const launcherRef = useRef<HTMLDivElement>(null);const handleClick = useCallback(() => {- void toggleRecording(status);+ void toggleRecording(status).then((started) => {+ if (started) {+ setRemindingConsent(true);+ }+ });}, [ status ]);+ const dismissConsent = useCallback(() => setRemindingConsent(false), []);++ useEffect(() => {+ if (status !== "recording" && status !== "starting") {+ setRemindingConsent(false);+ }+ }, [ status ]);++ const isShowingConsent = isRemindingConsent && status === "recording";+ useEffect(() => {+ if (!isShowingConsent) {+ return;+ }+ const timeout = setTimeout(dismissConsent, CONSENT_REMINDER_MS);+ return () => clearTimeout(timeout);+ }, [ isShowingConsent, dismissConsent ]);useEffect(() => {if (error) {@@ -62,7 +88,7 @@ export default function RecordMeetingButton({ launcherNote }: LauncherNoteProps)}return (- <div className="record-meeting-launcher">+ <div ref={launcherRef} className="record-meeting-launcher"><LaunchBarActionButtonlauncherNote={launcherNote}onClick={handleClick}@@ -79,10 +105,48 @@ export default function RecordMeetingButton({ launcherNote }: LauncherNoteProps)})}/>)}+ {isShowingConsent && (+ <ConsentReminder+ getAnchorRect={() =>+ launcherRef.current?.getBoundingClientRect() ?? new DOMRect()}+ keepsRecordings={keepsRecordings}+ onDismiss={dismissConsent}+ />+ )}</div>);}+/** How long the consent reminder stays open unless dismissed first. */+const CONSENT_REMINDER_MS = 10_000;++/**+ * A card beside the launcher asking to tell the people in the meeting and ask their consent. Only a+ * click on the card dismisses it, so the first click into the meeting note leaves it to be read.+ */+function ConsentReminder({ getAnchorRect, keepsRecordings, onDismiss }: {+ getAnchorRect(): DOMRect;+ keepsRecordings: boolean;+ onDismiss(): void;+}) {+ return (+ <Popover+ className="record-meeting-consent"+ getAnchorRect={getAnchorRect}+ placement={useLaunchBarTitlePosition()}+ >+ <div className="record-meeting-consent-body" role="status" onClick={onDismiss}>+ <Icon icon="bx bx-info-circle" />+ <span>+ {keepsRecordings+ ? t("record_meeting.consent_keeping_recordings")+ : t("record_meeting.consent")}+ </span>+ </div>+ </Popover>+ );+}+/** Shows an error once for each source that joins `stalledSources`. */function useStalledSourceWarnings(stalledSources: TranscriptSource[] | undefined) {const warned = useRef<TranscriptSource[]>([]);@@ -187,34 +251,39 @@ export function useTranscriptionSupported(shouldAsk: boolean) {return isSupported;}-/** Starts a recording into a new meeting note when idle, stops the running one when recording. */+/**+ * Starts a recording into a new meeting note when idle, stops the running one when recording.+ *+ * @returns Whether a recording started.+ */export async function toggleRecording(status: TranscriptionStatus) {const api = window.electronApi?.transcription;if (!api) {- return;+ return false;}if (status === "recording") {await api.stop();- return;+ return false;}if (status !== "idle") {- return;+ return false;}const resources = getTranscriptionResources(options.get("transcriptionModel"), options.is("transcriptionSpeakersEnabled"));if (!await requireResources(resources)) {- return;+ return false;}const note = (await createMeetingNote())?.note;if (!note) {- return;+ return false;}const error = await api.start(note.noteId);if (error) {toast.showError(error);}+ return !error;}/** Creates a text note titled with the current date and time in the inbox, and opens it. */diff --git a/apps/client/src/widgets/launch_bar/launch_bar_widgets.tsx b/apps/client/src/widgets/launch_bar/launch_bar_widgets.tsxindex 5e1394636f..f585c22e97 100644--- a/apps/client/src/widgets/launch_bar/launch_bar_widgets.tsx+++ b/apps/client/src/widgets/launch_bar/launch_bar_widgets.tsx@@ -90,6 +90,12 @@ export function useLauncherIconAndTitle(note: FNote) {};}+/** The side of a launcher its tooltips and popups open on. */+export function useLaunchBarTitlePosition() {+ const { isHorizontalLayout } = useContext(LaunchBarContext);+ return getTitlePosition(isHorizontalLayout);+}+function getTitlePosition(isHorizontalLayout: boolean) {if (cachedIsMobile) {return "top";diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Meeting transcription.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Meeting transcription.htmlindex 97e81885bc..53ede9e291 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Meeting transcription.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Meeting transcription.html@@ -38,7 +38,9 @@example <em>Meeting 2026-10-15 14:30</em>) in the <a class="reference-link"href="#root/_help_S0Fos78ZfcY7">Note Inbox</a>, opens it and starts transcribing.While it transcribes, the button turns into a <span class="tn-icon bx bx-stop-circle"></span> <em>Stop transcribing</em> button- and shows the time elapsed.</li>+ and shows the time elapsed. Beside it, a reminder asks you to let everyone+ in the meeting know that it is being transcribed and to ask for their consent;+ it closes by itself after 10 seconds, or when you click it.</li><li>To end the transcription, press the <span class="tn-icon bx bx-stop-circle"></span> <em>Stop transcribing</em> button.Trilium finishes transcribing what was already said before it stops.</li></ol>@@ -132,7 +134,8 @@states, recording a conversation without everyone's consent is a criminaloffense. The audio is stored unencrypted, even for protected notes. Whilethe option is on, the tooltip of the <em>Transcribe meeting</em> button says- so.</p>+ so, and the reminder shown when the transcription starts mentions that+ the audio is kept.</p></aside><h2>Limitations</h2><ul>diff --git a/docs/User Guide/User Guide/Meeting transcription.md b/docs/User Guide/User Guide/Meeting transcription.mdindex af03c3ef5d..2f8b88cbf1 100644--- a/docs/User Guide/User Guide/Meeting transcription.md+++ b/docs/User Guide/User Guide/Meeting transcription.md@@ -20,7 +20,7 @@ The speech recognition models are not part of Trilium. The first time you transc1. Press the <span class="tn-icon bx bx-microphone"></span> _Transcribe meeting_ button in the <a class="reference-link" href="Basic%20Concepts%20and%20Features/UI%20Elements/Launch%20Bar.md">Launch Bar</a>.2. If the models are not downloaded yet, confirm the download and wait for it to finish.-3. Trilium creates a text note titled with the current date and time (for example _Meeting 2026-10-15 14:30_) in the <a class="reference-link" href="Basic%20Concepts%20and%20Features/Notes/Note%20Inbox.md">Note Inbox</a>, opens it and starts transcribing. While it transcribes, the button turns into a <span class="tn-icon bx bx-stop-circle"></span> _Stop transcribing_ button and shows the time elapsed.+3. Trilium creates a text note titled with the current date and time (for example _Meeting 2026-10-15 14:30_) in the <a class="reference-link" href="Basic%20Concepts%20and%20Features/Notes/Note%20Inbox.md">Note Inbox</a>, opens it and starts transcribing. While it transcribes, the button turns into a <span class="tn-icon bx bx-stop-circle"></span> _Stop transcribing_ button and shows the time elapsed. Beside it, a reminder asks you to let everyone in the meeting know that it is being transcribed and to ask for their consent; it closes by itself after 10 seconds, or when you click it.4. To end the transcription, press the <span class="tn-icon bx bx-stop-circle"></span> _Stop transcribing_ button. Trilium finishes transcribing what was already said before it stops.Only one meeting can be transcribed at a time. The note itself is an ordinary text note: you can take notes in it during the meeting, rename it or move it anywhere in the tree. It carries the `#meetingRecording` label.@@ -52,7 +52,7 @@ The settings are in <a class="reference-link" href="Basic%20Concepts%20and%20Fe| _Keep recordings for troubleshooting_ | Keeps the audio of the meeting, the settings used and the transcript as it was produced, so that a problem can be reported and reproduced. It takes about 230 MB per hour of meeting and is never deleted automatically. The folder where they are kept is shown below the option. |> [!WARNING]-> Before turning on _Keep recordings for troubleshooting_, ask everyone in the meeting to agree to being recorded. In several countries and US states, recording a conversation without everyone's consent is a criminal offense. The audio is stored unencrypted, even for protected notes. While the option is on, the tooltip of the _Transcribe meeting_ button says so.+> Before turning on _Keep recordings for troubleshooting_, ask everyone in the meeting to agree to being recorded. In several countries and US states, recording a conversation without everyone's consent is a criminal offense. The audio is stored unencrypted, even for protected notes. While the option is on, the tooltip of the _Transcribe meeting_ button says so, and the reminder shown when the transcription starts mentions that the audio is kept.## Limitations