Skip to content

feat(clerk-js): send touch intent with session updates#8101

Merged
nikosdouvlis merged 3 commits intomainfrom
bryce/clerk-js-touch-intent
Mar 18, 2026
Merged

feat(clerk-js): send touch intent with session updates#8101
nikosdouvlis merged 3 commits intomainfrom
bryce/clerk-js-touch-intent

Conversation

@brkalow
Copy link
Member

@brkalow brkalow commented Mar 17, 2026

Summary

  • send intent on Session.touch() and __internal_touch() requests
  • mark setActive() touches as select_session or select_org, and focus refreshes as focus
  • add Clerk JS unit coverage for the new request payloads and touch call-site behavior

Test plan

Made with Cursor

Summary by CodeRabbit

  • New Features

    • Session operations accept an optional intent parameter ('focus', 'select_session', 'select_org') to indicate why a session was "touched" (e.g., focus, session switch, org switch).
  • Tests

    • Added tests verifying intent is accepted and included in session touch requests, and that request bodies reflect the provided intent.

Pass touch intent through session touch requests so focus refreshes, session switches, and org switches can trigger the matching FAPI behavior.

Made-with: Cursor
@changeset-bot
Copy link

changeset-bot bot commented Mar 17, 2026

🦋 Changeset detected

Latest commit: c4db595

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

This PR includes changesets to release 21 packages
Name Type
@clerk/clerk-js Patch
@clerk/shared Patch
@clerk/chrome-extension Patch
@clerk/expo Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/expo-passkeys Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/hono Patch
@clerk/localizations Patch
@clerk/msw Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/react Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/ui 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 Mar 17, 2026

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Mar 18, 2026 2:09pm

Request Review

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 17, 2026

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8101

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8101

@clerk/upgrade

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

@clerk/vue

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

commit: c4db595

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: b4026123-adeb-491c-aaed-567b02e7b16c

📥 Commits

Reviewing files that changed from the base of the PR and between aacae7f and a92435b.

📒 Files selected for processing (1)
  • .changeset/warm-touch-intent.md

📝 Walkthrough

Walkthrough

The changes extend the session touch API across the Clerk codebase to support an optional intent parameter. New types SessionTouchIntent and SessionTouchParams are introduced in the shared types module. The Session class methods touch and __internal_touch are updated to accept an optional intent parameter. The Clerk class computes and passes appropriate touch intents based on session selection or organization switching. Tests are updated to verify that touch operations receive the correct intent values. The intent parameter enables distinction between focus, select_session, and select_org operations.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat(clerk-js): send touch intent with session updates' accurately and clearly summarizes the main change: adding an intent parameter to session touch requests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

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

Tip

CodeRabbit can use Trivy to scan for security misconfigurations and secrets in Infrastructure as Code files.

Add a .trivyignore file to your project to customize which findings Trivy reports.

@nikosdouvlis nikosdouvlis merged commit 7e60d2b into main Mar 18, 2026
41 checks passed
@nikosdouvlis nikosdouvlis deleted the bryce/clerk-js-touch-intent branch March 18, 2026 14:18
nikosdouvlis added a commit that referenced this pull request Mar 18, 2026
nikosdouvlis added a commit that referenced this pull request Mar 18, 2026
jacekradko added a commit that referenced this pull request Mar 19, 2026
…tate

resolveAuthState had gaps in its condition branches that caused it to
return undefined, triggering "Invalid state" errors. This was exposed
by #8101 when touch responses came back without last_active_token.

Two fixes:
- When sessionId/userId exist but sessionClaims is missing (e.g. during
  client hydration before token fetch), return loading state instead of
  throwing
- When orgId exists but orgRole is missing, fall through to signed-in
  without org state instead of throwing
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.

2 participants