Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: preserve calendar push participant snapshots (#8838)

[._.]/ Adam Eivy8353ed052999
diff --git a/server/routes/calendar.js b/server/routes/calendar.js
index 6409b08bb0..d0a6292968 100644
--- a/server/routes/calendar.js
+++ b/server/routes/calendar.js
@@ -81,6 +81,18 @@ const pushSyncSchema = z.object({
description: z.string().optional().default(''),
status: z.string().optional().default('confirmed'),
htmlLink: z.string().optional(),
+ // No defaults: legacy push clients omit identity; explicit null/[] clears it.
+ organizer: z.object({
+ displayName: z.string().optional(),
+ email: z.string().optional(),
+ self: z.boolean().optional()
+ }).nullable().optional(),
+ attendees: z.array(z.object({
+ displayName: z.string().optional(),
+ email: z.string().optional(),
+ self: z.boolean().optional(),
+ responseStatus: z.string().optional()
+ })).optional(),
// Conference metadata feeds the cached `meetingUrl` join link (#6289).
// OPTIONAL with no default, and nullable: `selectMeetingUrl` distinguishes
// a producer that omitted them (preserve the cached link) from one that
diff --git a/server/routes/calendar.test.js b/server/routes/calendar.test.js
index 392996a9ff..ddfd9f9356 100644
--- a/server/routes/calendar.test.js
+++ b/server/routes/calendar.test.js
@@ -315,6 +315,26 @@ describe('Calendar Routes — push sync carries Google conference metadata (#628
calendarGoogleSync.pushSyncEvents.mockResolvedValue({ newEvents: 1, updated: 0, pruned: 0, total: 1 });
});
+ it('preserves participant projection and authoritative clears without accepting unrelated metadata', async () => {
+ const response = await push([{
+ ...baseEvent,
+ organizer: { email: '[email protected]', displayName: 'Example Organizer', self: true, privateNote: 'discard' },
+ attendees: [{ email: '[email protected]', self: true, responseStatus: 'declined', privateNote: 'discard' }],
+ }, { ...baseEvent, id: 'clear', organizer: null, attendees: [] }, baseEvent]);
+ expect(response.status).toBe(200);
+ expect(pushedEvents()[0].organizer).toEqual({ email: '[email protected]', displayName: 'Example Organizer', self: true });
+ expect(pushedEvents()[0].attendees).toEqual([{ email: '[email protected]', self: true, responseStatus: 'declined' }]);
+ expect(pushedEvents()[1]).toMatchObject({ organizer: null, attendees: [] });
+ expect(pushedEvents()[2]).not.toHaveProperty('organizer');
+ expect(pushedEvents()[2]).not.toHaveProperty('attendees');
+ });
+
+ it.each([{ organizer: 'invalid' }, { attendees: [{ self: 'yes' }] }])('rejects malformed participant types: %j', async fields => {
+ const response = await push([{ ...baseEvent, ...fields }]);
+ expect(response.status).toBe(400);
+ expect(calendarGoogleSync.pushSyncEvents).not.toHaveBeenCalled();
+ });
+
it('forwards conferenceData entry points and hangoutLink to the service', async () => {
const response = await push([{
...baseEvent,
diff --git a/server/services/calendarGoogleSync.js b/server/services/calendarGoogleSync.js
index a7bd2a1af3..da2398c0dd 100644
--- a/server/services/calendarGoogleSync.js
+++ b/server/services/calendarGoogleSync.js
@@ -55,10 +55,10 @@ export function normalizeGoogleEvent(event, subcalendarId, subcalendarName) {
// all. Only the chosen URL is ever retained — never the surrounding
// conference object, its passwords, or its dial-in codes (#6289).
meetingUrl: selectMeetingUrl(event),
- organizer: event.organizer
+ organizer: event.organizer === undefined ? undefined : event.organizer
? { name: event.organizer.displayName || '', email: event.organizer.email || '' }
: null,
- attendees,
+ attendees: event.attendees === undefined ? undefined : attendees,
myStatus,
subcalendarId,
subcalendarName,
@@ -127,9 +127,11 @@ export async function pushSyncEvents(accountId, calendarId, calendarName, rawEve
// Refresh the identity fields too so an event already in cache gains
// organizer/attendees for Tribe touchpoint matching and an up-to-date
// declined status (#2033) — not just newly-added events.
- existing.organizer = event.organizer;
- existing.attendees = event.attendees;
- existing.myStatus = event.myStatus;
+ if (event.organizer !== undefined) existing.organizer = event.organizer;
+ if (event.attendees !== undefined) {
+ existing.attendees = event.attendees;
+ existing.myStatus = event.myStatus;
+ }
// `undefined` means this producer never described the event's
// conferencing — a legacy push, or an MCP payload predating the field —
// so the cached link stands. Anything else is the current snapshot:
@@ -141,7 +143,7 @@ export async function pushSyncEvents(accountId, calendarId, calendarName, rawEve
} else {
// A newly cached event always carries the key, so `meetingUrl` is absent
// from the cache only for records written before this shipped.
- const retained = { ...event, meetingUrl: event.meetingUrl ?? null };
+ const retained = { ...event, organizer: event.organizer ?? null, attendees: event.attendees ?? [], meetingUrl: event.meetingUrl ?? null };
cache.events.push(retained);
existingMap.set(event.externalId, retained);
newCount++;
@@ -207,7 +209,7 @@ export async function pushSyncEvents(accountId, calendarId, calendarName, rawEve
* partial payload from driving a prune. Clearing a link is destructive too.
*/
function withExplicitConferenceFields(event) {
- return { ...event, hangoutLink: event?.hangoutLink ?? null, conferenceData: event?.conferenceData ?? null };
+ return { ...event, organizer: event?.organizer ?? null, attendees: event?.attendees ?? [], hangoutLink: event?.hangoutLink ?? null, conferenceData: event?.conferenceData ?? null };
}
const mcpSyncLock = new Map();
diff --git a/server/services/calendarGoogleSync.test.js b/server/services/calendarGoogleSync.test.js
index 7386769a92..2865db02dd 100644
--- a/server/services/calendarGoogleSync.test.js
+++ b/server/services/calendarGoogleSync.test.js
@@ -36,7 +36,7 @@ vi.mock('./settings.js', () => ({ getSettings: vi.fn(async () => ({})) }));
import { mcpSyncAccount, mcpDiscoverCalendars, pushSyncEvents } from './calendarGoogleSync.js';
import { runCliProviderPrompt } from '../lib/cliProviderRun.js';
import { getAccount, updateSyncStatus, updateSubcalendars } from './calendarAccounts.js';
-import { loadCache, saveCache } from './calendarSync.js';
+import { loadCache, saveCache, logCalendarTouchpoints } from './calendarSync.js';
const ACCOUNT_ID = '22222222-2222-2222-2222-222222222222';
const CAL_ID = '[email protected]';
@@ -441,3 +441,48 @@ describe('Google batch identity reconciliation (#8635)', () => {
]);
});
});
+
+
+describe('Google participant snapshot reconciliation (#8838)', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ getAccount.mockResolvedValue(account());
+ loadCache.mockResolvedValue({ events: [] });
+ });
+
+ it('retains declined identity on legacy updates and clears it on explicit snapshots', async () => {
+ await pushSyncEvents(ACCOUNT_ID, CAL_ID, 'Work', [{
+ ...rawEvent('identity', 'Meeting'),
+ organizer: { email: '[email protected]', displayName: 'Example Organizer' },
+ attendees: [{ email: '[email protected]', self: true, responseStatus: 'declined' }],
+ }]);
+ const retained = savedCache().events[0];
+ expect(retained.myStatus).toBe('declined');
+ expect(logCalendarTouchpoints.mock.calls.at(-1)[1][0]).toMatchObject({
+ organizer: { name: 'Example Organizer', email: '[email protected]' },
+ attendees: [{ email: '[email protected]', status: 'declined' }], myStatus: 'declined',
+ });
+ loadCache.mockResolvedValue({ events: [retained] });
+ await pushSyncEvents(ACCOUNT_ID, CAL_ID, 'Work', [rawEvent('identity', 'Updated')]);
+ expect(savedCache().events[0]).toMatchObject({ organizer: retained.organizer, attendees: retained.attendees, myStatus: 'declined' });
+ await pushSyncEvents(ACCOUNT_ID, CAL_ID, 'Work', [{ ...rawEvent('identity', 'Cleared'), organizer: null, attendees: [] }]);
+ expect(savedCache().events[0]).toMatchObject({ organizer: null, attendees: [] });
+ expect(savedCache().events[0].myStatus).toBeUndefined();
+ });
+
+ it('complete MCP snapshots clear omitted identities but partial snapshots preserve them', async () => {
+ await pushSyncEvents(ACCOUNT_ID, CAL_ID, 'Work', [{
+ ...rawEvent('identity', 'Meeting'), organizer: { email: '[email protected]' },
+ attendees: [{ email: '[email protected]', self: true, responseStatus: 'declined' }],
+ }]);
+ loadCache.mockResolvedValue(savedCache());
+ const text = JSON.stringify({ calendars: [{ calendarId: CAL_ID, calendarName: 'Work', events: [rawEvent('identity', 'Updated')] }] });
+ runCliProviderPrompt.mockResolvedValue({ text, exitCode: 1, partial: true });
+ await mcpSyncAccount(ACCOUNT_ID, null);
+ expect(savedCache().events[0].myStatus).toBe('declined');
+ runCliProviderPrompt.mockResolvedValue({ text, exitCode: 0, partial: false });
+ await mcpSyncAccount(ACCOUNT_ID, null);
+ expect(savedCache().events[0]).toMatchObject({ organizer: null, attendees: [] });
+ expect(savedCache().events[0].myStatus).toBeUndefined();
+ });
+});