feat: add 10 minute cooldown in instant meetings#24119
feat: add 10 minute cooldown in instant meetings#24119alishaz-polymath merged 5 commits intomainfrom
Conversation
Walkthrough
Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (3)**/*.ts📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Files:
**/*.{ts,tsx,js,jsx}⚙️ CodeRabbit configuration file
Files:
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/features/bookings/Booker/components/hooks/useBookings.ts (1)
218-226: Cooldown never expires without a timer
instantConnectCooldownMsis computed once per render. After we set the cooldown, nothing triggers further renders, so the button stays disabled indefinitely—even after the 10 min window. Add state + an interval (orrequestAnimationFrame) to tick the remaining time down and re-enable the UI when it reaches zero.Apply something like:
- const instantConnectCooldownMs = getInstantCooldownRemainingMs(eventTypeId); + const [instantConnectCooldownMs, setInstantConnectCooldownMs] = useState(() => + getInstantCooldownRemainingMs(eventTypeId) + ); + + useEffect(() => { + setInstantConnectCooldownMs(getInstantCooldownRemainingMs(eventTypeId)); + + if (!eventTypeId) return; + const intervalId = window.setInterval(() => { + const remaining = getInstantCooldownRemainingMs(eventTypeId); + setInstantConnectCooldownMs(remaining); + if (remaining <= 0) { + window.clearInterval(intervalId); + } + }, 1000); + + return () => window.clearInterval(intervalId); + }, [eventTypeId]);
🧹 Nitpick comments (1)
packages/features/bookings/Booker/components/InstantBooking.tsx (1)
40-65: Defensive onClick guard when disabled.Thanks for adding the cooldown tooltip. One micro-improvement I’d make is to skip wiring
onConnectNowwhen the button is disabled. Our<Button>wrapper already no-ops the handler, but avoiding the assignment keeps intent clearer and prevents surprises if the button implementation ever changes.- {disabled ? ( - <Tooltip content={t("connect_now_unavailable_tooltip") || "Connect now is not available right now."}> - <span className="inline-flex"> - <Button - disabled={disabled} - color="primary" - onClick={() => { - onConnectNow(); - }} + {disabled ? ( + <Tooltip content={t("connect_now_unavailable_tooltip") || "Connect now is not available right now."}> + <span className="inline-flex"> + <Button + disabled + color="primary" size="sm" className="w-full justify-center rounded-lg sm:w-auto"> {t("connect_now")} </Button> </span> </Tooltip> ) : ( <Button color="primary" onClick={() => { onConnectNow(); }}
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (6)
apps/web/pages/api/book/instant-event.ts(1 hunks)apps/web/public/static/locales/en/common.json(1 hunks)packages/features/bookings/Booker/Booker.tsx(3 hunks)packages/features/bookings/Booker/components/InstantBooking.tsx(2 hunks)packages/features/bookings/Booker/components/hooks/useBookings.ts(6 hunks)packages/lib/rateLimit.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
**/*.ts: For Prisma queries, only select data you need; never useinclude, always useselect
Ensure thecredential.keyfield is never returned from tRPC endpoints or APIs
Files:
apps/web/pages/api/book/instant-event.tspackages/lib/rateLimit.tspackages/features/bookings/Booker/components/hooks/useBookings.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js
.utc()in hot paths like loops
Files:
apps/web/pages/api/book/instant-event.tspackages/features/bookings/Booker/components/InstantBooking.tsxpackages/lib/rateLimit.tspackages/features/bookings/Booker/Booker.tsxpackages/features/bookings/Booker/components/hooks/useBookings.ts
**/*.{ts,tsx,js,jsx}
⚙️ CodeRabbit configuration file
Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.
Files:
apps/web/pages/api/book/instant-event.tspackages/features/bookings/Booker/components/InstantBooking.tsxpackages/lib/rateLimit.tspackages/features/bookings/Booker/Booker.tsxpackages/features/bookings/Booker/components/hooks/useBookings.ts
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Always use
t()for text localization in frontend code; direct text embedding should trigger a warning
Files:
packages/features/bookings/Booker/components/InstantBooking.tsxpackages/features/bookings/Booker/Booker.tsx
🧠 Learnings (2)
📚 Learning: 2025-07-15T12:59:34.389Z
Learnt from: eunjae-lee
PR: calcom/cal.com#22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.389Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.
Applied to files:
packages/features/bookings/Booker/Booker.tsxpackages/features/bookings/Booker/components/hooks/useBookings.ts
📚 Learning: 2025-08-28T10:48:03.862Z
Learnt from: anglerfishlyy
PR: calcom/cal.com#0
File: :0-0
Timestamp: 2025-08-28T10:48:03.862Z
Learning: In Cal.com booking pipeline, loadUsersByEventType must return a plain array of user objects, not host-wrapped objects; returning { user, ... } causes downstream watchlist/validation to throw (e.g., reading 'split').
Applied to files:
packages/features/bookings/Booker/components/hooks/useBookings.ts
🧬 Code graph analysis (2)
packages/features/bookings/Booker/components/InstantBooking.tsx (2)
packages/features/bookings/types.ts (1)
BookerEvent(34-69)packages/ui/components/button/Button.tsx (1)
Button(221-349)
packages/features/bookings/Booker/components/hooks/useBookings.ts (1)
packages/lib/webstorage.ts (1)
localStorage(6-36)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Tests / Unit
- GitHub Check: Type check / check-types
- GitHub Check: Linters / lint
🔇 Additional comments (2)
apps/web/public/static/locales/en/common.json (1)
2304-2304: Localized tooltip copy looks good.Text is localized via
connect_now_unavailable_tooltip, so the new tooltip message can be translated downstream. No issues here.packages/features/bookings/Booker/Booker.tsx (1)
540-555: LGTM – cooldown is plumbed through.
instantConnectCooldownMsnow flows intoInstantBooking, so the “Connect now” button respects the client-side cooldown. Looks solid to me.
sean-brydon
left a comment
There was a problem hiding this comment.
LGTM from a ratelimit implementation side. Havent tested
| hashedLink, | ||
| bookingForm, | ||
| metadata, | ||
| teamMemberEmail, |
There was a problem hiding this comment.
Why did we remove it, was it unused?
| "locked_by_team_admin": "Locked by team admin", | ||
| "app_not_connected": "You have not connected a {{appName}} account.", | ||
| "connect_now": "Connect now", | ||
| "connect_now_unavailable_tooltip": "Connect now is unavailable right now. Please book from above slots or try again later.", |
There was a problem hiding this comment.
NIT:
"Connect now is unavailable right now" sounds off. perhaps "Connect now is currently unavailable"?
E2E results are ready! |
What does this PR do?
Screen.Recording.2025-09-27.at.12.25.32.AM.mov
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?