Skip to content

Conversation

@brkalow
Copy link
Member

@brkalow brkalow commented Sep 2, 2025

Description

Prefer the popup flow for .lp.dev origins, which are previews for apps generated via leap.new.

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
    • Enables popup SSO on .lp.dev domains by recognizing them as preferred origins (e.g., preview.lp.dev, app.lp.dev), improving sign-in flow on those environments.
  • Tests
    • Added test coverage confirming .lp.dev domains are treated as preferred origins when not in an iframe.
  • Chores
    • Added changeset entry for a patch release.

@changeset-bot
Copy link

changeset-bot bot commented Sep 2, 2025

🦋 Changeset detected

Latest commit: c393a1a

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 Sep 2, 2025

Walkthrough

Extends the popup-preferred origin list by adding the .lp.dev suffix in originPrefersPopup(). Updates tests to cover .lp.dev subdomains. Adds a changeset entry to bump @clerk/clerk-js with a patch. No API or signature changes; only a small logic addition and corresponding tests.

Changes

Cohort / File(s) Change Summary
Popup origin preference update
packages/clerk-js/src/ui/utils/originPrefersPopup.ts
Added ".lp.dev" to POPUP_PREFERRED_ORIGINS so originPrefersPopup returns true for .lp.dev origins.
Tests for preferred origins
packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts
Added test cases asserting .lp.dev subdomains are treated as preferred origins outside iframes.
Changeset
.changeset/shy-places-grab.md
Added patch changeset noting the .lp.dev origin addition and version bump.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant Utils as originPrefersPopup()
  Caller->>Utils: Check if popup should be preferred
  rect rgba(200,230,255,0.3)
    note right of Utils: Evaluate environment
    Utils->>Utils: Is in iframe?
    alt In iframe
      Utils-->>Caller: true
    else Not in iframe
      Utils->>Utils: Does origin end with any suffix?<br/>(..., .v0.dev, .lp.dev)
      alt Matches preferred suffix
        Utils-->>Caller: true
      else No match
        Utils-->>Caller: false
      end
    end
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my nose at dots that delve,
New burrow found: the lands of .lp.dev!
Pop! goes the SSO, swift and neat,
Tests hop along on nimble feet.
Carrots compiled, the patch is live—
In cozy code, our popups thrive. 🥕✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch brk.feat/lp-dev-origin-prefers-popup

🪧 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 or @coderabbit 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.

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.

@vercel
Copy link

vercel bot commented Sep 2, 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 Sep 2, 2025 3:41pm

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 2, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: c393a1a

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)
.changeset/shy-places-grab.md (1)

5-5: Polish the changeset wording.

Add the article and brief context.

-Add `.lp.dev` to list of origins that prefer the popup SSO flow.
+Add `.lp.dev` to the list of origins that prefer the popup SSO flow (leap.new preview environments).
packages/clerk-js/src/ui/utils/originPrefersPopup.ts (2)

19-19: Match against hostname (not origin) to handle ports and SSR safely.

Using origin fails when a port is present (e.g., https://app.lp.dev:3000) and throws on SSR. Prefer hostname and guard window.

-export function originPrefersPopup(): boolean {
-  return inIframe() || POPUP_PREFERRED_ORIGINS.some(origin => window.location.origin.endsWith(origin));
-}
+export function originPrefersPopup(): boolean {
+  const hostname = typeof window !== 'undefined' ? window.location.hostname : '';
+  return inIframe() || POPUP_PREFERRED_ORIGINS.some(suffix => hostname.endsWith(suffix));
+}

13-17: Doc comment no longer only about iframes.

Reflect that we also prefer popup on specific preview domains.

- * Returns `true` if the current origin is one that is typically embedded via an iframe, which would benefit from the
- * popup flow.
+ * Returns `true` if running in an iframe or the current hostname matches a known preview/embedded domain
+ * that benefits from the popup flow.
packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts (1)

108-114: Good positive coverage for .lp.dev.

Consider adding negatives and a port case (will pass after hostname change): apex, lookalikes, and ported origins.

       it('should return true for .lp.dev domains', () => {
         mockLocationOrigin('https://preview.lp.dev');
         expect(originPrefersPopup()).toBe(true);

         mockLocationOrigin('https://app.lp.dev');
         expect(originPrefersPopup()).toBe(true);
       });
+
+      // Follow-ups (optional):
+      // - After switching to hostname in impl, add:
+      // mockLocationOrigin('https://app.lp.dev:3000'); expect(originPrefersPopup()).toBe(true);
+      // - Negative lookalikes:
+      // mockLocationOrigin('https://lp.dev'); expect(originPrefersPopup()).toBe(false);
+      // mockLocationOrigin('https://evil.lp.dev.malicious.com'); expect(originPrefersPopup()).toBe(false);
+      // mockLocationOrigin('https://app.lp.de'); expect(originPrefersPopup()).toBe(false);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

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

📒 Files selected for processing (3)
  • .changeset/shy-places-grab.md (1 hunks)
  • packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts (1 hunks)
  • packages/clerk-js/src/ui/utils/originPrefersPopup.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (11)
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/utils/originPrefersPopup.ts
  • packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts
**/*.{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/utils/originPrefersPopup.ts
  • packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

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

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/ui/utils/originPrefersPopup.ts
  • packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts
packages/**/*.{ts,tsx}

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

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/ui/utils/originPrefersPopup.ts
  • packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts
packages/**/*.{ts,tsx,d.ts}

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

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/ui/utils/originPrefersPopup.ts
  • packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.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/clerk-js/src/ui/utils/originPrefersPopup.ts
  • packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.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/clerk-js/src/ui/utils/originPrefersPopup.ts
  • packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts
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/utils/__tests__/originPrefersPopup.spec.ts
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/utils/__tests__/originPrefersPopup.spec.ts
**/__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/utils/__tests__/originPrefersPopup.spec.ts
.changeset/**

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

Automated releases must use Changesets.

Files:

  • .changeset/shy-places-grab.md
🧬 Code graph analysis (1)
packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts (1)
packages/clerk-js/src/ui/utils/originPrefersPopup.ts (1)
  • originPrefersPopup (18-20)
🪛 LanguageTool
.changeset/shy-places-grab.md

[grammar] ~5-~5: There might be a mistake here.
Context: ...erk/clerk-js': patch --- Add .lp.dev to list of origins that prefer the popup S...

(QB_NEW_EN)


[grammar] ~5-~5: There might be a mistake here.
Context: ... origins that prefer the popup SSO flow.

(QB_NEW_EN)

⏰ 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 (1)
packages/clerk-js/src/ui/utils/originPrefersPopup.ts (1)

10-10: Addition of .lp.dev looks good.

@brkalow brkalow merged commit f1ccc98 into main Sep 2, 2025
40 checks passed
@brkalow brkalow deleted the brk.feat/lp-dev-origin-prefers-popup branch September 2, 2025 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants