Skip to content

Add syncing with another device logic and navigation - #9343

Merged
MiSikora merged 6 commits into
developfrom
feature/mehow/simple-sync/sync-another-device-logic
Aug 4, 2026
Merged

Add syncing with another device logic and navigation#9343
MiSikora merged 6 commits into
developfrom
feature/mehow/simple-sync/sync-another-device-logic

Conversation

@MiSikora

@MiSikora MiSikora commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Task/Issue URL: https://app.asana.com/1/137249556945/project/72649045549333/task/1216422585541215?focus=true
Tech Design URL (if applicable): https://app.asana.com/1/137249556945/project/72649045549333/task/1216509582049467?focus=true
API Proposals URL(s) (if applicable): N/A

Description

Implements the pairing logic behind the connecting screen in the simplified sync flow. It also introduces a shared pairing result that travels back through the navigation tree to Sync Settings, which decides what to show when the flow finishes.

Connecting screen:

  • The code captured on the scan screen is routed on the connecting screen, which distinguishes pairng code version.
  • For V2 codes, a "Sync New Device?" dialog asks the user to confirm the pairing with "Sync Now" or "Cancel".
  • After confirming, a "Confirm on your other device…" dialog is shown. Tapping "Got It" plays the lock animation.
  • Once the pairing completes, the screen waits for the animation to finish, reports the result, and closes.
  • For legacy codes, the animation plays immediately while the code is processed. Legacy exchange codes are not handled yet.

Pairing result and navigation:

  • A new SyncPairingResult carries the outcome (the connected device, the elected role, and whether the code was scanned or displayed) from the leaf screens, ExchangeSyncCodeActivity and DisplayQrCodeActivity, up through the scan screen and SyncThisDeviceActivity back to SyncActivity.
  • When the setup succeeds by scanning a code, Sync Settings refreshes the device list and opens the recovery code screen.
  • When the setup succeeds through the displayed QR code, Sync Settings only refreshes the device list.
  • When the flow reports a failure, Sync Settings treats the setup as cancelled and resets the sync toggle.
  • If the connected device cannot be retrieved after a successful login, a failure is reported instead.

Steps to test this PR

Pair two devices by scanning a code

  • On both devices, open Sync Dev Settings.
  • On both devices, tap "Launch Sync Settings V2".
  • On both devices, tap "Sync With Another Device".
  • On the second device, tap "Show QR Code".
  • On the first device, scan the displayed code.
  • Verify the connecting screen opens on the first device.
  • Tap "Sync Now" on the device that shows the "Sync New Device?" dialog.
  • Verify the same device shows a "Confirm on your other device…" dialog.
  • If the other device shows a "Sync New Device?" dialog, tap "Sync Now" there as well.
  • Tap "Got It".
  • Verify the lock animation plays to the end on the first device.
  • Verify the recovery code screen opens on the first device.
  • Verify the recovery code screen does not open on the second device.
  • Verify both devices show each other in the synced devices list.

Add another device while sync is already enabled

  • On a device with sync enabled, open Sync Settings V2.
  • Tap "Sync With Another Device".
  • Complete the device authentication prompt.
  • Scan a sync code displayed on another device.
  • Complete the pairing confirmations.
  • Verify the flow returns to Sync Settings.
  • Verify the recovery code screen does not open.
  • Verify the new device appears in the synced devices list.

Start from Sync This Device

  • On a device without sync enabled, open Sync Settings V2.
  • Tap "Sync This Device".
  • Tap "Sync With Another Device".
  • Verify the scan screen opens on top of the Sync This Device screen.
  • Complete the pairing with another device.
  • Verify the recovery code screen opens.
  • Verify Sync Settings shows the connected device afterwards.

Already paired error

  • With both devices already synced together, tap "Sync With Another Device" on one of them.
  • Complete the device authentication prompt.
  • Scan a code displayed by the other device.
  • Verify an error dialog is shown saying the devices are already synced.
  • Dismiss the dialog.
  • Verify the connecting screen closes back to Sync Settings.

UI changes

N/A


Note

Medium Risk
Changes sync account pairing, login outcomes, and multi-activity result handling in security-sensitive sync setup; scope is large but mostly UI/navigation with existing dispatcher/repository APIs.

Overview
Introduces SyncPairingResult so scan/display pairing screens return a structured outcome (device, host/joiner role, scanned vs displayed code) instead of coarse success/failure result codes. ExchangeSyncCodeActivity is wired to a new ExchangeSyncCodeViewModel that routes V1/V2 codes, shows simplified pairing dialogs, runs the lock animation after confirmation, and finishes with that result.

Activity result contracts (DisplayQrCode, ExchangeSyncCode, ReadSyncCode, SyncThisDevice) now parse SyncCompleted / Dismissed and bubble SyncPairingResult up the stack. SyncActivity handles pairing completion: refresh devices, show recovery code only when the user scanned a code, reset setup on failure, and launch authenticated add another device via scan. SyncThisDeviceActivity opens the read-code flow instead of finishing with a redirect result.

Reviewed by Cursor Bugbot for commit 155c1eb. Bugbot is set up for automated code reviews on this repo. Configure here.

@MiSikora
MiSikora force-pushed the feature/mehow/simple-sync/sync-another-device-logic branch from 2ba2053 to fa3dbe7 Compare July 30, 2026 09:18
@MiSikora
MiSikora force-pushed the feature/msikora/simple-sync/generic-v1-error-handling branch from d6e490a to 0a7b4a6 Compare July 30, 2026 09:18
@MiSikora
MiSikora force-pushed the feature/mehow/simple-sync/sync-another-device-logic branch from fa3dbe7 to 8cd8843 Compare July 30, 2026 12:10
@MiSikora
MiSikora force-pushed the feature/msikora/simple-sync/generic-v1-error-handling branch 2 times, most recently from 0afa699 to cb00a58 Compare July 30, 2026 12:14
@MiSikora
MiSikora force-pushed the feature/mehow/simple-sync/sync-another-device-logic branch from 8cd8843 to 41e8be0 Compare July 30, 2026 12:14
@MiSikora
MiSikora force-pushed the feature/msikora/simple-sync/generic-v1-error-handling branch from cb00a58 to 192192b Compare July 30, 2026 13:00
@MiSikora
MiSikora force-pushed the feature/mehow/simple-sync/sync-another-device-logic branch from 41e8be0 to 159ad98 Compare July 30, 2026 13:00
@CDRussell

Copy link
Copy Markdown
Member

Verify the recovery code screen does not open on the second device.

@MiSikora in this case you don't get to choose Restore on App Reinstall on one of the devices, but do on the other. While I can understand not wanting to show recovery code on both perhaps, skipping the restore prompt on one device seems odd.

@MiSikora

MiSikora commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@CDRussell

skipping the restore prompt on one device seems odd.

I don't really have a strong opinion about that. Both scenarios makes sense to me. If you have a preference either way I'm ok going with it.

Perhaps it should be shown only if the device that shows QR code wasn't synced before?

@CDRussell

Copy link
Copy Markdown
Member

@MiSikora we'll pair on this as discussed soon, for posterity i think this can probably be auto-progressed instead of leaving it showing and requiring the user to tap it

Screenshot_20260803_131214

@MiSikora
MiSikora force-pushed the feature/mehow/simple-sync/sync-another-device-logic branch from 94137bc to 4dccacb Compare August 3, 2026 12:44
@MiSikora
MiSikora force-pushed the feature/msikora/simple-sync/generic-v1-error-handling branch from 9c715f5 to 2a09e23 Compare August 3, 2026 12:44
@MiSikora
MiSikora force-pushed the feature/mehow/simple-sync/sync-another-device-logic branch from 4dccacb to 75ff030 Compare August 3, 2026 13:13
@MiSikora
MiSikora force-pushed the feature/msikora/simple-sync/generic-v1-error-handling branch 2 times, most recently from 84e4ea6 to f555290 Compare August 3, 2026 16:30
@MiSikora
MiSikora force-pushed the feature/mehow/simple-sync/sync-another-device-logic branch from 75ff030 to 015cca9 Compare August 3, 2026 16:30
@MiSikora

MiSikora commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@CDRussell
I added the ack dialog auto-dismiss to this PR in 9002b85.

I added the recovery code final confirmation logic to #9356; it's in cbe610b. It was easier to resolve the git conflicts this way.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 015cca9. Configure here.

@MiSikora
MiSikora force-pushed the feature/msikora/simple-sync/generic-v1-error-handling branch from f555290 to 6ee74a7 Compare August 4, 2026 07:11
@MiSikora
MiSikora force-pushed the feature/mehow/simple-sync/sync-another-device-logic branch from 015cca9 to 4344ead Compare August 4, 2026 07:11

MiSikora commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Aug 4, 12:40 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Aug 4, 1:10 PM UTC: Graphite rebased this pull request as part of a merge.
  • Aug 4, 1:39 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Aug 4, 1:39 PM UTC: @MiSikora merged this pull request with Graphite.

@MiSikora
MiSikora changed the base branch from feature/msikora/simple-sync/generic-v1-error-handling to graphite-base/9343 August 4, 2026 12:55
@MiSikora
MiSikora changed the base branch from graphite-base/9343 to develop August 4, 2026 13:09
@MiSikora
MiSikora force-pushed the feature/mehow/simple-sync/sync-another-device-logic branch from 4344ead to 155c1eb Compare August 4, 2026 13:09
@MiSikora
MiSikora merged commit a99a378 into develop Aug 4, 2026
18 checks passed
@MiSikora
MiSikora deleted the feature/mehow/simple-sync/sync-another-device-logic branch August 4, 2026 13:39
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.

2 participants