Skip to content

Conversation

@tomerqodo
Copy link

@tomerqodo tomerqodo commented Jan 29, 2026

Benchmark PR from agentic-review-benchmarks#15

Summary by CodeRabbit

  • Refactor
    • Reorganized and consolidated internal type definitions across multiple modules for improved code maintainability and encapsulation.
    • Updated internal import references throughout the codebase to use locally defined types instead of external dependencies, reducing coupling between modules.
    • Streamlined the public type export structure to expose only necessary interfaces.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

Walkthrough

This refactoring consolidates type definitions by relocating the Slot type from TRPC server internals to the atoms booker package. New scheduling-related types are introduced, import statements across multiple hook files are updated to reference the new local type locations, and configuration files are adjusted to reflect the organizational changes.

Changes

Cohort / File(s) Summary
Type definitions migration
packages/platform/atoms/booker/types.ts, packages/trpc/server/routers/viewer/slots/types.ts
Slot type moved from TRPC package to atoms booker package. Local Slot type exported with fields: time, userIds, attendees, bookingUid, users. New types SlotInfo and GetAvailableSlotsResponse added to booker types.
Scheduling types
packages/platform/atoms/hooks/schedules/types.ts
New types introduced: Schedule, CreateScheduleHandlerReturn, DuplicateScheduleHandlerReturn, GetAvailabilityListHandlerReturn, CreateScheduleInput. New validation function validateCreateScheduleInput() added to validate schedule creation input.
Hook import updates
packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.ts, packages/platform/atoms/hooks/schedules/useAtomDuplicateSchedule.ts, packages/platform/atoms/hooks/schedules/useAtomGetAllSchedules.ts, packages/platform/atoms/hooks/useAvailableSlots.ts
Type imports updated from external TRPC paths to local type modules (./types or ../booker/types).
Configuration and export updates
biome.json, packages/platform/atoms/tsconfig.json, packages/platform/atoms/package.json
Biome linting rules updated to restrict imports from @calcom/trpc instead of @calcom/trpc/react. TypeScript config removes TRPC paths from include list. Package exports changed from ./booker to ./booker/types.
Test file imports
apps/web/test/lib/getSchedule/expects.ts
Slot type import source updated from @calcom/trpc/server/routers/viewer/slots/types to @calcom/atoms/booker/types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Types hop from here to there,
Organizing with such care,
Slots now rest in atoms' nest,
Schedules structured, cleanly dressed,
Imports dance their new ballet—
Refactoring saves the day! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main objective: removing trpc/server dependency from @calcom/atoms package. This is reflected in multiple file changes (import path updates, type migrations, and dependency removals).

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

✨ Finishing touches
  • 📝 Generate docstrings

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/platform/atoms/package.json (1)

44-59: Export points to a file that isn’t published in the npm package

./booker/types.ts is outside the current "files" whitelist (Line 44-48), so consumers of @calcom/atoms/booker/types will fail after publish. Either publish that source path or point the export to built output in dist.

🔧 Suggested fix (publish the source path)
   "files": [
     "dist",
     "globals.min.css",
-    "fonts"
+    "fonts",
+    "booker"
   ],
🤖 Fix all issues with AI agents
In `@packages/platform/atoms/booker/types.ts`:
- Around line 17-23: The callback mismatch: onTimeslotsLoaded expects
Record<string, Slot[]> but schedule.data.slots is Record<string, SlotInfo[]>
with different fields (Slot.userIds vs SlotInfo.toUser/fromUser). Fix by either
transforming schedule.data.slots into the Slot shape before invoking
onTimeslotsLoaded (map each SlotInfo to Slot by converting toUser/fromUser ids
into userIds:string[] and normalizing bookingUid/attendees/users), or by
changing the callback/type to accept Record<string, SlotInfo[]> and update any
downstream consumers; locate the types Slot and SlotInfo in types.ts and the
call site where onTimeslotsLoaded is invoked with schedule.data.slots to apply
the transformation or signature change.
🧹 Nitpick comments (1)
packages/platform/atoms/hooks/schedules/types.ts (1)

