Skip to content

[MSD benchmark] feat: add calendar cache status and actions#10

Open
khaliqgant wants to merge 28 commits into
msd-benchmark-base/cal_dot_com/pr-22532from
msd-benchmark/cal_dot_com/pr-22532
Open

[MSD benchmark] feat: add calendar cache status and actions#10
khaliqgant wants to merge 28 commits into
msd-benchmark-base/cal_dot_com/pr-22532from
msd-benchmark/cal_dot_com/pr-22532

Conversation

@khaliqgant

Copy link
Copy Markdown

MSD benchmark PR recreated from Martian Code Review Bench.

Source PR: calcom#22532
Dataset: cal_dot_com
Original title: feat: add calendar cache status and actions

Summary

imagen imagen

This pull request introduces a new feature to manage calendar cache data, including the ability to view cache status and delete cached data. It also includes several supporting updates to repositories, APIs, and UI components. Below is a summary of the most important changes grouped by theme.

New Feature: Calendar Cache Management

  • Added a deleteCache mutation to the TRPC calendarsRouter, enabling users to delete cached calendar data by credential ID. ([packages/trpc/server/routers/viewer/calendars/_router.tsxR27-R33](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-9e053175cc6dfb5717313e0587a730fff132f9d3c1200204f0ce8dac53a19280R27-R33))
  • Introduced the deleteCacheHandler to handle cache deletion logic, including validation of user access to the specified credential. ([packages/trpc/server/routers/viewer/calendars/deleteCache.handler.tsR1-R33](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-572888b8e0555167a5787847f29d5a46623eff170491acc0654e916f5b4afd18R1-R33))
  • Updated the connectedCalendarsHandler to enrich calendar data with cache status (cacheUpdatedAt) by querying the CalendarCacheRepository. ([packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.tsR27-R39](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-3f6a556ad60f26d0162770fcd81b5bddeb6ab0437552ac792045c3cd2608d710R27-R39))

UI Enhancements

  • Created a new CredentialActionsDropdown component to display cache status and provide options to delete cached data or disconnect integrations. ([packages/features/apps/components/CredentialActionsDropdown.tsxR1-R134](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-c78273434b95ab8276bb5eb24d9bc088b10af029388bdcd08cbe478f44269b31R1-R134))
  • Replaced the DisconnectIntegration component with CredentialActionsDropdown in the SelectedCalendarsSettingsWebWrapper UI, integrating the new cache management functionality. ([[1]](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-831b0874e07f01721f87926262c5c9674ff9d7443741dfb71ceb849656345b00L5-R5), [[2]](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-831b0874e07f01721f87926262c5c9674ff9d7443741dfb71ceb849656345b00L70-L81), [[3]](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-831b0874e07f01721f87926262c5c9674ff9d7443741dfb71ceb849656345b00L125-L135))

Repository and Database Updates

  • Added a getCacheStatusByCredentialIds method to the CalendarCacheRepository and its mock implementation to fetch cache statuses for multiple credentials. ([[1]](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-b36c72c0db751ba0cafe234dfa150817672869825333c22b074c4977a6135b8dR30-R32), [[2]](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-ceffbae9ef3da413495feac73a341672e77ffaf493cf67ada0b637ead80ded38R26-R30), [[3]](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-4cf8d3089fad7b6c8fe4172d8d42147f136b65baf30b726e57b9b10d179d4a99R172-R188))
  • Introduced a new updateManyByCredentialId method in the SelectedCalendarRepository to update multiple calendars by credential ID. ([packages/lib/server/repository/selectedCalendar.tsR400-R406](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-ccb4eecfa701e5b0c7d6ba87dcc550cdf3700a63ee252849045611599ecb9273R400-R406))
  • Added an updatedAt column to the CalendarCache table in the database schema and Prisma model to track the last update timestamp. ([[1]](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-9f597bd98bbcfdcf4861ee7bf0c238e7dfe54b456ceb69b852aaf3979c4102cfR1-R8), [[2]](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-56fa4d384ba6fb94b130e9eb42c5cad00734b025ebd6c197f76873469725ae87R1718))

Localization and Strings

  • Added new localization strings for cache management actions, such as "Cache Status," "Delete cached data," and "Cache deleted successfully." ([apps/web/public/static/locales/en/common.jsonR3376-R3382](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-57de4b8e5231f1d699891d98b0381d56e9e24537b0ca5420d1fba4f0597370bcR3376-R3382))

Miscellaneous

  • Updated package.json to replace ts-node with npx tsx for running the dev:cron script. ([apps/web/package.jsonL11-R11](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-14b60f636e1a2b0061da57aaf231cb1ed15a5dc0c592425ed82e58fec95d42d8L11-R11))

Review & Testing Checklist for Human

🔴 High Priority (5 items)

  • Verify deleteCache tRPC mutation exists - The component references trpc.viewer.calendars.deleteCache.useMutation() but this mutation implementation is not visible in the PR changes. Check if this endpoint exists or needs to be created.
  • End-to-end testing with Google Calendar - Install a Google Calendar integration and verify the credential-level dropdown appears, shows cache status, and deletion flow works correctly with confirmation dialog.
  • Test cache status display logic - Verify that cacheUpdatedAt timestamps are correctly formatted and displayed only for Google Calendar credentials with actual cache data.
  • Confirm repository pattern correctness - Test that getCacheStatusByCredentialIds() returns accurate data and the credential-to-cache mapping works properly in the UI.
  • Verify dropdown conditional rendering - Ensure the dropdown only appears for Google Calendar credentials and handles edge cases (no cache, disabled integrations, etc.).

Recommended Test Plan:

  1. Connect a Google Calendar integration to trigger cache creation
  2. Navigate to /apps/installed/calendar
  3. Verify dropdown appears on Google Calendar credential with cache status and timestamp
  4. Test "Delete cached data" action shows confirmation dialog
  5. Confirm cache deletion works and UI updates appropriately
  6. Test "Remove App" functionality still works correctly

Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    UI["CredentialActionsDropdown.tsx<br/>(New Component)"]:::major-edit
    Handler["connectedCalendars.handler.ts<br/>(Updated tRPC Handler)"]:::major-edit
    RepoInterface["calendar-cache.repository.interface.ts<br/>(Updated Interface)"]:::minor-edit
    RepoImpl["calendar-cache.repository.ts<br/>(Updated Implementation)"]:::minor-edit
    RepoMock["calendar-cache.repository.mock.ts<br/>(Updated Mock)"]:::minor-edit
    Translations["common.json<br/>(Added Translation Keys)"]:::minor-edit
    
    UI -->|"Uses repository via tRPC"| Handler
    Handler -->|"Calls getCacheStatusByCredentialIds"| RepoImpl
    RepoImpl -->|"Implements"| RepoInterface
    RepoMock -->|"Implements"| RepoInterface
    UI -->|"Uses translation keys"| Translations
    
    subgraph Legend
        L1[Major Edit]:::major-edit
        L2[Minor Edit]:::minor-edit
        L3[Context/No Edit]:::context
    end

    classDef major-edit fill:#90EE90
    classDef minor-edit fill:#87CEEB
    classDef context fill:#FFFFFF
Loading

Notes

  • Session Details: Requested by @zomars, implemented in Devin session: https://app.devin.ai/sessions/24545e0980df465995521419432a2a52
  • SelectedCalendar.updatedAt Usage: Currently only updated in backend via Google webhook handler but not displayed in frontend. Frontend uses cacheUpdatedAt from CalendarCache. Consider if SelectedCalendar.updatedAt update should be removed.
  • Import Path Resolution: Had to fix UI component import paths during development - watch for potential module resolution issues in different environments.
  • Testing Limitation: Local testing was limited due to no installed calendar integrations - end-to-end verification with real Google Calendar data is essential.

devin-ai-integration Bot and others added 28 commits July 15, 2025 16:20
- Add updatedAt field to CalendarCache schema with migration
- Create tRPC cacheStatus endpoint for fetching cache timestamps
- Add action dropdown to CalendarSwitch for Google Calendar entries
- Display formatted last updated timestamp in dropdown
- Add placeholder for cache deletion functionality
- Include translation strings for dropdown content

The dropdown only appears for Google Calendar integrations that have
active cache entries and provides cache management options for future
extensibility.

Co-Authored-By: zomars@cal.com <zomars@me.com>
- Remove problematic satisfies clause in selectedCalendar.ts
- Add missing cacheStatus parameter to ConnectedCalendarList component
- Fixes type errors that were preventing CI from passing

Co-Authored-By: zomars@cal.com <zomars@me.com>
- Remove separate cacheStatus tRPC endpoint as requested
- Return cache status as separate field in connectedCalendars response
- Update UI components to use cache data from connectedCalendars
- Fix Prisma type incompatibilities in repository files

Co-Authored-By: zomars@cal.com <zomars@me.com>
…e status

- Fix Prisma.SortOrder usage in membership.ts orderBy clauses
- Remove problematic satisfies clause in selectedCalendar.ts
- Fix TeamSelect type reference in team.ts
- Update SelectedCalendarsSettingsWebWrapper to properly pass cacheStatus data flow

Co-Authored-By: zomars@cal.com <zomars@me.com>
…ription logic

- Fix timestamp HTML entity encoding with interpolation escapeValue: false
- Only show dropdown for subscribed Google calendars (googleChannelId exists)
- Hide delete option when no cache data exists
- Include updatedAt and googleChannelId fields upstream in user repository
- Update data flow to pass subscription status through components

Co-Authored-By: zomars@cal.com <zomars@me.com>
…cache refresh

- Add updateManyByCredentialId method to SelectedCalendarRepository
- Update fetchAvailabilityAndSetCache to refresh SelectedCalendar timestamps
- Ensure webhook flow updates both CalendarCache and SelectedCalendar records
- Maintain proper timestamp tracking for calendar cache operations

Co-Authored-By: zomars@cal.com <zomars@me.com>
Introduces test-gcal-webhooks.sh to start Tunnelmole, extract the public URL, and update GOOGLE_WEBHOOK_URL in the .env file. Handles process management, rate limits, and ensures environment configuration for Google Calendar webhooks.
Replaces 'ts-node' with 'npx tsx' in the dev:cron script for running cron-tester.ts, likely to improve compatibility or leverage tsx features.
Renamed 'last_updated' to 'cache_last_updated' in locale file for clarity and updated CalendarSwitch to use the new string. Also added dark mode text color support for cache status display.
…ove App

- Create CredentialActionsDropdown component consolidating cache and app removal actions
- Add deleteCache tRPC mutation for credential-level cache deletion
- Update connectedCalendars handler to include cacheUpdatedAt at credential level
- Move dropdown from individual CalendarSwitch to credential level in SelectedCalendarsSettingsWebWrapper
- Remove cache-related props from CalendarSwitch component
- Add translation strings for cache management actions
- Consolidate all credential-level actions (cache management + Remove App) in one dropdown

Co-Authored-By: zomars@cal.com <zomars@me.com>
- Remove duplicate cache-related keys at lines 51-56
- Keep properly positioned keys later in file
- Addresses GitHub comment from zomars about duplicate keys

Co-Authored-By: zomars@cal.com <zomars@me.com>
- Address GitHub comment from zomars
- Rename 'last_updated' to 'cache_last_updated' for specificity
- Update usage in CredentialActionsDropdown component

Co-Authored-By: zomars@cal.com <zomars@me.com>
Co-Authored-By: zomars@cal.com <zomars@me.com>
…ttern

- Add confirmation dialog for destructive cache deletion action
- Replace direct Prisma calls with CalendarCacheRepository pattern
- Add getCacheStatusByCredentialIds method to repository interface
- Fix import paths for UI components
- Address GitHub review comments from zomars

Co-Authored-By: zomars@cal.com <zomars@me.com>
- Remove wrapping div around DisconnectIntegration component
- Fixes nested <p> tag validation error preventing Remove App functionality
- Maintains existing confirmation dialog patterns

Co-Authored-By: zomars@cal.com <zomars@me.com>
Removed unnecessary return values after setting status in the integrations API handler. This clarifies response handling and prevents returning the response object when not needed. Resolves "API handler should not return a value, received object".
Replaces the DisconnectIntegration component with an inline confirmation dialog for removing app credentials. Adds disconnect mutation logic and updates UI to improve user experience and consistency.
Added a default value of NOW() for the updatedAt column in the CalendarCache table to ensure existing and future rows have a valid timestamp. Updated the Prisma schema to reflect this change and provide compatibility for legacy data and raw inserts.
@khaliqgant khaliqgant changed the base branch from main to msd-benchmark-base/cal_dot_com/pr-22532 May 15, 2026 14:56
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.

4 participants