Skip to content

feat(clerk-js): re-apply touch intent with e2e coverage#8117

Open
nikosdouvlis wants to merge 3 commits intomainfrom
nikos/touch-intent-focus-token
Open

feat(clerk-js): re-apply touch intent with e2e coverage#8117
nikosdouvlis wants to merge 3 commits intomainfrom
nikos/touch-intent-focus-token

Conversation

@nikosdouvlis
Copy link
Member

@nikosdouvlis nikosdouvlis commented Mar 18, 2026

Why

We reverted the touch intent feature (ce67184) because the server wasn't populating last_active_token when it skipped client piggybacking for focus touches. That's now fixed server-side (clerk/clerk_go#17644). Re-applying the feature with an e2e test so this gap doesn't happen again.

What changed

Summary by CodeRabbit

  • New Features

    • Session touch now accepts an optional intent (focus, session switch, org switch) so the system can avoid expensive client piggybacking for focus-only touches and better differentiate touch reasons.
  • Tests

    • Added integration and unit tests validating touch behavior with intent, ensuring intents are preserved and handled across touch flows.

Adds an e2e test that triggers session.touch() with intent (sent
natively after the revert-of-revert) and asserts last_active_token
is present on the session. This would have caught the server-side
regression where focus touches skipping client piggybacking also
dropped the token from the response.
@vercel
Copy link

vercel bot commented Mar 18, 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 11:05pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Mar 18, 2026

🦋 Changeset detected

Latest commit: 3d8dc60

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 18, 2026

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 3d8dc60

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 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: 39f2e98b-7030-4fd1-90bb-b36c1c971c66

📥 Commits

Reviewing files that changed from the base of the PR and between 5269565 and 3d8dc60.

📒 Files selected for processing (1)
  • integration/tests/resiliency.test.ts

📝 Walkthrough

Walkthrough

Adds an optional intent parameter to session touch operations and related types (SessionTouchIntent, SessionTouchParams). The Clerk core computes a touchIntent during navigation and session activation and propagates it to session.touch() and __internal_touch() calls. Session request bodies now include the intent field. Private Clerk method #touchCurrentSession and session resource touch methods were updated to accept the optional intent parameter. Tests were added/updated to assert the intent is propagated in requests and internal touch flows.

Possibly related PRs

  • clerk/javascript PR 8101: Implements the same change—adding an optional intent parameter to session touch APIs and propagating it through Clerk, including tests and type updates.
🚥 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 title clearly summarizes the main change: re-applying the touch intent feature with end-to-end test coverage. It accurately reflects the primary objective of the PR.
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.

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@integration/tests/resiliency.test.ts`:
- Around line 389-397: The test currently calls setActive without an explicit
intent so it exercises the selection flow; to cover the previously failing
focus-touch path, change the test to explicitly send a focus intent (either by
calling session.touch({ intent: 'focus' }) or calling setActive with intent:
'focus') so the server-side focus handling and last_active_token logic are
exercised; update the call site around window.Clerk?.setActive / session.touch
to pass intent: 'focus' and assert the session still returns a valid
last_active_token.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: ASSERTIVE

Plan: Pro

Run ID: 62379cbd-1406-4d0b-82ab-90d01f4ba59a

📥 Commits

Reviewing files that changed from the base of the PR and between ac2f1c1 and 5269565.

📒 Files selected for processing (7)
  • .changeset/warm-touch-intent.md
  • integration/tests/resiliency.test.ts
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/clerk-js/src/core/resources/Session.ts
  • packages/clerk-js/src/core/resources/__tests__/Session.test.ts
  • packages/shared/src/types/session.ts

The server skips client piggybacking only for focus touches, so the
test needs to call session.touch({ intent: 'focus' }) directly instead
of setActive (which sends select_session).
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.

1 participant