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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: preserve standalone push updates and settle delayed sync starts (#7101)
[._.]/ Adam Eivy342c54d715ec
diff --git a/client/src/components/calendar/SyncTab.jsx b/client/src/components/calendar/SyncTab.jsxindex e55081c7f0..e527442295 100644--- a/client/src/components/calendar/SyncTab.jsx+++ b/client/src/components/calendar/SyncTab.jsx@@ -26,6 +26,8 @@ export default function SyncTab({ accounts, onRefresh }) {label: 'Calendar sync',successText: ({ newEvents }) => `Calendar sync complete: ${newEvents ?? 0} events`,onRefresh,+ // Direct Google pushes carry calendarId and have no started event.+ isStandaloneCompletion: ({ calendarId }) => Boolean(calendarId),onStart: clearProgress,onTerminal: clearProgress,});diff --git a/client/src/components/calendar/SyncTab.test.jsx b/client/src/components/calendar/SyncTab.test.jsxindex b2463441ff..22a728fe17 100644--- a/client/src/components/calendar/SyncTab.test.jsx+++ b/client/src/components/calendar/SyncTab.test.jsx@@ -57,17 +57,37 @@ describe('Calendar sync lifecycle', () => {render(<SyncTab accounts={[account]} onRefresh={vi.fn()} />);fireEvent.click(syncButton());await waitFor(() => expect(syncButton()).toBeEnabled());+ emit('started'); // The socket can deliver its start after HTTP settled.+ expect(syncButton()).toBeEnabled();expect(toast.warning).toHaveBeenCalledWith(expect.stringContaining('no usable token'));expect(api.syncCalendarAccount).toHaveBeenCalledWith(account.id, { silent: true });api.syncCalendarAccount.mockResolvedValue({ status: 'success', newEvents: 4 });fireEvent.click(syncButton());- emit('started');await waitFor(() => expect(toast.success).toHaveBeenCalledTimes(1));+ emit('started');+ expect(syncButton()).toBeEnabled();emit('completed', { status: 'success', newEvents: 4 });expect(toast.success).toHaveBeenCalledTimes(1);});+ it('reports repeated standalone Google pushes without settling an active manual sync', async () => {+ const onRefresh = vi.fn();+ render(<SyncTab accounts={[account]} onRefresh={onRefresh} />);+ emit('completed', { calendarId: 'work', status: 'success', newEvents: 1 });+ emit('completed', { calendarId: 'work', status: 'success', newEvents: 2 });+ expect(toast.success).toHaveBeenCalledTimes(2);+ expect(onRefresh).toHaveBeenCalledTimes(2);+ expect(syncButton()).toBeEnabled();+ emit('started');+ emit('completed', { calendarId: 'work', status: 'success', newEvents: 3 });+ expect(screen.queryByRole('button', { name: 'Sync' })).toBeNull();+ emit('completed', { status: 'success', newEvents: 4 });+ expect(syncButton()).toBeEnabled();+ expect(toast.success).toHaveBeenLastCalledWith('Calendar sync complete: 4 events');+ await waitFor(() => expect(api.getCalendarTokenStatus).toHaveBeenCalled());+ });+it('ignores an older HTTP result after a newer socket cycle starts', async () => {let resolve;api.syncCalendarAccount.mockImplementation(() => new Promise(done => { resolve = done; }));diff --git a/client/src/hooks/useAccountSyncStatus.js b/client/src/hooks/useAccountSyncStatus.jsindex 543dd63c9f..1b3a03822c 100644--- a/client/src/hooks/useAccountSyncStatus.js+++ b/client/src/hooks/useAccountSyncStatus.js@@ -26,12 +26,12 @@ function outcome(result, label, successText) {}/** One per-account cycle joins manual HTTP and socket terminal notifications. */-export function useAccountSyncStatus({ eventPrefix, label, successText, onRefresh, onStart, onTerminal }) {+export function useAccountSyncStatus({ eventPrefix, label, successText, onRefresh, onStart, onTerminal, isStandaloneCompletion }) {const [syncing, setSyncing] = useState({});const mounted = useMounted();const cycles = useRef(new Map());const callbacks = useRef({});- callbacks.current = { label, successText, onRefresh, onStart, onTerminal };+ callbacks.current = { label, successText, onRefresh, onStart, onTerminal, isStandaloneCompletion };const begin = useCallback((accountId, manual = false) => {const cycle = { awaitingStart: manual, settled: false };@@ -41,20 +41,23 @@ export function useAccountSyncStatus({ eventPrefix, label, successText, onRefresreturn cycle;}, []);- const finish = useCallback((accountId, result, expectedCycle) => {+ const finish = useCallback((accountId, result, expectedCycle, standalone = false) => {if (!mounted.current) return;let cycle = cycles.current.get(accountId);if (expectedCycle && cycle !== expectedCycle) return;- if (cycle?.settled) return;- if (!cycle) {+ if (!standalone && cycle?.settled) return;+ if (!standalone && !cycle) {cycle = {};cycles.current.set(accountId, cycle);}- cycle.settled = true;+ if (!standalone) cycle.settled = true;const current = callbacks.current;const terminal = outcome(result, current.label, current.successText);- setSyncing(prev => ({ ...prev, [accountId]: terminal.auth ? 'auth-required' : null }));- current.onTerminal?.(accountId);+ // Standalone pushes notify independently and cannot settle a manual sync.+ if (!standalone) {+ setSyncing(prev => ({ ...prev, [accountId]: terminal.auth ? 'auth-required' : null }));+ current.onTerminal?.(accountId);+ }toast[terminal.type](terminal.text);if (terminal.refresh) current.onRefresh?.();}, [mounted]);@@ -63,11 +66,13 @@ export function useAccountSyncStatus({ eventPrefix, label, successText, onRefresconst started = ({ accountId }) => {const cycle = cycles.current.get(accountId);// A server start acknowledges the manual cycle; it must not orphan its- // pending HTTP response. Later starts open a fresh notification cycle.- if (cycle?.awaitingStart && !cycle.settled) cycle.awaitingStart = false;+ // pending HTTP response, or reopen it if HTTP settled first. Later starts+ // open a fresh notification cycle.+ if (cycle?.awaitingStart) cycle.awaitingStart = false;else begin(accountId);};- const completed = ({ accountId, ...result }) => finish(accountId, result);+ const completed = ({ accountId, ...result }) =>+ finish(accountId, result, undefined, callbacks.current.isStandaloneCompletion?.(result));const failed = ({ accountId, error }) => finish(accountId, { status: 'error', error: error ?? 'unknown error' });const authRequired = ({ accountId }) => finish(accountId, { status: 'auth-required' });const handlers = { started, completed, failed, 'auth-required': authRequired };diff --git a/server/services/messageSync.test.js b/server/services/messageSync.test.jsindex e2bdccc2c4..59857d2496 100644--- a/server/services/messageSync.test.js+++ b/server/services/messageSync.test.js@@ -446,7 +446,7 @@ describe('syncAccount', () => {syncPlaywright.mockResolvedValue([]);updateSyncStatus.mockResolvedValue();- const result = await syncAccount(VALID_UUID, mockIo);+ await syncAccount(VALID_UUID, mockIo);expect(syncPlaywright).toHaveBeenCalled();});