fix(auth): explain expired environment credentials instead of offering a dead reconnect #11462
main fromrefs/pull/11462/head·opened View on GitHubProblem#
A paired client's session lasts 30 days (DEFAULT_SESSION_TTL) and there is no renewal path, so every remote environment eventually hits expiry. When it does, the server knows exactly what happened — SessionStore.verify fails with SessionTokenExpiredError — but the wire error flattens that into invalid_credential. The client then shows a generic red "<label> is offline" banner whose Reconnect button re-sends the same dead credential forever.
The only visible difference from an ordinary network outage is the banner's colour, because ChatView renders the same title for supervisor phase offline and phase blocked. Diagnosing a real instance of this took reading server-side trace logs to discover the word "expired" had been thrown away.
Fix#
Expiry now survives the trip to the client, and both clients act on it.
- Contracts —
EnvironmentAuthInvalidErrorcarries an optionalcredentialExpiredflag. It is an optional key sent only when true, following the existingdpopFailureReasonprecedent, so older clients keep decoding the payload and fall back toreason. Adding a newreasonliteral instead would have broken strict decoding on older clients. - Server —
serverAuthCredentialExpiredclassifies the underlying cause, covering session and websocket expiry, and everyfailEnvironmentAuthInvalidcall site passes it. - client-runtime —
presentConnectionStateexposesblockedReason, and a sharedconnectionNeedsPairinghelper answers the question both surfaces were getting wrong: retrying cannot clear an authentication block. A DPoP proof hint is now suppressed for expiry, where it would misdirect. - Web — banner becomes "
<label>needs pairing again" with a key icon, and the Reconnect button is gone. Connections remains as the way forward. - Mobile — same title change, and it stops telling the user it "will keep retrying automatically", which was actively false.
Desktop inherits the web change. The Connections panel improves for free via connectionStatusText.
Testing#
vp test run across the touched scopes: 233 passing. Typecheck clean on contracts, client-runtime, server, web, and mobile; targeted lint and format clean.
Tests were written first and watched fail — server classification (expired vs. the revoked near-miss), the client message mapping, blockedReason exposure, and connectionNeedsPairing.
⚠️ Outstanding#
Before/after screenshots are not attached, which this repo requires for UI changes. Capturing them means running the app in a browser, which needs maintainer sign-off — happy to produce them on request before merge.
Deliberately out of scope#
- No session renewal. There is no
rotate/renew/refreshanywhere in server auth today; adding one is a new auth-protocol feature, not a bug fix. This PR makes expiry legible and recoverable, it does not stop the 30-day logout. Worth a follow-up, ideally with a warning before expiry while the client can still act. retryNowdoes not re-sample connectivity (supervisor.ts), so Reconnect also silently fails whilenavigator.onLineis latched off after sleep. Real, separate concern, separate PR.
Model: Claude Opus 5 (1M context). Harness: Claude Code.
🤖 Generated with Claude Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
Macroscope skipped reviewing this pull request. Per-review cost limit exceeded (workspace setting).
This review would cost an estimated $63.06, which exceeds your per-review limit of $15.00.
The top 3 files driving up this estimate:
File Diff Size Estimate apps/server/src/mcp/toolkits/sessions/handlers.ts116.87KB $5.84 docs/internals/session-orchestration.md55.14KB $2.76 packages/contracts/src/sessionOrchestration.ts46.26KB $2.31 [Turn off this reminder going forward](https://app.macroscope.com/pingdotgg/settings#Personal)Tip
To get this pull request reviewed, you can:
- Comment
@macroscope-appon this PR to request a manual review (monthly spend limits still apply). - Exclude the file(s) above from review by adding a pattern to your
.macroscope/ignore.md— note that creating this file replaces Macroscope's built-in default ignores rather than extending them. - Raise your cost limit in your workspace billing settings.
- Comment
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — The PR is a broad fork/rebrand and capability expansion touching authentication, agent execution, persistence, desktop/mobile behavior, and production release workflows—not just an isolated credential-message fix. It also changes product defaults and suppresses a static-analysis job, so the combined runtime and operational impact requires human review.
Not approved because:
- Per-review cost limit exceeded (workspace setting). Approvability relies on correctness review in order to determine eligibility
Sign in to join this conversation.
Opened against the wrong repository by mistake — this targets the goodbirdhq/phoenix fork, not upstream. Reopening there. Apologies for the noise.