-
Notifications
You must be signed in to change notification settings - Fork 371
feat(clerk-js,clerk-react,types): Introduce TaskChooseOrganization
#6446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(clerk-js,clerk-react,types): Introduce TaskChooseOrganization
#6446
Conversation
🦋 Changeset detectedLatest commit: 9497c2c The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
b3614ba
to
e349b20
Compare
1f91214
to
a5af7fc
Compare
abafaaa
to
29d55e2
Compare
02c4157
to
e5b71e5
Compare
58a90f2
to
caac240
Compare
TaskChooseOrganization
TaskChooseOrganization
6bc24fe
to
54de71d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🔭 Outside diff range comments (1)
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx (1)
222-223
: Add test coverage for critical user flowsThe test suite is missing coverage for several important scenarios:
- Error handling during organization creation
- Successful organization creation flow
- Organization selection and activation
- Loading states while fetching organizations
- Handling of organization invitations and suggestions
Would you like me to generate additional test cases to cover these scenarios?
🧹 Nitpick comments (4)
.changeset/brown-garlics-boil.md (1)
13-15
: Consider adding migration guide for the deprecated componentSince this changeset deprecates
TaskSelectOrganization
in favor ofTaskChooseOrganization
, consider adding migration instructions or a link to migration documentation to help developers transition smoothly.Introduce `TaskChooseOrganization` component -It deprecates `TaskSelectOrganization`, and also introduces a new UI that make the experience similar to the previous `SignIn` and `SignUp` steps +It deprecates `TaskSelectOrganization`, and also introduces a new UI that makes the experience similar to the previous `SignIn` and `SignUp` steps. + +## Migration +Replace all instances of `TaskSelectOrganization` with `TaskChooseOrganization`. The API remains the same.packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx (1)
81-99
: Extract duplicate mock data to reduce code duplicationThe mock organization membership data is duplicated between tests. Consider extracting it to a shared constant or helper function.
Add at the top of the file after imports:
const mockOrganizationMembership = createFakeUserOrganizationMembership({ id: '1', organization: { id: '1', name: 'Existing Org', slug: 'org1', membersCount: 1, adminDeleteEnabled: false, maxAllowedMemberships: 1, pendingInvitationsCount: 1, }, });Then use it in both tests:
- fixtures.clerk.user?.getOrganizationMemberships.mockReturnValueOnce( - Promise.resolve({ - data: [ - createFakeUserOrganizationMembership({ - id: '1', - organization: { - id: '1', - name: 'Existing Org', - slug: 'org1', - membersCount: 1, - adminDeleteEnabled: false, - maxAllowedMemberships: 1, - pendingInvitationsCount: 1, - }, - }), - ], - total_count: 1, - }), - ); + fixtures.clerk.user?.getOrganizationMemberships.mockReturnValueOnce( + Promise.resolve({ + data: [mockOrganizationMembership], + total_count: 1, + }), + );Also applies to: 121-138
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx (1)
57-64
: Consider debouncing slug auto-generation for better performanceThe slug is updated on every keystroke when typing the organization name, which could cause performance issues with rapid typing.
import { useMemo } from 'react'; import { debounce } from '@/ui/utils/debounce'; // or lodash.debounce // Inside component: const debouncedUpdateSlug = useMemo( () => debounce((value: string) => { slugField.setValue(createSlug(value)); }, 300), [slugField] ); const onChangeName = (event: React.ChangeEvent<HTMLInputElement>) => { nameField.setValue(event.target.value); debouncedUpdateSlug(event.target.value); };packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx (1)
40-42
: Add defensive checks for data filteringWhile filtering falsy values is good, consider adding type guards to ensure the data structure is as expected.
- const userInvitationsData = userInvitations.data?.filter(a => !!a); - const userSuggestionsData = userSuggestions.data?.filter(a => !!a); + const userInvitationsData = userInvitations.data?.filter((a): a is UserOrganizationInvitationResource => !!a); + const userSuggestionsData = userSuggestions.data?.filter((a): a is OrganizationSuggestionResource => !!a);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
packages/react-router/src/__tests__/__snapshots__/exports.test.ts.snap
is excluded by!**/*.snap
packages/remix/src/__tests__/__snapshots__/exports.test.ts.snap
is excluded by!**/*.snap
packages/tanstack-react-start/src/__tests__/__snapshots__/exports.test.ts.snap
is excluded by!**/*.snap
📒 Files selected for processing (39)
.changeset/brown-garlics-boil.md
(1 hunks)integration/tests/session-tasks-eject-flow.test.ts
(1 hunks)packages/clerk-js/bundlewatch.config.json
(1 hunks)packages/clerk-js/sandbox/app.ts
(4 hunks)packages/clerk-js/sandbox/template.html
(1 hunks)packages/clerk-js/src/core/__tests__/clerk.test.ts
(4 hunks)packages/clerk-js/src/core/clerk.ts
(5 hunks)packages/clerk-js/src/core/warnings.ts
(2 hunks)packages/clerk-js/src/ui/common/organizations/OrganizationPreview.tsx
(1 hunks)packages/clerk-js/src/ui/components/CreateOrganization/CreateOrganizationForm.tsx
(1 hunks)packages/clerk-js/src/ui/components/OrganizationList/OrganizationListPage.tsx
(3 hunks)packages/clerk-js/src/ui/components/OrganizationList/UserMembershipList.tsx
(1 hunks)packages/clerk-js/src/ui/components/OrganizationList/shared.tsx
(1 hunks)packages/clerk-js/src/ui/components/SessionTasks/index.tsx
(2 hunks)packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
(1 hunks)packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
(1 hunks)packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
(1 hunks)packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
(1 hunks)packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskSelectOrganization.tsx
(0 hunks)packages/clerk-js/src/ui/components/SessionTasks/tasks/withTaskGuard.ts
(1 hunks)packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
(3 hunks)packages/clerk-js/src/ui/contexts/components/SessionTasks.ts
(2 hunks)packages/clerk-js/src/ui/customizables/elementDescriptors.ts
(1 hunks)packages/clerk-js/src/ui/elements/contexts/index.tsx
(1 hunks)packages/clerk-js/src/ui/hooks/useOrganizationListInView.ts
(1 hunks)packages/clerk-js/src/ui/lazyModules/components.ts
(3 hunks)packages/clerk-js/src/ui/types.ts
(4 hunks)packages/clerk-js/src/ui/utils/test/fixtureHelpers.ts
(3 hunks)packages/localizations/src/en-US.ts
(1 hunks)packages/nextjs/src/client-boundary/uiComponents.tsx
(1 hunks)packages/nextjs/src/index.ts
(1 hunks)packages/react/src/components/index.ts
(1 hunks)packages/react/src/components/uiComponents.tsx
(4 hunks)packages/react/src/isomorphicClerk.ts
(4 hunks)packages/testing/src/playwright/unstable/page-objects/sessionTask.ts
(1 hunks)packages/types/src/appearance.ts
(3 hunks)packages/types/src/clerk.ts
(3 hunks)packages/types/src/elementIds.ts
(1 hunks)packages/types/src/localization.ts
(1 hunks)
💤 Files with no reviewable changes (1)
- packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskSelectOrganization.tsx
✅ Files skipped from review due to trivial changes (15)
- packages/clerk-js/src/ui/elements/contexts/index.tsx
- packages/clerk-js/src/ui/lazyModules/components.ts
- integration/tests/session-tasks-eject-flow.test.ts
- packages/clerk-js/src/ui/components/SessionTasks/index.tsx
- packages/nextjs/src/index.ts
- packages/nextjs/src/client-boundary/uiComponents.tsx
- packages/react/src/components/index.ts
- packages/types/src/elementIds.ts
- packages/clerk-js/src/core/warnings.ts
- packages/react/src/components/uiComponents.tsx
- packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
- packages/clerk-js/src/ui/contexts/components/SessionTasks.ts
- packages/clerk-js/src/ui/types.ts
- packages/react/src/isomorphicClerk.ts
- packages/types/src/clerk.ts
🚧 Files skipped from review as they are similar to previous changes (18)
- packages/clerk-js/bundlewatch.config.json
- packages/localizations/src/en-US.ts
- packages/clerk-js/sandbox/template.html
- packages/testing/src/playwright/unstable/page-objects/sessionTask.ts
- packages/clerk-js/src/ui/components/SessionTasks/tasks/withTaskGuard.ts
- packages/clerk-js/src/core/tests/clerk.test.ts
- packages/clerk-js/src/ui/customizables/elementDescriptors.ts
- packages/clerk-js/src/ui/components/OrganizationList/OrganizationListPage.tsx
- packages/clerk-js/src/ui/components/CreateOrganization/CreateOrganizationForm.tsx
- packages/clerk-js/src/ui/components/OrganizationList/UserMembershipList.tsx
- packages/clerk-js/src/ui/utils/test/fixtureHelpers.ts
- packages/types/src/appearance.ts
- packages/types/src/localization.ts
- packages/clerk-js/src/ui/hooks/useOrganizationListInView.ts
- packages/clerk-js/src/ui/components/OrganizationList/shared.tsx
- packages/clerk-js/sandbox/app.ts
- packages/clerk-js/src/ui/common/organizations/OrganizationPreview.tsx
- packages/clerk-js/src/core/clerk.ts
🧰 Additional context used
📓 Path-based instructions (15)
.changeset/**
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Automated releases must use Changesets.
Files:
.changeset/brown-garlics-boil.md
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}
: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}
: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
**/*.{jsx,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}
: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}
: Always use functional components with hooks instead of class components
Follow PascalCase naming for components:UserProfile
,NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
packages/**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Unit tests should use Jest or Vitest as the test runner.
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/{clerk-js,elements,themes}/**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Visual regression testing should be performed for UI components.
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
**/*.tsx
📄 CodeRabbit Inference Engine (.cursor/rules/react.mdc)
**/*.tsx
: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
**/*.test.{jsx,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/react.mdc)
**/*.test.{jsx,tsx}
: Use React Testing Library
Test component behavior, not implementation
Use proper test queries
Implement proper test isolation
Use proper test coverage
Test component interactions
Use proper test data
Implement proper test setup
Use proper test cleanup
Implement proper test assertions
Use proper test structure
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
**/__tests__/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/typescript.mdc)
**/__tests__/**/*.{ts,tsx}
: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
**/*
⚙️ CodeRabbit Configuration File
If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (23)
- GitHub Check: Unit Tests (18, --filter=@clerk/astro --filter=@clerk/backend --filter=@clerk/express --filter=@c...
- GitHub Check: Integration Tests (nextjs, chrome, 14)
- GitHub Check: Integration Tests (react-router, chrome)
- GitHub Check: Integration Tests (expo-web, chrome)
- GitHub Check: Integration Tests (nextjs, chrome, 15)
- GitHub Check: Integration Tests (astro, chrome)
- GitHub Check: Integration Tests (billing, chrome)
- GitHub Check: Integration Tests (sessions, chrome)
- GitHub Check: Integration Tests (vue, chrome)
- GitHub Check: Integration Tests (elements, chrome)
- GitHub Check: Integration Tests (tanstack-react-router, chrome)
- GitHub Check: Integration Tests (generic, chrome)
- GitHub Check: Integration Tests (localhost, chrome)
- GitHub Check: Integration Tests (nuxt, chrome)
- GitHub Check: Integration Tests (ap-flows, chrome)
- GitHub Check: Integration Tests (quickstart, chrome)
- GitHub Check: Integration Tests (tanstack-react-start, chrome)
- GitHub Check: Integration Tests (express, chrome)
- GitHub Check: Publish with pkg-pr-new
- GitHub Check: Static analysis
- GitHub Check: Unit Tests (22, **)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx (1)
87-103
: Well-structured flow managementThe
TaskChooseOrganizationFlows
component cleanly manages the state transitions between create and choose flows with appropriate conditional rendering.packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx (1)
32-96
: Well-structured component with clear separation of concernsThe
ChooseOrganizationScreen
component is well-organized with:
- Clean separation between different organization states (memberships, invitations, suggestions)
- Proper infinite scrolling implementation
- Good use of composition patterns
...-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
Show resolved
Hide resolved
...-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
Show resolved
Hide resolved
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx (1)
1-222
: LGTM: Comprehensive test coverage with minor suggestionsExcellent test suite that thoroughly covers the
TaskChooseOrganization
component:✅ Strengths:
- Tests component behavior rather than implementation
- Covers all major user flows (choose/create organization, sign out)
- Proper use of React Testing Library and test fixtures
- Good edge case coverage (missing session tasks, different user states)
- Tests user interactions with proper event simulation
💡 Minor suggestions for future improvements:
- Consider extracting common fixture setup into helper functions to reduce repetition
- Some assertions could be more specific (e.g., checking form validation states)
The current implementation provides solid test coverage and follows testing best practices.
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx (1)
96-96
: Consider more user-friendly slug validationThe current regex pattern
^(?=.*[a-z0-9])[a-z0-9\-]+$
is quite restrictive. Consider:
- Providing clearer validation messages to users
- Making the pattern more permissive if business requirements allow
- Adding client-side validation feedback
<Form.PlainInput {...slugField.props} onChange={event => updateSlugField(event.target.value)} isRequired pattern='^(?=.*[a-z0-9])[a-z0-9\-]+$' + title="Organization slug must contain only lowercase letters, numbers, and hyphens" ignorePasswordManager />
packages/clerk-js/sandbox/app.ts (1)
1-2
: Fix import sorting order.The static analysis tool flagged an import sorting issue. Please run the autofix to sort these imports according to the project's ESLint configuration.
-import type { Clerk as ClerkType } from '../'; -import * as l from '../../localizations'; +import * as l from '../../localizations'; +import type { Clerk as ClerkType } from '../';
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
packages/react-router/src/__tests__/__snapshots__/exports.test.ts.snap
is excluded by!**/*.snap
packages/remix/src/__tests__/__snapshots__/exports.test.ts.snap
is excluded by!**/*.snap
packages/tanstack-react-start/src/__tests__/__snapshots__/exports.test.ts.snap
is excluded by!**/*.snap
📒 Files selected for processing (39)
.changeset/brown-garlics-boil.md
(1 hunks)integration/tests/session-tasks-eject-flow.test.ts
(1 hunks)packages/clerk-js/bundlewatch.config.json
(1 hunks)packages/clerk-js/sandbox/app.ts
(4 hunks)packages/clerk-js/sandbox/template.html
(1 hunks)packages/clerk-js/src/core/__tests__/clerk.test.ts
(4 hunks)packages/clerk-js/src/core/clerk.ts
(5 hunks)packages/clerk-js/src/core/warnings.ts
(2 hunks)packages/clerk-js/src/ui/common/organizations/OrganizationPreview.tsx
(1 hunks)packages/clerk-js/src/ui/components/CreateOrganization/CreateOrganizationForm.tsx
(1 hunks)packages/clerk-js/src/ui/components/OrganizationList/OrganizationListPage.tsx
(3 hunks)packages/clerk-js/src/ui/components/OrganizationList/UserMembershipList.tsx
(1 hunks)packages/clerk-js/src/ui/components/OrganizationList/shared.tsx
(1 hunks)packages/clerk-js/src/ui/components/SessionTasks/index.tsx
(2 hunks)packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
(1 hunks)packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
(1 hunks)packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
(1 hunks)packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
(1 hunks)packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskSelectOrganization.tsx
(0 hunks)packages/clerk-js/src/ui/components/SessionTasks/tasks/withTaskGuard.ts
(1 hunks)packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
(3 hunks)packages/clerk-js/src/ui/contexts/components/SessionTasks.ts
(2 hunks)packages/clerk-js/src/ui/customizables/elementDescriptors.ts
(1 hunks)packages/clerk-js/src/ui/elements/contexts/index.tsx
(1 hunks)packages/clerk-js/src/ui/hooks/useOrganizationListInView.ts
(1 hunks)packages/clerk-js/src/ui/lazyModules/components.ts
(3 hunks)packages/clerk-js/src/ui/types.ts
(4 hunks)packages/clerk-js/src/ui/utils/test/fixtureHelpers.ts
(3 hunks)packages/localizations/src/en-US.ts
(1 hunks)packages/nextjs/src/client-boundary/uiComponents.tsx
(1 hunks)packages/nextjs/src/index.ts
(1 hunks)packages/react/src/components/index.ts
(1 hunks)packages/react/src/components/uiComponents.tsx
(4 hunks)packages/react/src/isomorphicClerk.ts
(4 hunks)packages/testing/src/playwright/unstable/page-objects/sessionTask.ts
(1 hunks)packages/types/src/appearance.ts
(3 hunks)packages/types/src/clerk.ts
(3 hunks)packages/types/src/elementIds.ts
(1 hunks)packages/types/src/localization.ts
(1 hunks)
💤 Files with no reviewable changes (1)
- packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskSelectOrganization.tsx
✅ Files skipped from review due to trivial changes (13)
- integration/tests/session-tasks-eject-flow.test.ts
- packages/nextjs/src/client-boundary/uiComponents.tsx
- packages/nextjs/src/index.ts
- packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
- packages/react/src/components/index.ts
- packages/clerk-js/src/core/warnings.ts
- packages/clerk-js/src/ui/lazyModules/components.ts
- packages/clerk-js/src/ui/elements/contexts/index.tsx
- packages/types/src/elementIds.ts
- packages/clerk-js/src/ui/contexts/components/SessionTasks.ts
- packages/clerk-js/src/ui/types.ts
- packages/types/src/clerk.ts
- packages/react/src/isomorphicClerk.ts
🚧 Files skipped from review as they are similar to previous changes (17)
- packages/clerk-js/bundlewatch.config.json
- packages/clerk-js/src/ui/components/CreateOrganization/CreateOrganizationForm.tsx
- packages/clerk-js/src/ui/utils/test/fixtureHelpers.ts
- packages/clerk-js/src/ui/components/SessionTasks/tasks/withTaskGuard.ts
- packages/clerk-js/src/ui/customizables/elementDescriptors.ts
- packages/testing/src/playwright/unstable/page-objects/sessionTask.ts
- packages/clerk-js/src/ui/hooks/useOrganizationListInView.ts
- packages/clerk-js/src/core/tests/clerk.test.ts
- packages/clerk-js/sandbox/template.html
- packages/localizations/src/en-US.ts
- packages/clerk-js/src/ui/components/OrganizationList/OrganizationListPage.tsx
- packages/clerk-js/src/ui/components/OrganizationList/UserMembershipList.tsx
- packages/types/src/localization.ts
- packages/clerk-js/src/ui/components/OrganizationList/shared.tsx
- packages/types/src/appearance.ts
- packages/clerk-js/src/ui/common/organizations/OrganizationPreview.tsx
- packages/clerk-js/src/core/clerk.ts
🧰 Additional context used
📓 Path-based instructions (15)
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}
: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/components/SessionTasks/index.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/clerk-js/src/ui/components/SessionTasks/index.tsx
packages/react/src/components/uiComponents.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/sandbox/app.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/clerk-js/src/ui/components/SessionTasks/index.tsx
packages/react/src/components/uiComponents.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/sandbox/app.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/components/SessionTasks/index.tsx
packages/react/src/components/uiComponents.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/sandbox/app.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/components/SessionTasks/index.tsx
packages/react/src/components/uiComponents.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/sandbox/app.ts
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}
: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/clerk-js/src/ui/components/SessionTasks/index.tsx
packages/react/src/components/uiComponents.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/sandbox/app.ts
**/*.{jsx,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}
: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}
: Always use functional components with hooks instead of class components
Follow PascalCase naming for components:UserProfile
,NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/clerk-js/src/ui/components/SessionTasks/index.tsx
packages/react/src/components/uiComponents.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/clerk-js/src/ui/components/SessionTasks/index.tsx
packages/react/src/components/uiComponents.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/sandbox/app.ts
**/*.tsx
📄 CodeRabbit Inference Engine (.cursor/rules/react.mdc)
**/*.tsx
: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/clerk-js/src/ui/components/SessionTasks/index.tsx
packages/react/src/components/uiComponents.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
**/*
⚙️ CodeRabbit Configuration File
If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.
Files:
packages/clerk-js/src/ui/components/SessionTasks/index.tsx
packages/react/src/components/uiComponents.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/clerk-js/sandbox/app.ts
.changeset/**
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Automated releases must use Changesets.
Files:
.changeset/brown-garlics-boil.md
packages/**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Unit tests should use Jest or Vitest as the test runner.
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
packages/{clerk-js,elements,themes}/**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Visual regression testing should be performed for UI components.
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
**/*.test.{jsx,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/react.mdc)
**/*.test.{jsx,tsx}
: Use React Testing Library
Test component behavior, not implementation
Use proper test queries
Implement proper test isolation
Use proper test coverage
Test component interactions
Use proper test data
Implement proper test setup
Use proper test cleanup
Implement proper test assertions
Use proper test structure
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
**/__tests__/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/typescript.mdc)
**/__tests__/**/*.{ts,tsx}
: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces
Files:
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
🧬 Code Graph Analysis (2)
packages/clerk-js/src/ui/components/SessionTasks/index.tsx (3)
packages/clerk-js/src/ui/contexts/components/SessionTasks.ts (1)
TaskChooseOrganizationContext
(17-17)packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx (1)
TaskChooseOrganization
(105-107)packages/react/src/components/uiComponents.tsx (1)
TaskChooseOrganization
(638-664)
packages/react/src/components/uiComponents.tsx (4)
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx (1)
TaskChooseOrganization
(105-107)packages/clerk-js/src/ui/lazyModules/components.ts (1)
TaskChooseOrganization
(108-110)packages/react/src/components/withClerk.tsx (1)
withClerk
(7-37)packages/types/src/clerk.ts (1)
TaskChooseOrganizationProps
(2055-2061)
🪛 ESLint
packages/clerk-js/sandbox/app.ts
[error] 1-2: Run autofix to sort these imports!
(simple-import-sort/imports)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Integration Tests (nextjs, chrome, 14)
- GitHub Check: Integration Tests (nextjs, chrome, 15)
- GitHub Check: Integration Tests (billing, chrome)
- GitHub Check: Integration Tests (generic, chrome)
🔇 Additional comments (20)
packages/react/src/components/uiComponents.tsx (2)
12-12
: LGTM: Proper type import updateThe import has been correctly updated to use
TaskChooseOrganizationProps
instead of the deprecated type.
638-664
: LGTM: Consistent component migrationThe component has been properly migrated from
TaskSelectOrganization
toTaskChooseOrganization
with all necessary updates:
- Component name and props type updated
- Mount/unmount method names aligned with the new component name
- Component registration metadata updated consistently
The implementation follows the same pattern as other UI components in this file.
packages/clerk-js/src/ui/components/SessionTasks/index.tsx (2)
13-13
: LGTM: Proper import updatesThe imports have been correctly updated to use the new
TaskChooseOrganizationContext
andTaskChooseOrganization
component.Also applies to: 17-17
47-53
: LGTM: Consistent routing migrationThe route configuration has been properly updated:
- Uses the new
TaskChooseOrganizationContext
provider- Renders the new
TaskChooseOrganization
component- Maintains the same route path for backward compatibility
- Component name in context value matches the new component name
.changeset/brown-garlics-boil.md (1)
1-15
: LGTM: Comprehensive changeset documentationThe changeset properly documents this feature introduction:
- All affected packages are correctly listed with appropriate patch version bumps
- Clear description of the component migration and UI improvements
- Proper deprecation notice for the old component
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx (4)
1-27
: LGTM: Proper imports and hook usageGood use of Clerk hooks and UI utilities:
- Proper TypeScript imports
- Correct hook usage for organization management
- Appropriate context and state management imports
28-37
: LGTM: Well-structured form controlsForm field setup follows established patterns:
- Proper use of
useFormControl
for state management- Consistent localization key usage
- Appropriate field types and labels
39-55
: LGTM: Robust form submission handlingExcellent error handling and API integration:
- Prevents default form submission
- Proper loading state checks
- Good error handling with field-specific error display
- Correct navigation flow after successful organization creation
107-112
: LGTM: Conditional cancel button renderingGood conditional rendering pattern for the optional cancel functionality.
packages/clerk-js/sandbox/app.ts (3)
38-38
: LGTM: Component addition follows established pattern.The addition of
taskChooseOrganization
to the available components list is consistent with the existing pattern and aligns with the PR objective of introducing the new component.
99-99
: LGTM: Control registration is consistent.The component control registration follows the established pattern used by other components in the sandbox.
340-347
: LGTM: Route implementation follows established pattern.The new route implementation is consistent with other component routes. The
redirectUrlComplete
prop is appropriately configured to redirect to the user profile after completion.packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/ChooseOrganizationScreen.tsx (5)
32-96
: LGTM: Well-structured main component with proper loading states.The main
ChooseOrganizationScreen
component is well-implemented with:
- Proper loading state management combining multiple async operations
- Defensive filtering to handle SWR race conditions (lines 41-42)
- Conditional rendering based on pagination states
- Consistent use of element descriptors for theming
The comment explaining the filtering logic for race conditions shows good developer experience awareness.
98-130
: LGTM: Membership selection with proper async handling.The
MembershipPreview
component correctly:
- Uses
card.runAsync
for proper loading state management- Calls
setActive
to switch organizations- Navigates to the next task using the internal navigation API
- Follows the established pattern for organization selection
132-176
: LGTM: Invitation handling with optimistic UI updates.The
InvitationPreview
component implements sophisticated invitation handling:
- Optimistic cache updates without triggering revalidation to prevent layout shifts
- Proper error handling with
handleError
- State transition to membership preview after acceptance
- Uses the
populateCacheUpdateItem
utility for consistent cache managementThe approach to avoid layout shifts during acceptance is particularly thoughtful.
178-216
: LGTM: Suggestion handling with status-aware rendering.The
SuggestionPreview
component properly:
- Handles different suggestion states (accepted vs pending)
- Updates cache in-place without unnecessary revalidations
- Uses appropriate localization keys for different states
- Implements proper error handling
218-247
: LGTM: Create button with proper permission checks.The
CreateOrganizationButton
component correctly:
- Checks user permissions before rendering
- Uses proper element descriptors for theming
- Applies consistent styling with theme tokens
- Follows accessibility practices with proper event handlers
packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx (3)
15-85
: LGTM: Well-structured main component with comprehensive functionality.The
TaskChooseOrganizationInternal
component is excellently implemented with:
- Proper multi-session sign-out handling (lines 23-29) that respects different session contexts
- Loading state management that combines multiple async operations
- Smart initial flow determination based on existing resources (line 56)
- User identifier fallback logic using email or username
- Consistent UI structure with Flow.Root and Card components
- Proper spacing and layout using theme tokens
The sign-out logic correctly handles both single and multi-session scenarios.
87-103
: LGTM: Clean flow management with proper state transitions.The
TaskChooseOrganizationFlows
component provides clean flow management:
- Simple state management for switching between create and choose flows
- Proper conditional rendering based on current flow
- Intelligent cancel button logic that only shows when user has existing resources
- Uses card state provider for consistent loading/error states
105-107
: LGTM: Proper HOC composition for guards and providers.The export composition correctly applies:
- Session switch guard to handle session-related constraints
- Task guard for task-specific logic
- Card state provider for UI state management
The order of HOC application follows established patterns in the codebase.
TaskChooseOrganization
54de71d
to
3d7218e
Compare
3d7218e
to
9497c2c
Compare
TaskChooseOrganization
Description
TaskSelectOrganization
in favor ofTaskChooseOrganization
SignIn
andSignUp
stepsReminder: This is not a breaking change - even tho we haven't prefixed the previous component with
__experimental
, it wasn't released GA yet and after-auth is only enabled in staging.Context
It was previously rendering
OrganizationList
with aSessionTasksContext
, however, the styles were much different fromSignIn
orSignUp
, especially when it comes to spacing.Developers should be able to target
TaskChooseOrganization
and apply different styles to it and it shouldn't impactOrganizationList
- the same apply to the new localizations keys.The inner part of
TaskChooseOrganization
is still similar in terms of design toOrganizationList
, so we've extracted some components to a shared module, allowing us to provide different descriptors and IDs.Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Refactor
Bug Fixes
Tests