Skip to content

Add calendar awareness to Pulse summaries - #483

Merged
2witstudios merged 2 commits into
masterfrom
claude/add-calendar-awareness-CyYxk
Feb 7, 2026
Merged

2witstudios merged 2 commits into
masterfrom
claude/add-calendar-awareness-CyYxk

Conversation

@2witstudios

@2witstudios 2witstudios commented Feb 7, 2026 •

Copy link
Copy Markdown
Owner

Pulse now includes calendar event data when generating AI summaries,
enabling time-sensitive observations like upcoming meetings, events
in progress, and pending RSVP invitations.

Changes:

  • Query calendarEvents and eventAttendees in both on-demand and cron
    generation routes to fetch events happening now, upcoming today,
    and tomorrow
  • Include pending RSVP invitations as context for gentle nudges
  • Add calendar section to AI context data with categorized events
  • Update system prompt with calendar awareness message type examples
  • Add calendar stats (upcomingToday, pendingInvites) to GET /api/pulse
    response for real-time stat display
  • Update PulseResponse type to include calendar stats

https://claude.ai/code/session_01X2zYjFPfB2Ha2k6HRYb2FT

Summary by CodeRabbit

  • New Features
    • Pulse now provides calendar-aware insights by incorporating upcoming calendar events.
    • Events happening now, later today, and tomorrow are integrated into pulse content to improve relevance.
    • Pulse summaries now surface calendar statistics (upcoming today, pending RSVPs) and include a small sample of events.
    • Calendar visibility respects personal and shared drive permissions when showing events.

Pulse now includes calendar event data when generating AI summaries,
enabling time-sensitive observations like upcoming meetings, events
in progress, and pending RSVP invitations.

Changes:
- Query calendarEvents and eventAttendees in both on-demand and cron
  generation routes to fetch events happening now, upcoming today,
  and tomorrow
- Include pending RSVP invitations as context for gentle nudges
- Add calendar section to AI context data with categorized events
- Update system prompt with calendar awareness message type examples
- Add calendar stats (upcomingToday, pendingInvites) to GET /api/pulse
  response for real-time stat display
- Update PulseResponse type to include calendar stats

https://claude.ai/code/session_01X2zYjFPfB2Ha2k6HRYb2FT
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Feb 7, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds calendar awareness to Pulse: new calendar-context module, system prompt extraction, calendar queries and counts, and integration of categorized calendar events into cron, on-demand generation, response payloads, and the pulse summary schema.

Changes

Cohort / File(s) Summary
Calendar context module
apps/web/src/app/api/pulse/calendar-context.ts
New fetchCalendarContext and PulseCalendarEvent interface: builds visibility filters, queries calendar events and attendee rows, deduplicates, sorts, and returns categorized lists (happeningNow, upcomingToday, tomorrow), pendingInvites, and allEvents.
Pulse generation (cron & on-demand)
apps/web/src/app/api/pulse/cron/route.ts, apps/web/src/app/api/pulse/generate/route.ts
Import fetchCalendarContext and PULSE_SYSTEM_PROMPT; compute endOfTomorrow; inject calendar data into contextData and system prompt payloads; add "CALENDAR EVENTS" section and include sample events and counts in final summary.
Pulse API response & counts
apps/web/src/app/api/pulse/route.ts
Adds stats.calendar (upcomingToday, pendingInvites) to PulseResponse; implements visibility-aware DB queries for upcoming events and pending invites and includes counts in responses.
System prompt extraction
apps/web/src/app/api/pulse/pulse-prompt.ts
New exported PULSE_SYSTEM_PROMPT constant containing the workspace-assistant system prompt; replaces large in-file prompt strings in generators.
Schema / DB types
packages/db/src/schema/dashboard.ts
Extends PulseSummary.contextData JSONB type to optionally include a calendar object with counts and an events array (title, startAt).
Manifest / package
manifest_file, package.json
Minor manifest/package metadata updates referenced by diffs (unchanged public APIs).

Sequence Diagram(s)

sequenceDiagram
  participant Cron as Cron Job
  participant Generate as Generate API
  participant Calendar as fetchCalendarContext
  participant DB as Database
  participant AI as AI Model
  participant Store as Pulse Store

  Cron->>DB: load users / drives
  Cron->>Calendar: fetchCalendarContext(userId, driveIds, now, endOfTomorrow)
  Calendar->>DB: query calendar_events & event_attendees
  DB-->>Calendar: return categorized events & invites
  Cron->>AI: send context + PULSE_SYSTEM_PROMPT + calendar section
  AI-->>Cron: generated pulse summary
  Cron->>Store: persist pulse summary (contextData includes calendar)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I scoped the day with a twitch and a hop,
