Skip to content

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

fix(meetings): never resume a teammate's note on Join & transcribe (#2442)

Chad Piha196937c489bf
diff --git a/src/helpers/database.js b/src/helpers/database.js
index df7a43853..9e5fb0c61 100644
--- a/src/helpers/database.js
+++ b/src/helpers/database.js
@@ -5160,21 +5160,28 @@ class DatabaseManager {
}
}
- getNoteByCalendarEventId(eventId, excludeNoteId = null) {
+ // Join & transcribe resumes this note. Google gives every invitee's copy of an
+ // event the same id, so a teammate's synced note for the meeting must never
+ // match, or both apps record into one note. Ownership follows ownsNote() in
+ // spacePermissions.ts, plus Personal rows synced before owners were recorded.
+ getOwnNoteByCalendarEventId(eventId) {
try {
if (!this.db) throw new Error("Database not initialized");
const accountScope = this._accountScopeCondition("notes");
- const base = `SELECT * FROM notes
- WHERE calendar_event_id = ? AND deleted_at IS NULL
- AND ${accountScope.sql}`;
- if (excludeNoteId) {
- return (
- this.db
- .prepare(`${base} AND id != ? LIMIT 1`)
- .get(eventId, ...accountScope.params, excludeNoteId) || null
- );
- }
- return this.db.prepare(`${base} LIMIT 1`).get(eventId, ...accountScope.params) || null;
+ return (
+ this.db
+ .prepare(
+ `SELECT notes.* FROM notes
+ JOIN spaces ON spaces.id = notes.space_id
+ WHERE notes.calendar_event_id = ? AND notes.deleted_at IS NULL
+ AND ${accountScope.sql}
+ AND (notes.cloud_id IS NULL OR notes.owner_user_id = ?
+ OR (notes.owner_user_id IS NULL AND spaces.kind = 'private'))
+ ORDER BY datetime(notes.created_at) DESC, notes.id DESC
+ LIMIT 1`
+ )
+ .get(eventId, ...accountScope.params, this.activeAccountId) || null
+ );
} catch (error) {
debugLogger.error(
"Error getting note by calendar event id",
diff --git a/src/helpers/meetingDetectionEngine.js b/src/helpers/meetingDetectionEngine.js
index efd130eee..65c30b06d 100644
--- a/src/helpers/meetingDetectionEngine.js
+++ b/src/helpers/meetingDetectionEngine.js
@@ -564,9 +564,9 @@ class MeetingDetectionEngine {
});
}
- /** Navigates to the note already linked to a calendar event, if any. */
+ /** Navigates to the user's own note already linked to a calendar event, if any. */
async _resumeExistingEventNote(event, trigger) {
- const existingNote = this.databaseManager.getNoteByCalendarEventId(event.id);
+ const existingNote = this.databaseManager.getOwnNoteByCalendarEventId(event.id);
if (!existingNote?.id) return false;
debugLogger.info(
"Reusing existing note for calendar meeting",
diff --git a/test/helpers/meetingDetectionEngine.test.js b/test/helpers/meetingDetectionEngine.test.js
index 5e7a743ca..cb7a51fbf 100644
--- a/test/helpers/meetingDetectionEngine.test.js
+++ b/test/helpers/meetingDetectionEngine.test.js
@@ -162,6 +162,55 @@ test("a live recording with no note id still blocks a second manual meeting", as
assert.deepEqual(noteNavigations, []);
});
+// Join & transcribe resumes only a note the user owns for the event: a
+// teammate's synced note for the same invite never comes back from the lookup,
+// so the join must create the user's own note rather than record into theirs.
+function createJoinDatabase(ownNote) {
+ const lookups = [];
+ const saved = [];
+ const databaseManager = {
+ getCalendarEventById: (id) => ({ id, summary: "Weekly sync" }),
+ getOwnNoteByCalendarEventId: (id) => {
+ lookups.push(id);
+ return ownNote;
+ },
+ getMeetingsFolder: () => ({ id: 7 }),
+ saveNote: (title) => {
+ saved.push(title);
+ return { note: { id: 99, title } };
+ },
+ updateNote: (id, updates) => ({ note: { id, ...updates } }),
+ };
+ return { databaseManager, lookups, saved };
+}
+
+test("joining a calendar meeting resumes the user's own note for the event", async () => {
+ const { engine, meetingNavigations } = createEngine();
+ const db = createJoinDatabase({ id: 5, folder_id: 3 });
+ engine.databaseManager = db.databaseManager;
+
+ await engine.joinCalendarMeeting("event-1");
+
+ assert.deepEqual(db.lookups, ["event-1"]);
+ assert.deepEqual(db.saved, []);
+ assert.equal(meetingNavigations.length, 1);
+ assert.equal(meetingNavigations[0].noteId, 5);
+ assert.equal(meetingNavigations[0].folderId, 3);
+});
+
+test("joining a calendar meeting with no note of the user's own creates one", async () => {
+ const { engine, meetingNavigations } = createEngine();
+ const db = createJoinDatabase(null);
+ engine.databaseManager = db.databaseManager;
+
+ await engine.joinCalendarMeeting("event-1");
+
+ assert.deepEqual(db.saved, ["Weekly sync"]);
+ assert.equal(meetingNavigations.length, 1);
+ assert.equal(meetingNavigations[0].noteId, 99);
+ assert.equal(meetingNavigations[0].folderId, 7);
+});
+
// The IPC adapter derives detector preferences through this policy; the engine
// only has to honour whatever it is handed (adapter coverage lives in
// meetingDetectionPreferencesIpc.test.js).
diff --git a/test/helpers/notesOwnerDatabase.test.js b/test/helpers/notesOwnerDatabase.test.js
index 6c185270f..a9b1a0eec 100644
--- a/test/helpers/notesOwnerDatabase.test.js
+++ b/test/helpers/notesOwnerDatabase.test.js
@@ -227,3 +227,90 @@ test("markNoteSynced and markNoteSyncedIfUnchanged persist the returned owner",
db.db.close();
});
+
+// Join & transcribe resumes the user's note for a calendar event. Google gives
+// every invitee's copy of an event the same id, so a teammate's synced note for
+// the same meeting must never be resumed: both apps would record into one note.
+test("getOwnNoteByCalendarEventId never resumes a teammate's note for the same event", (t) => {
+ const db = createDb(t);
+ if (!db) return;
+ const space = createTestTeamSpace(db, "Eng");
+
+ db.upsertNoteFromCloud(
+ cloudNote({ id: "cloud-teammate", calendar_event_id: "event-1", user_id: "teammate" }),
+ null,
+ space.id
+ );
+ assert.equal(db.getOwnNoteByCalendarEventId("event-1"), null);
+
+ const own = db.saveNote("Weekly sync", "", "meeting").note;
+ db.updateNote(own.id, { calendar_event_id: "event-1" });
+ assert.equal(db.getOwnNoteByCalendarEventId("event-1").id, own.id);
+
+ db.db.close();
+});
+
+test("getOwnNoteByCalendarEventId resumes notes the user owns, newest first", (t) => {
+ const db = createDb(t);
+ if (!db) return;
+ const space = createTestTeamSpace(db, "Eng");
+ const insert = db.db.prepare(
+ `INSERT INTO notes (title, content, client_note_id, space_id, cloud_id, owner_user_id, calendar_event_id, created_at)
+ VALUES (?, '', ?, ?, ?, ?, ?, ?)`
+ );
+ const lookup = (eventId) => db.getOwnNoteByCalendarEventId(eventId)?.title ?? null;
+
+ insert.run("own team", "c-1", space.id, "cloud-1", "test-account", "event-team", "2026-07-01");
+ // Synced before ownership was recorded; only the user's notes live in Personal.
+ insert.run(
+ "legacy",
+ "c-2",
+ db.getPrivateSpaceId(),
+ "cloud-2",
+ null,
+ "event-legacy",
+ "2026-07-01"
+ );
+ // A team note whose owner the pull hasn't backfilled yet could be anyone's.
+ insert.run("unknown", "c-3", space.id, "cloud-3", null, "event-unknown", "2026-07-01");
+ insert.run("unsynced team", "c-4", space.id, null, null, "event-unsynced-team", "2026-07-01");
+ insert.run(
+ "teammate personal",
+ "c-5",
+ db.getPrivateSpaceId(),
+ "cloud-5",
+ "teammate",
+ "event-teammate-personal",
+ "2026-07-01"
+ );
+ // Local rows keep SQLite's "YYYY-MM-DD HH:MM:SS"; pulled rows keep the API's ISO
+ // string. The newer note has the lower id and would lose a plain text comparison.
+ insert.run(
+ "newer",
+ "c-6",
+ db.getPrivateSpaceId(),
+ null,
+ null,
+ "event-many",
+ "2026-07-01 10:05:00"
+ );
+ insert.run(
+ "older",
+ "c-7",
+ db.getPrivateSpaceId(),
+ "cloud-7",
+ "test-account",
+ "event-many",
+ "2026-07-01T10:00:00.000Z"
+ );
+ insert.run("teammate newest", "c-8", space.id, "cloud-8", "teammate", "event-many", "2026-07-03");
+
+ assert.equal(lookup("event-team"), "own team");
+ assert.equal(lookup("event-legacy"), "legacy");
+ assert.equal(lookup("event-unknown"), null);
+ assert.equal(lookup("event-unsynced-team"), "unsynced team");
+ assert.equal(lookup("event-teammate-personal"), null);
+ assert.equal(lookup("event-many"), "newer");
+
+ db.db.close();
+});