Clerk's short-lived JWTs (60s) can expire when browser tabs are backgrounded and the SDK's refresh interval is throttled. This left users silently logged out — actions returned 401s shown as generic error toasts with no recovery path. Prevention: refresh the Clerk JWT on tab visibility change so the token is always fresh when the user returns from a backgrounded tab. Detection: replace all 12 raw fetch() calls with an authFetch wrapper that catches 401 responses and sets an authDegraded state, triggering a blocking recovery overlay instead of confusing toasts. Recovery: AuthRecoveryOverlay (mirrors ConnectionOverlay pattern) prompts the user to reload the page, which re-authenticates via Clerk's long-lived session cookie. Also adds missing try/catch to handleStartDraft, handleMakePick, handleForceAutopick, handleForceManualPick, and handleReplacePick which previously had no network error handling. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| components | ||
| contexts | ||
| hooks | ||
| lib | ||
| models | ||
| routes | ||
| services | ||
| test | ||
| types | ||
| utils | ||
| welcome | ||
| app.css | ||
| root.tsx | ||
| routes.ts | ||