Skip to content

refactor: Remove trpc/react dependency from @calcom/atoms#12

Open
tomerqodo wants to merge 8 commits into
coderabbit_full_base_refactor_remove_trpc_react_dependency_from_calcom_atoms_pr12from
coderabbit_full_head_refactor_remove_trpc_react_dependency_from_calcom_atoms_pr12
Open

refactor: Remove trpc/react dependency from @calcom/atoms#12
tomerqodo wants to merge 8 commits into
coderabbit_full_base_refactor_remove_trpc_react_dependency_from_calcom_atoms_pr12from
coderabbit_full_head_refactor_remove_trpc_react_dependency_from_calcom_atoms_pr12

Conversation

@tomerqodo

@tomerqodo tomerqodo commented Jan 30, 2026

Copy link
Copy Markdown

Benchmark PR from agentic-review-benchmarks#12

Summary by CodeRabbit

  • Bug Fixes

    • Fixed team members list to display all members instead of filtered results in event type assignment workflows.
  • Refactor

    • Reorganized internal hooks and imports for improved code structure and reusability.
  • Chores

    • Updated linting rules to prevent circular dependencies across packages.

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

@coderabbitai

coderabbitai Bot commented Jan 30, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The PR restructures hook dependencies and import organization across the web and atoms packages. It migrates useTeamMembersWithSegment from atoms to the web package, updates component imports to reference the new locations, decouples the atoms package from TRPC to prevent circular dependencies, and adjusts type definitions in availability settings to rely on repository types instead of TRPC router outputs.

Changes

Cohort / File(s) Summary
Hook Migration
apps/web/modules/event-types/hooks/useTeamMembersWithSegment.tsx, packages/platform/atoms/event-types/hooks/useTeamMembersWithSegmentPlatform.tsx
New useTeamMembersWithSegment hook created in web package with TRPC query integration; corresponding hook removed from atoms package, leaving only platform-specific version and helper exports.
Component Updates
apps/web/modules/event-types/components/EditWeightsForAllTeamMembers.tsx
Updated imports to use new hook from web package and platform-specific import; added isPending destructuring from hook; rendering logic modified to iterate over all teamMembers instead of filtered subset.
Type Definition Updates
packages/platform/atoms/availability/AvailabilitySettings.tsx
Replaced RouterOutputs-based type for travelSchedules prop with TravelScheduleRepository.findTravelSchedulesByUserId return type; removed TRPC import in favor of repository type import.
Dependency Configuration
biome.json, packages/platform/atoms/tsconfig.json, packages/platform/atoms/package.json
Added biome linter rules forbidding TRPC imports within atoms package; removed trpc/react from tsconfig includes; added new public export mapping for useTeamMembersWithSegmentPlatform in package exports.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Through tangled imports we bounce and we mend,
TRPC and atoms now keep their own ends,
Hooks find new homes in their proper-bound nests,
Circular worries resolved—the warren now rests! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely describes the main objective: removing the trpc/react dependency from the @calcom/atoms package, which aligns with the file changes across multiple modules.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch coderabbit_full_head_refactor_remove_trpc_react_dependency_from_calcom_atoms_pr12

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 (2)
packages/platform/atoms/event-types/hooks/useTeamMembersWithSegmentPlatform.tsx (2)

13-13: Remove unused trpc import.

This import is unused in the file and contradicts the PR's objective of removing @calcom/trpc/react dependency from the atoms package. Additionally, the new biome.json linter rule will flag this import as an error.

🔧 Proposed fix
-import { trpc } from "@calcom/trpc/react";
-

83-94: Handle potentially undefined error.message in error response.

Line 90 accesses res.data.error.message when the API response status is not SUCCESS_STATUS. However, according to the ErrorType definition, the message property is optional (message?: string), so it could be undefined. Throwing new Error(undefined) results in an error message of the string "undefined", which is not informative. Provide a fallback message or access error.code as a fallback.

🤖 Fix all issues with AI agents
In `@apps/web/modules/event-types/components/EditWeightsForAllTeamMembers.tsx`:
- Around line 304-309: The list rendering currently maps over teamMembers,
bypassing the search filter; change the rendering to map over filteredMembers so
the searchQuery/TextField filtering is applied. Locate the JSX where
TeamMemberItem is rendered (the map using teamMembers and the conditional that
checks teamMembers.length) and replace those references with filteredMembers
while keeping the TeamMemberItem key, member prop, and
onWeightChange={handleWeightChange} intact; also update the "no members"
conditional to check filteredMembers.length so the empty state reflects the
filtered results.

