Skip to content

feat(clerk-js): Update SubscriptionDetails to support free trials #6569

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

Merged

Conversation

panteliselef
Copy link
Member

@panteliselef panteliselef commented Aug 18, 2025

Description

This PR introduces new labels and CTAs that reflect the free trial state inside <SubscriptionDetails/>.

Screenshot 2025-08-18 at 6 38 38 PM

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

  • New Features

    • Subscription Details now supports free trials: shows Free trial status, trial start/end dates, and first-payment date/amount; actions and confirmation copy adapt to include plan-aware cancel/keep free-trial flows. New localization keys added for trial and first-payment strings.
  • Tests

    • Added tests covering free-trial UI, labels, menu actions, and cancellation confirmation flow.
  • Chores

    • Bumped minor versions for localization, core UI, and types packages; tiny bundle size threshold adjusted.

Copy link

changeset-bot bot commented Aug 18, 2025

🦋 Changeset detected

Latest commit: bbebb54

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
@clerk/localizations Minor
@clerk/clerk-js Minor
@clerk/types Minor
@clerk/clerk-react Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/elements Patch
@clerk/expo-passkeys Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/remix Patch
@clerk/shared Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/themes Patch
@clerk/vue Patch

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

Copy link

vercel bot commented Aug 18, 2025

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

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Aug 18, 2025 4:03pm

Copy link

pkg-pr-new bot commented Aug 18, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6569

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6569

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6569

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6569

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6569

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6569

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6569

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6569

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6569

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6569

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6569

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6569

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6569

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6569

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6569

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6569

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6569

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6569

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6569

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6569

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6569

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6569

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6569

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6569

commit: bbebb54

Copy link
Contributor

coderabbitai bot commented Aug 18, 2025

📝 Walkthrough

Walkthrough

Adds free-trial support to SubscriptionDetails: UI labels, badges, headings, menu actions, and confirmation dialogs switch to trial-specific localization keys when selectedSubscription?.isFreeTrial is true. Subscription card and summary show trial-start/end and first-payment details. Two unit tests cover free-trial display and cancellation flow. New en-US localization keys and corresponding type definitions were added. A changeset bumps minor versions for @clerk/localizations, @clerk/clerk-js, and @clerk/types. bundlewatch size threshold for ui-common was slightly increased.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • 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 fee72b9 and bbebb54.

📒 Files selected for processing (1)
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/clerk-js/src/ui/components/SubscriptionDetails/tests/SubscriptionDetails.test.tsx

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 0

🧹 Nitpick comments (4)
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx (1)

1189-1196: Fix ESLint: remove unused getAllByText from destructure

getAllByText is not used in this test case and triggers @typescript-eslint/no-unused-vars. Remove it (or prefix with _).

Apply this diff:

-    const { getByRole, getByText, getAllByText, userEvent } = render(
+    const { getByRole, getByText, userEvent } = render(
       <Drawer.Root
         open
         onOpenChange={() => {}}
       >
         <SubscriptionDetails />
       </Drawer.Root>,
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (3)

291-302: Dialog description: correct branching and placeholders

  • Free-trial: cancelFreeTrialDescription (plan)
  • Upcoming: cancelSubscriptionNoCharge
  • Active non-trial: cancelSubscriptionAccessUntil (plan, date)

One small suggestion: avoid the type cast on date by guarding before rendering to make the invariant explicit.

Example:

- : localizationKeys('commerce.cancelSubscriptionAccessUntil', {
-     plan: selectedSubscription.plan.name,
-     // this will always be defined in this state
-     date: selectedSubscription.periodEnd as Date,
-   })
+ : selectedSubscription.periodEnd
+   ? localizationKeys('commerce.cancelSubscriptionAccessUntil', {
+       plan: selectedSubscription.plan.name,
+       date: selectedSubscription.periodEnd,
+     })
+   : localizationKeys('commerce.cancelSubscriptionNoCharge')

341-345: Optional: avoid template-literal keys for stronger typing

Using a template string inside localizationKeys works but loses key-level type safety. A small refactor keeps typing precise.

- <LineItems.Title
-   description={localizationKeys(
-     `commerce.subscriptionDetails.${isFreeTrial ? 'firstPaymentOn' : 'nextPaymentOn'}`,
-   )}
- />
+ <LineItems.Title
+   description={
+     isFreeTrial
+       ? localizationKeys('commerce.subscriptionDetails.firstPaymentOn')
+       : localizationKeys('commerce.subscriptionDetails.nextPaymentOn')
+   }
+ />
- <LineItems.Title
-   description={localizationKeys(
-     `commerce.subscriptionDetails.${isFreeTrial ? 'firstPaymentAmount' : 'nextPaymentAmount'}`,
-   )}
- />
+ <LineItems.Title
+   description={
+     isFreeTrial
+       ? localizationKeys('commerce.subscriptionDetails.firstPaymentAmount')
+       : localizationKeys('commerce.subscriptionDetails.nextPaymentAmount')
+   }
+ />

Also applies to: 349-353


62-76: Optional: annotate explicit return type for exported component

For public exports, we prefer explicit return types. Consider annotating SubscriptionDetails with JSX.Element.

-export const SubscriptionDetails = (props: __internal_SubscriptionDetailsProps) => {
+export const SubscriptionDetails = (props: __internal_SubscriptionDetailsProps): JSX.Element => {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • 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 64f64a1 and 34276a4.

📒 Files selected for processing (5)
  • .changeset/cruel-bears-sniff.md (1 hunks)
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx (1 hunks)
  • packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (9 hunks)
  • packages/localizations/src/en-US.ts (3 hunks)
  • packages/types/src/localization.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (17)
.changeset/**

📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/cruel-bears-sniff.md
**/*.{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/types/src/localization.ts
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
  • packages/localizations/src/en-US.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/types/src/localization.ts
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
  • packages/localizations/src/en-US.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/types/src/localization.ts
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
  • packages/localizations/src/en-US.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/types/src/localization.ts
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
  • packages/localizations/src/en-US.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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
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
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly 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
Use const assertions for literal types: as const
Use satisfies 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly 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/types/src/localization.ts
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
  • packages/localizations/src/en-US.ts
**/*.{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/types/src/localization.ts
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
  • packages/localizations/src/en-US.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.

Files:

  • packages/types/src/localization.ts
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
  • packages/localizations/src/en-US.ts
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/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/index.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/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/index.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/SubscriptionDetails/__tests__/SubscriptionDetails.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/SubscriptionDetails/__tests__/SubscriptionDetails.test.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/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/index.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/SubscriptionDetails/__tests__/SubscriptionDetails.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/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
packages/localizations/**/*

📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)

Localization files must be placed in 'packages/localizations/'.

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
🧬 Code Graph Analysis (2)
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx (3)
packages/clerk-js/src/ui/elements/Drawer.tsx (1)
  • Drawer (555-564)
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (1)
  • SubscriptionDetails (62-76)
packages/clerk-js/src/ui/lazyModules/components.ts (1)
  • SubscriptionDetails (116-118)
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (3)
packages/clerk-js/src/ui/customizables/elementDescriptors.ts (1)
  • descriptors (565-565)
packages/clerk-js/src/ui/elements/LineItems.tsx (1)
  • LineItems (289-294)
packages/clerk-js/src/ui/utils/formatDate.ts (1)
  • formatDate (1-13)
🪛 ESLint
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx

[error] 1189-1189: 'getAllByText' is assigned a value but never used. Allowed unused vars must match /^_/u.

(@typescript-eslint/no-unused-vars)

⏰ 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). (6)
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (12)
.changeset/cruel-bears-sniff.md (1)

2-7: Changeset looks correct and scoped to a minor feature bump

Minor version bumps for @clerk/localizations, @clerk/clerk-js, and @clerk/types with a concise feature note align with the surface-area of this PR (new i18n keys, UI work, and types). No concerns.

packages/types/src/localization.ts (2)

190-194: New commerce free-trial keys are well-typed

  • cancelFreeTrial*, keepFreeTrial entries added under commerce with correct param typing (plan where needed).
  • Matches usage in UI and strings in en-US.

No issues.


219-224: subscriptionDetails additions for trial/first-payment are consistent

  • firstPaymentOn/Amount and trialStartedOn/EndsOn added with plain LocalizationValue, which matches their usage patterns.
  • Complements existing nextPayment* keys without breaking older flows.

Looks good.

packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx (1)

1016-1123: Good coverage for active free-trial UI and actions

The test asserts all free-trial-specific labels, hides regular-subscription labels, and verifies the menu action. This aligns with the new i18n keys and gating logic. Nice.

packages/localizations/src/en-US.ts (2)

67-71: Free-trial dialog copy: accurate and aligned with types

  • cancelFreeTrial, cancelFreeTrialTitle, cancelFreeTrialDescription, keepFreeTrial are added and use the expected {{plan}} placeholder where appropriate.
  • Tone and phrasing fit the product voice.

Approved.


148-155: subscriptionDetails “first payment” and “trial” labels: LGTM

The new keys (firstPaymentOn/Amount, trialStartedOn/EndsOn) are present and used by the updated UI/tests. No placeholder or formatting issues spotted.

packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (6)

246-251: Confirmation “keep” action correctly switches for free trial

Switching the secondary button’s localization key to keepFreeTrial when isFreeTrial is true is correct and matches the UX.


261-266: Confirmation “cancel” action properly contextualized for free trial

Using the cancelFreeTrial key with the plan name parameter is consistent with the title/description and tests. Good.


278-285: Dialog title: correct localization gating and params

  • Free-trial: cancelFreeTrialTitle with plan param
  • Regular: cancelSubscriptionTitle with computed plan label

This matches the string contracts.


326-357: Summary uses “first payment” wording on free trials: correct

Deriving isFreeTrial from the active subscription and swapping nextPayment* to firstPayment* provides the right semantics for trials. Nicely done.


564-568: Detail labels correctly switch for trials

  • SubscribedOn → Trial started on
  • RenewsAt → Trial ends on (unless canceled)

Matches the expected UX and localizations.

Also applies to: 575-582


526-527: No changes needed—SubscriptionBadge supports the simplified { status: 'free_trial' } prop
The SubscriptionBadge component is defined as:

export const SubscriptionBadge = <T extends { status: CommerceSubscriptionItemResource['status'] }>({
  subscription,
  elementDescriptor,
}: {
  subscription: T | { status: 'free_trial' };
  elementDescriptor?: ElementDescriptor;
}) => {  }

Since its subscription prop already allows the { status: 'free_trial' } shape, passing only { status: 'free_trial' } when subscription.isFreeTrial is fully supported.

@panteliselef panteliselef force-pushed the elef/com-1124-update-subscriptiondetail-with-free-trial-info branch from 34276a4 to fee72b9 Compare August 18, 2025 15:43
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: 1

🧹 Nitpick comments (4)
packages/clerk-js/bundlewatch.config.json (1)

7-7: Slight bundle ceiling bump is fine; keep an eye on incremental drift

The +0.1KB tolerance for ui-common*.js seems reasonable for the new feature. Please keep these increases minimal and justified to avoid threshold creep over time. If the final built size fits under the old 114KB after tree-shaking tweaks, consider reverting.

packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx (1)

1213-1221: Nit: Localization copy may read a bit awkward (“Plan plan”)

The title string results in “Cancel free trial for Pro Plan plan?”. Consider updating the en-US localization to avoid the double “plan” (e.g., “Cancel free trial for Pro Plan?”). Tests will need updating accordingly if you change the copy.

packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (2)

277-285: Title handling is correct; consider refining localization to avoid “Plan plan”

Functionally correct. As a copy nit, the cancelFreeTrialTitle key that renders “Cancel free trial for {plan} plan?” can sound repetitive depending on plan names (“Pro Plan plan”). Consider revising the localized string to “Cancel free trial for {plan}?” and adjusting tests accordingly.


526-528: Avoid passing a partial “subscription-like” object to SubscriptionBadge

You’re constructing { status: 'free_trial' } to drive the badge. If SubscriptionBadge expects a CommerceSubscriptionItemResource, this is brittle and undermines type safety. Prefer one of:

  • Add a statusOverride?: 'free_trial' | ... prop to SubscriptionBadge, or
  • Move the isFreeTrial check inside SubscriptionBadge and render the free-trial badge based on the real subscription.

This keeps props typed and avoids sneaky runtime surprises if SubscriptionBadge starts relying on additional fields later.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • 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 34276a4 and fee72b9.

📒 Files selected for processing (6)
  • .changeset/cruel-bears-sniff.md (1 hunks)
  • packages/clerk-js/bundlewatch.config.json (1 hunks)
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx (1 hunks)
  • packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (9 hunks)
  • packages/localizations/src/en-US.ts (3 hunks)
  • packages/types/src/localization.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/cruel-bears-sniff.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/localizations/src/en-US.ts
  • packages/types/src/localization.ts
🧰 Additional context used
📓 Path-based instructions (14)
**/*.{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/bundlewatch.config.json
  • packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.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/bundlewatch.config.json
  • packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
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/SubscriptionDetails/index.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.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/SubscriptionDetails/index.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
packages/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.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/SubscriptionDetails/index.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
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
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly 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
Use const assertions for literal types: as const
Use satisfies 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly 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/SubscriptionDetails/index.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.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/SubscriptionDetails/index.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.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/SubscriptionDetails/index.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.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/SubscriptionDetails/index.tsx
  • packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.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/SubscriptionDetails/__tests__/SubscriptionDetails.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/SubscriptionDetails/__tests__/SubscriptionDetails.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/SubscriptionDetails/__tests__/SubscriptionDetails.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/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
🧬 Code Graph Analysis (2)
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (3)
packages/clerk-js/src/ui/customizables/elementDescriptors.ts (1)
  • descriptors (565-565)
packages/clerk-js/src/ui/elements/LineItems.tsx (1)
  • LineItems (289-294)
packages/clerk-js/src/ui/utils/formatDate.ts (1)
  • formatDate (1-13)
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx (3)
packages/clerk-js/src/ui/elements/Drawer.tsx (1)
  • Drawer (555-564)
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (1)
  • SubscriptionDetails (62-76)
packages/clerk-js/src/ui/lazyModules/components.ts (1)
  • SubscriptionDetails (116-118)
🪛 ESLint
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx

[error] 1189-1189: 'getAllByText' is assigned a value but never used. Allowed unused vars must match /^_/u.

(@typescript-eslint/no-unused-vars)

⏰ 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). (6)
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (8)
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx (1)

1017-1123: LGTM: Solid coverage for free-trial display and menu action

Good assertions for trial-specific labels, payment wording, and the “Cancel free trial” menu item. This meaningfully exercises the new UX.

packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (7)

246-251: Good: “Keep” action adapts to free-trial state

Switching the ghost button label between keepSubscription and keepFreeTrial aligns with the new flow and maintains localization. Looks correct.


260-266: Good: “Cancel” action leverages trial-aware localization with plan interpolation

The dynamic label properly injects the plan name for free trials. Matches the test assertions.


291-302: Description branches cover all states cleanly

The free-trial description route vs. upcoming vs. access-until is well delineated. Using handleError in the cancel path adheres to error-handling guidelines. No issues.


326-353: Nice: Summary switches to “first payment” wording when on free trial

Using firstPaymentOn/firstPaymentAmount when isFreeTrial keeps the semantics accurate. Localization keys are used consistently.


426-433: Menu action label correctly maps to trial-aware cancellation

Good conditional on subscription.isFreeTrial to surface the correct destructive action and copy.


564-580: Good: Trial-aware detail labels

Switching subscribedOn -> trialStartedOn and renewsAt -> trialEndsOn (when not canceled) makes the card details accurate for trials and keeps i18n intact.


326-327: isFreeTrial field confirmed on CommerceSubscriptionItemResource

The CommerceSubscriptionItemResource interface in packages/types/src/commerce.ts (line 1077) declares isFreeTrial: boolean, so using subscription.isFreeTrial here is safe.

@panteliselef panteliselef merged commit aa6a3c3 into main Aug 19, 2025
41 checks passed
@panteliselef panteliselef deleted the elef/com-1124-update-subscriptiondetail-with-free-trial-info branch August 19, 2025 10:28
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.

3 participants