crbench//

← all cases

feat: add calendar cache status and actions (#22532)

Tier 2 easy typescript · local · real merged PR from calcom/cal.com #22532

Ground-truth defects

d2 · other · low
logic: macOS-specific sed syntax with empty string after -i flag will fail on Linux systems

The change under review

diff (truncated — full diff)
diff --git a/apps/web/package.json b/apps/web/package.json
index 2a23a1d8ab..69b8ea9274 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -8,7 +8,7 @@
     "analyze:browser": "BUNDLE_ANALYZE=browser next build",
     "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next",
     "dev": "yarn copy-static && next dev --turbopack",
-    "dev:cron": "ts-node cron-tester.ts",
+    "dev:cron": "npx tsx cron-tester.ts",
     "dev-https": "NODE_TLS_REJECT_UNAUTHORIZED=0 next dev --experimental-https",
     "dx": "yarn dev",
     "test-codegen": "yarn playwright codegen http://localhost:3000",
diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json
index e56c241d45..90b7ca7e22 100644
--- a/apps/web/public/static/locales/en/common.json
+++ b/apps/web/public/static/locales/en/common.json
@@ -3378,5 +3378,12 @@
   "timezone_mismatch_tooltip": "You are viewing the report based on your profile timezone ({{userTimezone}}), while your browser is set to timezone ({{browserTimezone}})",
   "failed_bookings_by_field": "Failed Bookings By Field",
   "event_type_no_hosts": "No hosts are assigned to event type",
+  "cache_status": "Cache Status",
+  "cache_last_updated": "Last updated: {{timestamp}}",
+  "delete_cached_data": "Delete cached data",
+  "cache_deleted_successfully": "Cache deleted successfully",
+  "error_deleting_cache": "Error deleting cache",
+  "confirm_delete_cache": "Are you sure you want to delete the cached data? This action cannot be undone.",
+  "yes_delete_cache": "Yes, delete cache",
   "ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS": "↑↑↑↑↑↑↑↑↑↑↑↑↑ Add your new strings above here ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑"
 }
diff --git a/packages/app-store/googlecalendar/lib/CalendarService.ts b/packages/app-store/googlecalendar/lib/CalendarService.ts
index 07ae5308f6..e593557ed7 100644
--- a/packages/app-store/googlecalendar/lib/CalendarService.ts
+++ b/packages/app-store/googlecalendar/lib/CalendarService.ts
@@ -1019,6 +1019,9 @@ export default class GoogleCalendarService implements Calendar {
       const data = await this.fetchAvailability(parsedArgs);
       await this.setAvailabilityInCache(parsedArgs, data);
     }
+
+    // Update SelectedCalendar.updatedAt for all calendars under this credential
+    await SelectedCalendarRepository.updateManyByCredentialId(this.credential.id, {});
   }
 
   async createSelectedCalendar(
diff --git a/packages/features/apps/components/CredentialActionsDropdown.tsx b/packages/features/apps/components/CredentialActionsDropdown.tsx
new file mode 100644
index 0000000000..169e46c4d3
--- /dev/null
+++ b/packages/features/apps/components/CredentialActionsDropdown.tsx
@@ -0,0 +1,157 @@
+"use client";
+
+import { useState } from "react";
+
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { GOOGLE_CALENDAR_TYPE } from "@calcom/platform-constants";
+import { trpc } from "@calcom/trpc/react";
+import { Button } from "@calcom/ui/components/button";
+import { ConfirmationDialogContent } from "@calcom/ui/components/dialog";
+import { Dialog } from "@calcom/ui/components/dialog";
+import {
+  Dropdown,
+  DropdownItem,
+  DropdownMenuContent,
+  DropdownMenuItem,
+  DropdownMenuTrigger,
+} from "@calcom/ui/components/dropdown";
+import { showToast } from "@calcom/ui/components/toast";
+
+interface CredentialActionsDropdownProps {
+  credentialId: number;
+  integrationType: string;
+  cacheUpdatedAt?: Date | null;
+  onSuccess?: () => void;
+  delegationCredentialId?: string | null;
+  disableConnectionModification?: boolean;
+}
+
+export default function CredentialActionsDropdown({
+  credentialId,
+  integrationType,
+  cacheUpdatedAt,
+  onSuccess,
+  delegationCredentialId,
+  disableConnectionModification,
+}: CredentialActionsDropdownProps) {
+  const { t } = useLocale();
+  const [dropdownOpen, setDropdownOpen] = useState(false);
+  const [deleteModalOpen, setDeleteModalOpen] = useState(false);
+  const [disconnectModalOpen, setDisconnectModalOpen] = useState(false);
+
+  const deleteCacheMutation = trpc.viewer.calendars.deleteCache.useMutation({
+    onSuccess: () => {
+      showToast(t("cache_deleted_successfully"), "success");
+      onSuccess?.();
+    },
+    onError: () => {
+      showToast(t("error_deleting_cache"), "error");
+    },
+  });
+
+  const utils = trpc.useUtils();
+  const disconnectMutation = trpc.viewer.credentials.delete.useMutation({
+    onSuccess: () => {
+      showToast(t("app_removed_successfully"), "success");
+      onSuccess?.();
+    },
+    onError: () => {
+      showToast(t("error_removing_app"), "error");
+    },
+    async onSettled() {
+      await utils.viewer.calendars.connectedCalendars.invalidate();
+      await utils.viewer.apps.integrations.invalidate();
+    },
+  });
+
+  const isGoogleCalendar = integrationType === GOOGLE_CALENDAR_TYPE;
+  const canDisconnect = !delegationCredentialId && !disableConnectionModification;
+  const hasCache = isGoogleCalendar && cacheUpdatedAt;
+
+  if (!canDisconnect && !hasCache) {
+    return null;
+  }
+
+  return (
+    <>
+      <Dropdown open={dropdownOpen} onOpenChange={setDropdownOpen}>
+        <DropdownMenuTrigger asChild>
+          <Button type="button" variant="icon" color="secondary" StartIcon="ellipsis" />
+        </DropdownMenuTrigger>
+        <DropdownMenuContent>
+          {hasCache && (
+            <>
+              <DropdownMenuItem className="focus:ring-muted">
+                <div className="px-2 py-1">
+                  <div className="text-sm font-medium text-gray-900 dark:text-white">{t("cache_status")}</div>
+                  <div className="text-xs text-gray-500 dark:text-white">
+                    {t("cache_last_updated", {
+                      timestamp: new Intl.DateTimeFormat("en-US", {
+                        dateStyle: "short",
+                        timeStyle: "short",
+                      }).format(new Date(cacheUpdatedAt)),
+                      interpolation: { escapeValue: false },
+                    })}
+                  </div>
+                </div>
+              </DropdownMenuItem>
+              <DropdownMenuItem className="outline-none">
+                <DropdownItem
+                  type="button"
+                  color="destructive"
+                  StartIcon="trash"
+                  onClick={() => {
+                    setDeleteModalOpen(true);
+                    setDropdownOpen(false);
+                  }}>
+                  {t("delete_cached_data")}
+                </DropdownItem>
+              </DropdownMenuItem>
+            </>
+          )}
+          {canDisconnect && hasCache && <hr className="my-1" />}
+          {canDisconnect && (
+            <DropdownMenuItem className="outline-none">
+              <DropdownItem
+                type="button"
+                color="destructive"
+                StartIcon="trash"
+                onClick={() => {
+                  setDisconnectModalOpen(true);
+                  setDropdownOpen(false);
+                }}>
+                {t("remove_app")}
+              </DropdownItem>
+            </DropdownMenuItem>
+          )}
+        </DropdownMenuContent>
+      </Dropdown>
+
+      <Dialog open={deleteModalOpen} onOpenChange={setDeleteModalOpen}>
+        <ConfirmationDialogContent
+          variety="danger"
+          title={t("delete_cached_data")}
+          confirmBtnText={t("yes_delete_cache")}
+          onConfirm={() => {
+            deleteCacheMutation.mutate({ credentialId });
+            setDeleteModalOpen(false);
+          }}>
+          {t("confirm_delete_cache")}
+        </ConfirmationDialogContent>
+      </Dialog>
+
+      <Dialog open={disconnectModalOpen} onOpenChange={setDisconnectModalOpen}>
+        <ConfirmationDialogContent
+          variety="danger"
+          title={t("remove_app")}
+          confirmBtnText={t("yes_remove_app")}
+          onConfirm={() => {
+            disconnectMutation.mutate({ id: credentialId });
+            setDisconnectModalOpen(false);
+          }}>
+          {t("are_you_sure_you_want_to_remove_this_app")}
+        </ConfirmationDialogContent>
+      </Dialog>
+    </>
+  );
+}
diff --git a/packages/features/calendar-cache/calendar-cache.repository.interface.ts b/packages/features/calendar-cache/calendar-cache.repository.interface.ts
index 02832f1ba6..24b1bea9ad 100644
--- a/packages/features/calendar-cache/calendar-cache.repository.interface.ts
+++ b/packages/features/calendar-cache/calendar-cache.repository.interface.ts
@@ -27,4 +27,7 @@ export interface ICalendarCacheRepository {
     userId: number | null;
     args: FreeBusyArgs;
   }): Promise<CalendarCache | null>;
+  getCacheStatusByCredentialIds(
+    credentialIds: number[]
+  ): Promise<{ credentialId: number; updatedAt: Date | null }[]>;
 }
diff --git a/packages/features/calendar-cache/calendar-cache.repository.mock.ts b/packages/features/calendar-cache/calendar-cache.repository.mock.ts
index 94936d0714..e43a3f979d 100644
--- a/packages/features/calendar-cache/calendar-cache.repository.mock.ts
+++ b/packages/features/calendar-cache/calendar-cache.repository.mock.ts
@@ -23,4 +23,9 @@ export class CalendarCacheRepositoryMock implements ICalendarCacheRepository {
   async deleteManyByCredential() {
     log.info(`Skipping deleteManyByCredential due to calendar-cache being disabled`);
   }
+
+  async getCacheStatusByCredentialIds() {
+    log.info(`Skipping getCacheStatusByCredentialIds due to calendar-cache being disabled`);
+    return [];
+  }
 }
diff --git a/packages/features/calendar-cache/calendar-cache.repository.ts b/packages/features/calendar-cache/calendar-cache.repository.ts
index 24b7025deb..853e5afe18 100644
--- a/packages/features/calendar-cache/calendar-cache.repository.ts
+++ b/packages/features/calendar-cache/calendar-cache.repository.ts
@@ -169,4 +169,21 @@ export class CalendarCacheRepository implements ICalendarCacheRepository {
       },
     });
   }
+
+  async getCacheStatusByCredentialIds(credentialIds: number[]) {
+    const cacheStatuses = await prisma.calendarCache.groupBy({
+      by: ["credentialId"],
+      where: {
+        credentialId: { in: credentialIds },
+      },
+      _max: {
+        updatedAt: true,
+      },
+    });
+
+    return cacheStatuses.map((cache) => ({
+      credentialId: cache.credentialId,
+      updatedAt: cache._max.updatedAt,
+    }));
+  }
 }
diff --git a/packages/lib/getConnectedDestinationCalendars.ts b/packages/lib/getConnectedDestinationCalendars.ts
index 0778553700..da0d2fee64 100644
--- a/packages/lib/getConnectedDestinationCalendars.ts
+++ b/packages/lib/getConnectedDestinationCalendars.ts
@@ -18,8 +18,14 @@ type ReturnTypeGetConnectedCalendars = Awaited<ReturnType<typeof getConnectedCal
 type ConnectedCalendarsFromGetConnectedCalendars = ReturnTypeGetConnectedCalendars["connectedCalendars"];
 
 export type UserWithCalendars = Pick<User, "id" | "email"> & {
-  allSelectedCalendars: Pick<SelectedCalendar, "externalId" | "integration" | "eventTypeId">[];
-  userLevelSelectedCalendars: Pick<SelectedCalendar, "externalId" | "integration" | "eventTypeId">[];
+  allSelectedCalendars: Pick<
+    SelectedCalendar,
+    "externalId" | "integration" | "eventTypeId" | "updatedAt" | "googleChannelId"
+  >[];
+  userLevelSelectedCalendars: Pick<
+    SelectedCalendar,
+    "externalId" | "integration" | "eventTypeId" | "updatedAt" | "googleChannelId"
+  >[];
   destinationCalendar: DestinationCalendar | null;
 };
 
diff --git a/packages/lib/server/repository/selectedCalendar.ts b/packages/lib/server/repository/selectedCalendar.ts
index bdc6316b16..b1553f8ca7 100644
--- a/packages/lib/server/repository/selectedCalendar.ts
+++ b/packages/lib/server/repository/selectedCalendar.ts
@@ -257,8 +257,7 @@ export class SelectedCalendarRepository {
   }
 
   static async findMany({ where, select, orderBy }: FindManyArgs) {
-    const args = { where, select, orderBy } satisfies Prisma.SelectedCalendarFindManyArgs;
-    return await prisma.selectedCalendar.findMany(args);
+    return await prisma.selectedCalendar.findMany({ where, select, orderBy });
   }
 
   static async findUniqueOrThrow({ where }: { where: Prisma.SelectedCalendarWhereInput }) {
@@ -398,6 +397,13 @@ export class SelectedCalendarRepository {
     });
   }
 