In `@apps/web/modules/event-types/hooks/useTeamMembersWithSegment.tsx`:
- Line 1: Remove the unused named import useQuery from the top import line
(import { useQuery } from "@tanstack/react-query"); it's not referenced anywhere
in this module because the code uses
trpc.viewer.attributes.findTeamMembersMatchingAttributeLogic.useQuery instead,
so delete the useQuery symbol from the import to eliminate the lint error and
unused import.
🧹 Nitpick comments (1)
apps/web/modules/event-types/components/EditWeightsForAllTeamMembers.tsx (1)

126-128: Conditional hook pattern may violate React's rules of hooks.

The pattern of conditionally selecting a hook and then calling it could be problematic if isPlatform changes during the component lifecycle. While this likely works if isPlatform is stable (from context), consider a safer pattern.

♻️ Safer alternative using both hooks with conditional enabling
-  const useTeamMembersHook = isPlatform ? useTeamMembersWithSegmentPlatform : useTeamMembersWithSegment;
-
-  const { teamMembers, localWeightsInitialValues, isPending } = useTeamMembersHook({
+  const platformResult = useTeamMembersWithSegmentPlatform({
+    initialTeamMembers,
+    assignRRMembersUsingSegment: isPlatform && assignRRMembersUsingSegment,
+    teamId,
+    queryValue,
+    value,
+  });
+
+  const webResult = useTeamMembersWithSegment({
     initialTeamMembers,
-    assignRRMembersUsingSegment,
+    assignRRMembersUsingSegment: !isPlatform && assignRRMembersUsingSegment,
     teamId,
     queryValue,
     value,
   });
+
+  const { teamMembers, localWeightsInitialValues, isPending } = isPlatform ? platformResult : webResult;

Alternatively, if isPlatform is guaranteed to be stable for the component's lifetime (determined at mount and never changes), the current pattern is acceptable but should be documented with a comment.

Comment on lines +304 to 309
{teamMembers.map((member) => (
<TeamMemberItem key={member.value} member={member} onWeightChange={handleWeightChange} />
))}
{filteredMembers.length === 0 && (
{teamMembers.length === 0 && (
<div className="text-subtle py-4 text-center text-sm">{t("no_members_found")}</div>
)}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Search filtering is broken - should use filteredMembers instead of teamMembers.

The rendering loop iterates over teamMembers directly, but the search functionality (TextField on lines 294-301) updates searchQuery which is used to compute filteredMembers (lines 231-249). By using teamMembers instead of filteredMembers, the search/filter functionality is broken.

🐛 Proposed fix to restore search functionality
               <div className="flex max-h-[80dvh] flex-col overflow-y-auto rounded-md border">
-                {teamMembers.map((member) => (
+                {filteredMembers.map((member) => (
                   <TeamMemberItem key={member.value} member={member} onWeightChange={handleWeightChange} />
                 ))}
-                {teamMembers.length === 0 && (
+                {filteredMembers.length === 0 && (
                   <div className="text-subtle py-4 text-center text-sm">{t("no_members_found")}</div>
                 )}
               </div>
🤖 Prompt for AI Agents
In `@apps/web/modules/event-types/components/EditWeightsForAllTeamMembers.tsx`
around lines 304 - 309, The list rendering currently maps over teamMembers,
bypassing the search filter; change the rendering to map over filteredMembers so
the searchQuery/TextField filtering is applied. Locate the JSX where
TeamMemberItem is rendered (the map using teamMembers and the conditional that
checks teamMembers.length) and replace those references with filteredMembers
while keeping the TeamMemberItem key, member prop, and
onWeightChange={handleWeightChange} intact; also update the "no members"
conditional to check filteredMembers.length so the empty state reflects the
filtered results.

@@ -0,0 +1,37 @@
import { useQuery } from "@tanstack/react-query";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused useQuery import.

The useQuery import from @tanstack/react-query is not used in this file. The TRPC query uses trpc.viewer.attributes.findTeamMembersMatchingAttributeLogic.useQuery instead.

🧹 Proposed fix
-import { useQuery } from "@tanstack/react-query";
 import type { AttributesQueryValue } from "@calcom/lib/raqb/types";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { useQuery } from "@tanstack/react-query";
import type { AttributesQueryValue } from "@calcom/lib/raqb/types";
🤖 Prompt for AI Agents
In `@apps/web/modules/event-types/hooks/useTeamMembersWithSegment.tsx` at line 1,
Remove the unused named import useQuery from the top import line (import {
useQuery } from "@tanstack/react-query"); it's not referenced anywhere in this
module because the code uses
trpc.viewer.attributes.findTeamMembersMatchingAttributeLogic.useQuery instead,
so delete the useQuery symbol from the import to eliminate the lint error and
unused import.

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