Skip to content

feat(fixed-hosts): pick first host as organizer for collective events or round robbin with fixed hosts#28718

Open
bandhan-majumder wants to merge 3 commits intocalcom:mainfrom
bandhan-majumder:fix-21719
Open

feat(fixed-hosts): pick first host as organizer for collective events or round robbin with fixed hosts#28718
bandhan-majumder wants to merge 3 commits intocalcom:mainfrom
bandhan-majumder:fix-21719

Conversation

@bandhan-majumder
Copy link
Copy Markdown
Contributor

@bandhan-majumder bandhan-majumder commented Apr 3, 2026

What does this PR do?

For collective events or round robin with fixed hosts, it sets first host is the default organizer. This adds a new attribute isOrganizer for the host entity to which is false by default

Visual Demo (For contributors especially)

Video Demo (if applicable):

organizer.mp4

Image Demo (if applicable):

image

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Are there environment variables that should be set?
  • What are the minimal test data to have?
  • What is expected (happy path) to have (input and output)?
  • Any other important info that could help to test that PR

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my changes generate no new warnings
  • My PR is too large (>500 lines or >10 files) and should be split into smaller PRs

@bandhan-majumder bandhan-majumder requested a review from a team as a code owner April 3, 2026 02:34
@github-actions github-actions bot added enterprise area: enterprise, audit log, organisation, SAML, SSO Medium priority Created by Linear-GitHub Sync teams area: teams, round robin, collective, managed event-types ✨ feature New feature or request ❗️ migrations contains migration files and removed ✨ feature New feature or request Medium priority Created by Linear-GitHub Sync teams area: teams, round robin, collective, managed event-types enterprise area: enterprise, audit log, organisation, SAML, SSO labels Apr 3, 2026
@github-actions github-actions bot added enterprise area: enterprise, audit log, organisation, SAML, SSO Medium priority Created by Linear-GitHub Sync teams area: teams, round robin, collective, managed event-types ✨ feature New feature or request labels Apr 3, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 14 files

)}>
{option.label}
{option.isOrganizer && (
<span className="text-subtle ml-1 text-xs">({t("default_organizer")})</span>
Copy link
Copy Markdown
Contributor Author

@bandhan-majumder bandhan-majumder Apr 3, 2026

Choose a reason for hiding this comment

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

calling this default organizer instead of organizer because of this line

https://github.com/bandhan-majumder/cal.com/blob/aa21d89e8e733f7fe7b2459312d5740869a95fb9/packages/features/bookings/lib/service/RegularBookingService.ts#L1267

this tells that if the request has a teamMemberEmail field, then the exact member will be the organizer. and if not, then we can pick the organizer of the event among the hosts as organizer if exists.

@bandhan-majumder
Copy link
Copy Markdown
Contributor Author

One improvement that can be done is immediately showing the default organizer tag in the UI as soon as the first member gets added or the organizer gets removed (the earliest joiner is the organizer here) and invalidation happens. But here I tried to add form resetting logic but the current logic seem to be a bit complex and throwing type errors even though I regenerated the types.

@github-actions
Copy link
Copy Markdown
Contributor

This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active.

@github-actions github-actions bot added the Stale label Apr 11, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 11, 2026

📝 Walkthrough

Walkthrough

This pull request introduces an isOrganizer boolean flag to the Host entity across the application. The database schema and Prisma model are updated to include the new field with a default value of false. Type definitions, validation schemas, and database queries are extended to include isOrganizer in host objects. Component logic propagates the flag through host selection and rendering. The event type update handler implements logic to manage organizer assignment when hosts are added, removed, or modified, selecting the earliest-created remaining host or first newly-added host when the current organizer is no longer present. User/host loading and booking service logic are updated to prefer users marked as organizers where applicable.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Out of Scope Changes check ❓ Inconclusive Most changes directly support the isOrganizer feature (schema updates, UI labeling, organizer selection logic). However, extensive logic in the update handler for recalculating organizers and the fallback-to-first-user pattern in RegularBookingService may extend beyond the stated scope. Clarify whether the update handler's recalculation logic and booking service organizer selection fallbacks are intended scope or represent feature creep beyond setting first host as organizer.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(fixed-hosts): pick first host as organizer for collective events or round robbin with fixed hosts' directly describes the main feature being implemented—designating the first host as the default organizer for collective/round-robin events with fixed hosts.
Linked Issues check ✅ Passed The PR implementation fulfills the requirement from issue #20301/CAL-5348: it adds an isOrganizer flag to hosts and implements logic to make the first/earliest added host the organizer for collective events and round-robin with fixed hosts.
Description check ✅ Passed The PR description accurately describes the changeset: adding an isOrganizer attribute to hosts to designate the first host as the default organizer for collective events or round-robin with fixed hosts.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

❤️ Share

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

Copy link
Copy Markdown
Contributor

@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.

Caution

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

⚠️ Outside diff range comments (1)
packages/features/users/lib/getRoutedUsers.ts (1)

174-183: ⚠️ Potential issue | 🟡 Minor

Missing groupId property in fallback hosts.

The fallback hosts in getNormalizedHostsWithDelegationCredentials don't include groupId, while the equivalent code in getNormalizedHosts (line 131) includes groupId: null. This inconsistency could cause issues if downstream code expects groupId to be present.

🔧 Suggested fix
     const hostsWithoutDelegationCredential = eventType.users.map((user, index) => {
       return {
         isFixed: !eventType.schedulingType || eventType.schedulingType === SchedulingType.COLLECTIVE,
         isOrganizer: index === 0,
         email: user.email,
         user: user,
         createdAt: null,
+        groupId: null,
       };
     });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/features/users/lib/getRoutedUsers.ts` around lines 174 - 183, The
fallback host objects created in getRoutedUsers.ts (in the else branch that
builds hostsWithoutDelegationCredential) are missing the groupId property;
update the object returned in hostsWithoutDelegationCredential to include
groupId: null so it matches the shape produced by getNormalizedHosts (and by
getNormalizedHostsWithDelegationCredentials), ensuring downstream code expecting
groupId will not break.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/features/users/lib/getRoutedUsers.ts`:
- Around line 174-183: The fallback host objects created in getRoutedUsers.ts
(in the else branch that builds hostsWithoutDelegationCredential) are missing
the groupId property; update the object returned in
hostsWithoutDelegationCredential to include groupId: null so it matches the
shape produced by getNormalizedHosts (and by
getNormalizedHostsWithDelegationCredentials), ensuring downstream code expecting
groupId will not break.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6f1d3839-b3a0-4c1b-8259-a1b63a4cf407

📥 Commits

Reviewing files that changed from the base of the PR and between f3e07c5 and 36e215d.

📒 Files selected for processing (14)
  • apps/web/modules/event-types/components/AddMembersWithSwitch.tsx
  • apps/web/modules/event-types/components/tabs/assignment/EventTeamAssignmentTab.tsx
  • packages/features/bookings/lib/handleNewBooking/getEventTypesFromDB.ts
  • packages/features/bookings/lib/handleNewBooking/loadUsers.ts
  • packages/features/bookings/lib/service/RegularBookingService.ts
  • packages/features/eventtypes/components/CheckedTeamSelect.tsx
  • packages/features/eventtypes/lib/types.ts
  • packages/features/eventtypes/repositories/eventTypeRepository.ts
  • packages/features/users/lib/getRoutedUsers.ts
  • packages/i18n/locales/en/common.json
  • packages/prisma/migrations/20260403021738_add_is_organizer_to_host/migration.sql
  • packages/prisma/schema.prisma
  • packages/trpc/server/routers/viewer/eventTypes/heavy/update.handler.ts
  • packages/trpc/server/routers/viewer/eventTypes/types.ts

@github-actions github-actions bot removed the Stale label Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enterprise area: enterprise, audit log, organisation, SAML, SSO ✨ feature New feature or request Medium priority Created by Linear-GitHub Sync ❗️ migrations contains migration files size/M teams area: teams, round robin, collective, managed event-types

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CAL-5348] Always pick first host as the organizer

1 participant