Skip to content

feat(clerk-js): Send touch intent with session updates (core-2 backport)#8135

Merged
nikosdouvlis merged 2 commits intorelease/core-2from
nikos/core-2/backport-touch-intent
Mar 20, 2026
Merged

feat(clerk-js): Send touch intent with session updates (core-2 backport)#8135
nikosdouvlis merged 2 commits intorelease/core-2from
nikos/core-2/backport-touch-intent

Conversation

@nikosdouvlis
Copy link
Copy Markdown
Member

Summary

Backport of e00ec97 from main. The backend needs to know why a session touch was triggered so it can skip expensive client piggybacking for focus-only touches. This adds an optional intent parameter (focus, select_session, select_org) to session.touch().

The core-2 Session implementation is different from main (uses _basePost instead of _touchPost/_fetch, no __internal_touch method), so this was manually adapted rather than cherry-picked.

  • SessionTouchIntent and SessionTouchParams types added to @clerk/shared
  • Session.touch() accepts optional { intent } and passes it in the request body
  • clerk.ts determines intent based on context: focus for page focus events, select_session for session switches, select_org for organization switches
  • Tests cover all three intent values at the Session resource level, plus clerk.test.ts assertions updated to verify correct intent propagation

Test plan

  • Session.test.ts: 51 tests pass (3 new tests for intent parameter)
  • clerk.test.ts: has pre-existing swr resolution failure on core-2 (not caused by this PR), but assertions are updated to match

🤖 Generated with Claude Code

…ore-2)

Backport of e00ec97 from main. Adds optional `intent` parameter to
session.touch() to indicate why the touch was triggered (focus, session
switch, or org switch). This enables the backend to skip expensive
client piggybacking for focus-only touches.

Adapted for core-2's different Session implementation which uses
_basePost instead of _touchPost/_fetch and has no __internal_touch.
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 20, 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 20, 2026 1:03pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 20, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 85228d3c-14d2-402d-819a-780b8f25630a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nikos/core-2/backport-touch-intent
📝 Coding Plan
  • Generate coding plan for human review comments

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

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 20, 2026

🦋 Changeset detected

Latest commit: 2bb35df

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/shared 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/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/themes Patch
@clerk/types Patch
@clerk/vue Patch
@clerk/localizations 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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 20, 2026

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: 2bb35df

@nikosdouvlis nikosdouvlis changed the title feat(clerk-js): send touch intent with session updates (core-2 backport) feat(clerk-js): Send touch intent with session updates (core-2 backport) Mar 20, 2026
Update all remaining toHaveBeenCalled() assertions to
toHaveBeenCalledWith({ intent: ... }) for complete coverage
of touch intent propagation across all setActive paths.
@nikosdouvlis nikosdouvlis merged commit e5f213f into release/core-2 Mar 20, 2026
73 of 77 checks passed
@nikosdouvlis nikosdouvlis deleted the nikos/core-2/backport-touch-intent branch March 20, 2026 13:25
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.

3 participants