Repository navigation
fix(relay): refuse silent fallback when pairing invite fails - #11528
Conversation
When Orca Relay pairing fails, don't silently degrade to a LAN-only QR under the Relay label. Instead, surface structured failure information so the UI can clearly inform the user and offer recovery options.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (13)
📝 WalkthroughWalkthroughThe change introduces structured Mobile Relay mint-failure types and propagates them through runtime pairing, IPC, preload, and renderer layers. Relay offer generation now tracks concurrent requests, supersession, cleanup, and persistence failures. Device and revoke-outbox state is persisted before in-memory replacement. The mobile pairing UI adds failure notices, retry and LAN recovery actions, diagnostics copying, QR empty states, focus management, responsive scrolling, updated localization, and expanded integration and unit coverage. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 8
🧹 Nitpick comments (1)
src/shared/mobile-relay-mint-failure.test.ts (1)
4-34: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winConsider covering the structured-error-object branch.
Both tests exercise the
error instanceof Errorpath. The implementation also has a distinct branch for'code' in error && typeof error.code === 'string'(structured error objects) which isn't exercised here. Since this function gates what diagnostic info reaches users/logs, adding a case like{ code: 'relay_control_not_active' }(non-Error object) and a non-objecterror(e.g.null/string) would close the coverage gap on this security-sensitive redaction path.✅ Suggested additional test cases
+ it('preserves known codes from structured error objects', () => { + expect( + mobileRelayMintFailureFromUnknown({ + stage: 'create_pairing_relay', + error: { code: 'relay_control_not_active' }, + fallbackCode: 'relay_mint_failed', + fallbackMessage: 'Relay pairing invite request failed' + }) + ).toEqual({ + code: 'relay_control_not_active', + stage: 'create_pairing_relay', + message: 'Relay pairing invite request failed' + }) + }) + + it('falls back for non-object/non-Error error values', () => { + expect( + mobileRelayMintFailureFromUnknown({ + stage: 'create_pairing_relay', + error: 'relay_control_not_active', + fallbackCode: 'relay_mint_failed', + fallbackMessage: 'Relay pairing invite request failed' + }) + ).toEqual({ + code: 'relay_mint_failed', + stage: 'create_pairing_relay', + message: 'Relay pairing invite request failed' + }) + })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1d7ed165-d110-4398-8949-81d3dd442b02
📒 Files selected for processing (30)
src/main/ipc/mobile.test.tssrc/main/ipc/mobile.tssrc/main/runtime/device-registry.tssrc/main/runtime/relay/relay-revoke-outbox.test.tssrc/main/runtime/relay/relay-revoke-outbox.tssrc/main/runtime/runtime-rpc.test.tssrc/main/runtime/runtime-rpc.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/assets/mobile-page.csssrc/renderer/src/components/mobile/MobileHero.test.tsxsrc/renderer/src/components/mobile/MobileHero.tsxsrc/renderer/src/components/mobile/MobileHeroPairingStep.tsxsrc/renderer/src/components/mobile/MobilePage.test.tsxsrc/renderer/src/components/mobile/MobilePage.tsxsrc/renderer/src/components/mobile/MobilePageContent.tsxsrc/renderer/src/components/mobile/mobile-relay-mint-failure-notice.tsxsrc/renderer/src/components/mobile/use-mobile-pairing-generation.tssrc/renderer/src/components/mobile/use-mobile-pairing-qr-invalidation.tssrc/renderer/src/components/settings/MobilePairingConnectionOptions.test.tsxsrc/renderer/src/components/settings/MobilePairingConnectionOptions.tsxsrc/renderer/src/components/settings/MobilePairingQrSection.test.tsxsrc/renderer/src/components/settings/MobilePairingQrSection.tsxsrc/renderer/src/components/settings/MobilePairingSetupSection.test.tsxsrc/renderer/src/components/settings/MobilePairingSetupSection.tsxsrc/renderer/src/components/settings/MobilePane.test.tsxsrc/renderer/src/components/settings/MobilePane.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/shared/mobile-relay-mint-failure.test.tssrc/shared/mobile-relay-mint-failure.ts
Greptile SummaryThis PR fixes a silent degradation where Orca Relay pairing invite failures were masked by quietly falling back to a LAN-only QR code while still labeling it as Relay. The fix refuses that degradation, surfaces structured
Confidence Score: 4/5Safe to merge after addressing the selectedAddress disclosure in the Settings pane diagnostics payload; all core logic is well-guarded and tested. The concurrency, durability, and fail-closed relay logic are carefully implemented and covered by 21 new tests. One concrete data inconsistency exists: the settings-pane Copy diagnostics path includes the user LAN IP or Tailscale hostname in the clipboard JSON, while the mobile hero flow deliberately removes it to prevent that disclosure. Files Needing Attention: src/renderer/src/components/settings/MobilePane.tsx — copyRelayDiagnostics includes selectedAddress
|
| Filename | Overview |
|---|---|
| src/main/runtime/runtime-rpc.ts | Major rework of createMobilePairingOffer: adds generation-based concurrency queue, fail-closed relay logic, discardPendingMobilePairingDevice, queueOrRetainRelayDeviceRevoke, and queueRelayDeviceRevoke now returns bool |
| src/main/runtime/device-registry.ts | All mutating methods updated to persist-before-swap, addressing the previously flagged updateLastSeen gap; save() now requires explicit argument |
| src/main/runtime/relay/relay-revoke-outbox.ts | enqueue and removeItem both updated to persist-before-swap; save() takes explicit items arg |
| src/shared/mobile-relay-mint-failure.ts | New file; mobileRelayMintFailureFromUnknown correctly validates error codes via regex and redacts free-form messages |
| src/renderer/src/components/settings/MobilePane.tsx | copyRelayDiagnostics includes selectedAddress which the parallel MobilePage.tsx flow explicitly excludes for privacy |
| src/renderer/src/components/mobile/MobilePage.tsx | Replaces encodedConnectionMode with relayMintFailure; copyRelayDiagnostics deliberately excludes selectedAddress with an inline privacy comment |
| src/renderer/src/components/mobile/mobile-relay-mint-failure-notice.tsx | New component; 200ms spinner delay avoids flash; role/aria-live toggled between alert and status based on busy state |
| src/renderer/src/components/mobile/MobileHeroPairingStep.tsx | New component extracted from MobileHero; focus management useEffect correctly initializes pairingWasReadyRef from current props |
| src/renderer/src/components/settings/MobilePairingConnectionOptions.tsx | Adds relayMintFailed/relayMintRetrying props; arrow-key guard and tabIndex shifts correct under disabled state |
| src/preload/api-types.ts | available:false shape extended with optional reason, guidance, and relayFailure fields |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[createMobilePairingOffer] --> B{connectionMode == local-only?}
B -->|yes| C[Increment generation / Run serial directly]
B -->|no| D{Matches in-flight coalesce condition?}
D -->|yes| E[Return existing in-flight request]
D -->|no| F[Increment generation / Enqueue to serial queue]
C & F --> G[createMobilePairingOfferSerial]
G --> H[setMobilePairingConnectionMode]
H -->|throws/false| I[discardPendingMobilePairingDevice / return device_registry_unavailable]
H -->|local-only| J[Return LAN offer]
H -->|automatic| K{relayProvider available?}
K -->|no| L[refuseAutomaticWithoutRelay]
K -->|yes| M[createPairingRelay]
M -->|throws| N[mobileRelayMintFailureFromUnknown / refuseAutomaticWithoutRelay]
M -->|ok| O{Generation still current? token match?}
O -->|no| P[queueOrRetainRelayDeviceRevoke / return superseded]
O -->|yes| Q[setMobileRelayBinding]
Q -->|throws/false| R[queueOrRetainRelayDeviceRevoke / refuseAutomaticWithoutRelay]
Q -->|ok| S[Return Relay offer with encoded relay URL]
Reviews (2): Last reviewed commit: "fix issues" | Re-trigger Greptile
…i#11528) * fix(relay): refuse silent fallback when pairing invite fails When Orca Relay pairing fails, don't silently degrade to a LAN-only QR under the Relay label. Instead, surface structured failure information so the UI can clearly inform the user and offer recovery options. * fix issues
Summary
When Orca Relay pairing invite minting fails, the system previously silently fell back to a local-only (LAN) code while still labeling it as Relay. This masked the actual limitation from the user. The fix refuses that silent degradation and surfaces structured failure information to the UI, letting the user choose: Use LAN, Retry Relay, or copy diagnostics.
Changes
createMobilePairingOfferno longer returns a LAN-only QR when Relay provisioning fails under Anywhere mode; returnsavailable: falsewith structuredrelayFailureinsteadMobileRelayMintFailuretype with stage and code for diagnostics (redacts free-form error messages via regex)Screenshots
When Relay succeeds: no visual change.
When Relay fails:
Testing
pnpm lint/oxfmt --checkpnpm typecheckpnpm test— 21 new / updated tests covering:pnpm buildAI Review Report
Code review completed. Main checks:
Security Audit
^relay_[a-z0-9_]{1,74}$to block free-form error leaksrelayFailure,reason,guidance) typed and validated in preload/api-typesNotes