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: route Agenda sync through configured calendar providers (#8839)
[._.]/ Adam Eivyb402fe875937
diff --git a/client/src/components/calendar/AgendaTab.jsx b/client/src/components/calendar/AgendaTab.jsxindex 1b35d28fc3..1a384509f3 100644--- a/client/src/components/calendar/AgendaTab.jsx+++ b/client/src/components/calendar/AgendaTab.jsx@@ -1,8 +1,7 @@import { useState, useEffect, useCallback, useRef } from 'react';import { RefreshCw, Search, MapPin, Users, Clock } from 'lucide-react';-import toast from '../ui/Toast';import * as api from '../../services/api';-import socket from '../../services/socket';+import { useAccountSyncStatus } from '../../hooks/useAccountSyncStatus';import EventDetail from './EventDetail';import { formatCount, formatTimeOfDay as formatTime, formatWeekdayDate, localDateKey } from '../../utils/formatters';import BrailleSpinner from '../BrailleSpinner';@@ -104,22 +103,35 @@ export default function AgendaTab({ accounts }) {useEffect(() => {fetchEvents();- const onSyncCompleted = () => fetchEvents();- socket.on('calendar:sync:completed', onSyncCompleted);return () => {++requestGeneration.current;pending.current = false;- socket.off('calendar:sync:completed', onSyncCompleted);};}, [fetchEvents]);+ const { sync } = useAccountSyncStatus({+ eventPrefix: 'calendar',+ label: 'Calendar sync',+ successText: ({ newEvents }) => `Calendar sync complete: ${newEvents ?? 0} events`,+ onRefresh: fetchEvents,+ getAccountName: accountId => accounts.find(account => account.id === accountId)?.name,+ isStandaloneCompletion: ({ calendarId }) => Boolean(calendarId),+ });+ const batchPending = useRef(false);const enabledAccounts = accounts.filter(a => a.enabled);const handleSync = async () => {+ if (batchPending.current) return;+ batchPending.current = true;setSyncing(true);- await Promise.allSettled(enabledAccounts.map(a => api.syncCalendarAccount(a.id)));+ await Promise.allSettled(enabledAccounts.map(account => sync(account.id, () => {+ if (account.type !== 'google-calendar') return api.syncCalendarAccount(account.id, { silent: true });+ return account.syncMethod === 'google-api'+ ? api.apiSyncGoogleCalendar(account.id, { silent: true })+ : api.mcpSyncGoogleCalendar(account.id, { silent: true });+ })));+ batchPending.current = false;setSyncing(false);- toast.success('Calendar sync started');};const grouped = groupEventsByDay(events);diff --git a/client/src/components/calendar/AgendaTab.test.jsx b/client/src/components/calendar/AgendaTab.test.jsxindex 76bfcd52c8..a9ad28a1e2 100644--- a/client/src/components/calendar/AgendaTab.test.jsx+++ b/client/src/components/calendar/AgendaTab.test.jsx@@ -10,11 +10,14 @@ vi.mock('../../services/socket', () => ({ default: socketMock }));vi.mock('../../services/api', () => ({getCalendarEvents: vi.fn(),syncCalendarAccount: vi.fn(),+ apiSyncGoogleCalendar: vi.fn(),+ mcpSyncGoogleCalendar: vi.fn(),}));-vi.mock('../ui/Toast', () => ({ default: { success: vi.fn(), error: vi.fn() } }));+vi.mock('../ui/Toast', () => ({ default: { success: vi.fn(), error: vi.fn(), warning: vi.fn() } }));import * as api from '../../services/api';import AgendaTab from './AgendaTab';+import toast from '../ui/Toast';function LocationProbe() {const location = useLocation();@@ -197,7 +200,7 @@ describe('AgendaTab date scope and paging', () => {fireEvent.click(screen.getByRole('button', { name: 'Load more' }));await act(async () => {});const syncHandler = socketMock.on.mock.calls.filter(([name]) => name === 'calendar:sync:completed').at(-1)[1];- await act(async () => syncHandler());+ await act(async () => syncHandler({ accountId: 'personal', status: 'success' }));expect(screen.getByRole('status')).toHaveTextContent('50 of 105');expect(api.getCalendarEvents).toHaveBeenLastCalledWith(expect.objectContaining({ offset: 0 }));});@@ -228,3 +231,64 @@ describe('AgendaTab date scope and paging', () => {expect(screen.queryByRole('button', { name: 'Load more' })).toBeNull();});});+++describe('Agenda provider sync', () => {+ const syncAccounts = [+ { id: 'outlook', name: 'Example Outlook', enabled: true, type: 'outlook' },+ { id: 'google', name: 'Example Google', enabled: true, type: 'google-calendar', syncMethod: 'google-api' },+ { id: 'mcp', name: 'Example MCP', enabled: true, type: 'google-calendar', syncMethod: 'claude-mcp' },+ { id: 'disabled', enabled: false, type: 'google-calendar', syncMethod: 'google-api' },+ ];+ beforeEach(() => {+ vi.resetAllMocks();+ api.getCalendarEvents.mockResolvedValue({ events: [] });+ api.syncCalendarAccount.mockResolvedValue({ status: 'success', newEvents: 2 });+ api.apiSyncGoogleCalendar.mockResolvedValue({ status: 'success', newEvents: 1 });+ api.mcpSyncGoogleCalendar.mockResolvedValue({ status: 'success', newEvents: 3 });+ });++ it.each(['Sync', 'Sync now'])('routes %s to each enabled provider and refreshes HTTP-only completions', async action => {+ await renderAgenda(syncAccounts);+ await act(async () => fireEvent.click(screen.getByRole('button', { name: action })));+ expect(api.syncCalendarAccount).toHaveBeenCalledExactlyOnceWith('outlook', { silent: true });+ expect(api.apiSyncGoogleCalendar).toHaveBeenCalledExactlyOnceWith('google', { silent: true });+ expect(api.mcpSyncGoogleCalendar).toHaveBeenCalledExactlyOnceWith('mcp', { silent: true });+ expect(api.getCalendarEvents).toHaveBeenCalledTimes(4);+ expect(toast.success).toHaveBeenCalledTimes(3);+ expect(screen.getByRole('button', { name: 'Sync' })).not.toBeDisabled();+ const completed = socketMock.on.mock.calls.find(([name]) => name === 'calendar:sync:completed')[1];+ await act(async () => completed({ accountId: 'google', status: 'success', newEvents: 1 }));+ expect(toast.success).toHaveBeenCalledTimes(3);+ expect(api.getCalendarEvents).toHaveBeenCalledTimes(4);+ });++ it('keeps a mixed batch busy until HTTP settles and identifies failed and partial accounts', async () => {+ let rejectOutlook;+ api.syncCalendarAccount.mockImplementation(() => new Promise((_resolve, reject) => { rejectOutlook = reject; }));+ api.apiSyncGoogleCalendar.mockResolvedValue({ status: 'partial', reason: 'One calendar unavailable' });+ api.mcpSyncGoogleCalendar.mockResolvedValue({ status: 'success', newEvents: 1 });+ await renderAgenda(syncAccounts);+ await act(async () => fireEvent.click(screen.getByRole('button', { name: 'Sync' })));+ expect(screen.getByRole('button', { name: 'Sync' })).toBeDisabled();+ expect(toast.warning).toHaveBeenCalledWith('Example Google: Calendar sync incomplete: One calendar unavailable');+ expect(api.getCalendarEvents).toHaveBeenCalledTimes(3);+ await act(async () => rejectOutlook(new Error('Provider unavailable')));+ expect(toast.error).toHaveBeenCalledWith('Example Outlook: Calendar sync failed: Provider unavailable');+ expect(toast.success).toHaveBeenCalledExactlyOnceWith('Example MCP: Calendar sync complete: 1 events');+ expect(screen.getByRole('button', { name: 'Sync' })).not.toBeDisabled();+ expect(screen.getByRole('button', { name: 'Sync now' })).not.toBeDisabled();+ });++ it('warns about skipped and push-only outcomes without refreshing or claiming success', async () => {+ api.syncCalendarAccount.mockResolvedValue({ status: 'skipped' });+ api.apiSyncGoogleCalendar.mockResolvedValue({ status: 'push-only' });+ await renderAgenda(syncAccounts.slice(0, 2));+ await act(async () => fireEvent.click(screen.getByRole('button', { name: 'Sync now' })));+ expect(toast.warning).toHaveBeenCalledTimes(2);+ expect(toast.warning.mock.calls[0][0]).toContain('Example Outlook: Sync skipped');+ expect(toast.warning.mock.calls[1][0]).toContain('Example Google: This account receives pushed updates');+ expect(toast.success).not.toHaveBeenCalled();+ expect(api.getCalendarEvents).toHaveBeenCalledTimes(1);+ });+});diff --git a/client/src/hooks/useAccountSyncStatus.js b/client/src/hooks/useAccountSyncStatus.jsindex 1b3a03822c..e4e60490e2 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, isStandaloneCompletion }) {+export function useAccountSyncStatus({ eventPrefix, label, successText, onRefresh, onStart, onTerminal, isStandaloneCompletion, getAccountName }) {const [syncing, setSyncing] = useState({});const mounted = useMounted();const cycles = useRef(new Map());const callbacks = useRef({});- callbacks.current = { label, successText, onRefresh, onStart, onTerminal, isStandaloneCompletion };+ callbacks.current = { label, successText, onRefresh, onStart, onTerminal, isStandaloneCompletion, getAccountName };const begin = useCallback((accountId, manual = false) => {const cycle = { awaitingStart: manual, settled: false };@@ -58,7 +58,8 @@ export function useAccountSyncStatus({ eventPrefix, label, successText, onRefressetSyncing(prev => ({ ...prev, [accountId]: terminal.auth ? 'auth-required' : null }));current.onTerminal?.(accountId);}- toast[terminal.type](terminal.text);+ const accountName = current.getAccountName?.(accountId);+ toast[terminal.type](accountName ? `${accountName}: ${terminal.text}` : terminal.text);if (terminal.refresh) current.onRefresh?.();}, [mounted]);