Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(auth): explain expired environment credentials instead of offering a dead reconnect #11462

Closedgabrielsayers1(GitHub profile, opens in a new tab)wants to merge 241 commits intomain fromrefs/pull/11462/headopened View on GitHub

Problem

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 — EnvironmentAuthInvalidError carries an optional credentialExpired flag. It is an optional key sent only when true, following the existing dpopFailureReason precedent, so older clients keep decoding the payload and fall back to reason. Adding a new reason literal instead would have broken strict decoding on older clients.
  • Server — serverAuthCredentialExpired classifies the underlying cause, covering session and websocket expiry, and every failEnvironmentAuthInvalid call site passes it.
  • client-runtime — presentConnectionState exposes blockedReason, and a shared connectionNeedsPairing helper 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/refresh anywhere 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.
  • retryNow does not re-sample connectivity (supervisor.ts), so Reconnect also silently fails while navigator.onLine is latched off after sleep. Real, separate concern, separate PR.

Model: Claude Opus 5 (1M context). Harness: Claude Code.

🤖 Generated with Claude Code

    1. Opened against the wrong repository by mistake — this targets the goodbirdhq/phoenix fork, not upstream. Reopening there. Apologies for the noise.

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. 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:

      FileDiff SizeEstimate
      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

      Tip

      To get this pull request reviewed, you can:

      1. Comment @macroscope-app on this PR to request a manual review (monthly spend limits still apply).
      2. 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.
      3. Raise your cost limit in your workspace billing settings.
      [Turn off this reminder going forward](https://app.macroscope.com/pingdotgg/settings#Personal)
    4. 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
      Review your spending limits in [Billing settings](https://app.macroscope.com/pingdotgg/settings/billing), or comment `@macroscope-app review this PR` to bypass the limit and review now. You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).

Sign in to join this conversation.