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: hide declined meetings from Home after calendar sync (#2431)
Joshua29d1e5787bb6
diff --git a/src/helpers/appleCalendarManager.js b/src/helpers/appleCalendarManager.jsindex 47ec9e195..70882c96b 100644--- a/src/helpers/appleCalendarManager.js+++ b/src/helpers/appleCalendarManager.js@@ -286,7 +286,6 @@ class AppleCalendarManager {this.databaseManager.syncCalendarContacts("apple", null, contacts, notContacts);broadcastToWindows("acal-events-synced", {});- this.reminderScheduler.reconcileProvider("apple");this.reminderScheduler.scheduleNextMeeting();if (this._pendingConnect?.awaitingSnapshot) {diff --git a/src/helpers/calendarReminderScheduler.js b/src/helpers/calendarReminderScheduler.jsindex 6e1df1110..5b157c3e5 100644--- a/src/helpers/calendarReminderScheduler.js+++ b/src/helpers/calendarReminderScheduler.js@@ -26,6 +26,21 @@ class CalendarReminderScheduler {}scheduleNextMeeting() {+ if (this.activeMeeting) {+ this.reconcileProvider(this.activeMeeting.provider);+ }+ if (!this.activeMeeting) {+ // A delivered meeting that became eligible again (re-accepted before or+ // during the meeting) is active again, without a second reminder.+ const delivered = this.databaseManager+ .getUpcomingEvents(1)+ .find((event) => this.notifiedMeetings.has(notificationKey(event)));+ if (delivered) {+ this.activeMeeting = delivered;+ this._scheduleMeetingEnd(delivered);+ }+ }+if (this.nextMeetingTimer) {clearTimeout(this.nextMeetingTimer);this.nextMeetingTimer = null;@@ -104,9 +119,9 @@ class CalendarReminderScheduler {};}- // Refresh or clear the cached active event after a provider replaces its- // rows. Keep notifiedMeetings intact so periodic snapshots cannot re-fire a- // reminder that was already delivered.+ // Refresh or clear the cached active event on every schedule refresh. Keep+ // notifiedMeetings intact so periodic snapshots cannot re-fire a reminder+ // that was already delivered.reconcileProvider(provider) {if (!this.activeMeeting || this.activeMeeting.provider !== provider) return;diff --git a/src/helpers/database.js b/src/helpers/database.jsindex 21080bbdd..df7a43853 100644--- a/src/helpers/database.js+++ b/src/helpers/database.js@@ -891,6 +891,23 @@ class DatabaseManager {.run();}+ // One-time reset (user_version 4): older builds took a shared Google+ // calendar owner's RSVP as the connected user's; clear those cached+ // responses and force a full sync of those calendars.+ if (this.db.pragma("user_version", { simple: true }) < 4) {+ this.db.exec(`+ UPDATE calendar_events SET self_response_status = 'unknown'+ WHERE provider = 'google' AND NOT EXISTS (+ SELECT 1 FROM google_calendars c+ WHERE c.id = calendar_events.calendar_id+ AND (c.is_primary = 1 OR c.id = c.account_email)+ );+ UPDATE google_calendars SET sync_token = NULL, sync_token_expires_at = NULL+ WHERE is_primary = 0 AND (account_email IS NULL OR id != account_email);+ `);+ this.db.pragma("user_version = 4");+ }+this.db.exec(`CREATE TABLE IF NOT EXISTS apple_calendars (id TEXT PRIMARY KEY,@@ -4850,6 +4867,7 @@ class DatabaseManager {)).all()+ .filter((event) => event.self_response_status !== "declined").map(stripDedupeColumn);} catch (error) {debugLogger.error("Error getting active events", { error: error.message }, "gcal");@@ -4902,6 +4920,7 @@ class DatabaseManager {)).all(windowMinutes)+ .filter((event) => event.self_response_status !== "declined").map(stripDedupeColumn);} catch (error) {debugLogger.error("Error getting upcoming events", { error: error.message }, "gcal");diff --git a/src/helpers/googleCalendarManager.js b/src/helpers/googleCalendarManager.jsindex c21ace573..51a5f2df9 100644--- a/src/helpers/googleCalendarManager.js+++ b/src/helpers/googleCalendarManager.js@@ -244,7 +244,9 @@ class GoogleCalendarManager {}const isAllDay = !item.start?.dateTime;- const selfAttendee = item.attendees?.find((attendee) => attendee.self === true);+ const selfAttendee = selfIsUser+ ? item.attendees?.find((attendee) => attendee.self === true)+ : item.attendees?.find((attendee) => attendee.email?.toLowerCase() === ownEmail);toUpsert.push({id: item.id,calendar_id: calendar.id,diff --git a/src/helpers/microsoftCalendarManager.js b/src/helpers/microsoftCalendarManager.jsindex 6b77eaf92..a6852fb20 100644--- a/src/helpers/microsoftCalendarManager.js+++ b/src/helpers/microsoftCalendarManager.js@@ -247,9 +247,19 @@ class MicrosoftCalendarManager {// An occurrence still stripped after backfill (master fetch failed) has no// subject, attendees, or join link. Overwriting a row a previous sync// stored in full would demote that meeting to an untitled time block, so- // keep the stored row and only insert bare stubs we've never seen.- if (isStrippedOccurrence(item) && this.databaseManager.getCalendarEventById(item.id)) {- continue;+ // keep its details while applying any explicit RSVP update.+ if (isStrippedOccurrence(item)) {+ const cached = this.databaseManager.getCalendarEventById(item.id);+ if (cached) {+ if (typeof item.responseStatus?.response === "string") {+ toUpsert.push({+ ...cached,+ self_response_status:+ RESPONSE_STATUS_BY_GRAPH[item.responseStatus.response] || "unknown",+ });+ }+ continue;+ }}toUpsert.push(this._mapEvent(item, calendar));for (const a of item.attendees || []) {diff --git a/test/helpers/appleCalendarManager.test.js b/test/helpers/appleCalendarManager.test.jsindex 19d3b69a0..d5847e357 100644--- a/test/helpers/appleCalendarManager.test.js+++ b/test/helpers/appleCalendarManager.test.js@@ -115,7 +115,7 @@ test("rooms and resources are flagged in attendees and kept, with the user, outreplaceAppleCalendarEvents: (events) => saved.push(...events),syncCalendarContacts: (...args) => synced.push(args),},- { reconcileProvider: () => {}, scheduleNextMeeting: () => {} }+ { scheduleNextMeeting: () => {} });manager._applySnapshot({@@ -174,3 +174,23 @@ test("_mapEvent drops the organizer address only when the user organized the eveassert.equal(manager._mapEvent({ ...event, organizer_self: true }).organizer_email, null);assert.equal(manager._mapEvent(event).organizer_email, "[email protected]");});++test("Apple RSVP ignores another attendee's decline and follows current-user changes", () => {+ const AppleCalendarManager = loadManager();+ const manager = new AppleCalendarManager({}, {});+ for (const response of ["accepted", "declined", "tentative", "unknown"]) {+ const mapped = manager._mapEvent({+ id: "instance",+ calendar_id: "cal",+ title: "Meeting",+ status: "confirmed",+ start: "2026-10-01T10:00:00Z",+ end: "2026-10-01T11:00:00Z",+ attendees: [+ { email: "[email protected]", status: "declined" },+ { email: "[email protected]", self: true, status: response },+ ],+ });+ assert.equal(mapped.self_response_status, response);+ }+});diff --git a/test/helpers/calendarDatabase.test.js b/test/helpers/calendarDatabase.test.jsindex a812a846e..8e1190927 100644--- a/test/helpers/calendarDatabase.test.js+++ b/test/helpers/calendarDatabase.test.js@@ -249,7 +249,7 @@ test("reopening a pre-v2 database clears microsoft sync tokens once", (t) => {assert.equal(calendar.sync_token, null);assert.equal(calendar.sync_token_expires_at, null);// Reopening runs every later migration too.- assert.equal(reopened.db.pragma("user_version", { simple: true }), 3);+ assert.equal(reopened.db.pragma("user_version", { simple: true }), 4);reopened.db.close();});@@ -266,3 +266,126 @@ test("google sync token persists alongside its expiry", (t) => {assert.equal(calendar.sync_token_expires_at, expiresAt);db.db.close();});++test("Google shared RSVP repair is scoped, preserves notes, and runs once", (t) => {+ const db = createDb(t);+ if (!db) return;+ t.after(() => db.db.open && db.db.close());+ for (const id of ["primary", "shared", "[email protected]"]) {+ db.db+ .prepare(+ `INSERT INTO google_calendars+ (id, summary, is_primary, account_email, sync_token, sync_token_expires_at)+ VALUES (?, ?, ?, '[email protected]', 'old-google', 9999999999999)`+ )+ .run(id, id, id === "primary" ? 1 : 0);+ }+ insertCalendar(db, "microsoft", "ms");+ db.updateMicrosoftCalendarSyncToken("ms", "old-ms", 9999999999999);+ db.upsertCalendarEvents([+ ...["primary", "shared", "[email protected]", "orphan"].map((id) =>+ restEvent("google", id, id, { self_response_status: "declined" })+ ),+ restEvent("microsoft", "ms", "ms-event", { self_response_status: "declined" }),+ appleEvent("apple-event", { self_response_status: "declined" }),+ ]);+ const note = db.saveNote("Linked meeting", "Keep this note", "meeting").note;+ db.updateNote(note.id, { calendar_event_id: "shared" });+ const before = db.getCalendarEventById("shared");+ db.db.pragma("user_version = 3");+ db.db.close();+ const repaired = new DatabaseManager();+ t.after(() => repaired.db.open && repaired.db.close());+ assert.deepEqual(repaired.getCalendarEventById("shared"), {+ ...before,+ self_response_status: "unknown",+ });+ assert.equal(repaired.getCalendarEventById("orphan").self_response_status, "unknown");+ for (const id of ["primary", "[email protected]", "ms-event", "apple-event"]) {+ assert.equal(repaired.getCalendarEventById(id).self_response_status, "declined");+ }+ assert.equal(repaired.db.pragma("user_version", { simple: true }), 4);+ const calendars = repaired.getGoogleCalendars();+ assert.equal(calendars.find((c) => c.id === "shared").sync_token, null);+ assert.equal(calendars.find((c) => c.id === "shared").sync_token_expires_at, null);+ assert.equal(calendars.find((c) => c.id === "primary").sync_token, "old-google");+ assert.equal(calendars.find((c) => c.id === "[email protected]").sync_token, "old-google");+ assert.equal(+ repaired.db.prepare("SELECT sync_token FROM microsoft_calendars WHERE id='ms'").get()+ .sync_token,+ "old-ms"+ );+ assert.equal(+ repaired.db.prepare("SELECT calendar_event_id FROM notes WHERE id=?").get(note.id)+ .calendar_event_id,+ "shared"+ );+ repaired.upsertCalendarEvents([{ ...before, self_response_status: "accepted" }]);+ repaired.updateCalendarSyncToken("shared", "fresh", 9999999999999);+ repaired.db.close();+ const reopened = new DatabaseManager();+ t.after(() => reopened.db.close());+ assert.equal(reopened.getCalendarEventById("shared").self_response_status, "accepted");+ assert.equal(reopened.getGoogleCalendars().find((c) => c.id === "shared").sync_token, "fresh");+});++test("google: only self-declined schedule rows are hidden, and reacceptance restores them", (t) => {+ const db = createDb(t);+ if (!db) return;+ t.after(() => db.db.close());+ const now = Date.now();+ const make = (id, response, overrides = {}) =>+ restEvent("google", "cal", id, {+ start_time: new Date(now - 5 * 60_000).toISOString(),+ end_time: new Date(now + 30 * 60_000).toISOString(),+ self_response_status: response,+ attendees_count: 2,+ attendees: '[{"self":true,"responseStatus":"accepted"},{"responseStatus":"declined"}]',+ ...overrides,+ });+ const declined = make("declined", "declined", {+ hangout_link: "https://meet.google.com/abc-defg-hij",+ });+ const rows = [+ declined,+ ...["accepted", "tentative", "needsAction", "unknown"].map((response) =>+ make(response, response)+ ),+ ];+ db.upsertCalendarEvents(rows);+ const note = db.saveNote("Declined meeting notes", "Keep", "meeting").note;+ db.updateNote(note.id, { calendar_event_id: "declined" });+ const expected = ["accepted", "needsAction", "tentative", "unknown"];+ for (const events of [db.getUpcomingEvents(60), db.getActiveEvents()]) {+ assert.deepEqual(events.map((e) => e.id).sort(), expected);+ }+ assert.equal(db.getCalendarEventById("declined").hangout_link, declined.hangout_link);+ assert.equal(+ db.db.prepare("SELECT calendar_event_id FROM notes WHERE id=?").get(note.id).calendar_event_id,+ "declined"+ );+ db.upsertCalendarEvents([{ ...declined, self_response_status: "accepted" }]);+ assert.ok(db.getUpcomingEvents(60).some((e) => e.id === "declined"));+ assert.ok(db.getActiveEvents().some((e) => e.id === "declined"));+});++test("declined REST suppresses its stale Apple mirror", (t) => {+ const db = createDb(t);+ if (!db) return;+ t.after(() => db.db.close());+ const now = Date.now();+ const common = {+ summary: "Weekly planning",+ start_time: new Date(now - 5 * 60_000).toISOString(),+ end_time: new Date(now + 30 * 60_000).toISOString(),+ };+ db.upsertCalendarEvents([+ restEvent("google", "cal", "rest-instance", {+ ...common,+ self_response_status: "declined",+ }),+ appleEvent("apple-instance", { ...common, self_response_status: "accepted" }),+ ]);+ assert.deepEqual(db.getUpcomingEvents(120), []);+ assert.deepEqual(db.getActiveEvents(), []);+});diff --git a/test/helpers/calendarReminderScheduler.test.js b/test/helpers/calendarReminderScheduler.test.jsindex 37c2f049b..6b792a1c5 100644--- a/test/helpers/calendarReminderScheduler.test.js+++ b/test/helpers/calendarReminderScheduler.test.js@@ -190,3 +190,54 @@ test("resetting a provider re-arms the next meeting timer for upcoming events",scheduler.stop();});++test("schedule refresh clears a no-longer-eligible cached meeting", (t) => {+ const event = activeEvent("google", "meeting");+ let rows = [event];+ // Not started yet: the reminder fires in the minute before start.+ let active = [];+ const scheduler = new CalendarReminderScheduler({+ getUpcomingEvents: () => rows,+ getActiveEvents: () => active,+ });+ t.after(() => scheduler.stop());+ let prompts = 0;+ scheduler.meetingDetectionEngine = { handleCalendarReminder: () => prompts++ };+ scheduler.scheduleNextMeeting();+ assert.equal(prompts, 1);+ assert.ok(scheduler.meetingEndTimer);+ rows = [];+ scheduler.scheduleNextMeeting();+ assert.equal(scheduler.activeMeeting, null);+ assert.equal(scheduler.meetingEndTimer, null);+ assert.equal(prompts, 1);+ rows = [event];+ scheduler.scheduleNextMeeting();+ assert.equal(prompts, 1, "reacceptance cannot repeat a delivered reminder");+ assert.equal(scheduler.activeMeeting, event);+ active = rows;+ scheduler.onWakeFromSleep();+ assert.equal(prompts, 1, "waking after the start cannot repeat it either");+});++test("clearing the cached meeting restores another reminded running meeting", (t) => {+ const first = activeEvent("apple", "first");+ const second = activeEvent("apple", "second");+ let rows = [first];+ const scheduler = new CalendarReminderScheduler({+ getUpcomingEvents: () => rows,+ getActiveEvents: () => rows,+ });+ t.after(() => scheduler.stop());+ let prompts = 0;+ scheduler.meetingDetectionEngine = { handleCalendarReminder: () => prompts++ };+ scheduler.scheduleNextMeeting();+ rows = [first, second];+ scheduler.scheduleNextMeeting();+ assert.equal(scheduler.activeMeeting, second);+ rows = [first];+ scheduler.scheduleNextMeeting();+ assert.equal(scheduler.activeMeeting, first);+ scheduler.onWakeFromSleep();+ assert.equal(prompts, 2, "waking cannot repeat a delivered reminder");+});diff --git a/test/helpers/connectorActionsDatabase.test.js b/test/helpers/connectorActionsDatabase.test.jsindex 7f61cc300..d2010d742 100644--- a/test/helpers/connectorActionsDatabase.test.js+++ b/test/helpers/connectorActionsDatabase.test.js@@ -656,6 +656,7 @@ test("upgrading to user_version 3 forces a full calendar re-sync", (t) => {).all();assert.deepEqual(tokens, [{ sync_token: null }, { sync_token: null }]);- assert.equal(reopened.db.pragma("user_version", { simple: true }), 3);+ // Reopening also applies subsequent migrations.+ assert.equal(reopened.db.pragma("user_version", { simple: true }), 4);reopened.db.close();});diff --git a/test/helpers/googleCalendarManager.test.js b/test/helpers/googleCalendarManager.test.jsindex a2f6ac52b..06f4663bd 100644--- a/test/helpers/googleCalendarManager.test.js+++ b/test/helpers/googleCalendarManager.test.js@@ -77,7 +77,7 @@ test("_syncCalendar fetches all pages when nextPageToken is returned", async ()throw new Error(`Unexpected path: ${path}`);};- const calendar = { id: "cal-1", account_email: "[email protected]" };+ const calendar = { id: "cal-1", account_email: "[email protected]", is_primary: 1 };await manager._syncCalendar(calendar);assert.equal(apiCalls.length, 2, "should make 2 API calls for 2 pages");@@ -377,3 +377,53 @@ test("_syncCalendar trusts self as the user only on the account's primary calend]);});++async function syncGoogleResponse(calendar, attendees) {+ const rows = [];+ const GoogleCalendarManager = loadManagerModule();+ const manager = new GoogleCalendarManager(+ {+ removeStaleCalendarEvents: () => {},+ upsertCalendarEvents: (events) => rows.push(...events),+ removeCalendarEvents: () => {},+ updateCalendarSyncToken: () => {},+ syncCalendarContacts: () => {},+ },+ null,+ { scheduleNextMeeting: () => {} }+ );+ manager._apiGet = async () => ({+ items: [+ {+ id: "meeting",+ summary: "Planning",+ status: "confirmed",+ start: { dateTime: "2026-10-01T10:00:00Z" },+ end: { dateTime: "2026-10-01T11:00:00Z" },+ attendees,+ },+ ],+ });+ await manager._syncCalendar(calendar);+ return rows[0].self_response_status;+}++test("Google RSVP on a shared calendar uses the connected account's attendee", async () => {+ const shared = { id: "[email protected]", account_email: "[email protected]" };+ const colleague = { email: "[email protected]", self: true, responseStatus: "declined" };+ assert.equal(+ await syncGoogleResponse(shared, [+ colleague,+ { email: "[email protected]", responseStatus: "accepted" },+ ]),+ "accepted"+ );+ assert.equal(await syncGoogleResponse(shared, [colleague]), "unknown");+ assert.equal(+ await syncGoogleResponse(shared, [+ colleague,+ { email: "[email protected]", responseStatus: "unrecognized" },+ ]),+ "unknown"+ );+});diff --git a/test/helpers/microsoftCalendarManager.test.js b/test/helpers/microsoftCalendarManager.test.jsindex 87c893be1..25b8f4983 100644--- a/test/helpers/microsoftCalendarManager.test.js+++ b/test/helpers/microsoftCalendarManager.test.js@@ -447,3 +447,34 @@ test("fetchCalendars still saves the calendars when the address lookup fails", aassert.equal(calendars.length, 1);assert.equal(savedCalendars.length, 1);});++test("a stripped occurrence keeps details but applies explicit RSVP after master failure", async () => {+ const MicrosoftCalendarManager = loadManagerModule();+ const original = {+ id: "occ-1",+ calendar_id: "cal-1",+ provider: "microsoft",+ summary: "Standup",+ start_time: "2026-10-01T10:00:00Z",+ end_time: "2026-10-01T11:00:00Z",+ is_all_day: 0,+ status: "confirmed",+ availability_status: "busy",+ self_response_status: "accepted",+ hangout_link: "https://teams.live.com/meet/123",+ attendees_count: 1,+ attendees: '[{"email":"[email protected]"}]',+ };+ const upserted = [];+ const manager = createManager(MicrosoftCalendarManager, upserted, [], {+ getCalendarEventById: () => original,+ });+ manager._apiGet = async (url) => {+ if (!url.includes("/calendarView/delta")) throw new Error("master unavailable");+ return {+ value: [{ ...STRIPPED_OCCURRENCE, responseStatus: { response: "declined" } }],+ };+ };+ await manager._syncCalendar({ id: "cal-1", account_email: "[email protected]" });+ assert.deepEqual(upserted, [{ ...original, self_response_status: "declined" }]);+});