Skip to content

Turn meetings into live agent loops. Record, transcribe, and analyze meetings with real-time AI intelligence — before, during, and after calls.

feat: notification and meeting events handling

Om Gated2ebcff4982a
diff --git a/src/main/ipc/calendar.ts b/src/main/ipc/calendar.ts
index 2a2d28e..eea583f 100644
--- a/src/main/ipc/calendar.ts
+++ b/src/main/ipc/calendar.ts
@@ -18,6 +18,7 @@ import type {
CalendarSignInResult,
CalendarEventsResult,
CalendarAuthStatusResult,
+ UpcomingMeeting,
} from '../../shared/types/calendar.types';
const logger = createChildLogger('ipc-calendar');
@@ -107,6 +108,13 @@ export function setupCalendarHandlers(): void {
}
});
+ ipcMain.handle('calendar:set-recording-meeting', async (_event, eventId: string | null): Promise<{ success: boolean }> => {
+ logger.info({ eventId }, 'Setting recording meeting');
+ const poller = getCalendarPoller();
+ poller.setCurrentRecordingEvent(eventId);
+ return { success: true };
+ });
+
// Set up event forwarding from poller
const poller = getCalendarPoller();
@@ -119,6 +127,21 @@ export function setupCalendarHandlers(): void {
sendToRenderer('calendar:events-updated', events);
});
+ poller.on('open-meeting-setup', (meeting) => {
+ logger.info({ meetingId: meeting.id }, 'Opening meeting setup from notification');
+ sendToRenderer('calendar:open-meeting-setup', meeting);
+ });
+
+ poller.on('auto-start-recording', (meeting) => {
+ logger.info({ meetingId: meeting.id }, 'Auto-starting recording from notification');
+ sendToRenderer('calendar:auto-start-recording', meeting);
+ });
+
+ poller.on('overlapping-meeting', (data) => {
+ logger.info({ nextMeetingId: data.nextMeeting.id }, 'Overlapping meeting notification');
+ sendToRenderer('calendar:overlapping-meeting', data);
+ });
+
logger.info('Calendar IPC handlers registered');
}
@@ -127,6 +150,7 @@ export function removeCalendarHandlers(): void {
ipcMain.removeHandler('calendar:sign-out');
ipcMain.removeHandler('calendar:is-signed-in');
ipcMain.removeHandler('calendar:get-events');
+ ipcMain.removeHandler('calendar:set-recording-meeting');
logger.info('Calendar IPC handlers removed');
}
diff --git a/src/main/services/calendar-poller.service.ts b/src/main/services/calendar-poller.service.ts
index e4b0b06..a5414b9 100644
--- a/src/main/services/calendar-poller.service.ts
+++ b/src/main/services/calendar-poller.service.ts
@@ -1,13 +1,19 @@
/**
* Calendar Poller Service
*
- * Polls Google Calendar every 60 seconds and shows native notifications
- * for meetings starting within 2 minutes.
+ * Polls Google Calendar every 20 seconds and shows native notifications
+ * for meetings based on user's recording preferences.
+ *
+ * Notification Behaviors:
+ * - always_ask: Shows "Start Now" / "Don't Record" buttons, click opens MeetingSetupFlow
+ * - default_record: Auto-records at meeting start, "Don't Record" to skip
+ * - no_notification: No notifications shown
+ *
+ * Also handles overlapping meetings (when recording + new meeting in <5 mins)
*/
-import { Notification, BrowserWindow } from 'electron';
+import { Notification, BrowserWindow, app } from 'electron';
import { EventEmitter } from 'events';
-import path from 'path';
import { logger } from '../lib/logger';
import { fetchUpcomingEvents, CalendarAuthError } from './google-calendar.service';
import { isAuthenticated } from './google-auth.service';
@@ -21,13 +27,17 @@ const log = logger.child({ module: 'calendar-poller' });
const POLL_INTERVAL_MS = 20_000; // 20 seconds
const DEFAULT_NOTIFY_MINUTES_BEFORE = 2; // Default: notify 2 minutes before meeting
const UPCOMING_HOURS = 24; // Fetch events within next 24 hours
+const OVERLAPPING_THRESHOLD_MINS = 5; // Show overlapping notification if next meeting in <5 mins
class CalendarPollerService extends EventEmitter {
private pollInterval: NodeJS.Timeout | null = null;
private notifiedEventIds: Set<string> = new Set();
+ private skippedEventIds: Set<string> = new Set(); // User clicked "Don't Record"
+ private autoRecordTimers: Map<string, NodeJS.Timeout> = new Map(); // Scheduled auto-records
private cachedEvents: UpcomingMeeting[] = [];
private mainWindow: BrowserWindow | null = null;
private isPolling: boolean = false;
+ private currentRecordingEventId: string | null = null; // Track which meeting we're recording
/**
* Set the main window reference for showing on notification click
@@ -36,6 +46,20 @@ class CalendarPollerService extends EventEmitter {
this.mainWindow = window;
}
+ /**
+ * Set the currently recording event (called when recording starts)
+ */
+ setCurrentRecordingEvent(eventId: string | null): void {
+ this.currentRecordingEventId = eventId;
+ }
+
+ /**
+ * Check if currently recording
+ */
+ isRecording(): boolean {
+ return this.currentRecordingEventId !== null;
+ }
+
/**
* Start polling for calendar events
*/
@@ -74,6 +98,14 @@ class CalendarPollerService extends EventEmitter {
clearInterval(this.pollInterval);
this.pollInterval = null;
}
+
+ // Clear all scheduled auto-record timers
+ for (const [eventId, timer] of this.autoRecordTimers) {
+ clearTimeout(timer);
+ log.debug({ eventId }, 'Cancelled auto-record timer');
+ }
+ this.autoRecordTimers.clear();
+
this.isPolling = false;
this.cachedEvents = [];
log.info('Stopped calendar polling');
@@ -105,23 +137,26 @@ class CalendarPollerService extends EventEmitter {
const notifyMinutes = prefs?.notifyMinutesBefore ?? DEFAULT_NOTIFY_MINUTES_BEFORE;
const recordingBehavior = prefs?.recordingBehavior ?? 'always_ask';
+ // Fetch upcoming events
+ this.cachedEvents = await fetchUpcomingEvents(UPCOMING_HOURS);
+
+ // Prune old notification IDs (events that have passed)
+ this.pruneOldNotifications();
+
// If user chose "no_notification", skip notifications entirely
if (recordingBehavior === 'no_notification') {
log.debug('Recording behavior is no_notification - skipping notifications');
- // Still fetch events for other purposes (e.g., tray display)
- this.cachedEvents = await fetchUpcomingEvents(UPCOMING_HOURS);
this.emit('events-updated', this.cachedEvents);
return;
}
- // Fetch upcoming events
- this.cachedEvents = await fetchUpcomingEvents(UPCOMING_HOURS);
-
- // Prune old notification IDs (events that have passed)
- this.pruneOldNotifications();
+ // Check for overlapping meeting situation first
+ if (this.isRecording()) {
+ this.checkForOverlappingMeeting();
+ }
// Check for events starting soon
- const toNotify = this.checkForUpcomingNotifications(notifyMinutes, recordingBehavior);
+ const toNotify = this.checkForUpcomingNotifications(notifyMinutes);
// Send notifications
for (const event of toNotify) {
@@ -148,7 +183,7 @@ class CalendarPollerService extends EventEmitter {
/**
* Check for events that should trigger a notification
*/
- private checkForUpcomingNotifications(notifyMinutes: number, recordingBehavior: RecordingBehavior): UpcomingMeeting[] {
+ private checkForUpcomingNotifications(notifyMinutes: number): UpcomingMeeting[] {
const toNotify: UpcomingMeeting[] = [];
const thresholdMs = notifyMinutes * 60 * 1000;
@@ -156,6 +191,9 @@ class CalendarPollerService extends EventEmitter {
// Skip all-day events
if (event.isAllDay) continue;
+ // Skip events user has declined to record
+ if (this.skippedEventIds.has(event.id)) continue;
+
const msUntil = event.startTime.getTime() - Date.now();
// Event is starting within threshold and we haven't notified yet
@@ -168,17 +206,65 @@ class CalendarPollerService extends EventEmitter {
return toNotify;
}
+ /**
+ * Check for overlapping meeting scenario
+ * When recording + next meeting starts in < 5 mins
+ */
+ private checkForOverlappingMeeting(): void {
+ // Find the next upcoming meeting (not the one we're recording)
+ const nextMeeting = this.cachedEvents.find(event => {
+ if (event.isAllDay) return false;
+ if (event.id === this.currentRecordingEventId) return false;
+ if (this.skippedEventIds.has(event.id)) return false;
+
+ const msUntil = event.startTime.getTime() - Date.now();
+ return msUntil > 0 && msUntil <= OVERLAPPING_THRESHOLD_MINS * 60 * 1000;
+ });
+
+ if (nextMeeting && !this.notifiedEventIds.has(`overlap-${nextMeeting.id}`)) {
+ this.notifiedEventIds.add(`overlap-${nextMeeting.id}`);
+ this.sendOverlappingMeetingNotification(nextMeeting);
+ }
+ }
+
/**
* Prune notification IDs for events that have passed
*/
private pruneOldNotifications(): void {
const currentIds = new Set(this.cachedEvents.map(e => e.id));
+ const now = Date.now();
for (const id of this.notifiedEventIds) {
+ // Keep overlap IDs a bit longer
+ if (id.startsWith('overlap-')) {
+ const eventId = id.replace('overlap-', '');
+ if (!currentIds.has(eventId)) {
+ this.notifiedEventIds.delete(id);
+ }
+ continue;
+ }
+
if (!currentIds.has(id)) {
this.notifiedEventIds.delete(id);
}
}
+
+ // Also clean up skipped events that have passed
+ for (const id of this.skippedEventIds) {
+ const event = this.cachedEvents.find(e => e.id === id);
+ if (!event || event.startTime.getTime() < now) {
+ this.skippedEventIds.delete(id);
+ }
+ }
+
+ // Cancel auto-record timers for events that have passed
+ for (const [eventId, timer] of this.autoRecordTimers) {
+ const event = this.cachedEvents.find(e => e.id === eventId);
+ if (!event || event.startTime.getTime() < now) {
+ clearTimeout(timer);
+ this.autoRecordTimers.delete(eventId);
+ }
+ }
}
/**
@@ -186,14 +272,6 @@ class CalendarPollerService extends EventEmitter {
*/
private sendEventNotification(event: UpcomingMeeting, recordingBehavior: RecordingBehavior): void {
const minutes = event.minutesUntil;
- let body = minutes <= 1 ? 'Starting now' : `Starts in ${minutes} minute${minutes === 1 ? '' : 's'}`;
-
- // Add recording hint based on behavior
- if (recordingBehavior === 'default_record') {
- body += ' - Will auto-record';
- } else if (recordingBehavior === 'always_ask') {
- body += ' - Click to record';
- }
// Check if notifications are supported
if (!Notification.isSupported()) {
@@ -209,15 +287,51 @@ class CalendarPollerService extends EventEmitter {
notificationSupported: Notification.isSupported(),
}, 'Sending notification');
+ if (recordingBehavior === 'always_ask') {
+ this.sendAlwaysAskNotification(event, minutes);
+ } else if (recordingBehavior === 'default_record') {
+ this.sendDefaultRecordNotification(event, minutes);
+ }
+ }
+
+ /**
+ * Send notification for "always_ask" behavior
+ * Buttons: "Start Now" / "Don't Record"
+ * Click body: Open MeetingSetupFlow
+ */
+ private sendAlwaysAskNotification(event: UpcomingMeeting, minutes: number): void {
+ const body = minutes <= 1
+ ? `Starting now. Would you like to record it?`
+ : `Starting in ${minutes} minute${minutes === 1 ? '' : 's'}. Would you like to record it?`;
+
const notification = new Notification({
title: event.summary,
body,
urgency: 'critical',
+ actions: [
+ { type: 'button', text: 'Start Now' },
+ { type: 'button', text: "Don't Record" },
+ ],
+ });
+
+ notification.on('action', (_e, index) => {
+ if (index === 0) {
+ // "Start Now" - skip UX, start recording immediately
+ log.info({ eventId: event.id }, 'User clicked Start Now');
+ this.showMainWindow();
+ this.emit('auto-start-recording', event);
+ } else if (index === 1) {
+ // "Don't Record" - skip this meeting
+ log.info({ eventId: event.id }, 'User clicked Don\'t Record');
+ this.skippedEventIds.add(event.id);
+ }
});
notification.on('click', () => {
- log.info({ eventId: event.id }, 'Notification clicked');
+ // Click on notification body - open MeetingSetupFlow
+ log.info({ eventId: event.id }, 'Notification clicked - opening meeting setup');
this.showMainWindow();
+ this.emit('open-meeting-setup', event);
});
notification.on('show', () => {
@@ -236,6 +350,165 @@ class CalendarPollerService extends EventEmitter {
log.debug({ eventId: event.id }, 'notification.show() called');
}
+ /**
+ * Send notification for "default_record" behavior
+ * Shows warning, auto-records at meeting start
+ * Button: "Don't Record"
+ */
+ private sendDefaultRecordNotification(event: UpcomingMeeting, minutes: number): void {
+ const body = minutes <= 1
+ ? `Starting now. Recording will start automatically.`
+ : `Starting in ${minutes} minute${minutes === 1 ? '' : 's'}. Recording will start automatically.`;
+
+ const notification = new Notification({
+ title: event.summary,
+ body,
+ urgency: 'critical',
+ actions: [
+ { type: 'button', text: "Don't Record" },
+ ],
+ });
+
+ // Schedule auto-record at meeting start time
+ this.scheduleAutoRecord(event);
+
+ notification.on('action', (_e, index) => {
+ if (index === 0) {
+ // "Don't Record" - cancel auto-record and skip this meeting
+ log.info({ eventId: event.id }, 'User clicked Don\'t Record - cancelling auto-record');
+ this.skippedEventIds.add(event.id);
+ this.cancelAutoRecord(event.id);
+ }
+ });
+
+ notification.on('click', () => {
+ // Click on notification body - just open app (recording will auto-start)
+ log.info({ eventId: event.id }, 'Notification clicked - opening app');
+ this.showMainWindow();
+ });
+
+ notification.on('show', () => {
+ log.info({ eventId: event.id }, 'Notification shown');
+ });
+
+ notification.on('failed', (error) => {
+ log.error({ eventId: event.id, error }, 'Notification failed');
+ });
+
+ notification.show();
+ log.debug({ eventId: event.id }, 'notification.show() called');
+ }
+
+ /**
+ * Send notification for overlapping meeting scenario
+ * When user is recording and a new meeting starts soon
+ */
+ private sendOverlappingMeetingNotification(nextMeeting: UpcomingMeeting): void {
+ const minutes = nextMeeting.minutesUntil;
+ const body = `"${nextMeeting.summary}" starts in ${minutes} minute${minutes === 1 ? '' : 's'}. What would you like to do?`;
+
+ const notification = new Notification({
+ title: 'Next meeting starting soon',
+ body,
+ urgency: 'critical',
+ actions: [
+ { type: 'button', text: 'Remind in 5 mins' },
+ { type: 'button', text: 'Stop & Start Next' },
+ ],
+ });
+
+ notification.on('action', (_e, index) => {
+ if (index === 0) {
+ // "Remind in 5 mins" - snooze
+ log.info({ eventId: nextMeeting.id }, 'User clicked Remind in 5 mins');
+ // Remove the overlap notification marker so it can be shown again
+ setTimeout(() => {
+ this.notifiedEventIds.delete(`overlap-${nextMeeting.id}`);
+ }, 5 * 60 * 1000);
+ } else if (index === 1) {
+ // "Stop & Start Next" - emit event for renderer to handle
+ log.info({ eventId: nextMeeting.id }, 'User clicked Stop & Start Next');
+ this.showMainWindow();
+
+ // Find current meeting info
+ const currentMeeting = this.currentRecordingEventId
+ ? this.cachedEvents.find(e => e.id === this.currentRecordingEventId)
+ : undefined;
+
+ this.emit('overlapping-meeting', {
+ currentMeeting,
+ nextMeeting,
+ });
+ }
+ });
+
+ notification.on('click', () => {
+ log.info({ eventId: nextMeeting.id }, 'Overlapping notification clicked');
+ this.showMainWindow();
+ });
+
+ notification.show();
+ log.info({ eventId: nextMeeting.id }, 'Overlapping meeting notification shown');
+ }
+
+ /**
+ * Schedule auto-record at meeting start time
+ */
+ private scheduleAutoRecord(event: UpcomingMeeting): void {
+ // Don't schedule if already scheduled
+ if (this.autoRecordTimers.has(event.id)) {
+ log.debug({ eventId: event.id }, 'Auto-record already scheduled');
+ return;
+ }
+
+ const msUntilStart = event.startTime.getTime() - Date.now();
+
+ if (msUntilStart <= 0) {
+ // Meeting already started - trigger immediately (if not already recording)
+ if (!this.isRecording()) {
+ log.info({ eventId: event.id }, 'Meeting already started - triggering auto-record now');
+ this.showMainWindow();
+ this.emit('auto-start-recording', event);
+ }
+ return;
+ }
+
+ log.info({ eventId: event.id, msUntilStart }, 'Scheduling auto-record');
+
+ const timer = setTimeout(() => {
+ this.autoRecordTimers.delete(event.id);
+
+ // Check if user skipped this meeting or if we're already recording
+ if (this.skippedEventIds.has(event.id)) {
+ log.info({ eventId: event.id }, 'Skipping auto-record - user declined');
+ return;
+ }
+
+ if (this.isRecording()) {
+ log.info({ eventId: event.id }, 'Skipping auto-record - already recording');
+ return;
+ }
+
+ log.info({ eventId: event.id }, 'Auto-record timer fired - starting recording');
+ this.showMainWindow();
+ this.emit('auto-start-recording', event);
+ }, msUntilStart);
+
+ this.autoRecordTimers.set(event.id, timer);
+ }
+
+ /**
+ * Cancel a scheduled auto-record
+ */
+ private cancelAutoRecord(eventId: string): void {
+ const timer = this.autoRecordTimers.get(eventId);
+ if (timer) {
+ clearTimeout(timer);
+ this.autoRecordTimers.delete(eventId);
+ log.info({ eventId }, 'Cancelled auto-record');
+ }
+ }
+
/**
* Show and focus the main window
*/
@@ -250,7 +523,6 @@ class CalendarPollerService extends EventEmitter {
// On macOS, also show the dock icon
if (process.platform === 'darwin') {
- const { app } = require('electron');
app.dock?.show();
}
}
@@ -260,7 +532,16 @@ class CalendarPollerService extends EventEmitter {
*/
reset(): void {
this.notifiedEventIds.clear();
+ this.skippedEventIds.clear();
+
+ // Clear all auto-record timers
+ for (const timer of this.autoRecordTimers.values()) {
+ clearTimeout(timer);
+ }
+ this.autoRecordTimers.clear();
+
this.cachedEvents = [];
+ this.currentRecordingEventId = null;
}
}
diff --git a/src/main/services/google-calendar.service.ts b/src/main/services/google-calendar.service.ts
index 1f7a141..a251e73 100644
--- a/src/main/services/google-calendar.service.ts
+++ b/src/main/services/google-calendar.service.ts
@@ -119,6 +119,7 @@ function toUpcomingMeeting(event: CalendarEvent): UpcomingMeeting | null {
return {
id: event.id,
summary: event.summary || 'No title',
+ description: event.description,
startTime,
endTime,
minutesUntil,
diff --git a/src/main/services/tray.service.ts b/src/main/services/tray.service.ts
index 2481ff3..7794cdf 100644
--- a/src/main/services/tray.service.ts
+++ b/src/main/services/tray.service.ts
@@ -104,6 +104,9 @@ class TrayService {
label,
click: () => {
this.showMainWindow();
+ // Emit event to open MeetingSetupFlow with this meeting's data
+ const poller = getCalendarPoller();
+ poller.emit('open-meeting-setup', event);
},
});
}
diff --git a/src/preload/index.ts b/src/preload/index.ts
index d5771b6..da596e3 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -540,6 +540,8 @@ const api: IpcApi = {
isSignedIn: (): Promise<CalendarAuthStatusResult> => ipcRenderer.invoke('calendar:is-signed-in'),
getUpcomingEvents: (hours?: number): Promise<CalendarEventsResult> =>
ipcRenderer.invoke('calendar:get-events', hours),
+ setRecordingMeeting: (eventId: string | null): Promise<{ success: boolean }> =>
+ ipcRenderer.invoke('calendar:set-recording-meeting', eventId),
} as CalendarApi,
// Calendar event listeners
@@ -554,6 +556,21 @@ const api: IpcApi = {
ipcRenderer.on('calendar:events-updated', listener);
return () => ipcRenderer.removeListener('calendar:events-updated', listener);
},
+ onOpenMeetingSetup: (callback: (meeting: UpcomingMeeting) => void) => {
+ const listener = (_event: Electron.IpcRendererEvent, data: UpcomingMeeting) => callback(data);
+ ipcRenderer.on('calendar:open-meeting-setup', listener);
+ return () => ipcRenderer.removeListener('calendar:open-meeting-setup', listener);
+ },
+ onAutoStartRecording: (callback: (meeting: UpcomingMeeting) => void) => {
+ const listener = (_event: Electron.IpcRendererEvent, data: UpcomingMeeting) => callback(data);
+ ipcRenderer.on('calendar:auto-start-recording', listener);
+ return () => ipcRenderer.removeListener('calendar:auto-start-recording', listener);
+ },
+ onOverlappingMeeting: (callback: (data: { currentMeeting?: UpcomingMeeting; nextMeeting: UpcomingMeeting }) => void) => {
+ const listener = (_event: Electron.IpcRendererEvent, data: { currentMeeting?: UpcomingMeeting; nextMeeting: UpcomingMeeting }) => callback(data);
+ ipcRenderer.on('calendar:overlapping-meeting', listener);
+ return () => ipcRenderer.removeListener('calendar:overlapping-meeting', listener);
+ },
} as CalendarEvents,
// Workflows API
diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx
index 1afda8c..f0b263d 100644
--- a/src/renderer/App.tsx
+++ b/src/renderer/App.tsx
@@ -503,10 +503,15 @@ export function App() {
const [activeTab, setActiveTab] = useState<Tab>('home');
const [showRecordingPrefs, setShowRecordingPrefs] = useState(false);
const [showMeetingSetup, setShowMeetingSetup] = useState(false);
+ const [pendingOverlap, setPendingOverlap] = useState<{
+ currentMeeting?: { id: string; summary: string };
+ nextMeeting: { id: string; summary: string; description?: string };
+ } | null>(null);
const configStore = useConfigStore();
const sessionStore = useSessionStore();
- const { status: sessionStatus } = useSession();
+ const meetingSetupStore = useMeetingSetupStore();
+ const { status: sessionStatus, startRecording, stopRecording } = useSession();
const { allGranted, loading: permissionsLoading } = usePermissions();
// Global listener for recorder events - persists during navigation
@@ -514,6 +519,107 @@ export function App() {
const isAuthenticated = configStore.isAuthenticated();
+ // Listen for calendar notification events
+ React.useEffect(() => {
+ if (!isAuthenticated) return;
+
+ // Handle "open meeting setup" from notification/tray click
+ const unsubOpenSetup = window.electronAPI.calendarOn.onOpenMeetingSetup((meeting) => {
+ // Pre-fill the meeting setup store with meeting data
+ meetingSetupStore.reset();
+ meetingSetupStore.setInfo(meeting.summary, meeting.description || '');
+
+ // Switch to home tab and show meeting setup
+ setActiveTab('home');
+ setShowMeetingSetup(true);
+ });
+
+ // Handle "auto-start recording" from notification or default_record behavior
+ const unsubAutoStart = window.electronAPI.calendarOn.onAutoStartRecording(async (meeting) => {
+ // Skip UX entirely - start recording with meeting name
+ meetingSetupStore.reset();
+ meetingSetupStore.setInfo(meeting.summary, meeting.description || '');
+
+ // Ensure we're on home tab
+ setActiveTab('home');
+
+ // Notify main process about which meeting we're recording (for overlapping detection)
+ await window.electronAPI.calendar.setRecordingMeeting(meeting.id);
+
+ // Start recording directly with meeting data
+ await startRecording({
+ name: meeting.summary,
+ description: meeting.description || '',
+ questions: [],
+ checklist: [],
+ });
+ });
+
+ // Handle overlapping meeting notification
+ const unsubOverlap = window.electronAPI.calendarOn.onOverlappingMeeting((data) => {
+ // Store the overlap data for handling
+ setPendingOverlap({
+ currentMeeting: data.currentMeeting ? {
+ id: data.currentMeeting.id,
+ summary: data.currentMeeting.summary,
+ } : undefined,
+ nextMeeting: {
+ id: data.nextMeeting.id,
+ summary: data.nextMeeting.summary,
+ description: data.nextMeeting.description,
+ },
+ });
+ });
+
+ return () => {
+ unsubOpenSetup();
+ unsubAutoStart();
+ unsubOverlap();
+ };
+ }, [isAuthenticated, meetingSetupStore, startRecording]);
+
+ // Handle pending overlap action (stop current, start next)
+ React.useEffect(() => {
+ const handleOverlap = async () => {
+ if (!pendingOverlap) return;
+
+ const { nextMeeting } = pendingOverlap;
+
+ // Stop current recording
+ await stopRecording();
+
+ // Clear the current recording meeting
+ await window.electronAPI.calendar.setRecordingMeeting(null);
+
+ // Wait a moment for recording to fully stop
+ await new Promise(resolve => setTimeout(resolve, 500));
+
+ // Notify main process about new meeting we're recording
+ await window.electronAPI.calendar.setRecordingMeeting(nextMeeting.id);
+
+ // Start recording with next meeting
+ await startRecording({
+ name: nextMeeting.summary,
+ description: nextMeeting.description || '',
+ questions: [],
+ checklist: [],
+ });
+
+ setPendingOverlap(null);
+ };
+
+ if (pendingOverlap) {
+ handleOverlap();
+ }
+ }, [pendingOverlap, stopRecording, startRecording]);
+
+ // Clear recording meeting when session becomes idle
+ React.useEffect(() => {
+ if (sessionStatus === 'idle') {
+ window.electronAPI.calendar.setRecordingMeeting(null);
+ }
+ }, [sessionStatus]);
+
// Handle clearing session errors
const handleDismissError = () => {
sessionStore.setError(null);
diff --git a/src/shared/types/calendar.types.ts b/src/shared/types/calendar.types.ts
index 4289858..485b899 100644
--- a/src/shared/types/calendar.types.ts
+++ b/src/shared/types/calendar.types.ts
@@ -61,6 +61,7 @@ export interface CalendarEvent {
export interface UpcomingMeeting {
id: string;
summary: string;
+ description?: string;
startTime: Date;
endTime: Date;
minutesUntil: number;
@@ -109,9 +110,16 @@ export interface CalendarApi {
signOut: () => Promise<{ success: boolean; error?: string }>;
isSignedIn: () => Promise<CalendarAuthStatusResult>;
getUpcomingEvents: (hours?: number) => Promise<CalendarEventsResult>;
+ // Notify poller about recording state (for overlapping meeting detection)
+ setRecordingMeeting: (eventId: string | null) => Promise<{ success: boolean }>;
}
export interface CalendarEvents {
onAuthRequired: (callback: () => void) => () => void;
onEventsUpdated: (callback: (events: UpcomingMeeting[]) => void) => () => void;
+ // Notification action events
+ onOpenMeetingSetup: (callback: (meeting: UpcomingMeeting) => void) => () => void;
+ onAutoStartRecording: (callback: (meeting: UpcomingMeeting) => void) => () => void;
+ // Overlapping meeting event (recording active + new meeting starting)
+ onOverlappingMeeting: (callback: (data: { currentMeeting?: UpcomingMeeting; nextMeeting: UpcomingMeeting }) => void) => () => void;
}