Skip to content

fix(mobile): abandon pairing journals that can no longer reconcile - #12773

Merged
Jinwoo-H merged 3 commits into
mainfrom
fix/abandon-unreconcilable-pairing-journal
Aug 5, 2026
Merged

Jinwoo-H merged 3 commits into
mainfrom
fix/abandon-unreconcilable-pairing-journal

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Relay pairing can wedge permanently with pairing failed: mobile relay pairing recovering pending, with no way out short of wiping app data. Hit for real today.

The trap

saveMobileRelayPairingJournal refuses to start a new pairing while an unresolved journal exists that already recorded winner/authorizationMode — correct, since overwriting it could orphan a device registration.

The escape hatch is recoverMobileRelayPairing() at app startup, which asks the relay what became of the attempt. But every failure path in runRecovery fell through to return 'deferred', which keeps the journal. And recoveryCredentials only offers the invite while inviteExpiresAt > now. So once the invite expires:

  • resume credentials are the only ones tried, and they fail (nothing was ever installed)
  • the invite is never offered again
  • the journal is never cleared

That is a permanent block: relay pairing stays dead across restarts and reinstalls of the JS bundle, forever, because restarting reruns the identical logic. Quitting and reopening the app cannot help.

How it triggered

During today's relay lock-timeout incident (orca-cloud#231), pairings died mid-flight after recording winner/authorization. Recovery then could not reach the relay to reconcile them, so it deferred — and by the time the relay was healthy the invites had expired, leaving journals that could never be cleared.

Fix

Recovery now abandons a journal whose invite has expired, because after that point nothing can establish what happened. Re-pairing mints a fresh device, and any uncommitted server-side install expires on its own — so the cost of abandoning is one re-pair, versus permanently broken pairing.

A journal whose invite is still live keeps deferring, so a transient outage never discards a still-reconcilable attempt. That distinction is the one that matters, and it is covered by both tests.

Tests

  • abandons once the invite expired and the relay is unreachable → 'abandoned', clearJournal called
  • keeps the journal while the invite could still reconcile → 'deferred', clearJournal not called

Red before green by construction: 'abandoned' did not previously exist as an outcome. Recovery suite 5/5, tsc and oxlint clean.

Follow-up

The user-facing error is still a dead end — it names an internal concept and offers no action. Worth surfacing as "finishing a previous pairing… / start over" in the pairing UI, tracked with the other mobile relay UX work rather than widened here.

A pairing attempt interrupted after it recorded winner/authorizationMode
leaves a journal behind. `saveMobileRelayPairingJournal` then refuses
every later attempt with "mobile relay pairing recovery pending", and
recovery could only ever return 'deferred' on failure — it never cleared
the journal. Once the invite expired, no credential remained that could
establish what happened, so the block was permanent: relay pairing stayed
dead until app data was wiped.

Hit for real during the 2026-08-05 relay lock-timeout incident, where
pairings died mid-flight and recovery then could not reach the relay to
reconcile them.

Recovery now abandons a journal whose invite has expired, since nothing
can reconcile it after that point and re-pairing mints a fresh device
while any uncommitted server-side install expires on its own. A journal
whose invite is still live keeps deferring, so a transient outage never
discards a still-reconcilable attempt.
…rding

Abandoning exactly at invite expiry let a momentary relay outage discard a
journal whose resume credential would have reconciled it on the next
launch. Wait one further invite lifetime so only journals that have been
unreconcilable well past any short outage are cleared.
@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Mobile relay pairing recovery now returns abandoned when no committed install was observed after the invite expiry and 10-minute grace period. It clears the saved journal while suppressing clear failures. Recovery returns deferred and preserves the journal when the grace period has not elapsed or credential persistence fails after a committed install. Tests cover these outcomes.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the bug, fix, tests, and follow-up, but it omits several required template sections, including the AI review and security audit. Add the required Screenshots, AI Review Report, Security Audit, and Notes sections, including platform compatibility and security review findings.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states that unreconcilable mobile relay pairing journals are abandoned, matching the primary change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
mobile/src/transport/mobile-relay-pairing-recovery.test.ts (1)

223-237: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Cover journal-clear failure.

The expired test covers only a successful clearJournal call. The new branch intentionally suppresses clear failures at Line 146. Add a case where clearJournal rejects and assert the intended 'abandoned' result. This locks the best-effort error contract.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1e875659-41e6-4d0c-b9fd-ca9404064097

📥 Commits

Reviewing files that changed from the base of the PR and between d4dfc35 and 0214010.

📒 Files selected for processing (2)
  • mobile/src/transport/mobile-relay-pairing-recovery.test.ts
  • mobile/src/transport/mobile-relay-pairing-recovery.ts

publishCommitted runs inside the credential loop's catch, so a failed
local write — keychain or storage rejecting writeCredentialBundle or
saveHost after the relay authoritatively reported the install committed —
fell through to the stale-expiry branch and cleared the journal. That
destroys the one record left to retry the write from, stranding a
credential the desktop already holds.

Track the authoritative commit separately from local persistence and
never abandon once it has been observed; that journal stays until the
write succeeds. Reported by CodeRabbit on #12773.
@Jinwoo-H
Jinwoo-H merged commit be2f9ed into main Aug 5, 2026
44 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
mobile/src/transport/mobile-relay-pairing-recovery.test.ts (1)

258-270: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert that the failing credential write is reached.

publishCommitted checks endpoints.relay before it calls writeCredentialBundle. This test only checks the result and clearJournal. A malformed endpoint fixture could therefore pass for the wrong reason.

Add a call assertion for writeCredentialBundle.

Proposed assertion
     await expect(recoverMobileRelayPairing(deps)).resolves.toBe('deferred')
+    expect(deps.writeCredentialBundle).toHaveBeenCalled()
     expect(deps.clearJournal).not.toHaveBeenCalled()

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 306528bb-ad59-46db-af03-c8ff079c6a16

📥 Commits

Reviewing files that changed from the base of the PR and between f564918 and d90da23.

📒 Files selected for processing (2)
  • mobile/src/transport/mobile-relay-pairing-recovery.test.ts
  • mobile/src/transport/mobile-relay-pairing-recovery.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant