Home

mweinbach / agent-coworker

publicmweinbach/agent-coworker
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

fix: prevent codex auth token loss after app restart

7 months ago

02f6a3d
Authored
Max Weinbach3/11/2026, 6:44:38 PM
Four fixes addressing the token being reported as "gone" after closing and
reopening the desktop app:

1. Retry token refresh with backoff (3 attempts, 500ms/1s/2s) instead of
   a single attempt — transient network errors no longer cause permanent
   "not connected" state.

2. Add console.warn logging around every refresh attempt so failures are
   diagnosable from server logs.

3. Add `tokenRecoverable` field to ProviderStatus. When the access token
   is expired but a refresh token still exists, the desktop persistence
   layer now skips saving the "not connected" status, preventing stale
   state from sticking across restarts.

4. Guard against cross-process refresh races in refreshCodexAuthMaterial:
   re-read the auth file before writing and skip the write if another
   process already persisted a fresh token.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Parent1584a54

4 files changed
  • apps/desktop/src/app/persistedProviderState.ts+8−0
  • docs/websocket-protocol.md+1−0
  • src/providerStatus.ts+34−9
  • src/providers/codex-auth.ts+15−0