Skip to content

[CSM][Web] Scope recent-views by the userid claim, not sub - #1175

Merged
cloby99 merged 1 commit into
wso2-open-operations:mainfrom
Rashmika998:feature/csm-recent-views-userid-fix
Jul 19, 2026
Merged

cloby99 merged 1 commit into
wso2-open-operations:mainfrom
Rashmika998:feature/csm-recent-views-userid-fix

Conversation

@Rashmika998

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #1174 (already merged), which scoped the QuickNav palette's client-only "recent views" localStorage cache to the signed-in user, to prevent one user's recent/pinned cases from leaking to the next person signing in on a shared machine.

After merge, testing showed Recents still went missing in a new tab despite the correct-looking data sitting in localStorage. Root cause: this IdP issues a fresh sub value per session, not a stable one per account — confirmed by inspecting localStorage in a real browser, where the cached "last known user" pointer and the bucket actually holding the data had two different sub-looking values for the same person. No timing/caching fix on top of sub could work, since the identifier itself changes every sign-in.

  • Adds userid to IdTokenClaims (src/utils/userClaims.ts) — this IdP issues it as a stable per-account identifier, unlike sub.
  • Switches useRecentViews.ts's storage-key scoping from sub to userid.

Existing recents recorded under the old sub-keyed buckets are orphaned (harmless dead data, never read again) — Recents starts fresh under the userid-keyed bucket, but is now reliable across tabs/reloads/days going forward.

Test plan

🤖 Generated with Claude Code

Root cause of Recents staying empty across every previous fix attempt:
this IdP issues a fresh `sub` value per session, not a stable one per
account — confirmed by inspecting localStorage in a real browser, where
the cached "last known user" pointer and the bucket actually holding data
had two different sub-looking values for the same person. No amount of
timing/caching fixes on top of `sub` could work, since the identifier
itself changes every sign-in.

Switch to the ID token's `userid` claim (added to IdTokenClaims), which
this IdP issues as a stable per-account identifier. Existing recents
recorded under the old sub-keyed buckets are orphaned (harmless dead
data) — Recents starts fresh under the userid-keyed bucket, but is now
reliable across tabs/reloads/days going forward.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Rashmika998, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 19 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5e4274b8-f023-4b06-a5da-1f394c1cab48

📥 Commits

Reviewing files that changed from the base of the PR and between 8f85e9c and f71d1fe.

📒 Files selected for processing (2)
  • apps/csm-portal/webapp/src/features/csm-recent/hooks/useRecentViews.ts
  • apps/csm-portal/webapp/src/utils/userClaims.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@cloby99
cloby99 merged commit a234e64 into wso2-open-operations:main Jul 19, 2026
2 checks passed
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