mirror of
https://github.com/stablyai/orca.git
synced 2026-10-01 08:01:56 +00:00
Problem: every Anywhere/Relay pairing mint failure surfaced to the user as the generic relay_control_not_active code, whether the real cause was a revoked/absent cloud session, a missing relay.use entitlement, or a broker cold-start/transport failure. RelayAuthCoordinator already knew which of these happened on every path that publishes 'offline' but discarded it, so DesktopRelayService.requireActiveBroker() could only throw the one generic code. Fix: RelayAuthCoordinator now records why it last went offline (RelayOfflineReason, reusing the existing RELAY_HOST_CLOSE_REASON wire vocabulary for signed-out rather than inventing a parallel constant) and clears it once it goes back online. requireActiveBroker() maps that reason to relay_signed_out / relay_not_entitled / relay_broker_unavailable via relayOfflineReasonMintFailureCode(), falling back to relay_control_not_active when no reason is known. The code already flowed unchanged through mobileRelayMintFailureFromUnknown into the mobile_pairing_relay_failure payload (verified with a regression test), and neither renderer consumer maps failure.code to UI text today (only .stage and a separate auth-status flag), so no new user-facing strings or localization entries were needed. Also extends the "Copy diagnostics" payload (MobilePage.tsx) with the live relay status and app version via a new pure buildMobileRelayDiagnosticsPayload() builder, deliberately omitting any address (matching the existing LAN/Tailscale-leak precedent) — only relayStatus and appVersion are added. relay-auth-coordinator.ts and desktop-relay-service.ts were already at this repo's 300-line oxlint ceiling, so the offline-reason mapping, the retry-backoff jitter math, and the already independently-tested pairingAuthorizationForContext helper were extracted into their own small files (relay-offline-reason.ts, relay-retry-delay.ts, relay-pairing-authorization.ts) instead of disabling the rule. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>