Events and invites in a neat little hop—
I fetched what’s happening, tomorrow, and soon,
Poured them in pulses under moon and sun—
A rabbit-approved summary, short and bright! 🥕📅

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'Add calendar awareness to Pulse summaries' directly and clearly summarizes the main change: integrating calendar event data into the Pulse AI summary generation system.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/add-calendar-awareness-CyYxk

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In `@apps/web/src/app/api/pulse/cron/route.ts`:
- Around line 660-768: The calendar logic (calendarVisibility,
upcomingCalendarEvents, attendeeEventRows, pendingRsvps, merge/dedup, sorting,
and categorization) is duplicated and also ignores per-drive visibility
(PRIVATE) for non-creators; extract these into a shared helper (e.g.,
fetchCalendarContext(userId, driveIds, now, endOfToday, endOfTomorrow)) that
returns merged, deduped, sorted events plus pending RSVPs, then replace the
duplicated blocks in both cron/route.ts and generate/route.ts with calls to that
helper; while extracting, update the calendarVisibility construction used by
upcomingCalendarEvents and attendeeEventRows to explicitly exclude
calendarEvents with visibility = 'PRIVATE' unless eq(calendarEvents.createdById,
userId) or the driveId is in driveIds (i.e., only include drive events with
non-PRIVATE visibility or creator access), and ensure the helper accepts the
same parameters and enforces the same time bounds and limits used by
pendingRsvps.
- Line 32: The import symbol `lte` is unused in this module; remove `lte` from
the import list where it's declared (so the import statement no longer includes
`lte`) to eliminate the dead import and keep the file lint-clean—verify no other
references to `lte` (e.g., in functions or exports) exist before removing.

In `@apps/web/src/app/api/pulse/generate/route.ts`:
- Line 33: The import symbol `lte` is unused in the pulse generate route; remove
`lte` from the import list (the line that currently includes `lte`) so there are
no unused imports in the module and the linter stops flagging it.

In `@apps/web/src/app/api/pulse/route.ts`:
- Around line 172-203: The calendarVisibility logic currently uses driveIds to
include any event in those drives but ignores calendarEvents.visibility, leaking
PRIVATE/ATTENDEES_ONLY events; update the calendarVisibility construction so
that for the driveIds branch you only include drive-scoped events with
visibility = 'DRIVE' (or drive events the creator owns) and always exclude
calendarEvents with visibility = 'PRIVATE' unless eq(calendarEvents.createdById,
userId); additionally ensure ATTENDEES_ONLY events are not exposed via this
visibility filter (they should be returned only via attendeeEventRows or
eventAttendees joins) — update the calendarVisibility variable and the analogous
logic in the cron/generate handlers to combine checks on
calendarEvents.visibility, calendarEvents.createdById, driveIds, and membership
(via eventAttendees) so PRIVATE is creator-only and ATTENDEES_ONLY is limited to
creator and attendees.
🧹 Nitpick comments (1)
apps/web/src/app/api/pulse/generate/route.ts (1)

97-100: System prompt is duplicated across cron and generate routes.

Both PULSE_SYSTEM_PROMPT constants are identical (including the new calendar awareness section). This is a pre-existing concern amplified by the calendar additions — any future prompt tweak must be applied in two places. Consider extracting the prompt to a shared module (e.g., @/lib/ai/pulse-prompt.ts).

Comment thread apps/web/src/app/api/pulse/cron/route.ts Outdated
Comment thread apps/web/src/app/api/pulse/cron/route.ts
Comment thread apps/web/src/app/api/pulse/generate/route.ts Outdated
Comment thread apps/web/src/app/api/pulse/route.ts Outdated
…lication

- Remove unused `lte` imports from cron and generate routes (fixes lint/CI)
- Add `calendar` property to contextData schema type (fixes TS2769 build error)
- Extract shared `fetchCalendarContext` helper with visibility fix that excludes
  PRIVATE/ATTENDEES_ONLY events from other users in shared drives
- Apply same visibility fix to stats route (pulse/route.ts)
- Extract shared `PULSE_SYSTEM_PROMPT` to eliminate duplication across routes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@2witstudios
2witstudios merged commit 9f6e5a0 into master Feb 7, 2026
2 of 3 checks passed
@2witstudios
2witstudios deleted the claude/add-calendar-awareness-CyYxk branch March 11, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants