Skip to content

Conversation

@iagodahlem
Copy link
Member

@iagodahlem iagodahlem commented Aug 20, 2025

Description

Context

Fixes redirection when completing task within SignIn/SignUp context.

Previously, the session task route was trying to access afterSignInUrl/afterSignUpUrl from SignInContext/SignUpContext, which was undefined. The useSignInContext and useSignUpContext hooks have the logic where we extract the redirect URL query params.

Fix

Update logic to provide redirectUrlComplete as prop from the sign-in/sign-up routes.

CleanShot.2025-08-20.at.10.57.45.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

  • Bug Fixes

    • Fixed incorrect redirects after completing required session tasks in Sign In and Sign Up flows; users now land on the intended post-completion destinations (including combined flows) and reach protected pages after auth.
  • New Features

    • Added support for specifying a post-task redirect when sending users to session tasks, allowing precise control of landing destinations.
  • Chores

    • Added a patch release note documenting the session-task redirect fix.

@changeset-bot
Copy link

changeset-bot bot commented Aug 20, 2025

🦋 Changeset detected

Latest commit: c591a25

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

This PR includes changesets to release 22 packages
Name Type
@clerk/clerk-js Patch
@clerk/types 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/localizations Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/clerk-react 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

@vercel
Copy link

vercel bot commented Aug 20, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Skipped Skipped Aug 20, 2025 4:20pm

@LauraBeatris LauraBeatris changed the title fix(clerk-js): Pass query params to buildAfterSignInUrl fix(clerk-js): Fix redirect when completing task within SignIn/SignUp Aug 20, 2025
@LauraBeatris LauraBeatris marked this pull request as ready for review August 20, 2025 13:00
@LauraBeatris LauraBeatris force-pushed the iago/fix-session-tasks-redirect-url branch from e2f13a8 to 374ae0c Compare August 20, 2025 13:00
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 20, 2025

📝 Walkthrough

Walkthrough

Adds a changeset release note. SessionTasks now requires a redirectUrlComplete prop (internal SessionTasksProps) and provides it via SessionTasksContext instead of deriving it from SignIn/SignUp contexts; SignIn and SignUp routes now pass afterSignInUrl/afterSignUpUrl into LazySessionTasks. Clerk core added TasksRedirectOptions and updated buildTasksUrl(options?) and redirectToTasks(options?) to accept it. @clerk/types exports TasksRedirectOptions; React and Vue wrappers/components and the isomorphic client were updated to accept and forward task redirect options. Integration tests updated to expect navigation to /page-protected after sign-in/sign-up.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 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 c591a25 and 6427b93.

📒 Files selected for processing (1)
  • packages/vue/src/components/controlComponents.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/vue/src/components/controlComponents.ts
⏰ 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). (10)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (elements, chrome)

🪧 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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 20, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: 6427b93

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

♻️ Duplicate comments (1)
packages/clerk-js/src/ui/components/SessionTasks/index.tsx (1)

64-67: Good: explicit props type for redirected completion

Defining a dedicated SessionTasksProps clarifies ownership of redirectUrlComplete and removes the previous implicit context derivation.

This directly addresses the earlier review feedback to source the redirect URL via props rather than rebuilding it in this component.

🧹 Nitpick comments (6)
.changeset/mean-pumas-cut.md (1)

1-5: Good, but clarify the root cause and scope in the note

The message is accurate. Consider explicitly calling out that query parameters are now forwarded to buildAfterSignIn/UpUrl so redirect_url is no longer undefined when completing SessionTasks from SignIn/SignUp. Minor copy edit: end the sentence with a period.

Suggested tweak:

-Fix incorrect redirect when completing session tasks within `SignIn` and `SignUp` components
+Fix incorrect redirect when completing session tasks within `SignIn` and `SignUp` components.
+
+Query parameters are now forwarded when constructing the after sign-in/sign-up URL, fixing cases where `redirect_url` was undefined.
packages/clerk-js/src/ui/components/SessionTasks/index.tsx (5)

71-71: HOC props plumbing looks right; consider annotating the component type

withCardStateProvider should propagate props, but if its generic signature is not constrained, you may lose prop inference at call sites. If you see any typing friction, consider adding a generic parameter:

-export const SessionTasks = withCardStateProvider(({ redirectUrlComplete }: SessionTasksProps) => {
+export const SessionTasks = withCardStateProvider<SessionTasksProps>(({ redirectUrlComplete }) => {

If withCardStateProvider already infers props, feel free to ignore.


24-33: Unnecessary dependency in effect

redirectUrlComplete is included in the dependency array but not used inside the effect. Keeping it will cause re-runs on prop changes with no behavioral change.

-  }, [navigate, clerk, redirectUrlComplete]);
+  }, [navigate, clerk]);

80-91: Guard against empty redirectUrlComplete at runtime

If redirectUrlComplete were ever an empty string, navigate would resolve to the current route. If contexts guarantee a non-empty absolute/relative URL, we’re fine. Otherwise, add a safe fallback.

-    if (!task || clerk.session?.status === 'active') {
-      void navigate(redirectUrlComplete);
+    if (!task || clerk.session?.status === 'active') {
+      const target = redirectUrlComplete || '/';
+      void navigate(target);
       return;
     }

If you prefer not to default to '/', consider using a known fallback from context (e.g., signInFallbackRedirectUrl/signUpFallbackRedirectUrl) and thread it similarly.


107-114: navigateOnSetActive: matches the flow, minor nit on return style

Logic is correct: if no current task after session goes active, navigate to completion target; otherwise, route to the task. Optional: avoid returning the navigate promise unless a caller awaits it; side-effect is enough.

-    if (!currentTask) {
-      return navigate(redirectUrlComplete);
-    }
-
-    return navigate(`./${INTERNAL_SESSION_TASK_ROUTE_BY_KEY[currentTask.key]}`);
+    if (!currentTask) {
+      void navigate(redirectUrlComplete);
+      return;
+    }
+    void navigate(`./${INTERNAL_SESSION_TASK_ROUTE_BY_KEY[currentTask.key]}`);

1-121: Add regression tests for redirect behavior

No tests were added. This fix is prone to regress during refactors. Please add tests that verify:

  • When completing tasks from SignIn tasks route, we redirect to afterSignInUrl preserving query params.
  • When completing tasks from Combined Flow (SignIn → create → tasks), we redirect to afterSignUpUrl preserving query params.
  • When there are no pending tasks and session is active, navigating to /tasks immediately redirects to the completion URL.

I can draft a test plan and skeleton for unit/integration tests (React Router + mocked Clerk context) or e2e specs, depending on your setup. Want me to proceed?

📜 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 2fa2a41 and 374ae0c.

📒 Files selected for processing (4)
  • .changeset/mean-pumas-cut.md (1 hunks)
  • packages/clerk-js/src/ui/components/SessionTasks/index.tsx (2 hunks)
  • packages/clerk-js/src/ui/components/SignIn/index.tsx (1 hunks)
  • packages/clerk-js/src/ui/components/SignUp/index.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (11)
.changeset/**

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

Automated releases must use Changesets.

Files:

  • .changeset/mean-pumas-cut.md
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/SignUp/index.tsx
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/SignUp/index.tsx
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/SignUp/index.tsx
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.tsx
packages/**/*.{ts,tsx}

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

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/ui/components/SignUp/index.tsx
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/SignUp/index.tsx
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/SignUp/index.tsx
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/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/SignUp/index.tsx
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/SignUp/index.tsx
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/SignUp/index.tsx
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/src/ui/components/SignUp/index.tsx
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.tsx
⏰ 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). (22)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (tanstack-react-router, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (6)
packages/clerk-js/src/ui/components/SignUp/index.tsx (1)

82-84: LazySessionTasks prop and call sites verified

  • Confirmed packages/clerk-js/src/ui/lazyModules/components.ts exports SessionTasks via lazy(), and packages/clerk-js/src/ui/components/SessionTasks/index.tsx’s SessionTasksProps includes a redirectUrlComplete: string parameter.
  • All JSX render sites for LazySessionTasks have been located:
    • SignUp flow (SignUp/index.tsx): <LazySessionTasks redirectUrlComplete={signUpContext.afterSignUpUrl} />
    • SignIn flows (SignIn/index.tsx): two existing usages passing signInContext.afterSignUpUrl and signInContext.afterSignInUrl (unchanged).
  • Verified afterSignUpUrl in SignUpContext is typed as string.

No missing call sites or type mismatches detected.

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

138-140: Correct for combined flow “create/tasks”: use afterSignUpUrl

Using signInContext.afterSignUpUrl when the user is in the sign-up branch of the combined flow matches the intended redirect destination.


146-148: I wasn’t able to confirm that signInContext.afterSignInUrl always has a non-empty value at runtime. Please manually verify that the useSignInContext hook (and any underlying defaults like buildAfterSignInUrl) never return an empty string; if they can, add a fallback (e.g. || '/') when passing into <LazySessionTasks>.

  • Check the implementation of useSignInContext in packages/clerk-js/src/ui/hooks
  • Ensure afterSignInUrl defaults to a sensible non-empty URL
packages/clerk-js/src/ui/components/SessionTasks/index.tsx (3)

117-121: Context value wired correctly across routes

Providing redirectUrlComplete and navigateOnSetActive through SessionTasksContext/TaskChooseOrganizationContext ensures downstream tasks can reuse the correct completion target.


1-4: Unused import: useRef is used; all good

The added import of useRef is necessary for currentTaskContainer.


1-121: Verify SessionTasks Prop Usage & Lazy Export

  • SessionTasksProps is correctly defined with the required redirectUrlComplete: string in packages/clerk-js/src/ui/components/SessionTasks/index.tsx.
  • The lazy re-export in packages/clerk-js/src/ui/lazyModules/components.ts properly wraps and preserves the component’s prop types.
  • No internal <SessionTasks> or <LazySessionTasks> usages were found in this package.

Please confirm that every downstream consumer (including white-label shells and feature modules) renders <SessionTasks> (or <LazySessionTasks>) with redirectUrlComplete passed.

@LauraBeatris LauraBeatris marked this pull request as draft August 20, 2025 13:08
@LauraBeatris LauraBeatris marked this pull request as ready for review August 20, 2025 13:54
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 (2)
integration/tests/session-tasks-sign-in.test.ts (1)

59-59: Add coverage for query param pass-through (the root cause fixed in this PR)

Per the PR description, the bug was caused by not forwarding query params to buildAfterSignInUrl, leading to redirect_url being undefined. The current test verifies the path but not that query parameters are preserved. Consider adding a dedicated test to ensure that completing tasks redirects to the original URL including its query string.

Example test you can add in this file:

test('preserves query params in after sign-in redirect', async ({ page, context }) => {
  const u = createTestUtils({ app, page, context });

  // Sign in with email/password
  await u.po.signIn.goTo();
  await u.po.signIn.setIdentifier(user.email);
  await u.po.signIn.continue();
  await u.po.signIn.setPassword(user.password);
  await u.po.signIn.continue();
  await u.po.expect.toBeSignedIn();

  // Navigate to a protected route that includes a query param; `auth.protect` should push us to tasks
  await u.page.goToRelative('/page-protected?from=session-tasks');

  // Resolve the task and assert we land back on the same URL including the query
  const fakeOrganization = Object.assign(u.services.organizations.createFakeOrganization(), {
    slug: u.services.organizations.createFakeOrganization().slug + '-with-query-check',
  });
  await u.po.signIn.waitForMounted();
  await u.po.sessionTask.resolveForceOrganizationSelectionTask(fakeOrganization);
  await u.po.expect.toHaveResolvedTask();

  await u.page.waitForAppUrl('/page-protected?from=session-tasks');
});
integration/tests/session-tasks-sign-up.test.ts (1)

76-76: Also verify query param propagation for sign-up flows

To fully exercise the bug fix (forwarding query params into buildAfterSignIn/UpUrl), add a test ensuring that the final URL preserves query parameters after tasks are resolved.

Example test you can add in this file:

test('preserves query params in after sign-up redirect', async ({ page, context }) => {
  const u = createTestUtils({ app, page, context });

  // Sign up
  const localFakeUser = u.services.users.createFakeUser({ fictionalEmail: true, withUsername: true });
  await u.po.signUp.goTo();
  await u.po.signUp.signUpWithEmailAndPassword({
    email: localFakeUser.email,
    password: localFakeUser.password,
  });
  await u.po.expect.toBeSignedIn();

  // Go to protected route with query param so we get redirected to tasks
  await u.page.goToRelative('/page-protected?from=session-tasks');

  // Resolve task
  const fakeOrganization = Object.assign(u.services.organizations.createFakeOrganization(), {
    slug: u.services.organizations.createFakeOrganization().slug + '-with-query-check',
  });
  await u.po.sessionTask.resolveForceOrganizationSelectionTask(fakeOrganization);
  await u.po.expect.toHaveResolvedTask();

  // Assert query param is preserved
  await u.page.waitForAppUrl('/page-protected?from=session-tasks');

  await localFakeUser.deleteIfExists();
});
📜 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 374ae0c and 9b17162.

📒 Files selected for processing (2)
  • integration/tests/session-tasks-sign-in.test.ts (1 hunks)
  • integration/tests/session-tasks-sign-up.test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{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:

  • integration/tests/session-tasks-sign-up.test.ts
  • integration/tests/session-tasks-sign-in.test.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:

  • integration/tests/session-tasks-sign-up.test.ts
  • integration/tests/session-tasks-sign-in.test.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:

  • integration/tests/session-tasks-sign-up.test.ts
  • integration/tests/session-tasks-sign-in.test.ts
integration/**

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

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

Files:

  • integration/tests/session-tasks-sign-up.test.ts
  • integration/tests/session-tasks-sign-in.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/session-tasks-sign-up.test.ts
  • integration/tests/session-tasks-sign-in.test.ts
integration/**/*.{test,spec}.{js,ts}

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

Integration tests should use Playwright.

Files:

  • integration/tests/session-tasks-sign-up.test.ts
  • integration/tests/session-tasks-sign-in.test.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:

  • integration/tests/session-tasks-sign-up.test.ts
  • integration/tests/session-tasks-sign-in.test.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:

  • integration/tests/session-tasks-sign-up.test.ts
  • integration/tests/session-tasks-sign-in.test.ts
⏰ 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 (2)
integration/tests/session-tasks-sign-in.test.ts (1)

59-59: Updated redirect assertion to '/page-protected' is correct

This aligns with the "return to originally requested protected route after completing tasks" behavior. Good fix.

integration/tests/session-tasks-sign-up.test.ts (1)

76-76: Updated redirect assertion to '/page-protected' is correct

Matches the expected return-to behavior after resolving tasks when the user initially targeted a protected route.

@LauraBeatris LauraBeatris requested review from a team and removed request for nikosdouvlis and panteliselef August 20, 2025 13:59
@LauraBeatris LauraBeatris force-pushed the iago/fix-session-tasks-redirect-url branch from 9b17162 to a8f6f54 Compare August 20, 2025 14:00
</Route>
<Route path='tasks'>
<LazySessionTasks />
<LazySessionTasks redirectUrlComplete={signInContext.afterSignUpUrl} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Potentially what I would do is create a new <SessionTaskProvider> and map/pass properties of signInContext and signUpContext and later simply consume it via a useSessionTaskContext()

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 (3)
packages/react/src/isomorphicClerk.ts (2)

1280-1288: redirectToTasks now forwards options — this fixes the missing redirect params propagation

Good call passing the options through to clerk-js so task redirects can honor redirectUrl/redirectUrlComplete.

To align with the repo guideline of explicit return types for public APIs and improve discoverability, consider adding a JSDoc and explicit return type:

-  redirectToTasks = async (opts?: TasksRedirectOptions) => {
+  /**
+   * Redirects the user to pending session tasks.
+   * Accepts the same options as other redirect helpers (e.g. redirectUrl, redirectUrlComplete).
+   * @public
+   */
+  redirectToTasks = async (opts?: TasksRedirectOptions): Promise<void | undefined> => {
     const callback = () => this.clerkjs?.redirectToTasks(opts);

392-399: Bring buildTasksUrl signature to parity by accepting options

Core now supports passing options to buildTasksUrl; mirroring this here avoids a subtle inconsistency in the isomorphic bridge and lets callers pre-build task URLs with redirect options.

Apply:

-  buildTasksUrl = (): string | void => {
-    const callback = () => this.clerkjs?.buildTasksUrl() || '';
+  buildTasksUrl = (opts?: TasksRedirectOptions): string | void => {
+    const callback = () => this.clerkjs?.buildTasksUrl(opts) || '';
     if (this.clerkjs && this.loaded) {
       return callback();
     } else {
       this.premountMethodCalls.set('buildTasksUrl', callback);
     }
   };

If this is intentional (e.g., core accepts options but React surface shouldn’t), please confirm. Otherwise, this change keeps the API consistent.

packages/react/src/components/controlComponents.tsx (1)

169-175: Correctly forwards redirect options to clerk.redirectToTasks

This wires the options through and resolves the previous inability to read redirect params inside session tasks.

With the HOC, props includes a component?: string field that gets forwarded to clerk-js. It’s harmless (core ignores unknown keys) and consistent with other redirect components, but you can avoid leaking it by omitting before forwarding:

-export const RedirectToTasks = withClerk(({ clerk, ...props }: WithClerkProp<RedirectToTasksProps>) => {
+export const RedirectToTasks = withClerk(
+  ({ clerk, component: _omit, ...options }: WithClerkProp<RedirectToTasksProps>) => {
   React.useEffect(() => {
-    void clerk.redirectToTasks(props);
+    void clerk.redirectToTasks(options);
   }, []);
 
   return null;
-}, 'RedirectToTasks');
+}, 'RedirectToTasks');

Optionally mirror this cleanup for RedirectToSignIn/RedirectToSignUp in the future for consistency.

📜 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 2c4fb08 and 565f769.

📒 Files selected for processing (6)
  • .changeset/mean-pumas-cut.md (1 hunks)
  • packages/clerk-js/src/core/clerk.ts (5 hunks)
  • packages/react/src/components/controlComponents.tsx (2 hunks)
  • packages/react/src/isomorphicClerk.ts (2 hunks)
  • packages/react/src/types.ts (2 hunks)
  • packages/types/src/clerk.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/types/src/clerk.ts
  • packages/clerk-js/src/core/clerk.ts
  • .changeset/mean-pumas-cut.md
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{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/react/src/isomorphicClerk.ts
  • packages/react/src/components/controlComponents.tsx
  • packages/react/src/types.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/react/src/isomorphicClerk.ts
  • packages/react/src/components/controlComponents.tsx
  • packages/react/src/types.ts
packages/**/*.{ts,tsx}

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

TypeScript is required for all packages

Files:

  • packages/react/src/isomorphicClerk.ts
  • packages/react/src/components/controlComponents.tsx
  • packages/react/src/types.ts
packages/**/*.{ts,tsx,d.ts}

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

Packages should export TypeScript types alongside runtime code

Files:

  • packages/react/src/isomorphicClerk.ts
  • packages/react/src/components/controlComponents.tsx
  • packages/react/src/types.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/react/src/isomorphicClerk.ts
  • packages/react/src/components/controlComponents.tsx
  • packages/react/src/types.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/react/src/isomorphicClerk.ts
  • packages/react/src/components/controlComponents.tsx
  • packages/react/src/types.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/react/src/isomorphicClerk.ts
  • packages/react/src/components/controlComponents.tsx
  • packages/react/src/types.ts
**/*.{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/react/src/components/controlComponents.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/react/src/components/controlComponents.tsx
🧬 Code Graph Analysis (3)
packages/react/src/isomorphicClerk.ts (1)
packages/types/src/clerk.ts (1)
  • TasksRedirectOptions (1167-1167)
packages/react/src/components/controlComponents.tsx (2)
packages/react/src/components/withClerk.tsx (1)
  • withClerk (7-37)
packages/react/src/types.ts (2)
  • WithClerkProp (74-74)
  • RedirectToTasksProps (120-120)
packages/react/src/types.ts (1)
packages/types/src/clerk.ts (1)
  • TasksRedirectOptions (1167-1167)
⏰ 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). (21)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (tanstack-react-router, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Unit Tests (18, --filter=@clerk/astro --filter=@clerk/backend --filter=@clerk/express --filter=@c...
  • GitHub Check: Static analysis
🔇 Additional comments (3)
packages/react/src/isomorphicClerk.ts (1)

48-48: Type import alignment for TasksRedirectOptions looks correct

This keeps the isomorphic surface in sync with the new core/type changes.

packages/react/src/types.ts (1)

12-12: Imports updated to include TasksRedirectOptions — OK

Keeps React types aligned with new tasks redirect options surface.

packages/react/src/components/controlComponents.tsx (1)

9-9: Importing RedirectToTasksProps and WithClerkProp — OK

Type surface matches the new TasksRedirectOptions via the alias.

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

♻️ Duplicate comments (1)
packages/clerk-js/src/ui/components/SessionTasks/index.tsx (1)

64-66: Good move: make redirect target explicit via props

Switching to a prop-based redirectUrlComplete removes the brittle coupling to SignIn/SignUp contexts and aligns with the earlier feedback. This should prevent undefined redirects in task flows.

🧹 Nitpick comments (6)
packages/react/src/components/controlComponents.tsx (1)

169-175: Correctly forwards options to redirectToTasks; avoid leaking HOC-only props

This fixes the original bug by passing redirect options through. Minor nit: ...props currently includes the HOC’s component prop; forwarding it may leak an unknown key to redirectToTasks (and potentially into URLs if serialized). Strip it explicitly:

-export const RedirectToTasks = withClerk(({ clerk, ...props }: WithClerkProp<RedirectToTasksProps>) => {
+export const RedirectToTasks = withClerk(
+  ({ clerk, component: _component, ...props }: WithClerkProp<RedirectToTasksProps>) => {
   React.useEffect(() => {
     void clerk.redirectToTasks(props);
   }, []);
 
   return null;
-}, 'RedirectToTasks');
+}, 'RedirectToTasks');

Optional: add a brief JSDoc to document the accepted options for this public component, mirroring the signatures for the redirect methods.

packages/clerk-js/src/ui/components/SessionTasks/index.tsx (5)

24-33: Dependency nit: redirectUrlComplete isn’t used in this effect

redirectUrlComplete is included in the dependency array but never referenced in the effect body. Consider dropping it to avoid unnecessary re-runs.

-  }, [navigate, clerk, redirectUrlComplete]);
+  }, [navigate, clerk]);

25-26: Grammar nit in comment

Use “an abrupt UI transition”.

-    // Simulates additional latency to avoid a abrupt UI transition when navigating to the next task
+    // Simulates additional latency to avoid an abrupt UI transition when navigating to the next task

95-98: Simplify minHeight expression

currentTaskContainer is always a ref object (truthy), so the ternary is redundant.

-          minHeight: currentTaskContainer ? currentTaskContainer.current?.offsetHeight : undefined,
+          minHeight: currentTaskContainer.current?.offsetHeight,

107-114: Stabilize handler and context value to minimize re-renders

navigateOnSetActive and the provider value are recreated every render, causing unnecessary rerenders of consumers. Wrap the handler with useCallback and memoize the provider value with useMemo.

Add imports at the top:

-import { useEffect, useRef } from 'react';
+import { useEffect, useRef, useCallback, useMemo } from 'react';

Refactor handler and provider value:

-  const navigateOnSetActive = async ({ session }: { session: SessionResource }) => {
+  const navigateOnSetActive = useCallback(({ session }: { session: SessionResource }) => {
     const currentTask = session.currentTask;
     if (!currentTask) {
-      return navigate(redirectUrlComplete);
+      return navigate(redirectUrlComplete);
     }
 
     return navigate(`./${INTERNAL_SESSION_TASK_ROUTE_BY_KEY[currentTask.key]}`);
-  };
+  }, [navigate, redirectUrlComplete]);
+
+  const contextValue = useMemo(
+    () => ({ redirectUrlComplete, currentTaskContainer, navigateOnSetActive }),
+    [redirectUrlComplete, currentTaskContainer, navigateOnSetActive],
+  );
 
   return (
-    <SessionTasksContext.Provider value={{ redirectUrlComplete, currentTaskContainer, navigateOnSetActive }}>
+    <SessionTasksContext.Provider value={contextValue}>
       <SessionTasksRoutes />
     </SessionTasksContext.Provider>
   );

71-71: Type clarity

Nit: consider documenting whether redirectUrlComplete expects absolute URLs, relative paths, or both, and what the fallback behavior is if it’s empty (even though it’s typed as required). A short JSDoc on SessionTasksProps would help future maintainers.

📜 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 565f769 and e512960.

📒 Files selected for processing (11)
  • .changeset/mean-pumas-cut.md (1 hunks)
  • integration/tests/session-tasks-sign-in.test.ts (1 hunks)
  • integration/tests/session-tasks-sign-up.test.ts (1 hunks)
  • packages/clerk-js/src/core/clerk.ts (5 hunks)
  • packages/clerk-js/src/ui/components/SessionTasks/index.tsx (2 hunks)
  • packages/clerk-js/src/ui/components/SignIn/index.tsx (1 hunks)
  • packages/clerk-js/src/ui/components/SignUp/index.tsx (1 hunks)
  • packages/react/src/components/controlComponents.tsx (2 hunks)
  • packages/react/src/isomorphicClerk.ts (2 hunks)
  • packages/react/src/types.ts (2 hunks)
  • packages/types/src/clerk.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (9)
  • .changeset/mean-pumas-cut.md
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/types/src/clerk.ts
  • packages/react/src/isomorphicClerk.ts
  • packages/react/src/types.ts
  • integration/tests/session-tasks-sign-up.test.ts
  • integration/tests/session-tasks-sign-in.test.ts
  • packages/clerk-js/src/ui/components/SignUp/index.tsx
  • packages/clerk-js/src/core/clerk.ts
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{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/react/src/components/controlComponents.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/react/src/components/controlComponents.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.tsx
packages/**/*.{ts,tsx}

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

TypeScript is required for all packages

Files:

  • packages/react/src/components/controlComponents.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.tsx
packages/**/*.{ts,tsx,d.ts}

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

Packages should export TypeScript types alongside runtime code

Files:

  • packages/react/src/components/controlComponents.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/react/src/components/controlComponents.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/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/react/src/components/controlComponents.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/react/src/components/controlComponents.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/react/src/components/controlComponents.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/react/src/components/controlComponents.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/SessionTasks/index.tsx
🧬 Code Graph Analysis (2)
packages/react/src/components/controlComponents.tsx (2)
packages/react/src/components/withClerk.tsx (1)
  • withClerk (7-37)
packages/react/src/types.ts (2)
  • WithClerkProp (74-74)
  • RedirectToTasksProps (120-120)
packages/clerk-js/src/ui/components/SessionTasks/index.tsx (2)
packages/clerk-js/src/ui/lazyModules/components.ts (1)
  • SessionTasks (124-126)
packages/clerk-js/src/ui/elements/contexts/index.tsx (1)
  • withCardStateProvider (72-81)
🔇 Additional comments (3)
packages/react/src/components/controlComponents.tsx (1)

9-9: Type-only import for RedirectToTasksProps is correct

Using import type avoids bundling type-only symbols at runtime and matches the surrounding patterns. Looks good.

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

50-56: Correct propagation to task context

Passing redirectUrlComplete through TaskChooseOrganizationContext looks right and keeps downstream components decoupled from SignIn/SignUp internals.


71-91: Double-check redirectUrlComplete upstream
The early redirect guard in SessionTasks is correct, but since redirectUrlComplete is now passed in from parent contexts, please verify that these values can never be empty or untrusted (e.g. external URLs) and are properly sanitized.

• packages/clerk-js/src/ui/components/SignUp/index.tsx (redirectUrlComplete={signUpContext.afterSignUpUrl})
• packages/clerk-js/src/ui/components/SignIn/index.tsx
– redirectUrlComplete={signInContext.afterSignUpUrl}
– redirectUrlComplete={signInContext.afterSignInUrl}

Ensure your SignUp/SignIn context providers always initialize afterSignUpUrl/afterSignInUrl to a valid, non-empty path and sanitize any user-supplied values to prevent unintended redirects.

@LauraBeatris LauraBeatris force-pushed the iago/fix-session-tasks-redirect-url branch from c591a25 to 6427b93 Compare August 20, 2025 16:20
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 (5)
packages/vue/src/components/controlComponents.ts (1)

63-66: Align RedirectToTasks props with TasksRedirectOptions

To ensure Vue matches the core API and React implementation, update the RedirectToTasks component to accept TasksRedirectOptions instead of the generic RedirectOptions. The type is already exported from @clerk/types and the core redirectToTasks method signature uses it.

• File: packages/vue/src/components/controlComponents.ts
• Lines: 63–66

Apply this diff:

-import type {
-  ProtectProps as _ProtectProps,
-  HandleOAuthCallbackParams,
-  PendingSessionOptions,
-  RedirectOptions,
-} from '@clerk/types';
+import type {
+  ProtectProps as _ProtectProps,
+  HandleOAuthCallbackParams,
+  PendingSessionOptions,
+  RedirectOptions,
+  TasksRedirectOptions,
+} from '@clerk/types';
@@
-export const RedirectToTasks = defineComponent((props: RedirectOptions) => {
+export const RedirectToTasks = defineComponent((props: TasksRedirectOptions) => {
   useClerkLoaded(clerk => {
     void clerk.redirectToTasks(props);
   });

Optionally, add a doc comment for clarity:

/**
 * Redirects to the Session Tasks flow with task-specific options.
 * Public API: accepts all TasksRedirectOptions.
 */
packages/clerk-js/src/ui/components/SessionTasks/index.tsx (4)

4-4: Consider importing useCallback/useMemo to stabilize context and callbacks

You can reduce unnecessary re-renders by memoizing the context value and callback below. This requires adding useCallback/useMemo here.

Apply this diff:

-import { useEffect, useRef } from 'react';
+import { useEffect, useRef, useCallback, useMemo } from 'react';

64-66: Make prop readonly and document intent

Props are immutable; mark redirectUrlComplete as readonly and add a brief doc to clarify it should be a safe, post-tasks destination.

Apply this diff:

-type SessionTasksProps = {
-  redirectUrlComplete: string;
-};
+type SessionTasksProps = {
+  /**
+   * Destination when no tasks are pending or after tasks complete.
+   * Should be a safe, sanitized URL or path.
+   */
+  readonly redirectUrlComplete: string;
+};

107-114: Stabilize navigateOnSetActive with useCallback

navigateOnSetActive is passed via context; recreating it on each render can trigger consumers to re-render. Memoize it with useCallback.

Apply this diff:

-  const navigateOnSetActive = async ({ session }: { session: SessionResource }) => {
+  const navigateOnSetActive = useCallback(async ({ session }: { session: SessionResource }) => {
     const currentTask = session.currentTask;
     if (!currentTask) {
       return navigate(redirectUrlComplete);
     }
 
     return navigate(`./${INTERNAL_SESSION_TASK_ROUTE_BY_KEY[currentTask.key]}`);
-  };
+  }, [navigate, redirectUrlComplete]);

117-121: Memoize context value to avoid unnecessary provider churn

Passing a new object each render can cause child components to re-render. Memoize the provider value.

Apply this diff:

-  return (
-    <SessionTasksContext.Provider value={{ redirectUrlComplete, currentTaskContainer, navigateOnSetActive }}>
+  const providerValue = useMemo(
+    () => ({ redirectUrlComplete, currentTaskContainer, navigateOnSetActive }),
+    [redirectUrlComplete, navigateOnSetActive]
+  );
+
+  return (
+    <SessionTasksContext.Provider value={providerValue}>
       <SessionTasksRoutes />
     </SessionTasksContext.Provider>
   );
📜 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 e512960 and c591a25.

📒 Files selected for processing (12)
  • .changeset/mean-pumas-cut.md (1 hunks)
  • integration/tests/session-tasks-sign-in.test.ts (1 hunks)
  • integration/tests/session-tasks-sign-up.test.ts (1 hunks)
  • packages/clerk-js/src/core/clerk.ts (5 hunks)
  • packages/clerk-js/src/ui/components/SessionTasks/index.tsx (2 hunks)
  • packages/clerk-js/src/ui/components/SignIn/index.tsx (1 hunks)
  • packages/clerk-js/src/ui/components/SignUp/index.tsx (1 hunks)
  • packages/react/src/components/controlComponents.tsx (2 hunks)
  • packages/react/src/isomorphicClerk.ts (2 hunks)
  • packages/react/src/types.ts (2 hunks)
  • packages/types/src/clerk.ts (2 hunks)
  • packages/vue/src/components/controlComponents.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (9)
  • .changeset/mean-pumas-cut.md
  • packages/types/src/clerk.ts
  • packages/react/src/types.ts
  • packages/clerk-js/src/ui/components/SignUp/index.tsx
  • integration/tests/session-tasks-sign-up.test.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/react/src/isomorphicClerk.ts
  • integration/tests/session-tasks-sign-in.test.ts
  • packages/react/src/components/controlComponents.tsx
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{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/vue/src/components/controlComponents.ts
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/vue/src/components/controlComponents.ts
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.tsx
packages/**/*.{ts,tsx}

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

TypeScript is required for all packages

Files:

  • packages/vue/src/components/controlComponents.ts
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.tsx
packages/**/*.{ts,tsx,d.ts}

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

Packages should export TypeScript types alongside runtime code

Files:

  • packages/vue/src/components/controlComponents.ts
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/vue/src/components/controlComponents.ts
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/vue/src/components/controlComponents.ts
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/vue/src/components/controlComponents.ts
  • packages/clerk-js/src/ui/components/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/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/SignIn/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.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/index.tsx
  • packages/clerk-js/src/ui/components/SessionTasks/index.tsx
⏰ 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). (24)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (tanstack-react-router, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Unit Tests (18, --filter=@clerk/astro --filter=@clerk/backend --filter=@clerk/express --filter=@c...
  • 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 (4)
packages/vue/src/components/controlComponents.ts (1)

3-7: Type-only import aliasing looks good

Aliasing ProtectProps as _ProtectProps is consistent with the local naming and remains type-only. No action needed.

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

139-139: Correct mapping for combined flow: use afterSignUpUrl when tasks run under create/

When Sign In runs the combined “create” flow, completing tasks should honor the sign-up completion redirect. Using signInContext.afterSignUpUrl here looks correct.

Double-check there’s always a non-empty URL in this branch by asserting afterSignUpUrl is resolved by useSignInContext in combined flows. If a fallback exists (e.g., signUpFallbackRedirectUrl), consider coalescing to it.


147-147: Correct: tasks under Sign In should redirect to afterSignInUrl on completion

Passing signInContext.afterSignInUrl ensures post-task navigation aligns with the sign-in redirect semantics.

Please verify LazySessionTasks’ prop type requires a string and that useSignInContext always provides a safe, sanitized value. Integration tests appear to cover this path; ensure they fail if redirect is missing.

packages/clerk-js/src/ui/components/SessionTasks/index.tsx (1)

71-91: Add explicit return type to SessionTasks and verify URL safety

  • Apply the : JSX.Element return annotation to satisfy our TS/public-API guidelines.
  • I didn’t find any sanitize/safe utility wrapping redirectUrlComplete in the UI layer—only the config types expose allowedRedirectOrigins / allowedRedirectProtocols. It’s unclear whether these are enforced client-side before the prop reaches this component.
  • Please confirm that redirectUrlComplete is validated upstream (e.g. same-origin or allow-list enforcement). If not, consider adding a guard here to prevent open redirects.

Apply this diff:

-export const SessionTasks = withCardStateProvider(({ redirectUrlComplete }: SessionTasksProps) => {
+export const SessionTasks = withCardStateProvider(({ redirectUrlComplete }: SessionTasksProps): JSX.Element => {

@LauraBeatris LauraBeatris merged commit c28d29c into main Aug 20, 2025
39 checks passed
@LauraBeatris LauraBeatris deleted the iago/fix-session-tasks-redirect-url branch August 20, 2025 16:41
NicolasLopes7 pushed a commit that referenced this pull request Aug 20, 2025
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.

6 participants