+  static async updateManyByCredentialId(credentialId: number, data: Prisma.SelectedCalendarUpdateInput) {
+    return await prisma.selectedCalendar.updateMany({
+      where: { credentialId },
+      data,
+    });
+  }
+
   static async setErrorInWatching({ id, error }: { id: string; error: string }) {
     await SelectedCalendarRepository.updateById(id, {
       error,
diff --git a/packages/lib/server/repository/user.ts b/packages/lib/server/repository/user.ts
index adc6e05ecb..ae5091913a 100644
--- a/packages/lib/server/repository/user.ts
+++ b/packages/lib/server/repository/user.ts
@@ -896,6 +896,8 @@ export class UserRepository {
             eventTypeId: true,
             externalId: true,
             integration: true,
+            updatedAt: true,
+            googleChannelId: true,
           },
         },
         completedOnboarding: true,
diff --git a/packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx b/packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx
index 0cb6f3b5ea..0bf0134678 100644
--- a/packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx
+++ b/packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx
@@ -2,7 +2,7 @@ import Link from "next/link";
 import React from "react";
 
 import AppListCard from "@calcom/features/apps/components/AppListCard";
-import DisconnectIntegration from "@calcom/features/apps/components/DisconnectIntegration";
+import CredentialActionsDropdown from "@calcom/features/apps/components/CredentialActionsDropdown";
 import AdditionalCalendarSelector from "@calcom/features/calendars/AdditionalCalendarSelector";
 import { CalendarSwitch } from "@calcom/features/calendars/CalendarSwitch";
 import { useLocale } from "@calcom/lib/hooks/useLocale";
@@ -67,18 +67,16 @@ const ConnectedCalendarList = ({
               description={connectedCalendar.primary?.email ?? connectedCalendar.integration.description}
               className="border-subtle mt-4 rounded-lg border"
               actions={
-                // Delegation credential can't be disconnected
-                !connectedCalendar.delegationCredentialId &&
-                !disableConnectionModification && (
-                  <div className="flex w-32 justify-end">
-                    <DisconnectIntegration
-                      credentialId={connectedCalendar.credentialId}
-                      trashIcon
-                      onSuccess={onChanged}
-                      buttonProps={{ className: "border border-default" }}
-                    />
-                  </div>
-                )
+                <div className="flex w-32 justify-end">
+                  <CredentialActionsDropdown
+                    credentialId={connectedCalendar.credentialId}
+                    integrationType={connectedCalendar.integration.type}
+                    cacheUpdatedAt={connectedCalendar.cacheUpdatedAt}
+                    onSuccess={onChanged}
+                    delegationCredentialId={connectedCalendar.delegationCredentialId}
+                    disableConnectionModification={disableConnectionModification}
+                  />
+                </div>
               }>
               <div className="border-subtle border-t">
                 {!fromOnboarding && (
@@ -97,7 +95,7 @@ const ConnectedCalendarList = ({
                           destination={cal.externalId === destinationCalendarId}
                           credentialId={cal.credentialId}
                           eventTypeId={shouldUseEventTypeScope ? eventTypeId : null}
-                          delegationCredentialId={connectedCalendar.delegationCredentialId}
+                          delegationCredentialId={connectedCalendar.delegationCredentialId || null}
                         />
                       ))}
                     </ul>
@@ -122,17 +120,16 @@ const ConnectedCalendarList = ({
             }
             iconClassName="h-10 w-10 ml-2 mr-1 mt-0.5"
             actions={
-              // Delegation credential can't be disconnected
-              !connectedCalendar.delegationCredentialId && (
-                <div className="flex w-32 justify-end">
-                  <DisconnectIntegration
-                    credentialId={connectedCalendar.credentialId}
-                    trashIcon
-                    onSuccess={onChanged}
-                    buttonProps={{ className: "border border-default" }}
-                  />
-                </div>
-              )
+              <div className="flex w-32 justify-end">
+                <CredentialActionsDropdown
+                  credentialId={connectedCalendar.credentialId}
+                  integrationType={connectedCalendar.integration.type}
+                  cacheUpdatedAt={connectedCalendar.cacheUpdatedAt}
+                  onSuccess={onChanged}
+                  delegationCredentialId={connectedCalendar.delegationCredentialId}
+                  disableConnectionModification={disableConnectionModification}
+                />
+              </div>
             }
           />
         );
@@ -162,6 +159,7 @@ export const SelectedCalendarsSettingsWebWrapper = (props: SelectedCalendarsSett
       refetchOnWindowFocus: false,
     }
   );
+
   const { isPending } = props;
   const showScopeSelector = !!props.eventTypeId;
   const isDisabled = disabledScope ? disabledScope === scope : false;
diff --git a/packages/prisma/migrations/20250715160635_add_calendar_cache_updated_at/migration.sql b/packages/prisma/migrations/20250715160635_add_calendar_cache_updated_at/migration.sql
new file mode 100644
index 0000000000..53f16f5b88
--- /dev/null
+++ b/packages/prisma/migrations/20250715160635_add_calendar_cache_updated_at/migration.sql
@@ -0,0 +1,9 @@
+/*
+  Warnings:
+
+  - Added the required column `updatedAt` to the `CalendarCache` table without a default value. This is not possible if the table is not empty.
+
+*/
+-- AlterTable
+-- Add the column with a default value to safely handle existing rows
+ALTER TABLE "CalendarCache" ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT NOW();
diff --git a/packages/prisma/schema.prisma b/packages/prisma/schema.prisma
index b4c1698dff..9da776099e 100644
--- a/packages/prisma/schema.prisma
+++ b/packages/prisma/schema.prisma
@@ -1715,6 +1715,8 @@ model CalendarCache {
   key          String
   value        Json
   expiresAt    DateTime
+  // Provide an initial value for legacy rows and future raw inserts
+  updatedAt    DateTime    @default(now()) @updatedAt
   credentialId Int
   userId       Int?
   credential   Credential? @relation(fields: [credentialId], references: [id], onDelete: Cascade)
diff --git a/packages/trpc/server/routers/viewer/calendars/_router.tsx b/packages/trpc/server/routers/viewer/calendars/_router.tsx
index 649c97649a..8eb06da36f 100644
--- a/packages/trpc/server/routers/viewer/calendars/_router.tsx
+++ b/packages/trpc/server/routers/viewer/calendars/_router.tsx
@@ -1,3 +1,5 @@
+import { z } from "zod";
+
 import authedProcedure from "../../../procedures/authedProcedure";
 import { router } from "../../../trpc";
 import { ZConnectedCalendarsInputSchema } from "./connectedCalendars.schema";
@@ -22,4 +24,11 @@ export const calendarsRouter = router({
 
       return setDestinationCalendarHandler({ ctx, input });
     }),
+
+  deleteCache: authedProcedure
+    .input(z.object({ credentialId: z.number() }))
+    .mutation(async ({ ctx, input }) => {
+      const { deleteCacheHandler } = await import("./deleteCache.handler");
+      return deleteCacheHandler({ ctx, input });
+    }),
 });
diff --git a/packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts b/packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts
index 4553931985..3e4b22757d 100644
--- a/packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts
+++ b/packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts
@@ -1,3 +1,4 @@
+import { CalendarCacheRepository } from "@calcom/features/calendar-cache/calendar-cache.repository";
 import { getConnectedDestinationCalendarsAndEnsureDefaultsInDb } from "@calcom/lib/getConnectedDestinationCalendars";
 import { prisma } from "@calcom/prisma";
 import type { TrpcSessionUser } from "@calcom/trpc/server/types";
@@ -23,8 +24,19 @@ export const connectedCalendarsHandler = async ({ ctx, input }: ConnectedCalenda
       prisma,
     });
 
+  const credentialIds = connectedCalendars.map((cal) => cal.credentialId);
+  const cacheRepository = new CalendarCacheRepository();
+  const cacheStatuses = await cacheRepository.getCacheStatusByCredentialIds(credentialIds);
+
+  const cacheStatusMap = new Map(cacheStatuses.map((cache) => [cache.credentialId, cache.updatedAt]));
+
+  const enrichedConnectedCalendars = connectedCalendars.map((calendar) => ({
+    ...calendar,
+    cacheUpdatedAt: cacheStatusMap.get(calendar.credentialId) || null,
+  }));
+
   return {
-    connectedCalendars,
+    connectedCalendars: enrichedConnectedCalendars,
     destinationCalendar,
   };
 };
diff --git a/packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts b/packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts
new file mode 100644
index 0000000000..06cc1b7b24
--- /dev/null
+++ b/packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts
@@ -0,0 +1,33 @@
+import { prisma } from "@calcom/prisma";
+import type { TrpcSessionUser } from "@calcom/trpc/server/types";
+
+type DeleteCacheOptions = {
+  ctx: {
+    user: NonNullable<TrpcSessionUser>;

Leaderboard for this case

easy · 6 of 9 bots fully caught it (67% solve rate) · 67% avg coverage.

#BotResultCaughtCoverageFindingsFalse alarms
1 Claude Code (Opus 5.5) solved 1/1 100.0% 6 0
2 Cubic solved 1/1 100.0% 9 0
3 Drape (Deep Review) solved 1/1 100.0% 6 0
4 Mjolnir (Opus 5.5) solved 1/1 100.0% 3 0
5 qodo solved 1/1 100.0% 8 0
6 greptile solved 1/1 100.0% 7 1
7 cursor miss 0/1 0.0% 2 0
8 Drape (Review) miss 0/1 0.0% 7 0
9 Mjolnir (Sonnet 5.5) miss 0/1 0.0% 0 0

Bot results

Claude Code (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✓ exact
valid · impact low
Prisma's query engine adds the @updatedAt timestamp only when the update args are non-empty. With an empty data object the update is a no-op, so the intended updatedAt bump never happens. Nothing in the shown code sets updatedAt explicitly. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
The data parameter uses the single-record UpdateInput type, which allows relation fields, but updateMany only accepts UpdateManyMutationInput. That is a real type and contract mismatch. The only current caller passes {}, so the practical impact is limited. [grounded: diff] [consensus 3/5: valid=3, uncertain=1, invalid=1]
valid · impact low
The handler creates the real repository directly instead of going through CalendarCache.init, so it skips the feature-flag check. Every request now runs an extra groupBy query, and any error from it is unguarded and fails the whole connected-calendars response. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
tRPC maps a plain Error to INTERNAL_SERVER_ERROR (500), so an auth or not-found failure is reported as a server error. The claim about team and delegation credentials is weaker, but the core claim holds. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
In the error/empty branch, the old code gated disconnect only on delegationCredentialId. The new component requires !disableConnectionModification, so 'Remove app' is now hidden for broken calendars in places like the event-type advanced tab. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d2 · impact low
raw comments (6)
packages/app-store/googlecalendar/lib/CalendarService.ts:1024
`updateManyByCredentialId(this.credential.id, {})` passes an empty `data` object and relies on Prisma's `@updatedAt` to bump the timestamp. Prisma treats an update with no fields as a no-op, so `SelectedCalendar.updatedAt` never changes and the stated goal fails without any error. The call is also unguarded inside the cache-refresh path: if it throws, `fetchAvailabilityAndSetCache` fails even though the cache was already written. For delegation credentials, `this.credential.id` is not a real `credentialId` on the SelectedCalendar rows, so nothing matches. The fix is to set `updatedAt: new Date()` explicitly and scope the update to the calendars that were actually refreshed.
packages/lib/server/repository/selectedCalendar.ts:400
`updateManyByCredentialId` types `data` as `Prisma.SelectedCalendarUpdateInput`, but `prisma.selectedCalendar.updateMany` expects `SelectedCalendarUpdateManyMutationInput`, which allows no relation fields. Passing relation updates fails at runtime, and the mismatch may also be a type error.
packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:28
The handler creates `CalendarCacheRepository` directly, skipping the feature-flag check that normally picks the mock repository when calendar-cache is disabled. As a result, every connectedCalendars request now runs an extra `groupBy` over CalendarCache, even for users and orgs without the cache feature. If that query fails, the whole connected-calendars list fails, even though cache status is only decoration.
packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts:24
A missing or unauthorized credential throws a plain `Error`, which reaches the client as a 500 INTERNAL_SERVER_ERROR instead of a TRPCError with NOT_FOUND or FORBIDDEN. The ownership check (`userId: user.id`) also excludes team-owned and delegation credentials. Those can still show the 'Delete cached data' option in the UI, but the request will always fail.
packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx:121
Behavior change: in the second branch (calendars with an error or no calendars), the old code let the user disconnect regardless of `disableConnectionModification`. The new dropdown hides 'Remove app' when that flag is set. Users can then no longer remove broken credentials in contexts where the old code let them.
scripts/test-gcal-webhooks.sh:67
`sed -i '' -E ...` is BSD/macOS syntax. GNU sed on Linux reads `''` as the script and the expression as a filename, so it errors and GOOGLE_WEBHOOK_URL is never updated. Also, `cleanup` always runs `exit 0`, so failures (no URL found, rate limit) still report success.
Cubic · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✓ off by one
valid · impact low
The cache-delete mutation does not invalidate connectedCalendars itself; EventAdvancedTab renders the wrapper without onChanged, so the deleted cache status stays visible. [grounded: diff] [consensus 5/5: valid=5]
valid · impact low
No package.json in the repo declares tsx, so npx downloads an unpinned copy at run time, and the script fails when offline. [grounded: diff] [consensus 5/5: valid=5]
valid · impact low
Cache rows are written only under DB credentials (assertCalendarHasDbCredential). An in-memory delegation credential has a negative id, so the lookup never matches and delegated calendars never show cache status. [grounded: diff] [consensus 5/5: valid=5]
valid · impact low
CalendarCache.init normally returns the mock when the flag is off. The handler skips it and queries real rows directly, so stale cache status can show while the feature is disabled. [grounded: diff] [consensus 5/5: valid=5]
uncertain · impact low
The error paths (rate limit hit, URL not extracted) call cleanup, which always exits 0, so a failed setup reports success. [uncertain: quoted evidence is not in tree file scripts/test-gcal-webhooks.sh] [consensus 5/5: uncertain=5]
valid · matches d2 · impact low
valid · impact low
The path resolves from the caller's working directory, so running the script from the repo root writes .env one level above the repository. [grounded: tree scripts/test-gcal-webhooks.sh] [consensus 5/5: valid=5]
valid · impact medium
Prisma does not bump @updatedAt when the update data is empty, so the stated goal of the added line (advancing updatedAt) is not achieved. [grounded: diff] [consensus 5/5: valid=5]
valid · impact low
Before this change the wrapper div was rendered only when the card had an action. Now it always renders, even when the dropdown returns null, leaving a blank fixed-width column. [grounded: diff] [consensus 5/5: valid=5]
raw comments (10)
packages/features/apps/components/CredentialActionsDropdown.tsx:46
<!-- cubic:v=596e1c90-cbb3-484e-aea3-3ef065b1a7ee --> <!-- cubic:review-run=dfa3714f-6166-5ab2-a6e0-a4ea6f70af26 --> <!-- metadata:{"confidence":9} --> P2: When this dropdown is rendered without `onSuccess`, a successful cache deletion leaves the connected-calendar query stale, so the deleted cache still appears in the menu. Invalidate `connectedCalendars` after the cache mutation succeeds, independently of the optional callback. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/features/apps/components/CredentialActionsDropdown.tsx, line 43: <comment>When this dropdown is rendered without `onSuccess`, a successful cache deletion leaves the connected-calendar query stale, so the deleted cache still appears in the menu. Invalidate `connectedCalendars` after the cache mutation succeeds, independently of the optional callback.</comment> <file context> @@ -0,0 +1,157 @@ + const [disconnectModalOpen, setDisconnectModalOpen] = useState(false); + + const deleteCacheMutation = trpc.viewer.calendars.deleteCache.useMutation({ + onSuccess: () => { + showToast(t("cache_deleted_successfully"), "success"); + onSuccess?.(); </file context> ``` </details> ```suggestion onSuccess: async () => { showToast(t("cache_deleted_successfully"), "success"); await utils.viewer.calendars.connectedCalendars.invalidate(); onSuccess?.(); }, ```
apps/web/package.json:11
<!-- cubic:v=78454d6a-406e-407c-80a6-097b5c30352d --> <!-- cubic:review-run=dfa3714f-6166-5ab2-a6e0-a4ea6f70af26 --> <!-- metadata:{"confidence":9} --> P2: A clean Yarn install has no `tsx` binary, so `dev:cron` relies on `npx` downloading an unpinned package or fails offline. Add `tsx` to the workspace devDependencies and invoke the locked local binary. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At apps/web/package.json, line 11: <comment>A clean Yarn install has no `tsx` binary, so `dev:cron` relies on `npx` downloading an unpinned package or fails offline. Add `tsx` to the workspace devDependencies and invoke the locked local binary.</comment> <file context> @@ -8,7 +8,7 @@ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next", "dev": "yarn copy-static && next dev --turbopack", - "dev:cron": "ts-node cron-tester.ts", + "dev:cron": "npx tsx cron-tester.ts", "dev-https": "NODE_TLS_REJECT_UNAUTHORIZED=0 next dev --experimental-https", "dx": "yarn dev", </file context> ``` </details>
packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:27
<!-- cubic:v=0924fd30-6a5d-4541-9028-3fffd457f0a9 --> <!-- cubic:review-run=dfa3714f-6166-5ab2-a6e0-a4ea6f70af26 --> <!-- metadata:{"confidence":7} --> P2: When a connected calendar uses an in-memory delegation credential, its negative `credentialId` cannot match the positive database credential ID used by calendar-cache rows. Resolve the backing cache credential before this lookup, otherwise delegated Google calendars never show cache status or the cache-delete action. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts, line 27: <comment>When a connected calendar uses an in-memory delegation credential, its negative `credentialId` cannot match the positive database credential ID used by calendar-cache rows. Resolve the backing cache credential before this lookup, otherwise delegated Google calendars never show cache status or the cache-delete action.</comment> <file context> @@ -23,8 +24,19 @@ export const connectedCalendarsHandler = async ({ ctx, input }: ConnectedCalenda prisma, }); + const credentialIds = connectedCalendars.map((cal) => cal.credentialId); + const cacheRepository = new CalendarCacheRepository(); + const cacheStatuses = await cacheRepository.getCacheStatusByCredentialIds(credentialIds); </file context> ``` </details>
packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:28
<!-- cubic:v=67064bf3-5f9c-4a7a-bab2-76816714e60c --> <!-- cubic:review-run=dfa3714f-6166-5ab2-a6e0-a4ea6f70af26 --> <!-- metadata:{"confidence":8} --> P2: When the global `calendar-cache` flag is disabled, this bypasses the flag-aware mock and can expose stale cache status and delete actions. Initialize the repository through `CalendarCache.init(null)` so disabled deployments return no cache status. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts, line 28: <comment>When the global `calendar-cache` flag is disabled, this bypasses the flag-aware mock and can expose stale cache status and delete actions. Initialize the repository through `CalendarCache.init(null)` so disabled deployments return no cache status.</comment> <file context> @@ -23,8 +24,19 @@ export const connectedCalendarsHandler = async ({ ctx, input }: ConnectedCalenda }); + const credentialIds = connectedCalendars.map((cal) => cal.credentialId); + const cacheRepository = new CalendarCacheRepository(); + const cacheStatuses = await cacheRepository.getCacheStatusByCredentialIds(credentialIds); + </file context> ``` </details>
scripts/test-gcal-webhooks.sh:17
<!-- cubic:v=6ac9f9cd-107d-458d-bb18-ea9a39812524 --> <!-- cubic:review-run=dfa3714f-6166-5ab2-a6e0-a4ea6f70af26 --> <!-- metadata:{"confidence":9} --> P2: When Tunnelmole initialization fails or the rate limit is hit, `cleanup` exits with status 0, so callers treat the failed setup as successful and may continue with a stale webhook URL. Pass a nonzero status on error paths while keeping signal cleanup successful. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At scripts/test-gcal-webhooks.sh, line 17: <comment>When Tunnelmole initialization fails or the rate limit is hit, `cleanup` exits with status 0, so callers treat the failed setup as successful and may continue with a stale webhook URL. Pass a nonzero status on error paths while keeping signal cleanup successful.</comment> <file context> @@ -0,0 +1,79 @@ + kill "$TMOLE_PID" 2>/dev/null + wait "$TMOLE_PID" 2>/dev/null + fi + exit 0 +} + </file context> ``` </details>
scripts/test-gcal-webhooks.sh:68
<!-- cubic:v=aa3e4230-8a14-438f-8123-3de6c1c29873 --> <!-- cubic:review-run=dfa3714f-6166-5ab2-a6e0-a4ea6f70af26 --> <!-- metadata:{"confidence":10} --> P2: On Linux, the existing `GOOGLE_WEBHOOK_URL` is not updated because `sed -i ''` is macOS-only, yet the script continues and reports success. Use a portable in-place edit, such as a temporary backup suffix that is removed afterward. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At scripts/test-gcal-webhooks.sh, line 68: <comment>On Linux, the existing `GOOGLE_WEBHOOK_URL` is not updated because `sed -i ''` is macOS-only, yet the script continues and reports success. Use a portable in-place edit, such as a temporary backup suffix that is removed afterward.</comment> <file context> @@ -0,0 +1,79 @@ +fi + +if grep -q '^GOOGLE_WEBHOOK_URL=' "$ENV_FILE"; then + sed -i '' -E "s|^GOOGLE_WEBHOOK_URL=.*|GOOGLE_WEBHOOK_URL=$TUNNEL_URL|" "$ENV_FILE" +else + echo "GOOGLE_WEBHOOK_URL=$TUNNEL_URL" >> "$ENV_FILE" </file context> ``` </details> ```suggestion sed -i.bak -E "s|^GOOGLE_WEBHOOK_URL=.*|GOOGLE_WEBHOOK_URL=$TUNNEL_URL|" "$ENV_FILE" && rm -f "$ENV_FILE.bak" ```
scripts/test-gcal-webhooks.sh:5
<!-- cubic:v=536277f7-2d52-49de-be18-0f144279ee6c --> <!-- cubic:review-run=dfa3714f-6166-5ab2-a6e0-a4ea6f70af26 --> <!-- metadata:{"confidence":9} --> P2: Running `./scripts/test-gcal-webhooks.sh` from the repository root writes `GOOGLE_WEBHOOK_URL` outside the repository, so the web app keeps using the old root `.env` value. Resolve the env path from the script's directory instead of the caller's working directory. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At scripts/test-gcal-webhooks.sh, line 5: <comment>Running `./scripts/test-gcal-webhooks.sh` from the repository root writes `GOOGLE_WEBHOOK_URL` outside the repository, so the web app keeps using the old root `.env` value. Resolve the env path from the script's directory instead of the caller's working directory.</comment> <file context> @@ -0,0 +1,79 @@ + +# Configuration +LOG_FILE="/tmp/tmole.log" +ENV_FILE="../.env" +TM_PORT=3000 +TM_KEYWORD="https://.*\.tunnelmole\.net" </file context> ``` </details> ```suggestion ENV_FILE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/.env" ```
packages/app-store/googlecalendar/lib/CalendarService.ts:1024
<!-- cubic:v=4e603591-dd6f-418e-974a-857b15d0e202 --> <!-- cubic:review-run=dfa3714f-6166-5ab2-a6e0-a4ea6f70af26 --> <!-- metadata:{"confidence":10} --> P2: `fetchAvailabilityAndSetCache` passes an empty update payload, so Prisma does not advance `SelectedCalendar.updatedAt`. Pass `updatedAt: new Date()` or update another real field so the refresh timestamp is recorded. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/app-store/googlecalendar/lib/CalendarService.ts, line 1024: <comment>`fetchAvailabilityAndSetCache` passes an empty update payload, so Prisma does not advance `SelectedCalendar.updatedAt`. Pass `updatedAt: new Date()` or update another real field so the refresh timestamp is recorded.</comment> <file context> @@ -1019,6 +1019,9 @@ export default class GoogleCalendarService implements Calendar { } + + // Update SelectedCalendar.updatedAt for all calendars under this credential + await SelectedCalendarRepository.updateManyByCredentialId(this.credential.id, {}); } </file context> ``` </details> ```suggestion await SelectedCalendarRepository.updateManyByCredentialId(this.credential.id, { updatedAt: new Date() }); ```
packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx:70
<!-- cubic:v=cad258d5-90b3-4177-b3ca-1d4f06c3d265 --> <!-- cubic:review-run=dfa3714f-6166-5ab2-a6e0-a4ea6f70af26 --> <!-- metadata:{"confidence":9} --> P3: When a credential is delegated, disabled, or has no available cache action, `CredentialActionsDropdown` returns `null` but this fixed-width wrapper still reserves space. Render the wrapper only when an action is available so these cards do not show a blank action column. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx, line 70: <comment>When a credential is delegated, disabled, or has no available cache action, `CredentialActionsDropdown` returns `null` but this fixed-width wrapper still reserves space. Render the wrapper only when an action is available so these cards do not show a blank action column.</comment> <file context> @@ -67,18 +67,16 @@ const ConnectedCalendarList = ({ - /> - </div> - ) + <div className="flex w-32 justify-end"> + <CredentialActionsDropdown + credentialId={connectedCalendar.credentialId} </file context> ``` </details>
PR-level
<!-- cubic:review-summary:start --> **9 issues found** across 17 files <!-- cubic:review-summary:end --> <details> <summary>Prompt for AI agents (unresolved issues)</summary> ```text Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately. <file name="packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx"> <violation number="1" location="packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx:70"> P3: When a credential is delegated, disabled, or has no available cache action, `CredentialActionsDropdown` returns `null` but this fixed-width wrapper still reserves space. Render the wrapper only when an action is available so these cards do not show a blank action column.</violation> </file> <file name="packages/features/apps/components/CredentialActionsDropdown.tsx"> <violation number="1" location="packages/features/apps/components/CredentialActionsDropdown.tsx:43"> P2: When this dropdown is rendered without `onSuccess`, a successful cache deletion leaves the connected-calendar query stale, so the deleted cache still appears in the menu. Invalidate `connectedCalendars` after the cache mutation succeeds, independently of the optional callback.</violation> </file> <file name="apps/web/package.json"> <violation number="1" location="apps/web/package.json:11"> P2: A clean Yarn install has no `tsx` binary, so `dev:cron` relies on `npx` downloading an unpinned package or fails offline. Add `tsx` to the workspace devDependencies and invoke the locked local binary.</violation> </file> <file name="packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts"> <violation number="1" location="packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:27"> P2: When a connected calendar uses an in-memory delegation credential, its negative `credentialId` cannot match the positive database credential ID used by calendar-cache rows. Resolve the backing cache credential before this lookup, otherwise delegated Google calendars never show cache status or the cache-delete action.</violation> <violation number="2" location="packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:28"> P2: When the global `calendar-cache` flag is disabled, this bypasses the flag-aware mock and can expose stale cache status and delete actions. Initialize the repository through `CalendarCache.init(null)` so disabled deployments return no cache status.</violation> </file> <file name="scripts/test-gcal-webhooks.sh"> <violation number="1" location="scripts/test-gcal-webhooks.sh:5"> P2: Running `./scripts/test-gcal-webhooks.sh` from the repository root writes `GOOGLE_WEBHOOK_URL` outside the repository, so the web app keeps using the old root `.env` value. Resolve the env path from the script's directory instead of the caller's working directory.</violation> <violation number="2" location="scripts/test-gcal-webhooks.sh:17"> P2: When Tunnelmole initialization fails or the rate limit is hit, `cleanup` exits with status 0, so callers treat the failed setup as successful and may continue with a stale webhook URL. Pass a nonzero status on error paths while keeping signal cleanup successful.</violation> <violation number="3" location="scripts/test-gcal-webhooks.sh:68"> P2: On Linux, the existing `GOOGLE_WEBHOOK_URL` is not updated because `sed -i ''` is macOS-only, yet the script continues and reports success. Use a portable in-place edit, such as a temporary backup suffix that is removed afterward.</violation> </file> <file name="packages/app-store/googlecalendar/lib/CalendarService.ts"> <violation number="1" location="packages/app-store/googlecalendar/lib/CalendarService.ts:1024"> P2: `fetchAvailabilityAndSetCache` passes an empty update payload, so Prisma does not advance `SelectedCalendar.updatedAt`. Pass `updatedAt: new Date()` or update another real field so the refresh timestamp is recorded.</violation> </file> ``` </details> <sub>Reply with feedback, questions, or to request a fix.<br /><br />[Re-trigger cubic](https://www.cubic.dev/action/re-review/pr/drape-io/crbench-cubic-2026-09/21/ai_pr_review_github_delivery_e4898b44c2c14e45d8e44e4f8d8ebeb3acd8d50bb1ee20ee48377df1a92ece82?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F21)</sub> <!-- cubic:review-post:ai_pr_review_github_delivery_e4898b44c2c14e45d8e44e4f8d8ebeb3acd8d50bb1ee20ee48377df1a92ece82:816c8b874c2792607d4bf8003372cdb158d42c22:dfa3714f-6166-5ab2-a6e0-a4ea6f70af26 -->
cursor · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✗ —
valid · impact low
The new code passes an empty data object to updateMany. Prisma does not write anything for an empty update, so the @updatedAt bump this line is meant to trigger never happens. The new line is a no-op. [grounded: diff] [consensus 5/5: valid=5]
valid · impact low
After a successful deleteCache, the component only calls the optional onSuccess prop, unlike disconnect, which invalidates connectedCalendars in onSettled. EventAdvancedTab renders the wrapper without onChanged, so the old cacheUpdatedAt stays on screen there. [grounded: diff] [consensus 5/5: valid=5]
raw comments (3)
packages/app-store/googlecalendar/lib/CalendarService.ts:1024
### Empty update skips calendar timestamp **Medium Severity** <!-- DESCRIPTION START --> `fetchAvailabilityAndSetCache` calls `updateManyByCredentialId` with an empty `{}` payload, which does not bump `SelectedCalendar.updatedAt`. Prisma `updateMany` only writes `@updatedAt` when `data` includes a real field change, so this refresh is a no-op after availability is cached. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: bebfe622-34b3-4825-85ac-3611c4330490 --> <!-- LOCATIONS START packages/app-store/googlecalendar/lib/CalendarService.ts#L1022-L1024 packages/lib/server/repository/selectedCalendar.ts#L399-L405 LOCATIONS END --> <details> <summary>Additional Locations (1)</summary> - [`packages/lib/server/repository/selectedCalendar.ts#L399-L405`](https://github.com/drape-io/crbench-cursor-2026-09/blob/eb7574cd1ba5c6e5b29c0f969080331203e7073a/packages/lib/server/repository/selectedCalendar.ts#L399-L405) </details> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjY2Y2VhNGUwLTgyZmEtNGEyZS1iMDljLTcxYjkzN2Y1ODljMyIsImVuY3J5cHRpb25LZXkiOiJzRzRqc01KYUdqRlVNOWFKel9qUVU5WDYtcTcyRHJTdzc2SG1PY2xpUUcwIiwiYnJhbmNoIjoidDItY2FsLWNvbS0yMjUzMiIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjY2Y2VhNGUwLTgyZmEtNGEyZS1iMDljLTcxYjkzN2Y1ODljMyIsImVuY3J5cHRpb25LZXkiOiJzRzRqc01KYUdqRlVNOWFKel9qUVU5WDYtcTcyRHJTdzc2SG1PY2xpUUcwIiwiYnJhbmNoIjoidDItY2FsLWNvbS0yMjUzMiIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjIxLCJjb21taXRTaGEiOiJlYjc1NzRjZDFiYTVjNmU1YjI5YzBmOTY5MDgwMzMxMjAzZTcwNzNhIiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit eb7574cd1ba5c6e5b29c0f969080331203e7073a. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
packages/features/apps/components/CredentialActionsDropdown.tsx:50
### Cache delete leaves stale UI **Medium Severity** <!-- DESCRIPTION START --> `deleteCache` never invalidates `viewer.calendars.connectedCalendars`. After a successful purge the dropdown still shows the old `cacheUpdatedAt` and the delete action, unless an optional parent `onSuccess` happens to refetch. Disconnect in the same component does invalidate those queries. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 43806d5b-5b95-4ada-8251-ccfbe9f0acbc --> <!-- LOCATIONS START packages/features/apps/components/CredentialActionsDropdown.tsx#L41-L50 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjBmMjg0MjI0LTBmOGYtNGZhOS05YTI4LTFmNjZmY2E5ZWFjNSIsImVuY3J5cHRpb25LZXkiOiJlSUMzaE5lX0hOWVBrTTlMYnRITEhaNkNPSzF1VjlLSkZaekp4VlhsSDdnIiwiYnJhbmNoIjoidDItY2FsLWNvbS0yMjUzMiIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjBmMjg0MjI0LTBmOGYtNGZhOS05YTI4LTFmNjZmY2E5ZWFjNSIsImVuY3J5cHRpb25LZXkiOiJlSUMzaE5lX0hOWVBrTTlMYnRITEhaNkNPSzF1VjlLSkZaekp4VlhsSDdnIiwiYnJhbmNoIjoidDItY2FsLWNvbS0yMjUzMiIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjIxLCJjb21taXRTaGEiOiJlYjc1NzRjZDFiYTVjNmU1YjI5YzBmOTY5MDgwMzMxMjAzZTcwNzNhIiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit eb7574cd1ba5c6e5b29c0f969080331203e7073a. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
PR-level
<!-- BUGBOT_REVIEW --> Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues. <!-- BUGBOT_FIX_ALL --> <a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTo0NWY5ZGY1Ni0yYzY5LTRmNzAtOGEyMi03NmUxMmM0NTZlNzgiLCJlbmNyeXB0aW9uS2V5IjoiN1JkanA5Z2I3TU9YV2N4a1dBZl9OaURIUDhiNzJOMjB3YmhTbGtBbEFsNCIsImJyYW5jaCI6InQyLWNhbC1jb20tMjI1MzIiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <!-- /BUGBOT_FIX_ALL --> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN --> <sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).</sup> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END --> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit eb7574cd1ba5c6e5b29c0f969080331203e7073a. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
Drape (Deep Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✓ exact
valid · impact medium
Prisma does not write anything for an update whose data object is empty, so @updatedAt is never set. The new call therefore does not refresh SelectedCalendar.updatedAt, which is the thing its own comment says it is meant to do. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
tRPC turns a plain Error into INTERNAL_SERVER_ERROR (500). The new handler should return NOT_FOUND or FORBIDDEN when the user doesn't own the credential. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d2 · impact low
valid · impact low
EventAdvancedTab renders SelectedCalendarsSettingsWebWrapper without onChanged, and deleteCacheMutation invalidates nothing itself. On that tab, connectedCalendars is never refetched after a cache delete, so the old cache status stays on screen. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
The groupBy has no expiresAt filter, so cache rows that have expired and are no longer served still produce a cache status and a delete option. This is a minor inconsistency with how cache reads treat expiry. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
The locale is hardcoded to en-US, so the timestamp is not formatted for the user's language in a component that is otherwise localized. [grounded: diff] [consensus 3/3: valid=3]
raw comments (6)
packages/app-store/googlecalendar/lib/CalendarService.ts:1024
**Selected calendars' updatedAt is never bumped** Prisma only sets `@updatedAt` when the update has at least one field, so `updateManyByCredentialId(this.credential.id, {})` does nothing. SelectedCalendar.updatedAt stays as it was after every webhook refresh. Pass `{ updatedAt: new Date() }` explicitly. ``` packages/app-store/googlecalendar/lib/CalendarService.ts:1023 // Update SelectedCalendar.updatedAt for all calendars under this credential packages/app-store/googlecalendar/lib/CalendarService.ts:1024 await SelectedCalendarRepository.updateManyByCredentialId(this.credential.id, {}); packages/lib/server/repository/selectedCalendar.ts:400 static async updateManyByCredentialId(credentialId: number, data: Prisma.SelectedCalendarUpdateInput) { packages/lib/server/repository/selectedCalendar.ts:401 return await prisma.selectedCalendar.updateMany({ packages/prisma/schema.prisma:860 updatedAt DateTime? @updatedAt ```
packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts:25
**Unauthorized cache delete returns a 500 error** When the credential doesn't belong to the user, `deleteCacheHandler` throws a plain `Error`. tRPC reports that as INTERNAL_SERVER_ERROR instead of NOT_FOUND/FORBIDDEN and logs it as a server fault. Throw `new TRPCError({ code: "NOT_FOUND" })` instead. ``` packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts:17 const credential = await prisma.credential.findFirst({ packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts:18 where: { packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts:19 id: credentialId, packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts:20 userId: user.id, packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts:25 throw new Error("Credential not found or access denied"); ```
scripts/test-gcal-webhooks.sh:69
**Script's env update fails on Linux sed** `sed -i ''` is BSD/macOS syntax; GNU sed treats `''` as the script and fails, so on Linux the existing GOOGLE_WEBHOOK_URL isn't updated while the script still prints success. Use a portable form, e.g. `sed -i.bak ... && rm file.bak`. ``` scripts/test-gcal-webhooks.sh:68 sed -i '' -E "s|^GOOGLE_WEBHOOK_URL=.*|GOOGLE_WEBHOOK_URL=$TUNNEL_URL|" "$ENV_FILE" scripts/test-gcal-webhooks.sh:69 else scripts/test-gcal-webhooks.sh:70 echo "GOOGLE_WEBHOOK_URL=$TUNNEL_URL" >> "$ENV_FILE" scripts/test-gcal-webhooks.sh:71 fi ```
packages/features/apps/components/CredentialActionsDropdown.tsx:43
**Event-type tab keeps showing deleted cache** In the event type Advanced tab, no onChanged is passed. After a cache delete, nothing invalidates viewer.calendars.connectedCalendars, so the old "Last updated" time and the delete option stay visible. Invalidate connectedCalendars in deleteCacheMutation's onSettled, as disconnectMutation does. ``` packages/features/apps/components/CredentialActionsDropdown.tsx:43 onSuccess: () => { packages/features/apps/components/CredentialActionsDropdown.tsx:44 showToast(t("cache_deleted_successfully"), "success"); packages/features/apps/components/CredentialActionsDropdown.tsx:45 onSuccess?.(); packages/features/apps/components/CredentialActionsDropdown.tsx:46 }, packages/features/apps/components/CredentialActionsDropdown.tsx:61 async onSettled() { packages/features/apps/components/CredentialActionsDropdown.tsx:62 await utils.viewer.calendars.connectedCalendars.invalidate(); packages/features/apps/components/CredentialActionsDropdown.tsx:63 await utils.viewer.apps.integrations.invalidate(); packages/features/apps/components/CredentialActionsDropdown.tsx:64 }, ```
packages/features/calendar-cache/calendar-cache.repository.ts:176
**Cache status shown for expired cache entries** `getCacheStatusByCredentialIds` doesn't filter on `expiresAt`, so expired rows that are never read again still make the UI show a cache status and a delete option. Add `expiresAt: { gte: new Date() }` to the where clause. ``` packages/features/calendar-cache/calendar-cache.repository.ts:173 async getCacheStatusByCredentialIds(credentialIds: number[]) { packages/features/calendar-cache/calendar-cache.repository.ts:174 const cacheStatuses = await prisma.calendarCache.groupBy({ packages/features/calendar-cache/calendar-cache.repository.ts:175 by: ["credentialId"], packages/features/calendar-cache/calendar-cache.repository.ts:176 where: { packages/features/calendar-cache/calendar-cache.repository.ts:121 cached = await prisma.calendarCache.findUnique({ packages/features/calendar-cache/calendar-cache.repository.ts:122 where: { packages/features/calendar-cache/calendar-cache.repository.ts:123 credentialId_key: { packages/features/calendar-cache/calendar-cache.repository.ts:124 credentialId, packages/features/calendar-cache/calendar-cache.repository.ts:125 key, packages/features/calendar-cache/calendar-cache.repository.ts:126 }, ```
packages/features/apps/components/CredentialActionsDropdown.tsx:89
**Cache timestamp always formatted as en-US** The last-updated date is formatted with a hardcoded "en-US" locale, ignoring the user's language, so non-US users see month/day order. Use the locale from `useLocale()` (`i18n.language`). ``` packages/features/apps/components/CredentialActionsDropdown.tsx:88 {t("cache_last_updated", { packages/features/apps/components/CredentialActionsDropdown.tsx:89 timestamp: new Intl.DateTimeFormat("en-US", { packages/features/apps/components/CredentialActionsDropdown.tsx:90 dateStyle: "short", packages/features/apps/components/CredentialActionsDropdown.tsx:91 timeStyle: "short", ```
Drape (Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✗ —
valid · impact low
The change adds an updateMany with empty data on every refresh. It exists only to bump updatedAt, and with an empty payload it may not bump it at all. This is a small, real overhead. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
tRPC maps a plain Error to INTERNAL_SERVER_ERROR, so an unauthorized or missing credential produces a 500. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
The old Alert branch only checked delegationCredentialId. It now passes disableConnectionModification, so canDisconnect becomes false in EventAdvancedTab and the remove button is hidden there. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
The handler bypasses CalendarCache.init, which is what picks the mock when the feature is disabled. As a result, cache status is queried and shown even when calendar-cache is turned off. [grounded: diff] [consensus 3/3: valid=3]
uncertain · impact low
cleanup always exits 0, and it is called on the rate-limit and missing-URL failure paths, so the script reports success when it fails. [uncertain: quoted evidence is not in tree file scripts/test-gcal-webhooks.sh] [consensus 3/4: uncertain=3, valid=1]
valid · impact low
In-memory delegation credentials have negative ids (assertCalendarHasDbCredential rejects ids below 0), while CalendarCache rows are keyed by real DB credential ids. The lookup by the connected calendar's credentialId therefore misses for delegation calendars. [grounded: tree packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts] [consensus 3/4: valid=3, uncertain=1]
valid · impact low
The locale is hardcoded, so non-English users see a US-formatted timestamp inside translated text. [grounded: diff] [consensus 3/3: valid=3]
raw comments (7)
packages/app-store/googlecalendar/lib/CalendarService.ts:1024
**Extra updateMany query on every Google webhook** Each webhook or unwatch refresh runs updateManyByCredentialId(credential.id, {}) over all of the credential's SelectedCalendars, only to touch updatedAt, which nothing reads. Empty data may not even bump @updatedAt. Remove the call, or set updatedAt: new Date() explicitly. ``` packages/app-store/googlecalendar/lib/CalendarService.ts:1023 // Update SelectedCalendar.updatedAt for all calendars under this credential packages/app-store/googlecalendar/lib/CalendarService.ts:1024 await SelectedCalendarRepository.updateManyByCredentialId(this.credential.id, {}); packages/lib/server/repository/selectedCalendar.ts:400 static async updateManyByCredentialId(credentialId: number, data: Prisma.SelectedCalendarUpdateInput) { packages/lib/server/repository/selectedCalendar.ts:401 return await prisma.selectedCalendar.updateMany({ packages/lib/server/repository/selectedCalendar.ts:402 where: { credentialId }, packages/lib/server/repository/selectedCalendar.ts:403 data, packages/lib/server/repository/selectedCalendar.ts:404 }); packages/lib/server/repository/selectedCalendar.ts:405 } ```
packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts:23
**Cache deletion failure returns a generic server error** When the credential isn't found or isn't owned by the caller, `deleteCacheHandler` throws a plain `Error`. tRPC turns that into a 500 instead of a 404 or 403. Throw a `TRPCError` with code NOT_FOUND or FORBIDDEN instead of `Error`. ``` packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts:24 if (!credential) { packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts:25 throw new Error("Credential not found or access denied"); ```
packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx:122
**Broken calendar loses remove button in event settings** In the event type Advanced tab (disableConnectionModification=true), a credential with no calendars used to show a remove button. CredentialActionsDropdown now hides it, so users can't remove the broken connection there. Don't pass disableConnectionModification in the Alert branch if the old behavior is wanted. ``` packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx:122 actions={ packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx:123 <div className="flex w-32 justify-end"> packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx:124 <CredentialActionsDropdown packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx:125 credentialId={connectedCalendar.credentialId} packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx:122 (base) } packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx:123 (base) iconClassName="h-10 w-10 ml-2 mr-1 mt-0.5" packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx:124 (base) actions={ packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx:125 (base) // Delegation credential can't be disconnected packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx:126 (base) !connectedCalendar.delegationCredentialId && ( packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx:127 (base) <div className="flex w-32 justify-end"> ```
packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:28
**Cache status ignores the calendar-cache disabled switch** `connectedCalendarsHandler` builds `new CalendarCacheRepository()` directly. It does not go through `CalendarCache.init`, which picks the mock repository when calendar-cache is disabled. The `getCacheStatusByCredentialIds` mock added in this change is therefore never used. Get the repository from `CalendarCache.initFromCredentialId` or `CalendarCache.init`, so the disabled mock is used. ``` packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:27 const credentialIds = connectedCalendars.map((cal) => cal.credentialId); packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:28 const cacheRepository = new CalendarCacheRepository(); packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:29 const cacheStatuses = await cacheRepository.getCacheStatusByCredentialIds(credentialIds); packages/features/calendar-cache/calendar-cache.repository.mock.ts:27 async getCacheStatusByCredentialIds() { packages/features/calendar-cache/calendar-cache.ts:15 static async initFromCredentialId(credentialId: number): Promise<ICalendarCacheRepository> { packages/features/calendar-cache/calendar-cache.ts:16 log.debug("initFromCredentialId", safeStringify({ credentialId })); packages/features/calendar-cache/calendar-cache.ts:17 const credentialForCalendarCache = await getCredentialForCalendarCache({ credentialId }); packages/features/calendar-cache/calendar-cache.ts:19 const calendarForCalendarCache = await getCalendar(credentialForCalendarCache); packages/features/calendar-cache/calendar-cache.ts:20 return await CalendarCache.init(calendarForCalendarCache); packages/features/calendar-cache/calendar-cache.ts:21 } ```
scripts/test-gcal-webhooks.sh:40
**Script exits 0 when tunnel URL is missing** On a rate limit, a URL extraction failure, or a reused tmole whose /tmp/tmole.log is missing, cleanup runs `exit 0`, so callers see success although GOOGLE_WEBHOOK_URL was never written. Have cleanup take an exit code, and pass a non-zero one on failure paths. ``` scripts/test-gcal-webhooks.sh:10 # Clean exit function scripts/test-gcal-webhooks.sh:11 cleanup() { scripts/test-gcal-webhooks.sh:12 if [ "$OWNED_PID" = true ]; then scripts/test-gcal-webhooks.sh:13 echo -e "\nStopping Tunnelmole (PID: $TMOLE_PID)..." ```
packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:27
**Cache status never shown for delegation credentials** `cacheStatusMap` is keyed by `credentialId`, which is -1 for delegation-credential calendars. Their `CalendarCache` rows use the real DB credential id, so the lookup always returns null. Resolve the real DB credential id for delegation calendars before the cache lookup. ``` packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:27 const credentialIds = connectedCalendars.map((cal) => cal.credentialId); packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:28 const cacheRepository = new CalendarCacheRepository(); packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:29 const cacheStatuses = await cacheRepository.getCacheStatusByCredentialIds(credentialIds); packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:31 const cacheStatusMap = new Map(cacheStatuses.map((cache) => [cache.credentialId, cache.updatedAt])); ```
packages/features/apps/components/CredentialActionsDropdown.tsx:90
**Cache timestamp ignores user locale** The cache-updated time is formatted with a hardcoded "en-US" locale, so it ignores the user's language even though the surrounding text is translated. Use the user's locale from `useLocale` (i18n.language) when formatting. ``` packages/features/apps/components/CredentialActionsDropdown.tsx:88 {t("cache_last_updated", { packages/features/apps/components/CredentialActionsDropdown.tsx:89 timestamp: new Intl.DateTimeFormat("en-US", { packages/features/apps/components/CredentialActionsDropdown.tsx:90 dateStyle: "short", packages/features/apps/components/CredentialActionsDropdown.tsx:91 timeStyle: "short", ```
greptile · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✓ off by one
valid · impact medium
Prisma short-circuits update operations that have empty data, so @updatedAt is not reliably bumped. The comment says the call is meant to advance updatedAt, which it may fail to do. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
The handler skips the CalendarCache.init feature-flag factory, so it queries the DB table and can show stale cache status even when the feature is disabled. [grounded: diff] [consensus 3/3: valid=3]
invalid
DB-backed delegated user credentials carry the user's userId, so the ownership check passes. In-memory delegation credentials have negative ids and no cache rows keyed to them, so hasCache is false for them. The claim that the action 'always errors' doesn't hold. [invalid: contradiction] [consensus 3/3: invalid=3]
valid · impact low
tsx is not declared in any package.json or in yarn.lock (grep found nothing), so npx has to download an unpinned version at run time. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
The relative path is resolved from the caller's current directory, not from the script's location, so running the script from anywhere else edits the wrong .env file. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d2 · impact low
valid · impact low
cleanup is called on the failure paths (rate limit, missing URL) and always exits 0, so callers see success even when setup failed. [grounded: diff] [consensus 3/3: valid=3]
raw comments (8)
packages/app-store/googlecalendar/lib/CalendarService.ts:1024
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Timestamp Update Is Empty** Passing an empty update object does not modify a scalar field, so this call does not reliably advance Prisma's `@updatedAt` value as the comment intends. After availability is refreshed, `SelectedCalendar.updatedAt` can remain stale. Explicitly write the timestamp or another field instead of relying on an empty update.
packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:28
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Disabled Cache Is Bypassed** This handler directly constructs the database-backed repository instead of using the existing calendar-cache factory. When the global `calendar-cache` feature is disabled, loading connected calendars still queries `CalendarCache` and may expose stale status or fail where the configured mock would return no cache data.
packages/features/apps/components/CredentialActionsDropdown.tsx:69
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Delegated Cache Action Fails** Cache actions are enabled only from the Google integration type and timestamp, unlike disconnection, which also checks delegation ownership. A database-backed delegated Google credential can therefore show “Delete cached data,” but the mutation rejects it because authorization requires `credential.userId` to match the current user. The advertised action consistently ends with an error.
apps/web/package.json:11
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Cron Runner Is Undeclared** The package command changes from the declared `ts-node` dependency to `npx tsx`, but `tsx` is absent from both manifests and the lockfile. The command therefore relies on an implicit network installation and an unpinned package version, causing it to fail in offline or install-disabled development environments. Declare and invoke a locked workspace dependency instead.
scripts/test-gcal-webhooks.sh:6
<a href="#"><img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"></a> **Environment Path Uses Caller** `ENV_FILE="../.env"` is resolved from the caller's working directory rather than the script's directory. Invoking the executable from the repository root targets the parent directory, potentially creating or modifying an unrelated `.env` while leaving the application's root `.env` unchanged. Derive the path from `BASH_SOURCE[0]` or the repository root.
scripts/test-gcal-webhooks.sh:69
<a href="#"><img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"></a> **Sed Command Is Nonportable** The replacement branch uses BSD `sed -i ''` syntax, which fails under GNU sed in common Linux development environments. When `GOOGLE_WEBHOOK_URL` already exists, its value remains unchanged, but the script lacks fail-fast handling and still prints that the update succeeded. Use portable replacement logic or handle both sed variants.
scripts/test-gcal-webhooks.sh:17
<a href="#"><img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"></a> **Failures Exit Successfully** `cleanup` always exits successfully, including when initialization produces no URL or Tunnelmole reports a rate limit. Automation and callers therefore cannot distinguish setup failure from success. Accept a status argument or exit nonzero on these failure paths.
PR-level
<h3>Greptile Summary</h3> This PR adds credential-level calendar-cache status and deletion controls, records cache update timestamps, and introduces related developer tooling. - Extends the calendar-cache repository and connected-calendar response with latest cache timestamps. - Adds an authenticated cache-deletion mutation and a combined cache/disconnect dropdown. - Adds the `CalendarCache.updatedAt` schema migration and expands selected-calendar data. - Changes the cron runner and introduces a Google Calendar webhook helper. - The review found blocking issues in timestamp advancement, disabled-feature repository wiring, delegated credential actions, and the undeclared cron runner dependency, plus portability problems in the webhook helper. <h3>Confidence Score: 1/5</h3> The PR is not safe to merge until cache refresh timestamps, disabled-cache wiring, delegated cache actions, and the cron runner dependency are corrected. The changed refresh path does not reliably perform its promised timestamp update, connected-calendar loading bypasses the disabled-cache implementation, delegated credentials can receive an unusable deletion action, and the cron command depends on an undeclared package; the webhook helper also has non-blocking portability and failure-reporting defects. **Files Needing Attention:** packages/app-store/googlecalendar/lib/CalendarService.ts, packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts, packages/features/apps/components/CredentialActionsDropdown.tsx, apps/web/package.json, scripts/test-gcal-webhooks.sh <details><summary><h3>Important Files Changed</h3></summary> | Filename | Overview | |----------|----------| | packages/app-store/googlecalendar/lib/CalendarService.ts | Attempts to mark selected calendars refreshed using an empty Prisma update that does not reliably advance the intended timestamp. | | packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts | Adds cache-status enrichment but bypasses the configured concrete/mock calendar-cache factory. | | packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts | Adds an authenticated, directly owned credential check before deleting credential-scoped cache rows. | | packages/features/apps/components/CredentialActionsDropdown.tsx | Combines cache and disconnect actions, but exposes cache deletion for delegated credentials that the server rejects. | | packages/features/calendar-cache/calendar-cache.repository.ts | Adds a grouped latest-update query for cache rows by credential. | | packages/prisma/schema.prisma | Adds a Prisma-managed creation/update timestamp to calendar-cache records. | | packages/prisma/migrations/20250715160635_add_calendar_cache_updated_at/migration.sql | Adds the required cache timestamp with a default that safely initializes existing rows. | | apps/web/package.json | Replaces the declared TypeScript runner with an undeclared and unlocked `npx tsx` dependency. | | scripts/test-gcal-webhooks.sh | Adds a webhook tunnel helper with caller-dependent paths, non-portable replacement syntax, and misleading success exits. | </details> <details open><summary><h3>Sequence Diagram</h3></summary> ```mermaid sequenceDiagram participant UI as Selected Calendars UI participant API as calendars router participant Handler as connectedCalendarsHandler participant Cache as CalendarCacheRepository participant DB as Prisma / Database UI->>API: connectedCalendars API->>Handler: authenticated request Handler->>Cache: getCacheStatusByCredentialIds(ids) Cache->>DB: groupBy credentialId, max(updatedAt) DB-->>Cache: cache status rows Cache-->>Handler: timestamps Handler-->>UI: calendars + cacheUpdatedAt opt User chooses Delete cached data UI->>API: deleteCache(credentialId) API->>DB: verify credential.userId API->>DB: deleteMany CalendarCache rows API-->>UI: success or access-denied error end ``` </details> <!-- greptile_other_comments_section --> <sub>Reviews (1): Last reviewed commit: ["Update apps/web/package.json and 16 more..."](https://github.com/drape-io/crbench-greptile-2026-09/commit/ec936df82ecd56bfde3ac20aa803c0d472574e40) | [Re-trigger Greptile](https://app.greptile.com/api/retrigger?id=64288921)</sub>
Mjolnir (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✓ exact
valid · impact medium
Prisma's query engine only adds @updatedAt timestamps when the write args are non-empty (update_datetimes skips empty args). An updateMany with `{}` is therefore a no-op, so the change's stated goal of bumping SelectedCalendar.updatedAt is never met. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d2 · impact low
valid · impact medium
This is the same root cause as finding 0. Because the data is empty, Prisma does not set @updatedAt, so the updatedAt field newly selected in user.ts never shows when the cache was last synced. [grounded: diff] [consensus 3/3: valid=3]
raw comments (3)
packages/app-store/googlecalendar/lib/CalendarService.ts:1023
[P2] Empty `updateMany` does not bump `SelectedCalendar.updatedAt` The comment says this call refreshes `SelectedCalendar.updatedAt` for every calendar under the credential, but it passes `{}` as `data` to `updateManyByCredentialId`. Prisma only fills in `@updatedAt` fields when the update has at least one other field to write. When `data` is empty, the query engine skips the UPDATE and returns a count of 0. So after every `fetchAvailabilityAndSetCache` run (for example, after each Google webhook), `updatedAt` keeps its old value. This adds a database round-trip that does nothing. To actually bump the timestamp, the call needs an explicit value such as `{ updatedAt: new Date() }`.
scripts/test-gcal-webhooks.sh:69
[P3] `sed -i ''` only works with BSD/macOS sed The script updates `GOOGLE_WEBHOOK_URL` with `sed -i '' -E ...`, and that syntax is specific to BSD/macOS sed. GNU sed on Linux reads `''` as the sed script and the `s|...|` expression as a filename. The command fails, so when `.env` already contains `GOOGLE_WEBHOOK_URL`, the URL is not updated. The script still prints "✅ Updated GOOGLE_WEBHOOK_URL", so the failure is easy to miss. This only affects developers running the helper on Linux.
packages/app-store/googlecalendar/lib/CalendarService.ts:1023
[P2] An `updateMany` with empty data won't refresh `SelectedCalendar.updatedAt` The comment says this call updates `SelectedCalendar.updatedAt` for every calendar under the credential after the cache is refilled. It passes an empty `data` object (`updateManyByCredentialId(this.credential.id, {})`), and Prisma only adds the `@updatedAt` timestamp when the update has at least one other field. With nothing to write, Prisma treats the `updateMany` as a no-op and returns `{ count: 0 }` without running an UPDATE. So `updatedAt` stays the same on every `fetchAvailabilityAndSetCache` run, and the `updatedAt` value now selected in `user.ts`/`UserWithCalendars` never shows when the cache was last synced. To actually bump the timestamp, the call has to set the field explicitly, for example `{ updatedAt: new Date() }`.
Mjolnir (Sonnet 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✗ —
qodo · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✓ off by one
valid · impact low
Delegated calendars expose an in-memory (non-DB) credentialId while cache rows are keyed by real DB credential; the groupBy on credentialId returns nothing for them, so cacheUpdatedAt is null and cache controls are hidden. The deletion half is unreachable via UI but the core claim holds. [grounded: tree packages/features/calendar-cache/calendar-cache.repository.ts] [consensus 3/3: valid=3]
valid · impact low
Locale is hard-coded to en-US despite useLocale being available, so non-US users see US formatting. [grounded: tree packages/features/apps/components/CredentialActionsDropdown.tsx] [consensus 3/3: valid=3]
valid · impact low
Relative path resolves against cwd; running from repo root writes ../.env outside the repo. [grounded: tree scripts/test-gcal-webhooks.sh] [consensus 3/3: valid=3]
valid · matches d2 · impact low
uncertain · impact low
cleanup is called on rate-limit and URL-extraction failures and always exits 0, masking failures. [uncertain: quoted evidence is not in tree file scripts/test-gcal-webhooks.sh] [consensus 3/5: uncertain=3, valid=2]
valid · impact medium
Passing empty data to updateMany gives Prisma no field to change, so the intended updatedAt refresh likely does not occur. [grounded: tree packages/app-store/googlecalendar/lib/CalendarService.ts] [consensus 3/3: valid=3]
valid · impact low
deleteCacheMutation relies only on optional onSuccess; EventAdvancedTab renders the wrapper without onChanged, so connectedCalendars isn't invalidated and stale cache status remains. [grounded: tree packages/features/apps/components/CredentialActionsDropdown.tsx] [consensus 3/3: valid=3]
valid · impact low
Bypasses CalendarCache.init feature gate, so the groupBy query runs and legacy rows can surface even when caching is disabled. [grounded: tree packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts] [consensus 3/3: valid=3]
raw comments (10)
packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:29
<img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> 2\. Delegated calendars hide cache controls <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> The status lookup uses the synthetic credential ID exposed for delegated calendars, although delegated cache reads intentionally locate reusable records by user ID and cache key. These calendars therefore receive no <b><i>cacheUpdatedAt</i></b>, and attempting deletion with the synthetic ID would also fail the database-credential ownership check. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Delegated calendars use an in-memory synthetic credential ID, but the new status and deletion paths assume every cache belongs to a persisted credential ID. ## Fix Focus Areas - packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts[27-35] - packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts[17-30] - packages/features/apps/components/CredentialActionsDropdown.tsx[67-73] ## Recommended Fix Detect delegated credentials and resolve their cache status and authorized deletion using the existing delegated-cache identity model based on the authenticated user and relevant cache records, rather than querying credential ID `-1`. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
packages/features/apps/components/CredentialActionsDropdown.tsx:92
<img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> 3\. Dates always use united states format <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>CredentialActionsDropdown</i></b> hard-codes <b><i>en-US</i></b> when formatting the cache timestamp despite already obtaining the active translation context from <b><i>useLocale</i></b>. Users of other locales consequently see the newly added date and time in United States ordering and conventions. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Cache timestamps are formatted with a hard-coded United States locale instead of the user's active locale. ## Fix Focus Areas - packages/features/apps/components/CredentialActionsDropdown.tsx[37-37] - packages/features/apps/components/CredentialActionsDropdown.tsx[88-94] ## Recommended Fix Read the active language from the `i18n` object returned by `useLocale` and pass it to `Intl.DateTimeFormat` instead of `en-US`. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
scripts/test-gcal-webhooks.sh:5
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 1\. Root runs edit the parent environment <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>ENV_FILE</i></b> is a relative path resolved from the caller&#x27;s working directory rather than from the script&#x27;s directory. Running the script normally from the repository root creates or edits <b><i>../.env</i></b>, while the application continues using the repository&#x27;s own <b><i>.env</i></b>. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description The webhook helper resolves its environment file from the caller's working directory and can modify a file outside the repository. ## Fix Focus Areas - scripts/test-gcal-webhooks.sh[3-5] - scripts/test-gcal-webhooks.sh[61-70] ## Recommended Fix Determine the absolute directory containing the script, derive the repository root from it, and set `ENV_FILE` to that root's `.env` regardless of the current working directory. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
scripts/test-gcal-webhooks.sh:70
<img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> 4\. Linux users cannot update the address <code>🐞 Bug</code> <code>☼ Reliability</code> <pre> The existing-variable branch uses the BSD-specific <b><i>sed -i &#x27;&#x27;</i></b> form, which fails under GNU sed. Linux developers with an existing <b><i>GOOGLE_WEBHOOK_URL</i></b> therefore retain the old address even though the script prints that it was updated. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description The script's in-place replacement syntax is specific to BSD sed and fails on Linux systems using GNU sed. ## Fix Focus Areas - scripts/test-gcal-webhooks.sh[67-73] ## Recommended Fix Replace the platform-specific command with a portable temporary-file replacement or explicitly select compatible syntax based on the detected sed implementation, and report success only after the operation succeeds. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
scripts/test-gcal-webhooks.sh:17
<img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> 5\. Tunnel failures return successful status <code>🐞 Bug</code> <code>☼ Reliability</code> <pre> <b><i>cleanup</i></b> always executes <b><i>exit 0</i></b>, including when it is called after rate limiting or failure to extract a tunnel address. Automated callers and developers therefore cannot distinguish failed initialization from a successful script run by its exit status. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description The cleanup function converts detected Tunnelmole initialization failures into successful process exits. ## Fix Focus Areas - scripts/test-gcal-webhooks.sh[10-18] - scripts/test-gcal-webhooks.sh[46-58] ## Recommended Fix Allow `cleanup` to accept and return an exit status, call it with a nonzero status from failure branches, and retain zero only for normal signal-driven or completed shutdown. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
packages/app-store/googlecalendar/lib/CalendarService.ts:1024
<img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> 6\. Selections keep stale refresh times <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>fetchAvailabilityAndSetCache</i></b> calls <b><i>updateManyByCredentialId</i></b> with an empty data object, so the forwarded Prisma update has no field to change and does not refresh <b><i>SelectedCalendar.updatedAt</i></b>. This runs after availability is fetched and cached, including when rebuilding cache after unwatching one calendar while others remain, leaving the timestamp named by the new comment unchanged. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` Issue description `fetchAvailabilityAndSetCache` intends to refresh every selected calendar's `updatedAt`, but passes `{}` through to Prisma, which performs no timestamp change. Fix Focus Areas - packages/app-store/googlecalendar/lib/CalendarService.ts[1023-1024] - packages/lib/server/repository/selectedCalendar.ts[400-405] Recommended Fix Pass an explicit timestamp update, such as `{ updatedAt: new Date() }`, to `updateManyByCredentialId` after successful cache population. Keep the update scoped by credential ID. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
packages/features/apps/components/CredentialActionsDropdown.tsx:46
<img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> 7\. Deleted cache status remains on screen <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>deleteCacheMutation</i></b> only invokes the optional <b><i>onSuccess</i></b> callback and never invalidates <b><i>viewer.calendars.connectedCalendars</i></b>, the query that supplies <b><i>cacheUpdatedAt</i></b>. When callers such as the Event Advanced settings page omit the callback, deleting all cache rows leaves the mounted dropdown showing the previous last-updated status and delete action until an unrelated refetch occurs. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description After a successful cache deletion, the `viewer.calendars.connectedCalendars` query remains cached, so components without an `onSuccess` callback continue rendering the old `cacheUpdatedAt` value and related cache status. ## Fix Focus Areas - packages/features/apps/components/CredentialActionsDropdown.tsx[42-50] - packages/features/apps/components/CredentialActionsDropdown.tsx[130-140] ## Recommended Fix Obtain the tRPC query utilities before defining `deleteCacheMutation`, then invalidate `viewer.calendars.connectedCalendars` in the mutation's success or settled handler independently of the optional parent callback. Retain the callback for callers that need additional refresh work. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts:29
<img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> 8\. Disabled caching still hits the database <code>🐞 Bug</code> <code>➹ Performance</code> <pre> <b><i>connectedCalendarsHandler</i></b> constructs <b><i>CalendarCacheRepository</i></b> directly instead of using <b><i>CalendarCache.init</i></b>, which selects the no-op <b><i>CalendarCacheRepositoryMock</i></b> when calendar caching is disabled. Every connected-calendars request therefore reaches the cache table and executes the cache-status grouping query even with caching globally disabled, allowing legacy rows to surface through <b><i>cacheUpdatedAt</i></b>. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description The connected-calendars handler bypasses the calendar-cache feature gate by constructing the concrete repository directly, causing the cache-status query to access cache storage even while caching is disabled and potentially expose legacy cache state through `cacheUpdatedAt`. ## Fix Focus Areas - packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts[27-35] - packages/features/calendar-cache/calendar-cache.ts[14-29] ## Recommended Fix Initialize the repository through `CalendarCache.init(null)` and call `getCacheStatusByCredentialIds` on the returned interface. Alternatively, add an equivalent status-specific feature-aware factory; in either case, ensure the disabled path returns `CalendarCacheRepositoryMock` so the status lookup produces an empty result without querying the database. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
PR-level
<h3>PR Summary by Qodo</h3> Expose Google Calendar cache status and deletion controls <code>✨ Enhancement</code> <code>🕐 40+ Minutes</code> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <details> <summary>AI Description</summary> <dl> <dd> <br/> ><pre> >• Shows latest Google Calendar cache timestamps in connected calendar settings. >• Lets credential owners delete cached availability through a confirmed action. >• Tracks cache freshness and adds local webhook testing tooling. ></pre> </dd> </dl> </details> <details> <summary>Diagram</summary> <dl> <dd> <br/> ```mermaid sequenceDiagram actor U as User participant UI as Calendar Settings participant API as Calendars API participant CR as Cache Repository participant DB as Prisma Database participant GC as Google Calendar U->>UI: Open connected calendars UI->>API: Fetch calendars API->>CR: Request cache status CR->>DB: Group by credential DB-->>CR: Latest timestamps CR-->>API: Cache statuses API-->>UI: Enriched calendars GC->>DB: Refresh availability cache GC->>DB: Touch calendar timestamps U->>UI: Confirm cache deletion UI->>API: Delete credential cache API->>DB: Verify owner and delete DB-->>API: Deletion result API-->>UI: Show result ``` </dd> </dl> </details> <details> <summary>High-Level Assessment</summary> <dl> <dd> <br/> >The following are alternative approaches to this PR: <details> <summary><b>1. Route deletion through CalendarCacheRepository</b></summary> <dl> <dd> - ➕ Keeps cache persistence behind the existing repository abstraction. - ➕ Supports disabled-cache implementations consistently through the repository mock. - ➕ Makes cache deletion easier to isolate in tests. - ➖ Credential ownership must still be checked separately in the handler. - ➖ Requires aligning the existing repository deletion method with this API use case. </dd> </dl> </details> <details> <summary><b>2. Persist freshness on each credential</b></summary> <dl> <dd> - ➕ Avoids grouping cache rows whenever connected calendars are requested. - ➕ Provides a single timestamp even after all cache rows are deleted. - ➖ Duplicates state derived from cache records. - ➖ Every cache write and deletion path must synchronize the credential timestamp. - ➖ Requires broader migration and lifecycle changes. </dd> </dl> </details> >**Recommendation:** Keep CalendarCache.updatedAt as the freshness source because it accurately reflects persisted cache entries and requires limited denormalization. Prefer invoking the existing cache repository for deletion after ownership validation rather than deleting through Prisma directly, preserving repository boundaries and disabled-cache behavior. </dd> </dl> </details> <details> <summary> Files changed (17) <code> +379 / -31 </code> </summary> <dl> <dd> <br/> <details> <summary>Enhancement (14) <code> +290 / -30 </code></summary> <dl> <dd> <details> <summary>common.json<code>Add cache management translations</code> <code>+7/-0</code></summary> <br/> >Add cache management translations > ><pre> >• Adds English labels, confirmations, timestamps, and success or error messages for calendar cache management. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-57de4b8e5231f1d699891d98b0381d56e9e24537b0ca5420d1fba4f0597370bc'>apps/web/public/static/locales/en/common.json</a> </details> <details> <summary>CalendarService.ts<code>Touch selected calendars after cache refresh</code> <code>+3/-0</code></summary> <br/> >Touch selected calendars after cache refresh > ><pre> >• Updates all selected calendars associated with the credential after refreshing availability data, ensuring their update timestamps reflect synchronization activity. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-6bfbaf63c841dc9343dba0c7487e30a546ffe2a63c9d9418379d0dbb88644d27'>packages/app-store/googlecalendar/lib/CalendarService.ts</a> </details> <details> <summary>CredentialActionsDropdown.tsx<code>Add credential cache and disconnect actions</code> <code>+157/-0</code></summary> <br/> >Add credential cache and disconnect actions > ><pre> >• Introduces a dropdown that displays Google Calendar cache freshness and offers confirmed cache deletion. It also consolidates credential disconnection while respecting delegated and modification-disabled credentials. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-c78273434b95ab8276bb5eb24d9bc088b10af029388bdcd08cbe478f44269b31'>packages/features/apps/components/CredentialActionsDropdown.tsx</a> </details> <details> <summary>calendar-cache.repository.interface.ts<code>Define cache status lookup contract</code> <code>+3/-0</code></summary> <br/> >Define cache status lookup contract > ><pre> >• Extends the cache repository interface with a batched credential-status lookup returning latest update timestamps. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-b36c72c0db751ba0cafe234dfa150817672869825333c22b074c4977a6135b8d'>packages/features/calendar-cache/calendar-cache.repository.interface.ts</a> </details> <details> <summary>calendar-cache.repository.mock.ts<code>Support cache status calls when caching is disabled</code> <code>+5/-0</code></summary> <br/> >Support cache status calls when caching is disabled > ><pre> >• Implements the new status lookup in the disabled-cache repository by logging and returning an empty result. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-ceffbae9ef3da413495feac73a341672e77ffaf493cf67ada0b637ead80ded38'>packages/features/calendar-cache/calendar-cache.repository.mock.ts</a> </details> <details> <summary>calendar-cache.repository.ts<code>Aggregate latest cache timestamps by credential</code> <code>+17/-0</code></summary> <br/> >Aggregate latest cache timestamps by credential > ><pre> >• Queries calendar cache records in one grouped operation and returns each credential&#x27;s most recent update timestamp. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-4cf8d3089fad7b6c8fe4172d8d42147f136b65baf30b726e57b9b10d179d4a99'>packages/features/calendar-cache/calendar-cache.repository.ts</a> </details> <details> <summary>getConnectedDestinationCalendars.ts<code>Include selected-calendar synchronization fields</code> <code>+8/-2</code></summary> <br/> >Include selected-calendar synchronization fields > ><pre> >• Expands selected-calendar types to carry update timestamps and Google channel identifiers through connected-calendar processing. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-40234d044a7b817c8a743908131b8ad9ec2800e325a1df68564a8c8b14f93ee8'>packages/lib/getConnectedDestinationCalendars.ts</a> </details> <details> <summary>selectedCalendar.ts<code>Add bulk selected-calendar updates by credential</code> <code>+8/-2</code></summary> <br/> >Add bulk selected-calendar updates by credential > ><pre> >• Adds a repository method for updating every selected calendar associated with a credential. It also simplifies the findMany Prisma invocation. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-ccb4eecfa701e5b0c7d6ba87dcc550cdf3700a63ee252849045611599ecb9273'>packages/lib/server/repository/selectedCalendar.ts</a> </details> <details> <summary>user.ts<code>Select calendar update and channel metadata</code> <code>+2/-0</code></summary> <br/> >Select calendar update and channel metadata > ><pre> >• Includes updatedAt and googleChannelId when loading a user&#x27;s selected calendars. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-0f8054c8d2d91141494df28691020185a2c12c81cad5e5bdd649532582a61c89'>packages/lib/server/repository/user.ts</a> </details> <details> <summary>SelectedCalendarsSettingsWebWrapper.tsx<code>Expose credential cache actions in calendar settings</code> <code>+23/-25</code></summary> <br/> >Expose credential cache actions in calendar settings > ><pre> >• Replaces standalone disconnect controls with the shared credential actions dropdown for connected calendars. It passes cache status and credential restrictions into the new control. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-831b0874e07f01721f87926262c5c9674ff9d7443741dfb71ceb849656345b00'>packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx</a> </details> <details> <summary>schema.prisma<code>Track CalendarCache update times</code> <code>+2/-0</code></summary> <br/> >Track CalendarCache update times > ><pre> >• Adds an automatically initialized and maintained updatedAt field to the CalendarCache model. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-56fa4d384ba6fb94b130e9eb42c5cad00734b025ebd6c197f76873469725ae87'>packages/prisma/schema.prisma</a> </details> <details> <summary>_router.tsx<code>Register authenticated cache deletion mutation</code> <code>+9/-0</code></summary> <br/> >Register authenticated cache deletion mutation > ><pre> >• Adds a validated calendars.deleteCache mutation and lazily loads its handler. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-9e053175cc6dfb5717313e0587a730fff132f9d3c1200204f0ce8dac53a19280'>packages/trpc/server/routers/viewer/calendars/_router.tsx</a> </details> <details> <summary>connectedCalendars.handler.ts<code>Enrich connected calendars with cache freshness</code> <code>+13/-1</code></summary> <br/> >Enrich connected calendars with cache freshness > ><pre> >• Loads latest cache timestamps in a batch and adds cacheUpdatedAt to each connected calendar response. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-3f6a556ad60f26d0162770fcd81b5bddeb6ab0437552ac792045c3cd2608d710'>packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts</a> </details> <details> <summary>deleteCache.handler.ts<code>Authorize and delete credential cache</code> <code>+33/-0</code></summary> <br/> >Authorize and delete credential cache > ><pre> >• Verifies that the requested credential belongs to the authenticated user before deleting all associated calendar cache records. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-572888b8e0555167a5787847f29d5a46623eff170491acc0654e916f5b4afd18'>packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts</a> </details> </dd> </dl> </details> <details> <summary>Other (3) <code> +89 / -1 </code></summary> <dl> <dd> <details> <summary>package.json<code>Run the cron tester with tsx</code> <code>+1/-1</code></summary> <br/> >Run the cron tester with tsx > ><pre> >• Replaces the ts-node invocation with npx tsx for the local cron development command. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-14b60f636e1a2b0061da57aaf231cb1ed15a5dc0c592425ed82e58fec95d42d8'>apps/web/package.json</a> </details> <details> <summary>migration.sql<code>Add cache update timestamps safely</code> <code>+9/-0</code></summary> <br/> >Add cache update timestamps safely > ><pre> >• Adds a required updatedAt column to CalendarCache with a database default so existing rows can be migrated safely. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-9f597bd98bbcfdcf4861ee7bf0c238e7dfe54b456ceb69b852aaf3979c4102cf'>packages/prisma/migrations/20250715160635_add_calendar_cache_updated_at/migration.sql</a> </details> <details> <summary>test-gcal-webhooks.sh<code>Add Google Calendar webhook tunnel helper</code> <code>+79/-0</code></summary> <br/> >Add Google Calendar webhook tunnel helper > ><pre> >• Adds a local script that starts or reuses Tunnelmole, writes its URL to GOOGLE_WEBHOOK_URL, handles rate limits, and cleans up owned processes. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-702a3028e76828d3f0db7e6ded4b9e3a82057c53d5bb397dcb01d3fc1541c1de'>scripts/test-gcal-webhooks.sh</a> </details> </dd> </dl> </details> </dd> </dl> </details>
PR-level
<h3>Code Review by Qodo</h3> <code>🐞 Bugs (8)</code> <code>📘 Rule violations (0)</code> <code>📜 Skill insights (0)</code> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <br/> <img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> <details> <summary> 1. Root runs edit the parent environment <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>ENV_FILE</i></b> is a relative path resolved from the caller&#x27;s working directory rather than from the >script&#x27;s directory. Running the script normally from the repository root creates or edits <b><i>../.env</i></b>, >while the application continues using the repository&#x27;s own <b><i>.env</i></b>. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[scripts/test-gcal-webhooks.sh[5]](https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-702a3028e76828d3f0db7e6ded4b9e3a82057c53d5bb397dcb01d3fc1541c1deR5-R5)</code> > >```diff >+ENV_FILE="../.env" >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The script reads, creates, and updates <b><i>../.env</i></b> without first changing directories or resolving the >script location. Repository tooling and the environment template identify <b><i>.env</i></b> at the repository >root as the application configuration file. ></pre> > > <code>[scripts/test-gcal-webhooks.sh[3-5]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/scripts/test-gcal-webhooks.sh/#L3-L5)</code> > <code>[scripts/test-gcal-webhooks.sh[61-73]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/scripts/test-gcal-webhooks.sh/#L61-L73)</code> > <code>[package.json[53-55]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/package.json/#L53-L55)</code> > <code>[.env.example[150-150]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/.env.example/#L150-L150)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >The webhook helper resolves its environment file from the caller's working directory and can modify a file outside the repository. > >## Fix Focus Areas >- scripts/test-gcal-webhooks.sh[3-5] >- scripts/test-gcal-webhooks.sh[61-70] > >## Recommended Fix >Determine the absolute directory containing the script, derive the repository root from it, and set `ENV_FILE` to that root's `.env` regardless of the current working directory. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <br/> <img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> <details> <summary> 2. Delegated calendars hide cache controls <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> >The status lookup uses the synthetic credential ID exposed for delegated calendars, although >delegated cache reads intentionally locate reusable records by user ID and cache key. These >calendars therefore receive no <b><i>cacheUpdatedAt</i></b>, and attempting deletion with the synthetic ID would >also fail the database-credential ownership check. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts[R27-29]](https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-3f6a556ad60f26d0162770fcd81b5bddeb6ab0437552ac792045c3cd2608d710R27-R29)</code> > >```diff >+ const credentialIds = connectedCalendars.map((cal) => cal.credentialId); >+ const cacheRepository = new CalendarCacheRepository(); >+ const cacheStatuses = await cacheRepository.getCacheStatusByCredentialIds(credentialIds); >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >Delegated credentials are created with ID <b><i>-1</i></b>, while existing cache access explicitly handles that >case through <b><i>userId</i></b> and key. The new status query groups only by credential ID, and deletion >requires a persisted credential with the same ID owned by the user. ></pre> > > <code>[packages/lib/delegationCredential/server.ts[78-104]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/lib/delegationCredential/server.ts/#L78-L104)</code> > <code>[packages/features/calendar-cache/calendar-cache.repository.ts[94-119]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/features/calendar-cache/calendar-cache.repository.ts/#L94-L119)</code> > <code>[packages/features/calendar-cache/calendar-cache.repository.ts[173-187]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/features/calendar-cache/calendar-cache.repository.ts/#L173-L187)</code> > <code>[packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts[17-30]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts/#L17-L30)</code> > <code>[packages/features/apps/components/CredentialActionsDropdown.tsx[67-73]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/features/apps/components/CredentialActionsDropdown.tsx/#L67-L73)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Delegated calendars use an in-memory synthetic credential ID, but the new status and deletion paths assume every cache belongs to a persisted credential ID. > >## Fix Focus Areas >- packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts[27-35] >- packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts[17-30] >- packages/features/apps/components/CredentialActionsDropdown.tsx[67-73] > >## Recommended Fix >Detect delegated credentials and resolve their cache status and authorized deletion using the existing delegated-cache identity model based on the authenticated user and relevant cache records, rather than querying credential ID `-1`. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 3. Dates always use United States format <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>CredentialActionsDropdown</i></b> hard-codes <b><i>en-US</i></b> when formatting the cache timestamp despite already >obtaining the active translation context from <b><i>useLocale</i></b>. Users of other locales consequently see >the newly added date and time in United States ordering and conventions. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/features/apps/components/CredentialActionsDropdown.tsx[R89-92]](https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-c78273434b95ab8276bb5eb24d9bc088b10af029388bdcd08cbe478f44269b31R89-R92)</code> > >```diff >+ timestamp: new Intl.DateTimeFormat("en-US", { >+ dateStyle: "short", >+ timeStyle: "short", >+ }).format(new Date(cacheUpdatedAt)), >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The component initializes locale support but formats with a fixed locale. Existing repository code >demonstrates passing a caller-provided locale into <b><i>Intl.DateTimeFormat</i></b>. ></pre> > > <code>[packages/features/apps/components/CredentialActionsDropdown.tsx[37-37]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/features/apps/components/CredentialActionsDropdown.tsx/#L37-L37)</code> > <code>[packages/features/apps/components/CredentialActionsDropdown.tsx[88-94]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/features/apps/components/CredentialActionsDropdown.tsx/#L88-L94)</code> > <code>[packages/lib/hooks/useLocale.ts[10-28]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/lib/hooks/useLocale.ts/#L10-L28)</code> > <code>[packages/features/ee/video/ViewRecordingsDialog.tsx[43-56]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/features/ee/video/ViewRecordingsDialog.tsx/#L43-L56)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Cache timestamps are formatted with a hard-coded United States locale instead of the user's active locale. > >## Fix Focus Areas >- packages/features/apps/components/CredentialActionsDropdown.tsx[37-37] >- packages/features/apps/components/CredentialActionsDropdown.tsx[88-94] > >## Recommended Fix >Read the active language from the `i18n` object returned by `useLocale` and pass it to `Intl.DateTimeFormat` instead of `en-US`. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 4. Linux users cannot update the address <code>🐞 Bug</code> <code>☼ Reliability</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> >The existing-variable branch uses the BSD-specific <b><i>sed -i &#x27;&#x27;</i></b> form, which fails under GNU sed. >Linux developers with an existing <b><i>GOOGLE_WEBHOOK_URL</i></b> therefore retain the old address even though >the script prints that it was updated. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[scripts/test-gcal-webhooks.sh[R67-70]](https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-702a3028e76828d3f0db7e6ded4b9e3a82057c53d5bb397dcb01d3fc1541c1deR67-R70)</code> > >```diff >+if grep -q '^GOOGLE_WEBHOOK_URL=' "$ENV_FILE"; then >+ sed -i '' -E "s|^GOOGLE_WEBHOOK_URL=.*|GOOGLE_WEBHOOK_URL=$TUNNEL_URL|" "$ENV_FILE" >+else >+ echo "GOOGLE_WEBHOOK_URL=$TUNNEL_URL" >> "$ENV_FILE" >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The replacement branch passes an empty argument after <b><i>-i</i></b>, which is the macOS/BSD invocation form, >and the following success message is unconditional. The append branch does not help users whose >environment file already contains the variable. ></pre> > > <code>[scripts/test-gcal-webhooks.sh[67-73]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/scripts/test-gcal-webhooks.sh/#L67-L73)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >The script's in-place replacement syntax is specific to BSD sed and fails on Linux systems using GNU sed. > >## Fix Focus Areas >- scripts/test-gcal-webhooks.sh[67-73] > >## Recommended Fix >Replace the platform-specific command with a portable temporary-file replacement or explicitly select compatible syntax based on the detected sed implementation, and report success only after the operation succeeds. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details><summary><ins><strong>View medium (4)</strong></ins></summary><br/> <details> <summary> 5. Tunnel failures return successful status <code>🐞 Bug</code> <code>☼ Reliability</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>cleanup</i></b> always executes <b><i>exit 0</i></b>, including when it is called after rate limiting or failure to >extract a tunnel address. Automated callers and developers therefore cannot distinguish failed >initialization from a successful script run by its exit status. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[scripts/test-gcal-webhooks.sh[17]](https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-702a3028e76828d3f0db7e6ded4b9e3a82057c53d5bb397dcb01d3fc1541c1deR17-R17)</code> > >```diff >+ exit 0 >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >Both explicit startup failure branches invoke <b><i>cleanup</i></b>, and that function unconditionally exits >with status zero. No later command can restore a failure status because the process exits >immediately. ></pre> > > <code>[scripts/test-gcal-webhooks.sh[10-18]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/scripts/test-gcal-webhooks.sh/#L10-L18)</code> > <code>[scripts/test-gcal-webhooks.sh[46-58]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/scripts/test-gcal-webhooks.sh/#L46-L58)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >The cleanup function converts detected Tunnelmole initialization failures into successful process exits. > >## Fix Focus Areas >- scripts/test-gcal-webhooks.sh[10-18] >- scripts/test-gcal-webhooks.sh[46-58] > >## Recommended Fix >Allow `cleanup` to accept and return an exit status, call it with a nonzero status from failure branches, and retain zero only for normal signal-driven or completed shutdown. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 6. Selections keep stale refresh times <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>fetchAvailabilityAndSetCache</i></b> calls <b><i>updateManyByCredentialId</i></b> with an empty data object, so the >forwarded Prisma update has no field to change and does not refresh <b><i>SelectedCalendar.updatedAt</i></b>. >This runs after availability is fetched and cached, including when rebuilding cache after unwatching >one calendar while others remain, leaving the timestamp named by the new comment unchanged. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/app-store/googlecalendar/lib/CalendarService.ts[R1023-1024]](https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-6bfbaf63c841dc9343dba0c7487e30a546ffe2a63c9d9418379d0dbb88644d27R1023-R1024)</code> > >```diff >+ // Update SelectedCalendar.updatedAt for all calendars under this credential >+ await SelectedCalendarRepository.updateManyByCredentialId(this.credential.id, {}); >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The added call explicitly documents a timestamp refresh but supplies no data, and the repository >forwards that object unchanged. The selected-calendar model&#x27;s timestamp is managed as an update >field, while the cache-population flow reaches this call after completing its writes. ></pre> > > <code>[packages/app-store/googlecalendar/lib/CalendarService.ts[990-1024]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/app-store/googlecalendar/lib/CalendarService.ts/#L990-L1024)</code> > <code>[packages/lib/server/repository/selectedCalendar.ts[400-405]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/lib/server/repository/selectedCalendar.ts/#L400-L405)</code> > <code>[packages/prisma/schema.prisma[851-860]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/prisma/schema.prisma/#L851-L860)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >Issue description >`fetchAvailabilityAndSetCache` intends to refresh every selected calendar's `updatedAt`, but passes `{}` through to Prisma, which performs no timestamp change. > >Fix Focus Areas >- packages/app-store/googlecalendar/lib/CalendarService.ts[1023-1024] >- packages/lib/server/repository/selectedCalendar.ts[400-405] > >Recommended Fix >Pass an explicit timestamp update, such as `{ updatedAt: new Date() }`, to `updateManyByCredentialId` after successful cache population. Keep the update scoped by credential ID. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 7. Deleted cache status remains on screen <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>deleteCacheMutation</i></b> only invokes the optional <b><i>onSuccess</i></b> callback and never invalidates ><b><i>viewer.calendars.connectedCalendars</i></b>, the query that supplies <b><i>cacheUpdatedAt</i></b>. When callers such >as the Event Advanced settings page omit the callback, deleting all cache rows leaves the mounted >dropdown showing the previous last-updated status and delete action until an unrelated refetch >occurs. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/features/apps/components/CredentialActionsDropdown.tsx[R42-46]](https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-c78273434b95ab8276bb5eb24d9bc088b10af029388bdcd08cbe478f44269b31R42-R46)</code> > >```diff >+ const deleteCacheMutation = trpc.viewer.calendars.deleteCache.useMutation({ >+ onSuccess: () => { >+ showToast(t("cache_deleted_successfully"), "success"); >+ onSuccess?.(); >+ }, >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The server deletion removes all cache rows, but the UI derives its cache status solely from the >connected-calendars response. The mutation success handler only displays a toast and invokes an >optional callback; unlike the disconnect mutation in the same component, it does not invalidate the >connected-calendars query, whose wrapper also disables focus refetching, and at least one enabled >call site supplies no <b><i>onChanged</i></b> refresh callback, leaving no reliable refresh path. ></pre> > > <code>[packages/features/apps/components/CredentialActionsDropdown.tsx[42-65]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/features/apps/components/CredentialActionsDropdown.tsx/#L42-L65)</code> > <code>[packages/features/apps/components/CredentialActionsDropdown.tsx[67-95]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/features/apps/components/CredentialActionsDropdown.tsx/#L67-L95)</code> > <code>[packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts[17-32]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/trpc/server/routers/viewer/calendars/deleteCache.handler.ts/#L17-L32)</code> > <code>[packages/features/eventtypes/components/tabs/advanced/EventAdvancedTab.tsx[370-385]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/features/eventtypes/components/tabs/advanced/EventAdvancedTab.tsx/#L370-L385)</code> > <code>[packages/features/apps/components/CredentialActionsDropdown.tsx[42-50]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/features/apps/components/CredentialActionsDropdown.tsx/#L42-L50)</code> > <code>[packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts[27-39]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts/#L27-L39)</code> > <code>[packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx[152-161]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper.tsx/#L152-L161)</code> > <code>[packages/features/eventtypes/components/tabs/advanced/EventAdvancedTab.tsx[372-385]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/features/eventtypes/components/tabs/advanced/EventAdvancedTab.tsx/#L372-L385)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >After a successful cache deletion, the `viewer.calendars.connectedCalendars` query remains cached, so components without an `onSuccess` callback continue rendering the old `cacheUpdatedAt` value and related cache status. > >## Fix Focus Areas >- packages/features/apps/components/CredentialActionsDropdown.tsx[42-50] >- packages/features/apps/components/CredentialActionsDropdown.tsx[130-140] > >## Recommended Fix >Obtain the tRPC query utilities before defining `deleteCacheMutation`, then invalidate `viewer.calendars.connectedCalendars` in the mutation's success or settled handler independently of the optional parent callback. Retain the callback for callers that need additional refresh work. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 8. Disabled caching still hits the database <code>🐞 Bug</code> <code>➹ Performance</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>connectedCalendarsHandler</i></b> constructs <b><i>CalendarCacheRepository</i></b> directly instead of using ><b><i>CalendarCache.init</i></b>, which selects the no-op <b><i>CalendarCacheRepositoryMock</i></b> when calendar caching is >disabled. Every connected-calendars request therefore reaches the cache table and executes the >cache-status grouping query even with caching globally disabled, allowing legacy rows to surface >through <b><i>cacheUpdatedAt</i></b>. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts[R27-29]](https://github.com/drape-io/crbench-qodo-2026-09/pull/89/files#diff-3f6a556ad60f26d0162770fcd81b5bddeb6ab0437552ac792045c3cd2608d710R27-R29)</code> > >```diff >+ const credentialIds = connectedCalendars.map((cal) => cal.credentialId); >+ const cacheRepository = new CalendarCacheRepository(); >+ const cacheStatuses = await cacheRepository.getCacheStatusByCredentialIds(credentialIds); >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The established <b><i>CalendarCache.init</i></b> factory checks the global feature flag and returns ><b><i>CalendarCacheRepositoryMock</i></b> when caching is disabled, and the mock&#x27;s status method returns an >empty list without querying the database. The handler instead instantiates the concrete database >repository directly, proving that its cache-status lookup bypasses the disabled-feature path and >accesses cache storage. ></pre> > > <code>[packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts[27-35]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts/#L27-L35)</code> > <code>[packages/features/calendar-cache/calendar-cache.ts[22-29]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/features/calendar-cache/calendar-cache.ts/#L22-L29)</code> > <code>[packages/features/calendar-cache/calendar-cache.repository.mock.ts[23-30]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/features/calendar-cache/calendar-cache.repository.mock.ts/#L23-L30)</code> > <code>[packages/features/calendar-cache/calendar-cache.repository.ts[173-187]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/features/calendar-cache/calendar-cache.repository.ts/#L173-L187)</code> > <code>[packages/features/calendar-cache/calendar-cache.ts[14-29]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/features/calendar-cache/calendar-cache.ts/#L14-L29)</code> > <code>[packages/features/calendar-cache/calendar-cache.repository.mock.ts[27-30]](https://github.com/drape-io/crbench-qodo-2026-09/blob/39563b73e3dfc7095a9ff50d8033f314584631e9/packages/features/calendar-cache/calendar-cache.repository.mock.ts/#L27-L30)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >The connected-calendars handler bypasses the calendar-cache feature gate by constructing the concrete repository directly, causing the cache-status query to access cache storage even while caching is disabled and potentially expose legacy cache state through `cacheUpdatedAt`. > >## Fix Focus Areas >- packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts[27-35] >- packages/features/calendar-cache/calendar-cache.ts[14-29] > >## Recommended Fix >Initialize the repository through `CalendarCache.init(null)` and call `getCacheStatusByCredentialIds` on the returned interface. Alternatively, add an equivalent status-specific feature-aware factory; in either case, ensure the disabled path returns `CalendarCacheRepositoryMock` so the status lookup produces an empty result without querying the database. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-context:start --> <details><summary><strong>Context sources</strong></summary> <div>Review mode: <code>🧠 Deep</code>: This spans calendar caching, database migration, authorization-sensitive deletion, UI behavior, repository queries, and webhook tooling across many independent logic sites, creating a high density of easy-to-miss defects.</div> <!-- qodo-context:end --> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-daily-tip:start --> <details> <summary><strong>Tip of the day</strong></summary> <br/> <pre>💡 Did you know, you can reply &#x27;qodo&#x27; on any finding to push back, ask questions, or dig deeper</pre> <a href="https://docs.qodo.ai/tips-and-tricks">More tips ↗</a> | <a href="https://app.qodo.ai/configurations?tab=display-preferences">Customize Qodo ↗</a> | <a href="https://docs.qodo.ai">Qodo docs ↗</a> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-daily-tip:end --> <!-- https://github.com/drape-io/crbench-qodo-2026-09/commit/39563b73e3dfc7095a9ff50d8033f314584631e9 --> <a href="https://www.qodo.ai"><img src="https://www.qodo.ai/wp-content/uploads/2025/03/qodo-logo.svg" width="80" alt="Qodo Logo"></a>