Skip to content

fix(dashboard): graceful UX when an impersonation grant is revoked mid-session#1293

Merged
iammukeshm merged 1 commit into
mainfrom
fix/impersonation-revoked-ux
Jun 9, 2026
Merged

fix(dashboard): graceful UX when an impersonation grant is revoked mid-session#1293
iammukeshm merged 1 commit into
mainfrom
fix/impersonation-revoked-ux

Conversation

@iammukeshm

Copy link
Copy Markdown
Member

What

Revoking (or expiring) an in-progress impersonation left the dead impersonation token installed in the dashboard: every request 401d, but the page just rendered a stuck red error band under a half-loaded surface while the "End impersonation" banner lingered — a confusing, broken-looking state.

The dashboard now detects this and routes to a calm full-screen Impersonation ended terminal page that clears the dead token via Back to sign in. Mirrors the existing deactivated-tenant flow.

How

  • api-client.ts — new isImpersonationRevokedError(): true on a 401 while the active token carries the act_sub impersonation claim. This is the durable signal — production deliberately blanks the 401 body (the "Impersonation grant revoked or ended" reason is dev-only), and impersonation sessions never hold a refresh token, so such a 401 always propagates to the hook instead of being silently refreshed-and-retried.
  • query-client.ts — extended the global query/mutation error hook (alongside the existing tenant-deactivated branch) to route to /impersonation-ended, passing the dev-only reason via router state. Does not clear the token here (would race ProtectedRoute to /login).
  • pages/impersonation-ended.tsx — new top-level terminal page mirroring tenant-deactivated.tsx.
  • routes.tsx — lazy import + top-level route (outside ProtectedRoute/AppShell).

Tests

  • New tests/impersonation/impersonation-ended.spec.ts (2 specs): a 401 on an impersonation session routes to the page; Back to sign in clears the token and lands on /login. Both green.
  • tsc -b clean, eslint clean.

Docs

Changelog entry (2026-06-09) added in the separate docs repo.

🤖 Generated with Claude Code

…d-session

Revoking (or expiring) an in-progress impersonation left the dead
impersonation token installed: every request 401d but the page just
rendered a stuck error band under a half-loaded surface while the
"End impersonation" banner lingered.

Detect the case (a 401 while the active token carries the act_sub
impersonation claim - a durable signal, since prod keeps the 401 body
opaque) in the global query/mutation error hook and route to a calm
full-screen "Impersonation ended" terminal page that clears the dead
token via "Back to sign in". Mirrors the existing tenant-deactivated flow.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@iammukeshm iammukeshm merged commit 1fdd384 into main Jun 9, 2026
15 checks passed
@iammukeshm iammukeshm deleted the fix/impersonation-revoked-ux branch June 9, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant