Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(calendar): only show the Now badge for real meetings (#7820)

teo9a84e41777ca
diff --git a/apps/web/src/components/app/sidebar-next/queries/use-next-meeting-badge.ts b/apps/web/src/components/app/sidebar-next/queries/use-next-meeting-badge.ts
index d199cfe146..4bd9e1b849 100644
--- a/apps/web/src/components/app/sidebar-next/queries/use-next-meeting-badge.ts
+++ b/apps/web/src/components/app/sidebar-next/queries/use-next-meeting-badge.ts
@@ -10,7 +10,7 @@ import { createMemo } from 'solid-js';
* The Calendar button's badge: `Now` during a meeting, minutes until the next
* one when it is under an hour away. Reads the same visible calendars and
* upcoming-events source as the calendar view's agenda, so a calendar hidden
- * there never counts here. Mount it only where Calendar is on the rail — it
+ * there never counts here; only meetings count, not every agenda entry. Mount it only where Calendar is on the rail — it
* starts fetching on mount.
*/
export function useNextMeetingBadge() {
diff --git a/apps/web/src/features/calendar/types.ts b/apps/web/src/features/calendar/types.ts
index 3964491c00..d81a389efc 100644
--- a/apps/web/src/features/calendar/types.ts
+++ b/apps/web/src/features/calendar/types.ts
@@ -3,6 +3,7 @@ import type { CalendarAttendee } from '@service-storage/generated/schemas/calend
import type { CalendarEventSourceContent } from '@service-storage/generated/schemas/calendarEventSourceContent';
import type { CalendarOccurrenceItem } from '@service-storage/generated/schemas/calendarOccurrenceItem';
import type { EventReminders } from '@service-storage/generated/schemas/eventReminders';
+import type { EventTransparency } from '@service-storage/generated/schemas/eventTransparency';
import type { EventType } from '@service-storage/generated/schemas/eventType';
import {
isTimedPointEvent,
@@ -97,6 +98,8 @@ export interface CalendarEvent {
reminderEventType?: EventType;
/** Provider event type; absent means a regular event. */
eventType?: EventType;
+ /** `transparent` events show the owner as free; absent means busy. */
+ transparency?: EventTransparency;
/** Calendar of the copy this chip shows. Mutations address that copy. */
calendarId?: string;
/**
@@ -261,6 +264,7 @@ export function mapCalendarOccurrence(
reminderCalendarId: canonical.calendarId ?? undefined,
reminderEventType: canonical.eventType ?? undefined,
eventType: content.eventType ?? undefined,
+ transparency: content.transparency,
calendarId,
sourceCalendarIds: sources.map((candidate) => candidate.calendarId),
timeZone: time.kind === 'timed' ? (time.timeZone ?? undefined) : undefined,
diff --git a/apps/web/src/features/meetings/core/next-meeting-badge.test.ts b/apps/web/src/features/meetings/core/next-meeting-badge.test.ts
index 7d4a04d8e4..adebb7df0b 100644
--- a/apps/web/src/features/meetings/core/next-meeting-badge.test.ts
+++ b/apps/web/src/features/meetings/core/next-meeting-badge.test.ts
@@ -17,6 +17,7 @@ const event = (
allDay: false,
eventId: `${start}-${end}`,
occurrenceKey: '',
+ isMeeting: true,
...overrides,
});
@@ -125,6 +126,33 @@ describe('nextMeetingBadge', () => {
).toBeUndefined();
});
+ it('ignores events that are not meetings', () => {
+ expect(
+ nextMeetingBadge(
+ [
+ event('2026-10-07T14:00:00Z', '2026-10-07T18:00:00Z', {
+ isMeeting: false,
+ }),
+ event('2026-10-07T15:10:00Z', '2026-10-07T15:30:00Z', {
+ isMeeting: false,
+ }),
+ ],
+ NOW
+ )
+ ).toBeUndefined();
+ expect(
+ nextMeetingBadge(
+ [
+ event('2026-10-07T14:00:00Z', '2026-10-07T18:00:00Z', {
+ isMeeting: false,
+ }),
+ event('2026-10-07T15:25:00Z', '2026-10-07T15:30:00Z'),
+ ],
+ NOW
+ )
+ ).toMatchObject({ kind: 'soon', label: '25m' });
+ });
+
it('ignores events with unparseable or inverted times', () => {
expect(
nextMeetingBadge(
diff --git a/apps/web/src/features/meetings/core/next-meeting-badge.ts b/apps/web/src/features/meetings/core/next-meeting-badge.ts
index e2c47483ca..300ffb97ba 100644
--- a/apps/web/src/features/meetings/core/next-meeting-badge.ts
+++ b/apps/web/src/features/meetings/core/next-meeting-badge.ts
@@ -8,9 +8,9 @@ export type NextMeetingBadge =
| { kind: 'soon'; label: string; minutes: number };
/**
- * The sidebar badge for the current moment: `Now` while a timed event is in
- * progress, else the minutes until the next timed event when it is under an
- * hour away. All-day events are ignored — they never mark a meeting.
+ * The sidebar badge for the current moment: `Now` while a timed meeting is in
+ * progress, else the minutes until the next timed meeting when it is under an
+ * hour away. All-day events and non-meetings are ignored.
*/
export function nextMeetingBadge(
events: readonly UpcomingCalendarEvent[],
@@ -19,7 +19,7 @@ export function nextMeetingBadge(
const nowMs = now.getTime();
let soonest = Number.POSITIVE_INFINITY;
for (const event of events) {
- if (event.allDay) continue;
+ if (event.allDay || !event.isMeeting) continue;
const start = Date.parse(event.start);
const end = Date.parse(event.end);
if (!Number.isFinite(start) || !Number.isFinite(end) || end < start) {
diff --git a/apps/web/src/features/meetings/core/upcoming-calendar-events.test.ts b/apps/web/src/features/meetings/core/upcoming-calendar-events.test.ts
index 16e90012ba..da88c16faf 100644
--- a/apps/web/src/features/meetings/core/upcoming-calendar-events.test.ts
+++ b/apps/web/src/features/meetings/core/upcoming-calendar-events.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';
import {
isCalendarEventOngoing,
+ isMeetingEvent,
selectUpcomingCalendarEvents,
type UpcomingCalendarEvent,
} from './upcoming-calendar-events';
@@ -15,6 +16,57 @@ const call = (hour: number): UpcomingCalendarEvent => ({
start: `2026-09-23T${hour}:00:00Z`,
end: `2026-09-23T${hour + 1}:00:00Z`,
allDay: false,
+ isMeeting: true,
+});
+
+const guest = {
+ email: '[email protected]',
+ isSelf: false,
+ isOrganizer: false,
+ isOptional: false,
+ responseStatus: 'accepted' as const,
+};
+const self = { ...guest, email: '[email protected]', isSelf: true };
+const room = 'https://meet.google.com/one-room';
+
+describe('isMeetingEvent', () => {
+ it('counts busy regular events with a call link or another guest', () => {
+ expect(isMeetingEvent({ attendees: [] }, room)).toBe(true);
+ expect(
+ isMeetingEvent(
+ { eventType: 'default', transparency: 'opaque', attendees: [guest] },
+ undefined
+ )
+ ).toBe(true);
+ });
+
+ it('skips solo blocks without a call link', () => {
+ expect(isMeetingEvent({ attendees: [] }, undefined)).toBe(false);
+ expect(isMeetingEvent({ attendees: [self] }, undefined)).toBe(false);
+ });
+
+ it('skips events that show the viewer as free', () => {
+ expect(
+ isMeetingEvent(
+ { transparency: 'transparent', attendees: [self, guest] },
+ room
+ )
+ ).toBe(false);
+ });
+
+ it('skips status-style event types', () => {
+ for (const eventType of [
+ 'out_of_office',
+ 'focus_time',
+ 'working_location',
+ 'birthday',
+ 'from_gmail',
+ ] as const) {
+ expect(isMeetingEvent({ eventType, attendees: [guest] }, room)).toBe(
+ false
+ );
+ }
+ });
});
describe('upcoming calendar calls', () => {
diff --git a/apps/web/src/features/meetings/core/upcoming-calendar-events.ts b/apps/web/src/features/meetings/core/upcoming-calendar-events.ts
index 41ed4d2265..1c66fc7a1d 100644
--- a/apps/web/src/features/meetings/core/upcoming-calendar-events.ts
+++ b/apps/web/src/features/meetings/core/upcoming-calendar-events.ts
@@ -1,3 +1,5 @@
+import type { CalendarEvent } from '../../calendar/types';
+
/** One calendar occurrence, with an optional safe conference link. */
export type UpcomingCalendarEvent = {
id: string;
@@ -9,8 +11,26 @@ export type UpcomingCalendarEvent = {
allDay: boolean;
eventId: string;
occurrenceKey: string;
+ /** Whether the event is a busy meeting rather than a status or solo block. */
+ isMeeting: boolean;
};
+/**
+ * A meeting is a regular event that shows the viewer as busy and has a call
+ * link or someone else invited. Out of office, focus time, birthdays, Gmail
+ * reservations, free events, and solo blocks are not meetings.
+ */
+export function isMeetingEvent(
+ event: Pick<CalendarEvent, 'eventType' | 'transparency' | 'attendees'>,
+ url: string | undefined
+): boolean {
+ if (event.eventType !== undefined && event.eventType !== 'default') {
+ return false;
+ }
+ if (event.transparency === 'transparent') return false;
+ return Boolean(url) || event.attendees.some((person) => !person.isSelf);
+}
+
function timestamp(value: string, allDay: boolean) {
return Date.parse(allDay ? `${value}T00:00:00` : value);
}
diff --git a/apps/web/src/features/meetings/queries/upcoming-calendar-events.test.ts b/apps/web/src/features/meetings/queries/upcoming-calendar-events.test.ts
index 72c72d7363..4ada87ae26 100644
--- a/apps/web/src/features/meetings/queries/upcoming-calendar-events.test.ts
+++ b/apps/web/src/features/meetings/queries/upcoming-calendar-events.test.ts
@@ -271,6 +271,12 @@ describe('upcoming calendar events source', () => {
).toEqual(['event-4', 'event-5', 'event-6']);
expect(result.events()[1].url).toBeUndefined();
expect(result.events()[2].url).toBeUndefined();
+ expect(
+ result
+ .events()
+ .slice(0, 4)
+ .map((event) => event.isMeeting)
+ ).toEqual([false, false, false, true]);
expect(list).toHaveBeenCalledTimes(2);
expect(list.mock.calls[1][0].start).toBe(list.mock.calls[0][0].end);
});
diff --git a/apps/web/src/features/meetings/queries/upcoming-calendar-events.ts b/apps/web/src/features/meetings/queries/upcoming-calendar-events.ts
index 599e329d31..f19c399675 100644
--- a/apps/web/src/features/meetings/queries/upcoming-calendar-events.ts
+++ b/apps/web/src/features/meetings/queries/upcoming-calendar-events.ts
@@ -12,6 +12,7 @@ import {
import { safeConferenceUrl } from '../../calendar/utils/conference-link';
import { calendarMacroCallUrl } from '../../calendar/utils/macro-call-link';
import {
+ isMeetingEvent,
selectUpcomingCalendarEvents,
type UpcomingCalendarEvent,
} from '../core/upcoming-calendar-events';
@@ -85,21 +86,22 @@ export function useUpcomingCalendarEventsSource(options: SourceOptions) {
});
});
const events = createMemo(() =>
- calendarEvents().map(
- (event): UpcomingCalendarEvent => ({
+ calendarEvents().map((event): UpcomingCalendarEvent => {
+ const url =
+ calendarMacroCallUrl(event) ?? safeConferenceUrl(event.conferenceUrl);
+ return {
id: event.id,
title: event.title,
color: event.calendar.color,
- url:
- calendarMacroCallUrl(event) ??
- safeConferenceUrl(event.conferenceUrl),
+ url,
start: event.start,
end: event.end,
allDay: event.allDay,
eventId: event.eventId,
occurrenceKey: event.occurrenceKey,
- })
- )
+ isMeeting: isMeetingEvent(event, url),
+ };
+ })
);
windows.push({ query, enabled, events, calendarEvents });
}