Skip to content

Distinguish auth failures from session expiry with new 'unauthorized' state#46

Merged
jancurn merged 3 commits intomainfrom
claude/session-states-ux-Jr69j
Mar 8, 2026
Merged

Distinguish auth failures from session expiry with new 'unauthorized' state#46
jancurn merged 3 commits intomainfrom
claude/session-states-ux-Jr69j

Conversation

@jancurn
Copy link
Member

@jancurn jancurn commented Mar 8, 2026

Summary

This PR introduces a new unauthorized session state to distinguish authentication failures (401/403 responses or token refresh failures) from session expiry (404 responses). It also adds a disconnected display state to surface when the bridge process is alive but the server has been unreachable for more than 2 minutes.

Key Changes

  • New session states: Added unauthorized status for auth failures, separate from expired (which now specifically means session ID rejection). Updated SessionStatus type to include unauthorized.

  • Disconnected state detection: Implemented DISCONNECTED_THRESHOLD_MS (2 minutes) to detect when a bridge is running but the server hasn't responded recently. This is displayed as a yellow "disconnected" indicator without blocking operations (auto-recovers when server responds).

  • Improved status display:

    • live (green) - Bridge running and server responding
    • disconnected (yellow) - Bridge running but server unreachable >2min
    • crashed (yellow) - Bridge process dead
    • unauthorized (red) - Auth rejected; shows recovery hint: mcpc login <target> && mcpc <session> restart
    • expired (red) - Session ID rejected; shows recovery hint: mcpc <session> restart
  • Auth error handling: Updated bridge process to distinguish between authentication errors (mark as unauthorized) and session expiry errors (mark as expired), with appropriate logging and recovery guidance.

  • Session consolidation: Updated cleanup logic to remove both expired and unauthorized sessions when cleanExpired is enabled, and to preserve these states during bridge crash detection.

  • Error messages: Improved createServerAuthError to suggest mcpc <session> restart instead of full reconnect flow.

  • Documentation: Updated CLAUDE.md and CHANGELOG.md to document the new session states and their recovery procedures.

Implementation Details

  • The getBridgeStatus() function now checks lastSeenAt timestamp to determine if a bridge is truly disconnected vs. live.
  • The handlePossibleExpiration() method now branches on authentication errors vs. session expiry errors.
  • Recovery hints are shown inline in session list output for unauthorized sessions to guide users toward the correct fix.

https://claude.ai/code/session_01SXnUgdS4xhnQXbvCxEXcAG

claude and others added 3 commits March 8, 2026 21:12
Split the overloaded 'expired' state into distinct states:
- 'unauthorized' (new): auth failures (401/403, token refresh failure)
  with actionable login guidance in session listing
- 'expired': session ID rejection (404) only

Add 'disconnected' display state: shown when bridge is alive but
server hasn't responded in >2 minutes (uses existing lastSeenAt
field, no new persisted data). Auto-recovers silently.

https://claude.ai/code/session_01SXnUgdS4xhnQXbvCxEXcAG
…d constants

Move both constants to src/lib/types.ts so bridge and CLI reference a single
source of truth. DISCONNECTED_THRESHOLD_MS is now 4 × KEEPALIVE_INTERVAL_MS
instead of a hardcoded 2-minute value.

https://claude.ai/code/session_01SXnUgdS4xhnQXbvCxEXcAG
@jancurn jancurn merged commit 88b76af into main Mar 8, 2026
6 checks passed
@jancurn jancurn deleted the claude/session-states-ux-Jr69j branch March 12, 2026 14:17
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.

3 participants