-
Notifications
You must be signed in to change notification settings - Fork 419
fix(clerk-js): Fix redirect when completing task within SignIn/SignUp
#6580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: c591a25 The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
4c690c6 to
fd77c1b
Compare
SignIn/SignUp
e2f13a8 to
374ae0c
Compare
📝 WalkthroughWalkthroughAdds 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 detailsConfiguration used: CodeRabbit UI 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
There was a problem hiding this 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 completionDefining 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 noteThe 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 typewithCardStateProvider 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 effectredirectUrlComplete 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 runtimeIf 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 styleLogic 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 behaviorNo 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.
📒 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.tsxpackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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.tsxpackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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.tsxpackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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.tsxpackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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.tsxpackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor 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
Useconst assertionsfor literal types:as const
Usesatisfiesoperator 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 ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor 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.tsxpackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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.tsxpackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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.tsxpackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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.tsxpackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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.tsxpackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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.tsexportsSessionTasksvialazy(), andpackages/clerk-js/src/ui/components/SessionTasks/index.tsx’sSessionTasksPropsincludes aredirectUrlComplete: stringparameter.- All JSX render sites for
LazySessionTaskshave been located:
- SignUp flow (
SignUp/index.tsx):<LazySessionTasks redirectUrlComplete={signUpContext.afterSignUpUrl} />- SignIn flows (
SignIn/index.tsx): two existing usages passingsignInContext.afterSignUpUrlandsignInContext.afterSignInUrl(unchanged).- Verified
afterSignUpUrlinSignUpContextis typed asstring.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 afterSignUpUrlUsing 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 thatsignInContext.afterSignInUrlalways has a non-empty value at runtime. Please manually verify that theuseSignInContexthook (and any underlying defaults likebuildAfterSignInUrl) never return an empty string; if they can, add a fallback (e.g.|| '/') when passing into<LazySessionTasks>.
- Check the implementation of
useSignInContextinpackages/clerk-js/src/ui/hooks- Ensure
afterSignInUrldefaults to a sensible non-empty URLpackages/clerk-js/src/ui/components/SessionTasks/index.tsx (3)
117-121: Context value wired correctly across routesProviding redirectUrlComplete and navigateOnSetActive through SessionTasksContext/TaskChooseOrganizationContext ensures downstream tasks can reuse the correct completion target.
1-4: Unused import: useRef is used; all goodThe added import of useRef is necessary for currentTaskContainer.
1-121: Verify SessionTasks Prop Usage & Lazy Export
- SessionTasksProps is correctly defined with the required
redirectUrlComplete: stringinpackages/clerk-js/src/ui/components/SessionTasks/index.tsx.- The lazy re-export in
packages/clerk-js/src/ui/lazyModules/components.tsproperly 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>) withredirectUrlCompletepassed.
There was a problem hiding this 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 flowsTo 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.
📒 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.tsintegration/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.tsintegration/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
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor 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
Useconst assertionsfor literal types:as const
Usesatisfiesoperator 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 ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor 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.tsintegration/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.tsintegration/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.tsintegration/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.tsintegration/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.tsintegration/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.tsintegration/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 correctThis 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 correctMatches the expected return-to behavior after resolving tasks when the user initially targeted a protected route.
9b17162 to
a8f6f54
Compare
| </Route> | ||
| <Route path='tasks'> | ||
| <LazySessionTasks /> | ||
| <LazySessionTasks redirectUrlComplete={signInContext.afterSignUpUrl} /> |
There was a problem hiding this comment.
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()
4042ec6 to
2c4fb08
Compare
2c4fb08 to
565f769
Compare
There was a problem hiding this 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 propagationGood 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 optionsCore 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.redirectToTasksThis wires the options through and resolves the previous inability to read redirect params inside session tasks.
With the HOC, props includes a
component?: stringfield 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.
📒 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.tspackages/react/src/components/controlComponents.tsxpackages/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.tspackages/react/src/components/controlComponents.tsxpackages/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.tspackages/react/src/components/controlComponents.tsxpackages/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.tspackages/react/src/components/controlComponents.tsxpackages/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
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor 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
Useconst assertionsfor literal types:as const
Usesatisfiesoperator 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 ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor 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.tspackages/react/src/components/controlComponents.tsxpackages/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.tspackages/react/src/components/controlComponents.tsxpackages/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.tspackages/react/src/components/controlComponents.tsxpackages/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 correctThis 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 — OKKeeps React types aligned with new tasks redirect options surface.
packages/react/src/components/controlComponents.tsx (1)
9-9: Importing RedirectToTasksProps and WithClerkProp — OKType surface matches the new TasksRedirectOptions via the alias.
565f769 to
e512960
Compare
There was a problem hiding this 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 propsSwitching to a prop-based
redirectUrlCompleteremoves 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 propsThis fixes the original bug by passing redirect options through. Minor nit:
...propscurrently includes the HOC’scomponentprop; forwarding it may leak an unknown key toredirectToTasks(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
redirectUrlCompleteis 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 commentUse “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
currentTaskContaineris 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
navigateOnSetActiveand the providervalueare recreated every render, causing unnecessary rerenders of consumers. Wrap the handler withuseCallbackand memoize the providervaluewithuseMemo.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 clarityNit: consider documenting whether
redirectUrlCompleteexpects 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 onSessionTasksPropswould 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.
📒 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.tsxpackages/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.tsxpackages/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.tsxpackages/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.tsxpackages/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
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor 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
Useconst assertionsfor literal types:as const
Usesatisfiesoperator 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 ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor 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.tsxpackages/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.tsxpackages/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.tsxpackages/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.tsxpackages/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.tsxpackages/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 correctUsing
import typeavoids 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 contextPassing
redirectUrlCompletethroughTaskChooseOrganizationContextlooks 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 sinceredirectUrlCompleteis 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/afterSignInUrlto a valid, non-empty path and sanitize any user-supplied values to prevent unintended redirects.
e1d9762 to
c591a25
Compare
c591a25 to
6427b93
Compare
There was a problem hiding this 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 TasksRedirectOptionsTo ensure Vue matches the core API and React implementation, update the
RedirectToTaskscomponent to acceptTasksRedirectOptionsinstead of the genericRedirectOptions. The type is already exported from@clerk/typesand the coreredirectToTasksmethod signature uses it.• File: packages/vue/src/components/controlComponents.ts
• Lines: 63–66Apply 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 callbacksYou 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 intentProps 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 useCallbacknavigateOnSetActive 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 churnPassing 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.
📒 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.tspackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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.tspackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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.tspackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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.tspackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor 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
Useconst assertionsfor literal types:as const
Usesatisfiesoperator 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 ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor 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.tspackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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.tspackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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.tspackages/clerk-js/src/ui/components/SignIn/index.tsxpackages/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.tsxpackages/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.tsxpackages/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.tsxpackages/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 goodAliasing 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 completionPassing 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 toSessionTasksand verify URL safety
- Apply the
: JSX.Elementreturn annotation to satisfy our TS/public-API guidelines.- I didn’t find any
sanitize/safeutility wrappingredirectUrlCompletein the UI layer—only the config types exposeallowedRedirectOrigins/allowedRedirectProtocols. It’s unclear whether these are enforced client-side before the prop reaches this component.- Please confirm that
redirectUrlCompleteis 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 => {
…p` (#6580) Co-authored-by: Laura Beatris <[email protected]>
Description
Context
Fixes redirection when completing task within
SignIn/SignUpcontext.Previously, the session task route was trying to access
afterSignInUrl/afterSignUpUrlfromSignInContext/SignUpContext, which was undefined. TheuseSignInContextanduseSignUpContexthooks have the logic where we extract the redirect URL query params.Fix
Update logic to provide
redirectUrlCompleteas prop from the sign-in/sign-up routes.CleanShot.2025-08-20.at.10.57.45.mp4
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
Bug Fixes
New Features
Chores