-
Notifications
You must be signed in to change notification settings - Fork 419
feat(ui,clerk-js,shared): Surface organization creation defaults #7488
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
base: main
Are you sure you want to change the base?
feat(ui,clerk-js,shared): Surface organization creation defaults #7488
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
81ea1f2 to
12005fb
Compare
21f7045 to
7093f4b
Compare
5393111 to
97c7605
Compare
97c7605 to
c5fcb39
Compare
13af5ff to
22edba6
Compare
📝 WalkthroughWalkthroughThis pull request implements organization creation defaults functionality across the Clerk JavaScript SDK and UI components. It introduces new type definitions for organization creation defaults with advisory capabilities, adds a new resource class to fetch these defaults from an API endpoint, and extends existing organization settings to track whether this feature is enabled. The Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
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
📜 Review details
Configuration used: Repository YAML (base), Organization UI (inherited)
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 (16)
packages/clerk-js/src/core/resources/OrganizationCreationDefaults.ts(1 hunks)packages/clerk-js/src/core/resources/OrganizationSettings.ts(2 hunks)packages/clerk-js/src/core/resources/User.ts(2 hunks)packages/clerk-js/src/test/fixture-helpers.ts(2 hunks)packages/localizations/src/en-US.ts(1 hunks)packages/shared/src/types/index.ts(2 hunks)packages/shared/src/types/localization.ts(1 hunks)packages/shared/src/types/organizationCreationDefaults.ts(1 hunks)packages/shared/src/types/organizationSettings.ts(2 hunks)packages/shared/src/types/snapshots.ts(2 hunks)packages/shared/src/types/user.ts(2 hunks)packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx(5 hunks)packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsx(1 hunks)packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx(1 hunks)packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx(5 hunks)packages/ui/src/elements/AvatarUploader.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (21)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
All code must pass ESLint checks with the project's configuration
Files:
packages/shared/src/types/organizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsxpackages/shared/src/types/user.tspackages/ui/src/elements/AvatarUploader.tsxpackages/localizations/src/en-US.tspackages/shared/src/types/snapshots.tspackages/clerk-js/src/core/resources/OrganizationCreationDefaults.tspackages/clerk-js/src/core/resources/User.tspackages/clerk-js/src/core/resources/OrganizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsxpackages/shared/src/types/index.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsxpackages/clerk-js/src/test/fixture-helpers.tspackages/shared/src/types/organizationCreationDefaults.tspackages/shared/src/types/localization.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/shared/src/types/organizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsxpackages/shared/src/types/user.tspackages/ui/src/elements/AvatarUploader.tsxpackages/localizations/src/en-US.tspackages/shared/src/types/snapshots.tspackages/clerk-js/src/core/resources/OrganizationCreationDefaults.tspackages/clerk-js/src/core/resources/User.tspackages/clerk-js/src/core/resources/OrganizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsxpackages/shared/src/types/index.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsxpackages/clerk-js/src/test/fixture-helpers.tspackages/shared/src/types/organizationCreationDefaults.tspackages/shared/src/types/localization.ts
packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/shared/src/types/organizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsxpackages/shared/src/types/user.tspackages/ui/src/elements/AvatarUploader.tsxpackages/localizations/src/en-US.tspackages/shared/src/types/snapshots.tspackages/clerk-js/src/core/resources/OrganizationCreationDefaults.tspackages/clerk-js/src/core/resources/User.tspackages/clerk-js/src/core/resources/OrganizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsxpackages/shared/src/types/index.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsxpackages/clerk-js/src/test/fixture-helpers.tspackages/shared/src/types/organizationCreationDefaults.tspackages/shared/src/types/localization.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Follow established naming conventions (PascalCase for components, camelCase for variables)
Files:
packages/shared/src/types/organizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsxpackages/shared/src/types/user.tspackages/ui/src/elements/AvatarUploader.tsxpackages/localizations/src/en-US.tspackages/shared/src/types/snapshots.tspackages/clerk-js/src/core/resources/OrganizationCreationDefaults.tspackages/clerk-js/src/core/resources/User.tspackages/clerk-js/src/core/resources/OrganizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsxpackages/shared/src/types/index.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsxpackages/clerk-js/src/test/fixture-helpers.tspackages/shared/src/types/organizationCreationDefaults.tspackages/shared/src/types/localization.ts
packages/**/src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
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
Implement proper logging with different levels
Files:
packages/shared/src/types/organizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsxpackages/shared/src/types/user.tspackages/ui/src/elements/AvatarUploader.tsxpackages/localizations/src/en-US.tspackages/shared/src/types/snapshots.tspackages/clerk-js/src/core/resources/OrganizationCreationDefaults.tspackages/clerk-js/src/core/resources/User.tspackages/clerk-js/src/core/resources/OrganizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsxpackages/shared/src/types/index.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsxpackages/clerk-js/src/test/fixture-helpers.tspackages/shared/src/types/organizationCreationDefaults.tspackages/shared/src/types/localization.ts
**/*.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
Files:
packages/shared/src/types/organizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsxpackages/shared/src/types/user.tspackages/ui/src/elements/AvatarUploader.tsxpackages/localizations/src/en-US.tspackages/shared/src/types/snapshots.tspackages/clerk-js/src/core/resources/OrganizationCreationDefaults.tspackages/clerk-js/src/core/resources/User.tspackages/clerk-js/src/core/resources/OrganizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsxpackages/shared/src/types/index.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsxpackages/clerk-js/src/test/fixture-helpers.tspackages/shared/src/types/organizationCreationDefaults.tspackages/shared/src/types/localization.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/*.{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
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Implement type guards forunknowntypes using the patternfunction isType(value: unknown): value is Type
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details in classes
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like<T extends { id: string }>
Use utility types likeOmit,Partial, andPickfor data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @param, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Useconst assertionswithas constfor literal types
Usesatisfiesoperator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...
Files:
packages/shared/src/types/organizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsxpackages/shared/src/types/user.tspackages/ui/src/elements/AvatarUploader.tsxpackages/localizations/src/en-US.tspackages/shared/src/types/snapshots.tspackages/clerk-js/src/core/resources/OrganizationCreationDefaults.tspackages/clerk-js/src/core/resources/User.tspackages/clerk-js/src/core/resources/OrganizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsxpackages/shared/src/types/index.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsxpackages/clerk-js/src/test/fixture-helpers.tspackages/shared/src/types/organizationCreationDefaults.tspackages/shared/src/types/localization.ts
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use ESLint with custom configurations tailored for different package types
Files:
packages/shared/src/types/organizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsxpackages/shared/src/types/user.tspackages/ui/src/elements/AvatarUploader.tsxpackages/localizations/src/en-US.tspackages/shared/src/types/snapshots.tspackages/clerk-js/src/core/resources/OrganizationCreationDefaults.tspackages/clerk-js/src/core/resources/User.tspackages/clerk-js/src/core/resources/OrganizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsxpackages/shared/src/types/index.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsxpackages/clerk-js/src/test/fixture-helpers.tspackages/shared/src/types/organizationCreationDefaults.tspackages/shared/src/types/localization.ts
**/*.{js,ts,jsx,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use Prettier for code formatting across all packages
Files:
packages/shared/src/types/organizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsxpackages/shared/src/types/user.tspackages/ui/src/elements/AvatarUploader.tsxpackages/localizations/src/en-US.tspackages/shared/src/types/snapshots.tspackages/clerk-js/src/core/resources/OrganizationCreationDefaults.tspackages/clerk-js/src/core/resources/User.tspackages/clerk-js/src/core/resources/OrganizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsxpackages/shared/src/types/index.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsxpackages/clerk-js/src/test/fixture-helpers.tspackages/shared/src/types/organizationCreationDefaults.tspackages/shared/src/types/localization.ts
**/*
⚙️ 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.
**/*: Only comment on issues that would block merging, ignore minor or stylistic concerns.
Restrict feedback to errors, security risks, or functionality-breaking problems.
Do not post comments on code style, formatting, or non-critical improvements.
Keep reviews short: flag only issues that make the PR unsafe to merge.
Group similar issues into a single comment instead of posting multiple notes.
Skip repetition: if a pattern repeats, mention it once at a summary level only.
Do not add general suggestions, focus strictly on merge-blocking concerns.
If there are no critical problems, respond with minimal approval (e.g., 'Looks good'). Do not add additional review.
Avoid line-by-line commentary unless it highlights a critical bug or security hole.
Highlight only issues that could cause runtime errors, data loss, or severe maintainability issues.
Ignore minor optimization opportunities, focus solely on correctness and safety.
Provide a top-level summary of critical blockers rather than detailed per-line notes.
Comment only when the issue must be resolved before merge, otherwise remain silent.
When in doubt, err on the side of fewer comments, brevity and blocking issues only.
Avoid posting any refactoring issues.
Files:
packages/shared/src/types/organizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsxpackages/shared/src/types/user.tspackages/ui/src/elements/AvatarUploader.tsxpackages/localizations/src/en-US.tspackages/shared/src/types/snapshots.tspackages/clerk-js/src/core/resources/OrganizationCreationDefaults.tspackages/clerk-js/src/core/resources/User.tspackages/clerk-js/src/core/resources/OrganizationSettings.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsxpackages/shared/src/types/index.tspackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsxpackages/clerk-js/src/test/fixture-helpers.tspackages/shared/src/types/organizationCreationDefaults.tspackages/shared/src/types/localization.ts
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.tsx: Use error boundaries in React components
Minimize re-renders in React components
**/*.tsx: Use proper type definitions for props and state in React components
Leverage TypeScript's type inference where possible in React components
Use proper event types for handlers in React components
Implement proper generic types for reusable React components
Use proper type guards for conditional rendering in React components
Files:
packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsxpackages/ui/src/elements/AvatarUploader.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
**/*.{md,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Update documentation for API changes
Files:
packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsxpackages/ui/src/elements/AvatarUploader.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components (e.g.,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
Separate UI components from business logic components
Use useState for simple state management in React components
Use useReducer for complex state logic in React components
Implement proper state initialization in React components
Use proper state updates with callbacks in React components
Implement proper state cleanup in React components
Use Context API for theme/authentication state management
Implement proper state persistence in React applications
Use React.memo for expensive components
Implement proper useCallback for handlers in React components
Use proper useMemo for expensive computations in React components
Implement proper virtualization for lists in React components
Use proper code splitting with React.lazy in React applications
Implement proper cleanup in useEffect hooks
Use proper refs for DOM access in React components
Implement proper event listener cleanup in React components
Use proper abort controllers for fetch in React components
Implement proper subscription cleanup in React components
Use proper HTML elements for semantic HTML in React components
Implement proper ARIA attributes for accessibility in React components
Use proper heading hierarchy in React components
Implement proper form labels in React components
Use proper button types in React components
Implement proper focus management for keyboard navigation in React components
Use proper keyboard shortcuts in React components
Implement proper tab order in React components
Use proper ...
Files:
packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsxpackages/ui/src/elements/AvatarUploader.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsxpackages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
packages/localizations/**/*
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Organize localization translations in
packages/localizations/with support for 30+ languages and RTL language support
Files:
packages/localizations/src/en-US.ts
**/localizations/**/*.ts
⚙️ CodeRabbit configuration file
**/localizations/**/*.ts: Review the changes to localization files with the following guidelines:
- Ensure that no existing translations are accidentally removed unless they are being replaced or fixed. If a string is removed, verify that it is intentional and justified.
- Check that all translations are friendly, formal, or semi-formal. Explicit, offensive, or inappropriate language is not allowed. If you find any potentially offensive language or are unsure, tag the @clerk/sdk-infra team in a separate comment. If you do not intend to tag the team, refer to it as "Clerk SDK Infra team" instead.
- Use the most up-to-date base localization file (https://github.com/clerk/javascript/blob/main/packages/localizations/src/en-US.ts) to validate changes, ensuring consistency and completeness.
- Confirm that new translations are accurate, contextually appropriate, and match the intent of the original English strings.
- Check for formatting issues, such as missing placeholders, incorrect variable usage, or syntax errors.
- Ensure that all keys are unique and that there are no duplicate or conflicting entries.
- If you notice missing translations for new keys, flag them for completion.
Files:
packages/localizations/src/en-US.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{test,spec}.{ts,tsx,js,jsx}: Unit tests are required for all new functionality
Verify proper error handling and edge cases
Include tests for all new features
Files:
packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
**/*.{test,spec,e2e}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use real Clerk instances for integration tests
Files:
packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
**/*.test.tsx
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use React Testing Library for component testing
Files:
packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
**/*.{test,spec}.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.{test,spec}.{jsx,tsx}: Use React Testing Library for unit testing React components
Test component behavior, not implementation details
Use proper test queries in React Testing Library tests
Implement proper test isolation in React component tests
Use proper test coverage in React component tests
Test component interactions in integration tests
Use proper test data in React component tests
Implement proper test setup in React component tests
Use proper test cleanup in React component tests
Implement proper test assertions in React component tests
Use proper test structure for React component tests
Files:
packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use React Testing Library for component testing
Files:
packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
**/index.ts
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
Avoid barrel files (index.ts re-exports) as they can cause circular dependencies
Files:
packages/shared/src/types/index.ts
🧠 Learnings (1)
📚 Learning: 2025-12-12T19:54:17.554Z
Learnt from: wobsoriano
Repo: clerk/javascript PR: 7447
File: packages/localizations/src/en-US.ts:904-905
Timestamp: 2025-12-12T19:54:17.554Z
Learning: In Clerk's JavaScript localization files (packages/localizations/src/*.ts), undefined values for localization keys are intentional and should not be flagged as issues. When a key is undefined, the system uses the default message from the API response as a fallback. Do not flag these as errors; preserve this expected behavior.
Applied to files:
packages/localizations/src/en-US.ts
🧬 Code graph analysis (7)
packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsx (1)
packages/shared/src/types/organizationCreationDefaults.ts (1)
OrganizationCreationDefaultsResource(21-32)
packages/shared/src/types/user.ts (1)
packages/shared/src/types/organizationCreationDefaults.ts (1)
OrganizationCreationDefaultsResource(21-32)
packages/shared/src/types/snapshots.ts (1)
packages/shared/src/types/organizationCreationDefaults.ts (1)
OrganizationCreationDefaultsJSON(8-19)
packages/clerk-js/src/core/resources/User.ts (1)
packages/clerk-js/src/core/resources/OrganizationCreationDefaults.ts (1)
OrganizationCreationDefaults(11-71)
packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx (1)
packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx (1)
TaskChooseOrganization(168-173)
packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx (2)
packages/shared/src/types/organizationCreationDefaults.ts (1)
OrganizationCreationDefaultsResource(21-32)packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsx (1)
OrganizationCreationDefaultsAlert(6-25)
packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx (1)
packages/shared/src/types/organizationCreationDefaults.ts (1)
OrganizationCreationDefaultsResource(21-32)
⏰ 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). (1)
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (8)
packages/clerk-js/src/test/fixture-helpers.ts (1)
347-349: LGTM - Test fixture helper follows established patterns.The new
withOrganizationCreationDefaultshelper is implemented consistently with other organization settings helpers in this file.Also applies to: 362-362
packages/shared/src/types/organizationCreationDefaults.ts (1)
1-32: LGTM - Type definitions are clean and consistent.The new types follow established patterns in the codebase with separate JSON and Resource interfaces, appropriate use of literal types for
OrganizationCreationAdvisoryTypeandOrganizationCreationAdvisorySeverity, and nullableadvisoryfor optional warnings.packages/shared/src/types/snapshots.ts (1)
31-31: LGTM - Snapshot type follows standard pattern.The new
OrganizationCreationDefaultsJSONSnapshotfollows the same pattern as other snapshot type aliases in this file.Also applies to: 147-148
packages/clerk-js/src/core/resources/User.ts (1)
56-56: LGTM - Clean delegation to OrganizationCreationDefaults.The new method follows the same delegation pattern as
getOrganizationInvitationsandgetOrganizationSuggestions.Also applies to: 279-280
packages/shared/src/types/user.ts (1)
10-10: LGTM - Type definition matches implementation.The method signature in
UserResourcecorrectly matches the implementation inUser.tswith explicit return type.Also applies to: 119-119
packages/localizations/src/en-US.ts (1)
880-883: LGTM - Localization string is clear and properly formatted.The new alert message uses the correct placeholder syntax and provides actionable guidance to users.
packages/shared/src/types/index.ts (1)
16-16: LGTM - Export additions are straightforward.The reorganization and new export for
organizationCreationDefaultsfollow the existing structure of this index file.Also applies to: 36-36
packages/clerk-js/src/core/resources/OrganizationSettings.ts (1)
26-30: LGTM - Property addition follows established pattern.The new
organizationCreationDefaultsproperty is implemented consistently with other settings properties likedomainsandslug, using proper default values and safe deserialization.Also applies to: 59-64
| static async retrieve(): Promise<OrganizationCreationDefaultsResource> { | ||
| return await BaseResource._fetch({ | ||
| path: '/me/organization_creation_defaults', | ||
| method: 'GET', | ||
| }).then(res => { | ||
| const data = res?.response as unknown as OrganizationCreationDefaultsJSON; | ||
| return new OrganizationCreationDefaults(data); | ||
| }); | ||
| } |
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.
Unsafe type casting bypasses validation and could cause runtime errors.
Line 55 uses as unknown as OrganizationCreationDefaultsJSON to force-cast the API response without any validation. If the API returns malformed data or the response structure changes, this will bypass type safety and could cause runtime errors when the resource properties are accessed.
🔎 Proposed fix with runtime validation
static async retrieve(): Promise<OrganizationCreationDefaultsResource> {
return await BaseResource._fetch({
path: '/me/organization_creation_defaults',
method: 'GET',
}).then(res => {
- const data = res?.response as unknown as OrganizationCreationDefaultsJSON;
+ const data = res?.response;
+ // Basic runtime validation
+ if (!data || typeof data !== 'object') {
+ throw new Error('Invalid organization creation defaults response');
+ }
return new OrganizationCreationDefaults(data);
});
}Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In packages/clerk-js/src/core/resources/OrganizationCreationDefaults.ts around
lines 50 to 58, the code force-casts the API response using "as unknown as
OrganizationCreationDefaultsJSON" which bypasses runtime validation; replace the
cast with a proper runtime check: extract res.response, validate required fields
and types (either with a small type-guard function or an existing JSON/schema
validator), throw or return a clear error if validation fails, and only then
construct and return new OrganizationCreationDefaults(validatedData); do not use
"as unknown as" to silence type checking.
| if (file) { | ||
| await organization.setLogo({ file }); | ||
| } else if (defaultLogoUrl) { | ||
| const response = await fetch(defaultLogoUrl); | ||
| const blob = await response.blob(); | ||
| const logoFile = new File([blob], 'logo', { type: blob.type }); | ||
| await organization.setLogo({ file: logoFile }); | ||
| } |
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.
Missing error handling for logo fetch could break organization creation.
The fetch and blob conversion for defaultLogoUrl (lines 69-74) has no error handling. If the network request fails, the response is not a valid image, or blob conversion fails, it will throw an unhandled exception and prevent the organization from being created.
🔎 Proposed fix with error handling
const organization = await createOrganization(createOrgParams);
if (file) {
await organization.setLogo({ file });
} else if (defaultLogoUrl) {
- const response = await fetch(defaultLogoUrl);
- const blob = await response.blob();
- const logoFile = new File([blob], 'logo', { type: blob.type });
- await organization.setLogo({ file: logoFile });
+ try {
+ const response = await fetch(defaultLogoUrl);
+ if (!response.ok) {
+ throw new Error('Failed to fetch logo');
+ }
+ const blob = await response.blob();
+ const logoFile = new File([blob], 'logo', { type: blob.type });
+ await organization.setLogo({ file: logoFile });
+ } catch (err) {
+ // Log error but don't block organization creation
+ console.error('Failed to set default logo:', err);
+ }
}📝 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.
| if (file) { | |
| await organization.setLogo({ file }); | |
| } else if (defaultLogoUrl) { | |
| const response = await fetch(defaultLogoUrl); | |
| const blob = await response.blob(); | |
| const logoFile = new File([blob], 'logo', { type: blob.type }); | |
| await organization.setLogo({ file: logoFile }); | |
| } | |
| if (file) { | |
| await organization.setLogo({ file }); | |
| } else if (defaultLogoUrl) { | |
| try { | |
| const response = await fetch(defaultLogoUrl); | |
| if (!response.ok) { | |
| throw new Error('Failed to fetch logo'); | |
| } | |
| const blob = await response.blob(); | |
| const logoFile = new File([blob], 'logo', { type: blob.type }); | |
| await organization.setLogo({ file: logoFile }); | |
| } catch (err) { | |
| // Log error but don't block organization creation | |
| console.error('Failed to set default logo:', err); | |
| } | |
| } |
🤖 Prompt for AI Agents
In
packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
around lines 67 to 74, the code fetches and converts defaultLogoUrl to a File
without any error handling which can throw and abort organization creation; wrap
the fetch/blob/file creation in a try/catch, check response.ok before calling
response.blob(), and only call organization.setLogo when the blob->File
succeeds; on error, log the error (or surface a non-blocking UI message) and
continue creating the organization without a logo so a failed image fetch does
not stop the flow.
| await handleFileDrop(f); | ||
| }; | ||
|
|
||
| const hasExistingImage = !!(avatarPreview.props as { imageUrl?: string })?.imageUrl; |
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.
Unsafe type assertion could cause runtime errors.
The type assertion (avatarPreview.props as { imageUrl?: string }) assumes the props structure without validation. If avatarPreview.props has a different shape, this could fail or return incorrect results at runtime.
🔎 Proposed fix with proper type guard
- const hasExistingImage = !!(avatarPreview.props as { imageUrl?: string })?.imageUrl;
+ const hasExistingImage = !!(
+ typeof avatarPreview.props === 'object' &&
+ avatarPreview.props !== null &&
+ 'imageUrl' in avatarPreview.props &&
+ (avatarPreview.props as { imageUrl?: string }).imageUrl
+ );📝 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.
| const hasExistingImage = !!(avatarPreview.props as { imageUrl?: string })?.imageUrl; | |
| const hasExistingImage = !!( | |
| typeof avatarPreview.props === 'object' && | |
| avatarPreview.props !== null && | |
| 'imageUrl' in avatarPreview.props && | |
| (avatarPreview.props as { imageUrl?: string }).imageUrl | |
| ); |
🤖 Prompt for AI Agents
In packages/ui/src/elements/AvatarUploader.tsx around line 93, the code uses an
unsafe type assertion on avatarPreview.props to access imageUrl which can cause
runtime errors if props has a different shape; replace the assertion with a
runtime type guard: check that avatarPreview and avatarPreview.props are
objects, verify that 'imageUrl' is a key in props and that its value is a string
(or undefined is acceptable), then derive hasExistingImage from that validated
value (or narrow the avatarPreview type through a proper discriminated
union/interface before accessing imageUrl).
|
I'll hold merging this one after the winter break |
| actionText: 'Signed in as {{identifier}}', | ||
| }, | ||
| alerts: { | ||
| existingOrgWithDomain: |
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.
Will generate the other locale files once I get a first PR review, in case the localization key changes
Description
Resolves ORGS-1027, ORGS-1136
Introduce organization creation defaults to
TaskChooseOrganizationcomponent - this is based new "Require organization membership" options from the Clerk Dashboard, where C1s can define default organization naming rulesWe're also now detecting a default logo based on the user's email domain.
CleanShot.2025-12-19.at.12.32.42.mp4
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
Release Notes
New Features
Localization
Tests
✏️ Tip: You can customize this high-level summary in your review settings.