38-49: Validation helper is too permissive for its name

validateCreateScheduleInput only validates name, yet returns CreateScheduleInput. Consider validating eventTypeId and schedule shape (or renaming to reflect partial validation) to avoid false confidence.

♻️ Minimal shape checks
 export function validateCreateScheduleInput(input: unknown): CreateScheduleInput {
   if (!input || typeof input !== 'object') {
     throw new Error('Invalid input: must be an object');
   }

   const data = input as Record<string, unknown>;

   if (typeof data.name !== 'string' || data.name.length === 0) {
     throw new Error('Invalid input: name must be a non-empty string');
   }
+
+  if ('eventTypeId' in data && typeof data.eventTypeId !== 'number') {
+    throw new Error('Invalid input: eventTypeId must be a number');
+  }
+
+  if ('schedule' in data) {
+    if (!Array.isArray(data.schedule) || !data.schedule.every(Array.isArray)) {
+      throw new Error('Invalid input: schedule must be a 2D array');
+    }
+  }

   return data as CreateScheduleInput;
 }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e998214 and 57f113b.

📒 Files selected for processing (11)
  • apps/web/test/lib/getSchedule/expects.ts
  • biome.json
  • packages/platform/atoms/booker/types.ts
  • packages/platform/atoms/hooks/schedules/types.ts
  • packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.ts
  • packages/platform/atoms/hooks/schedules/useAtomDuplicateSchedule.ts
  • packages/platform/atoms/hooks/schedules/useAtomGetAllSchedules.ts
  • packages/platform/atoms/hooks/useAvailableSlots.ts
  • packages/platform/atoms/package.json
  • packages/platform/atoms/tsconfig.json
  • packages/trpc/server/routers/viewer/slots/types.ts
💤 Files with no reviewable changes (2)
  • packages/trpc/server/routers/viewer/slots/types.ts
  • packages/platform/atoms/tsconfig.json
🔇 Additional comments (6)
packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.ts (1)

7-8: LGTM — local type import aligns with the refactor.

packages/platform/atoms/hooks/schedules/useAtomDuplicateSchedule.ts (1)

7-8: LGTM — consistent type sourcing.

packages/platform/atoms/hooks/schedules/useAtomGetAllSchedules.ts (1)

7-8: LGTM — type import migration looks correct.

packages/platform/atoms/hooks/useAvailableSlots.ts (1)

11-11: Type import relocation looks good.

Localizing GetAvailableSlotsResponse keeps this hook decoupled from TRPC server internals as intended.

apps/web/test/lib/getSchedule/expects.ts (1)

4-4: Updated Slot type source is consistent with the refactor.

biome.json (1)

339-351: Restricted import patterns updated appropriately.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines +17 to +23
export type Slot = {
time: string;
userIds?: string[];
attendees?: number;
bookingUid?: string;
users?: string[];
};
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's look at the Slot type definition (lines 17-23)
cat -n packages/platform/atoms/booker/types.ts | sed -n '1,50p'

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 1870


🏁 Script executed:

# Let's also see the lines around 115-136 to view SlotInfo
cat -n packages/platform/atoms/booker/types.ts | sed -n '100,150p'

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 1207


🏁 Script executed:

# Search for usage of these types and ID comparisons
rg -n --type=ts 'userIds|toUser|fromUser' packages/platform/atoms/booker/ -A 2 -B 2

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 1477


🏁 Script executed:

# Search for where Slot and SlotInfo are used/compared
rg -n --type=ts 'Slot\[|SlotInfo\[|\.userIds|\.toUser\.id|\.fromUser\.id' packages/platform/atoms/booker/ -A 1 -B 1

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 562


🏁 Script executed:

# Search for onTimeslotsLoaded callback usage to see how Slot[] is used
rg -n --type=ts --type=tsx 'onTimeslotsLoaded' packages/platform/ -A 5 -B 2

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 113


🏁 Script executed:

# Search for GetAvailableSlotsResponse usage to see how SlotInfo is converted or used
rg -n --type=ts --type=tsx 'GetAvailableSlotsResponse' packages/platform/ -A 3 -B 2

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 113


🏁 Script executed:

# Look for any slot transformation/conversion logic
rg -n --type=ts --type=tsx 'SlotInfo|toUser|fromUser' packages/platform/ -A 3 -B 1 | head -100

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 113


🏁 Script executed:

# Search for Slot type usage and API calls in the booker directory
rg -n --type=ts --type=tsx 'slots.*=|availableSlots' packages/platform/atoms/booker/ -A 2 -B 1

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 113


🏁 Script executed:

# Search for onTimeslotsLoaded callback usage
rg -n 'onTimeslotsLoaded' packages/platform/atoms/booker/ -A 5 -B 2

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 2488


🏁 Script executed:

# Search for GetAvailableSlotsResponse usage to see how SlotInfo is converted
rg -n 'GetAvailableSlotsResponse' packages/platform/ -A 3 -B 2

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 1849


🏁 Script executed:

# Look for slot transformation/conversion logic in the booker directory
rg -n 'SlotInfo|toUser.*id|fromUser.*id' packages/platform/atoms/booker/ -A 2 -B 1

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 535


🏁 Script executed:

# Search for where Slot type is mapped from API response (SlotInfo)
rg -n 'map.*Slot|transform.*Slot|convert.*Slot' packages/platform/atoms/booker/ -A 3

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 68


🏁 Script executed:

# Check if there are any type assertions or casting between Slot and SlotInfo
rg -n 'as Slot|as SlotInfo' packages/platform/atoms/booker/ -B 2 -A 2

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 68


🏁 Script executed:

# Find where schedule is defined in BookerPlatformWrapper.tsx
rg -n 'const schedule|useAvailableSlots' packages/platform/atoms/booker/BookerPlatformWrapper.tsx -A 5 -B 2

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 861


🏁 Script executed:

# Check the useAvailableSlots hook implementation for any transformation
cat -n packages/platform/atoms/hooks/useAvailableSlots.ts

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 1753


🏁 Script executed:

# Search for any slot transformation or mapping logic in the booker directory
rg -n 'SlotInfo.*Slot|Slot.*SlotInfo|slots\.map|slots\.forEach' packages/platform/atoms/booker/ -A 2

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 68


🏁 Script executed:

# Check for actual property access patterns on the slots passed to onTimeslotsLoaded
rg -n 'onTimeslotsLoaded' packages/platform/ -A 20 | head -60

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 5525


🏁 Script executed:

# Look for userIds or toUser access patterns in the booker component files
rg -n '\.userIds|\.toUser|\.fromUser' packages/platform/atoms/booker/ -B 3 -A 1

Repository: qodo-benchmark/cal.com-combined-coderabbit

Length of output: 68


Reconcile Slot and SlotInfo type definitions or transform API response before callback

onTimeslotsLoaded expects Record<string, Slot[]> but receives schedule.data.slots which is Record<string, SlotInfo[]>. These types have incompatible structures: Slot uses userIds: string[] while SlotInfo uses toUser: { id: number } and fromUser: { id: string }. Either transform the API response to match the Slot type before passing to the callback, or update the callback signature to accept SlotInfo.

🤖 Prompt for AI Agents
In `@packages/platform/atoms/booker/types.ts` around lines 17 - 23, The callback
mismatch: onTimeslotsLoaded expects Record<string, Slot[]> but
schedule.data.slots is Record<string, SlotInfo[]> with different fields
(Slot.userIds vs SlotInfo.toUser/fromUser). Fix by either transforming
schedule.data.slots into the Slot shape before invoking onTimeslotsLoaded (map
each SlotInfo to Slot by converting toUser/fromUser ids into userIds:string[]
and normalizing bookingUid/attendees/users), or by changing the callback/type to
accept Record<string, SlotInfo[]> and update any downstream consumers; locate
the types Slot and SlotInfo in types.ts and the call site where
onTimeslotsLoaded is invoked with schedule.data.slots to apply the
transformation or signature change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants