Skip to content

Conversation

@alexcarpenter
Copy link
Member

@alexcarpenter alexcarpenter commented Oct 30, 2025

Description

Removes the last used badge rendering from sign-up.

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

  • Bug Fixes
    • Removed the "Last used" authentication badge from the sign-up flow for a cleaner user experience.

@vercel
Copy link

vercel bot commented Oct 30, 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 Oct 30, 2025 2:11pm

@changeset-bot
Copy link

changeset-bot bot commented Oct 30, 2025

🦋 Changeset detected

Latest commit: 5c93ae5

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

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo 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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 30, 2025

Walkthrough

This change introduces a feature flag (showLastAuthenticationStrategy) to control rendering of the last authentication strategy badge in social authentication flows. The sign-in flow enables it, while the sign-up flow disables it, with validation logic added to the SocialButtons component.

Changes

Cohort / File(s) Change Summary
Changeset & Release Notes
.changeset/heavy-badgers-beam.md
Adds patch-level changeset for @clerk/clerk-js noting UI change: removal of last used badge from sign-up rendering.
Test Coverage
integration/tests/last-authentication-strategy.test.ts
New test case verifying the "Last used" badge is not displayed on sign-up flow even when lastAuthenticationStrategy is provided; mocks API and asserts zero occurrences of .cl-lastAuthenticationStrategyBadge.
Sign-In Configuration
packages/clerk-js/src/ui/components/SignIn/SignInSocialButtons.tsx
Adds showLastAuthenticationStrategy={true} prop to SocialButtons component, enabling badge display in sign-in flow.
Sign-Up Configuration
packages/clerk-js/src/ui/components/SignUp/SignUpSocialButtons.tsx
Adds showLastAuthenticationStrategy={false} prop to SocialButtons component, disabling badge display in sign-up flow.
Core Feature Implementation
packages/clerk-js/src/ui/elements/SocialButtons.tsx
Adds showLastAuthenticationStrategy?: boolean prop to SocialButtonsRootProps; introduces validation logic that computes and validates clientLastAuth against available strategies via isValidStrategy, conditionally applying it only when valid.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Pay attention to the validation logic in SocialButtons.tsx to ensure invalid strategies are properly nullified
  • Verify that prop defaults (false for sign-up, true for sign-in) are applied correctly across component instantiations
  • Confirm that the isValidStrategy check prevents display of non-existent authentication strategies

Poem

A badge hides away from the sign-up path,
While sign-in shows what users hath,
With flags that validate with care,
The last strategy goes... poof—not there! 🎭✨

Pre-merge checks and finishing touches

❌ 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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "chore(clerk-js): Only render last used badge on sign-in" directly corresponds to the main objective and changes in the changeset. The title clearly and specifically conveys that the last used badge is now restricted to sign-in only, which accurately reflects the implementation where showLastAuthenticationStrategy is set to true on sign-in and false on sign-up. The title is concise, specific, and would allow a teammate scanning commit history to quickly understand the primary change without ambiguity or vagueness.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch alexcarpenter/lastAuthenticationStrategy-visibility

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 30, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: 5c93ae5

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 (1)
packages/clerk-js/src/ui/elements/SocialButtons.tsx (1)

84-90: Excellent defensive validation logic.

The guarded flow correctly:

  1. Only retrieves lastAuthenticationStrategy when the feature is enabled
  2. Validates that the strategy is currently available using isValidStrategy
  3. Safely handles undefined/null cases with optional chaining

This prevents rendering a badge for providers that may have been disabled after being used previously.

Consider adding a brief comment explaining the validation rationale:

+  // Only use lastAuthenticationStrategy if the feature is enabled and the strategy is currently available
   const clientLastAuth = showLastAuthenticationStrategy ? clerk.client?.lastAuthenticationStrategy : null;
📜 Review details

Configuration used: Path: .coderabbit.yaml

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 2587aa6 and 5c93ae5.

📒 Files selected for processing (5)
  • .changeset/heavy-badgers-beam.md (1 hunks)
  • integration/tests/last-authentication-strategy.test.ts (1 hunks)
  • packages/clerk-js/src/ui/components/SignIn/SignInSocialButtons.tsx (1 hunks)
  • packages/clerk-js/src/ui/components/SignUp/SignUpSocialButtons.tsx (1 hunks)
  • packages/clerk-js/src/ui/elements/SocialButtons.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (13)
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/SignIn/SignInSocialButtons.tsx
  • packages/clerk-js/src/ui/components/SignUp/SignUpSocialButtons.tsx
  • packages/clerk-js/src/ui/elements/SocialButtons.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/SignIn/SignInSocialButtons.tsx
  • packages/clerk-js/src/ui/components/SignUp/SignUpSocialButtons.tsx
  • integration/tests/last-authentication-strategy.test.ts
  • packages/clerk-js/src/ui/elements/SocialButtons.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/ui/components/SignIn/SignInSocialButtons.tsx
  • packages/clerk-js/src/ui/components/SignUp/SignUpSocialButtons.tsx
  • integration/tests/last-authentication-strategy.test.ts
  • packages/clerk-js/src/ui/elements/SocialButtons.tsx
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/ui/components/SignIn/SignInSocialButtons.tsx
  • packages/clerk-js/src/ui/components/SignUp/SignUpSocialButtons.tsx
  • packages/clerk-js/src/ui/elements/SocialButtons.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/SignIn/SignInSocialButtons.tsx
  • packages/clerk-js/src/ui/components/SignUp/SignUpSocialButtons.tsx
  • packages/clerk-js/src/ui/elements/SocialButtons.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/SignIn/SignInSocialButtons.tsx
  • packages/clerk-js/src/ui/components/SignUp/SignUpSocialButtons.tsx
  • integration/tests/last-authentication-strategy.test.ts
  • packages/clerk-js/src/ui/elements/SocialButtons.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/SignIn/SignInSocialButtons.tsx
  • packages/clerk-js/src/ui/components/SignUp/SignUpSocialButtons.tsx
  • packages/clerk-js/src/ui/elements/SocialButtons.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/SignIn/SignInSocialButtons.tsx
  • packages/clerk-js/src/ui/components/SignUp/SignUpSocialButtons.tsx
  • integration/tests/last-authentication-strategy.test.ts
  • packages/clerk-js/src/ui/elements/SocialButtons.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/SignIn/SignInSocialButtons.tsx
  • packages/clerk-js/src/ui/components/SignUp/SignUpSocialButtons.tsx
  • packages/clerk-js/src/ui/elements/SocialButtons.tsx
integration/**

📄 CodeRabbit inference engine (.cursor/rules/global.mdc)

Framework integration templates and E2E tests should be placed under the integration/ directory

Files:

  • integration/tests/last-authentication-strategy.test.ts
integration/**/*

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

End-to-end tests and integration templates must be located in the 'integration/' directory.

Files:

  • integration/tests/last-authentication-strategy.test.ts
integration/**/*.{test,spec}.{js,ts}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Integration tests should use Playwright.

Files:

  • integration/tests/last-authentication-strategy.test.ts
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/heavy-badgers-beam.md
🧬 Code graph analysis (1)
integration/tests/last-authentication-strategy.test.ts (1)
integration/testUtils/index.ts (1)
  • createTestUtils (24-86)
⏰ 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). (28)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (5)
.changeset/heavy-badgers-beam.md (1)

1-5: LGTM! Changeset properly documents the patch.

The changeset correctly documents this as a patch-level change with a clear description that aligns with the PR objectives.

packages/clerk-js/src/ui/elements/SocialButtons.tsx (1)

44-44: Well-designed feature flag with safe defaults.

The new optional prop showLastAuthenticationStrategy is properly typed and defaults to false, ensuring backward compatibility while enabling fine-grained control over badge rendering in sign-in vs sign-up flows.

Also applies to: 64-64

packages/clerk-js/src/ui/components/SignUp/SignUpSocialButtons.tsx (1)

35-35: Clear implementation of the intended behavior.

Passing showLastAuthenticationStrategy={false} explicitly disables the last used badge during sign-up, which directly addresses the PR objective to remove badge rendering from the sign-up flow.

packages/clerk-js/src/ui/components/SignIn/SignInSocialButtons.tsx (1)

36-36: Maintains existing sign-in behavior explicitly.

Setting showLastAuthenticationStrategy={true} preserves the current sign-in experience where the last used authentication method is highlighted, creating a clear and intentional distinction from the sign-up flow.

integration/tests/last-authentication-strategy.test.ts (1)

119-130: Thorough test coverage for the sign-up scenario.

The test effectively validates that the last used badge is not displayed during sign-up, even when lastAuthenticationStrategy is present in the client response. The test properly:

  • Mocks the API response with a known strategy
  • Navigates to the sign-up flow
  • Asserts the badge is not rendered

This provides good regression protection for the new behavior.

@alexcarpenter alexcarpenter merged commit fae192f into main Oct 30, 2025
42 checks passed
@alexcarpenter alexcarpenter deleted the alexcarpenter/lastAuthenticationStrategy-visibility branch October 30, 2025 14:21
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.

4 participants