Skip to content

Handle sync logic on the displayed QR code page - #9328

Merged
MiSikora merged 4 commits into
developfrom
feature/mehow/simple-sync/show-code-logic
Jul 30, 2026
Merged

Handle sync logic on the displayed QR code page#9328
MiSikora merged 4 commits into
developfrom
feature/mehow/simple-sync/show-code-logic

Conversation

@MiSikora

@MiSikora MiSikora commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

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

Description

Wires up the connection logic behind the QR code screen in the simplified Sync With Another Device flow.

Completing the connection:

  • When another device scans the code, a "Sync your data?" confirmation dialog is shown, naming the other device when it is known. The dialog covers both roles this device can be elected into, host or joiner.
  • Tapping "Sync Now" continues the connection. Tapping "Cancel" denies it, which ends the session with a "Sync canceled." dialog.
  • Once the devices are connected, the QR code screen and the "Sync With Another Device" screen behind it close, returning the user to Sync Settings, where the new device appears in the device list.
  • When the v2 connect flow is disabled (canUseV2ConnectFlow, canShowV2ConnectCode), the legacy flow is used instead. After showing the code, the screen polls for the connection every 5 seconds and closes the flow in the same way once the other device connects. If polling fails with a connect or login error, an error dialog is shown.

Copying and sharing the code:

  • "Copy Text Code" copies the code to the clipboard as sensitive content. A "Recovery Code Copied" snackbar confirms the action, unless the system already shows its own clipboard confirmation.
  • "Share" opens the system share sheet with the code as plain text.
  • Both buttons do nothing while the code is still loading.

Failure handling:

  • Dismissing any error dialog on the QR code screen reports a failure result and closes both the QR code screen and the "Sync With Another Device" screen.

The screens now communicate through activity result contracts (QrCodeContract and CodeExchangeContract) instead of plain intents, so the sync result can propagate back to Sync Settings.

Steps to test this PR

Connect two devices via the QR code

  • Open Sync Dev Settings.
  • Tap "Launch Sync Settings V2".
  • Tap "Sync With Another Device".
  • Complete the device authentication prompt.
  • Tap "Show QR Code".
  • On a second device, go to "Sync With Another Device" in Sync & Backup.
  • Scan the code shown on the first device.
  • When the "Sync your data?" dialog appears, tap "Sync Now".
  • Verify the QR code screen and the "Sync With Another Device" screen close.
  • Verify the second device appears in the device list in Sync Settings.

Cancel the connection

  • Tap "Show QR Code" again on the first device.
  • Scan the code with the second device.
  • When the "Sync your data?" dialog appears, tap "Cancel".
  • Verify a "Sync canceled." dialog is shown.
  • Dismiss the dialog.
  • Verify the setup screens close without the devices being connected.

Copy the code

  • On the QR code screen, tap "Copy Text Code".
  • Verify the code is in the clipboard.
  • Verify a confirmation is shown, either the system clipboard notification or a snackbar.

Share the code

  • On the QR code screen, tap "Share".
  • Verify the system share sheet opens with the code as text.

Legacy connect flow

  • Disable the canUseV2ConnectFlow and canShowV2ConnectCode feature flags.
  • Tap "Sync With Another Device".
  • Tap "Show QR Code".
  • Scan the code with the second device.
  • Verify the devices connect and the setup screens close within a few seconds, without a confirmation dialog.

Note

Medium Risk
Changes device pairing confirmation, legacy polling, and multi-activity result propagation in the sync connect path—important user data flow but built on existing dispatcher/repository APIs.

Overview
Completes the Sync With Another Device QR screen by driving real connect/pairing behavior in SyncExchangeViewModel and QrCodeActivity, instead of TODO stubs.

V2 pairing: When another device uses the code, the QR screen shows host/joiner “Sync your data?” dialogs and forwards confirm/deny to SyncCodeDispatcher. Successful login fires pixels, sets a success activity result, and closes the screen.

Legacy (V1) path: If v2 connect flags are off, the screen still shows the QR code but polls pollConnectionKeys every 5 seconds until sync completes or connect/login errors surface.

Copy & share: Copy uses sensitive clipboard handling with optional snackbar; share uses new ShareAction.shareText for the plain-text linking URL. Both are no-ops until the code is loaded.

Navigation: QrCodeContract and CodeExchangeContract replace raw intents so CodeExchangeActivity and SyncActivity can close the stack on success/failure from the QR screen. Launch source is passed through assisted-injection on the exchange ViewModel for analytics.

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

@MiSikora MiSikora changed the title Handle sync QR code logic Handle sync logic on the displayed QR code page Jul 29, 2026

@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 ad1ab62. Configure here.

MiSikora commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Jul 30, 10:42 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jul 30, 11:13 AM UTC: Graphite rebased this pull request as part of a merge.
  • Jul 30, 11:15 AM UTC: Graphite couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'Code Formatting').
  • Jul 30, 12:31 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jul 30, 12:31 PM UTC: @MiSikora merged this pull request with Graphite.

@MiSikora
MiSikora changed the base branch from feature/msikora/simple-sync/scan-code to graphite-base/9328 July 30, 2026 10:55
@MiSikora
MiSikora changed the base branch from graphite-base/9328 to develop July 30, 2026 11:12
@MiSikora
MiSikora force-pushed the feature/mehow/simple-sync/show-code-logic branch from b074d48 to b271b3c Compare July 30, 2026 11:12
@MiSikora
MiSikora force-pushed the feature/mehow/simple-sync/show-code-logic branch from b271b3c to fb05324 Compare July 30, 2026 12:10
@MiSikora
MiSikora merged commit b5ffb52 into develop Jul 30, 2026
18 checks passed
@MiSikora
MiSikora deleted the feature/mehow/simple-sync/show-code-logic branch July 30, 2026 12:31
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