Skip to content

Conversation

@LauraBeatris
Copy link
Member

@LauraBeatris LauraBeatris commented Dec 17, 2025

Description

Resolves ORGS-1027, ORGS-1136

Introduce organization creation defaults to TaskChooseOrganization component - this is based new "Require organization membership" options from the Clerk Dashboard, where C1s can define default organization naming rules

We'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 test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

Release Notes

  • New Features

    • Added organization creation defaults with pre-filled form fields (name, slug, logo).
    • Added advisory alerts to warn users if an organization already exists for their detected domain.
    • Enhanced organization creation flow with logo upload capability.
  • Localization

    • Added new alert message for existing organizations with matching domains.
  • Tests

    • Added test coverage for organization creation defaults behavior and prefilled form values.

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

@vercel
Copy link

vercel bot commented Dec 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Dec 19, 2025 3:32pm

@LauraBeatris LauraBeatris changed the title feat(ui,clerk-js,shared): Add organization creation defaults to components feat(ui,clerk-js,shared): Surface organization creation defaults to components Dec 17, 2025
@changeset-bot
Copy link

changeset-bot bot commented Dec 17, 2025

⚠️ No Changeset found

Latest commit: 22edba6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@LauraBeatris LauraBeatris force-pushed the laura/orgs-1136-update-taskchooseorganization-to-show-warning-when branch from 21f7045 to 7093f4b Compare December 19, 2025 13:52
@LauraBeatris LauraBeatris force-pushed the laura/orgs-1136-update-taskchooseorganization-to-show-warning-when branch 2 times, most recently from 5393111 to 97c7605 Compare December 19, 2025 14:25
@LauraBeatris LauraBeatris force-pushed the laura/orgs-1136-update-taskchooseorganization-to-show-warning-when branch from 97c7605 to c5fcb39 Compare December 19, 2025 14:49
@LauraBeatris LauraBeatris force-pushed the laura/orgs-1136-update-taskchooseorganization-to-show-warning-when branch from 13af5ff to 22edba6 Compare December 19, 2025 15:31
@LauraBeatris LauraBeatris marked this pull request as ready for review December 19, 2025 15:34
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 19, 2025

📝 Walkthrough

Walkthrough

This 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 TaskChooseOrganization screen is updated to conditionally fetch and display these defaults when enabled, including pre-filling form fields with default values and rendering advisory alerts when existing organizations are detected for a user's email domain. Supporting changes include fixture helpers for testing, new localization strings, and UI component enhancements for avatar uploading and form pre-population.

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR comprehensively addresses both ORGS-1027 and ORGS-1136 objectives: new types added to @clerk/shared/types, clerk-js resources updated to consume defaults, conditional fetching based on enabled flag implemented, default naming/logo rendered in TaskChooseOrganization with warning alerts.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing organization creation defaults: type definitions, resource classes, UI components for alerts and form prefilling, test fixtures, and localization strings. A minor adjustment to AvatarUploader appears supportive of the avatar upload feature.
Title check ✅ Passed The title accurately describes the main change: introducing organization creation defaults to UI, clerk-js, and shared packages as a new feature.

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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.

📥 Commits

Reviewing files that changed from the base of the PR and between e9be68d and 22edba6.

📒 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.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsx
  • packages/shared/src/types/user.ts
  • packages/ui/src/elements/AvatarUploader.tsx
  • packages/localizations/src/en-US.ts
  • packages/shared/src/types/snapshots.ts
  • packages/clerk-js/src/core/resources/OrganizationCreationDefaults.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/OrganizationSettings.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
  • packages/shared/src/types/index.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
  • packages/clerk-js/src/test/fixture-helpers.ts
  • packages/shared/src/types/organizationCreationDefaults.ts
  • packages/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.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsx
  • packages/shared/src/types/user.ts
  • packages/ui/src/elements/AvatarUploader.tsx
  • packages/localizations/src/en-US.ts
  • packages/shared/src/types/snapshots.ts
  • packages/clerk-js/src/core/resources/OrganizationCreationDefaults.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/OrganizationSettings.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
  • packages/shared/src/types/index.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
  • packages/clerk-js/src/test/fixture-helpers.ts
  • packages/shared/src/types/organizationCreationDefaults.ts
  • packages/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.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsx
  • packages/shared/src/types/user.ts
  • packages/ui/src/elements/AvatarUploader.tsx
  • packages/localizations/src/en-US.ts
  • packages/shared/src/types/snapshots.ts
  • packages/clerk-js/src/core/resources/OrganizationCreationDefaults.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/OrganizationSettings.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
  • packages/shared/src/types/index.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
  • packages/clerk-js/src/test/fixture-helpers.ts
  • packages/shared/src/types/organizationCreationDefaults.ts
  • packages/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.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsx
  • packages/shared/src/types/user.ts
  • packages/ui/src/elements/AvatarUploader.tsx
  • packages/localizations/src/en-US.ts
  • packages/shared/src/types/snapshots.ts
  • packages/clerk-js/src/core/resources/OrganizationCreationDefaults.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/OrganizationSettings.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
  • packages/shared/src/types/index.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
  • packages/clerk-js/src/test/fixture-helpers.ts
  • packages/shared/src/types/organizationCreationDefaults.ts
  • packages/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.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsx
  • packages/shared/src/types/user.ts
  • packages/ui/src/elements/AvatarUploader.tsx
  • packages/localizations/src/en-US.ts
  • packages/shared/src/types/snapshots.ts
  • packages/clerk-js/src/core/resources/OrganizationCreationDefaults.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/OrganizationSettings.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
  • packages/shared/src/types/index.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
  • packages/clerk-js/src/test/fixture-helpers.ts
  • packages/shared/src/types/organizationCreationDefaults.ts
  • packages/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.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsx
  • packages/shared/src/types/user.ts
  • packages/ui/src/elements/AvatarUploader.tsx
  • packages/localizations/src/en-US.ts
  • packages/shared/src/types/snapshots.ts
  • packages/clerk-js/src/core/resources/OrganizationCreationDefaults.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/OrganizationSettings.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
  • packages/shared/src/types/index.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
  • packages/clerk-js/src/test/fixture-helpers.ts
  • packages/shared/src/types/organizationCreationDefaults.ts
  • packages/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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Implement type guards for unknown types using the pattern function isType(value: unknown): value is Type
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details in classes
Use protected for inheritance hierarchies
Use public explicitly 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 like Omit, Partial, and Pick for 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
Use const assertions with as const for literal types
Use satisfies operator 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.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsx
  • packages/shared/src/types/user.ts
  • packages/ui/src/elements/AvatarUploader.tsx
  • packages/localizations/src/en-US.ts
  • packages/shared/src/types/snapshots.ts
  • packages/clerk-js/src/core/resources/OrganizationCreationDefaults.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/OrganizationSettings.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
  • packages/shared/src/types/index.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
  • packages/clerk-js/src/test/fixture-helpers.ts
  • packages/shared/src/types/organizationCreationDefaults.ts
  • packages/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.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsx
  • packages/shared/src/types/user.ts
  • packages/ui/src/elements/AvatarUploader.tsx
  • packages/localizations/src/en-US.ts
  • packages/shared/src/types/snapshots.ts
  • packages/clerk-js/src/core/resources/OrganizationCreationDefaults.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/OrganizationSettings.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
  • packages/shared/src/types/index.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
  • packages/clerk-js/src/test/fixture-helpers.ts
  • packages/shared/src/types/organizationCreationDefaults.ts
  • packages/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.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsx
  • packages/shared/src/types/user.ts
  • packages/ui/src/elements/AvatarUploader.tsx
  • packages/localizations/src/en-US.ts
  • packages/shared/src/types/snapshots.ts
  • packages/clerk-js/src/core/resources/OrganizationCreationDefaults.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/OrganizationSettings.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
  • packages/shared/src/types/index.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
  • packages/clerk-js/src/test/fixture-helpers.ts
  • packages/shared/src/types/organizationCreationDefaults.ts
  • packages/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.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/OrganizationCreationDefaultsAlert.tsx
  • packages/shared/src/types/user.ts
  • packages/ui/src/elements/AvatarUploader.tsx
  • packages/localizations/src/en-US.ts
  • packages/shared/src/types/snapshots.ts
  • packages/clerk-js/src/core/resources/OrganizationCreationDefaults.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/OrganizationSettings.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
  • packages/shared/src/types/index.ts
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/index.tsx
  • packages/clerk-js/src/test/fixture-helpers.ts
  • packages/shared/src/types/organizationCreationDefaults.ts
  • packages/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.tsx
  • packages/ui/src/elements/AvatarUploader.tsx
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
  • packages/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.tsx
  • packages/ui/src/elements/AvatarUploader.tsx
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
  • packages/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.tsx
  • packages/ui/src/elements/AvatarUploader.tsx
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/__tests__/TaskChooseOrganization.test.tsx
  • packages/ui/src/components/SessionTasks/tasks/TaskChooseOrganization/CreateOrganizationScreen.tsx
  • packages/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 withOrganizationCreationDefaults helper 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 OrganizationCreationAdvisoryType and OrganizationCreationAdvisorySeverity, and nullable advisory for optional warnings.

packages/shared/src/types/snapshots.ts (1)

31-31: LGTM - Snapshot type follows standard pattern.

The new OrganizationCreationDefaultsJSONSnapshot follows 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 getOrganizationInvitations and getOrganizationSuggestions.

Also applies to: 279-280

packages/shared/src/types/user.ts (1)

10-10: LGTM - Type definition matches implementation.

The method signature in UserResource correctly matches the implementation in User.ts with 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 organizationCreationDefaults follow 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 organizationCreationDefaults property is implemented consistently with other settings properties like domains and slug, using proper default values and safe deserialization.

Also applies to: 59-64

Comment on lines +50 to +58
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);
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

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.

Comment on lines +67 to +74
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 });
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

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.

Suggested change
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;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

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.

Suggested change
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).

@LauraBeatris LauraBeatris changed the title feat(ui,clerk-js,shared): Surface organization creation defaults to components feat(ui,clerk-js,shared): Surface organization creation defaults Dec 19, 2025
@LauraBeatris
Copy link
Member Author

I'll hold merging this one after the winter break

actionText: 'Signed in as {{identifier}}',
},
alerts: {
existingOrgWithDomain:
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants