Repository navigation
fix: drop late send scans on enter manually - #2035
Conversation
Camera, gallery and paste scans on the recipient screen are kept as the visit's scan, like nearby reads, so Enter Manually, Contacts and closing Send cancel one still decoding. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
A camera, gallery or nearby read delivered after Enter Manually, Contacts or Send closing starts no scan until the recipient screen shows again. A scan that closes Send itself releases the visit's handle, so a later visit cannot cancel it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
[Medium impact] This PR appears safe to merge. SummaryThis PR keeps camera, gallery, paste, and continued-address scans tied to the current Send visit.
No actionable issues were found. Acknowledged scope from Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Recipient screen resumes] --> B[Allow recipient reads]
B --> C[Start scan and keep its job]
C --> D{What happens next?}
D -->|Enter Manually, Contacts, or close Send| E[Cancel scan and block late reads]
E --> A
D -->|Scan closes Send itself| F[Release handle and let work finish]
D -->|Request is ready| G[Open amount or review screen]
Reviews (1) · Last reviewed commit: "fix: drop reads from a recipient screen ..." · Reviewed by Greptile |
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Drops a camera, gallery or paste scan that is still decoding when the payer taps Enter Manually, opens Contacts or closes Send: every recipient-screen request and paste is now kept as the visit's scan job, and reads the recipient screen delivers on its own are ignored from leaving it until its ON_RESUME. Reviewed 2c9c6ad1d, full tier on the view model and screen changes.
What I checked, and 5 candidates I ruled out
Read in full: the diff to SendRecipientScreen.kt and AppViewModel.kt, plus launchScan, onAddressContinue, onPasteClick, hideSheet, showSheet, handleQuickPayIfApplicable and QrCodeAnalyzer at the head. The new cases in AppViewModelSendFlowTest.kt were read against the paths they claim to cover.
Call sites traced: SendEvent.AddressContinue is built in three places: the address screen's Continue (isRecipientRead stays false, so it is never dropped), the nearby source (isNearbyRead = true, so isRecipientRead defaults to true), and the camera and gallery handlers (explicit isRecipientRead = true). hasLeftSendRecipient is set by Enter Manually, Contacts (both branches, Paykit on or off) and hideSheet while Send is shown, and cleared only by onSendRecipientShown.
Not built here: on this track an auto review does not run the branch's Gradle build, so this is reasoned from the code and from CI.
CI: on this head, build-and-test (unit tests), lint, detekt and build-local passed. The build gate is red from the first run: compose-ui / ui-tests aborted at 128 of 258 tests with INSTRUMENTATION_ABORTED: System has crashed, with one failure in SendConfirmScreenTest.preparingUsdtRequestUsesUsdtAccentAndCannotPay. That file is not in this PR. A second CI run on the same head has its ui-tests and local e2e shards still pending.
Ruled out
- Cancelling the visit job stops a payment:
handleQuickPayIfApplicableonly sets_quickPayDataand navigates. Nothing in the scan job sends, so cancelling it after routing stops only the fee estimate for a request the payer left. - A scan that closes Send cancels itself:
hideSheetchecksisRunningScan(a thread-local set by the scan's own coroutine context) and then only drops the handle. The pasted-contact test pins down that a later visit cannot cancel that job. - A duplicate camera frame loses the handle:
launchScanreturns null for the same active scan, andjob?.letkeeps the running job's handle. This is covered by the duplicate-read test. - The flag never clears on a back navigation: the observer is registered on the recipient entry's
LocalLifecycleOwner, and that entry reachesON_RESUMEagain on return from Address, Contacts or Coming Soon. While the recipient entry sits under Address in the back stack, a background and foreground cycle resumes only the Address entry, so the flag stays set as it should. - A recipient read on a new visit before
ON_RESUME:hideSheetleaves the flag true, so a read that lands between the recipient screen's composition and its firstON_RESUMEon a later visit is dropped. The camera analyzer is attached only afterTRANSITION_SCREEN_MS, so this window can only catch an NFC or Bluetooth read during the opening transition, and a second tap goes through. I ruled this out narrowly, since that wiring has no unit test (the PR's Gaps list says so too).
Merge confidence: 4/5. No findings, but the ON_RESUME reset has no test, and the first CI run's ui-tests crashed in a file this PR does not touch, with the rerun still pending.
Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed (the review runner does not report it)
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR diff against its merge base, at 2c9c6ad1d.
No new actionable code findings.
All changed surfaces were assessed with no actionable code findings. Camera, gallery, nearby, manual-address, and pasted scans on the Send flow are now tracked in sendVisitScanJob, late recipient-screen reads (isRecipientRead = true) are dropped from Enter Manually, Contacts, or Send closing until SendRecipientScreen receives ON_RESUME, and scans that close Send themselves (isRunningScan == true) release the handle without cancelling their ongoing work.
Validation and limitations: Local Gradle execution could not run in this review environment (Android SDK unavailable). On 2c9c6ad1d, CI passed build-and-test, compose-ui / ui-tests, build, detekt, and lint; e2e-tests-local - send was still in progress at review time. The 15 new unit tests in AppViewModelSendFlowTest.kt cover the AppViewModel cancellation, recipient-left drop, resume reset, and handle-release paths; SendRecipientScreen's ON_RESUME lifecycle hook and gallery callback wiring remain unexercised by UI tests.
iOS parity: Compared against SendOptionsView.swift in synonymdev/bitkit-ios at master (7fdf32e1e) and draft twin synonymdev/bitkit-ios#1432 (f1ee713a5). Both platforms drop late camera, gallery/photo, NFC, Bluetooth, and paste reads after leaving the Send recipient screen. Minor non-defect platform differences: iOS also invalidates the scanner visit when the offline overlay covers Send (pre-existing on Android), while Android's sendVisitScanJob also cancels an in-flight manual-entry lookup if Send is closed.
Recommended before device testing: Wait for e2e-tests-local - send to finish on 2c9c6ad1d. During device testing, cover the gaps the author reported from their API 35 emulator run at 2c9c6ad1d: manual case 5 with a Spending balance, the NFC portion of case 7 on a physical device, and Paykit payment-methods loading in case 9 with a contact that publishes Paykit endpoints.
Device testing: Not performed in this review.
Suggested additional test cases:
- Android (gallery scan → Enter Manually): With a slow LNURL-pay QR image saved in the device gallery, open Send, tap Gallery, select that QR image, and tap Enter Manually before the LNURL lookup finishes → the address screen stays open after the lookup would return, no LNURL amount screen or error replaces it, and going Back to the recipient screen allows scanning or picking from Gallery again.
Reviewer model: gemini-4-neon
Reasoning effort: high
There was a problem hiding this comment.
Verdict: ✅ Approve
Findings: None.
QA for 2c9c6ad: Android 16 emulator, regtest devDebug built from this head.
Gallery lookup cannot replace manual entry ✅ Enter Manually stayed open after the delayed lookup returned; selecting the same image after Back started a fresh lookup, confirmed in app and endpoint logs.
Extends manual cases 1 and 4 with the gallery case requested in QA review. The LNURL endpoint delayed each response by 10 seconds.
gallery-manual-2x.2x.mp4
Manual invoice entry still routes ✅ Pasting an amountless regtest invoice on the address screen and tapping Continue opened Bitcoin Amount.
Manual case 5, using an amountless invoice so no Spending balance was required.
manual-invoice-2x.2x.mp4
Scan cancellation and contact refresh regressions ✅ The focused AppViewModelSendFlowTest suite passed, including a contact refresh surviving a later Send visit and Enter Manually.
Automated coverage for manual case 9's cancellation boundary, late camera and paste results, duplicate reads, returning to the recipient screen, and manual Continue.
Not driven: NFC in manual case 7 requires physical NFC hardware. Manual case 5 used an amountless invoice; a funded fixed-amount invoice and case 9 with live contact payment endpoints were not driven on the emulator.
Relied on the author's same-head device evidence for the unchanged camera, paste, Contacts, close/reopen and background cases, alongside the code review and QA review.
Full review: 747926f…2c9c6ad, four changed files. Device coverage added gallery and manual-entry checks; the test additions ran in the focused suite and the changelog was read.
Twin: synonymdev/bitkit-ios#1432 matches the intended late-result behavior after leaving Send.
Reviewed by gpt-6.1-sol-high
|
Merged, as it was approved and green. |
Fixes #2029
This PR drops a camera, gallery or paste scan that is still decoding when the payer leaves the Send recipient screen.
Description
Cause: the recipient screen keeps the decode job of a request so that Enter Manually, Contacts and closing Send can cancel it, but only for nearby reads (NFC and Bluetooth). Camera, gallery and paste scans were not kept, so their result still routed. A camera frame decoded after the tap, while the recipient screen was still leaving, also started a new scan.
Changes:
Checked:
Out of Scope
Design
N/A — no UI changes.
Preview
Camera on a slow LNURL-pay QR, Enter Manually before it answers: the address screen stays after the lookup returns.
2035-camera-enter-manually.mp4
Back to the recipient screen, the same QR routes again.
2035-rescan-after-back.mp4
Camera on a QR, Contacts: nothing routes over the list; back on the recipient screen the QR routes.
2035-camera-contacts.mp4
Send closed with the camera on a QR, then reopened: Send does not reopen by itself and the camera reads on the new visit.
2035-close-reopen.mp4
QA Notes
Setup
Regtest
devDebugbuild of this branch. An LNURL-pay QR code whose server answers slowly (throttle the phone's connection or use a slow endpoint) so the decode takes a few seconds.Journeys
N/A — not drivable; see Manual Tests.
Manual Tests
Automated Checks
AppViewModelSendFlowTest.kt— a camera scan and a paste still decoding do not route after Enter Manually, and a camera scan does not route after ContactsAppViewModelSendFlowTest.kt— a repeated camera read keeps the decoding scan cancellableAppViewModelSendFlowTest.kt— a paste still preparing does not reopen Send after the sheet closesAppViewModelSendFlowTest.kt— a camera frame delivered after Enter Manually, Contacts or Send closing starts no scan, and the recipient screen reads again once it is shownAppViewModelSendFlowTest.kt— an address continued after Enter Manually routes, and a paste replacing a scan still decoding routesAppViewModelSendFlowTest.kt— a pasted contact's refresh is not cancelled by a later Send visitAppViewModelSendFlowTest.kt— a login request from the recipient camera or a paste still opens its sheetEvidence
Device run on
2c9c6ad1d, API 35 emulator, regtestdevDebug, no Spending balance (a routed LNURL shows "Unable To Pay (LNURL)" and closes Send; a routed invoice shows "Insufficient Spending Balance"), a local LNURL-pay server answering after 10 s, the camera fed from a QR image:Handling decodedorLNURL:line.lightning:deep link each routed once.Run locally on
2c9c6ad1d, no device:./gradlew testDevDebugUnitTest --tests "to.bitkit.viewmodels.AppViewModelSendFlowTest"— 808 tests, 0 failures./gradlew compileDevDebugKotlin,./gradlew detekt --rerun-tasks,./gradlew lintDevDebug— passedGaps
AppViewModelSendFlowTest.kt; CI runs the rest.Models used
claude-opus-5-5(reasoning:medium)claude-fable-5-2(reasoning:medium)claude-opus-5-5(reasoning:Unknown)Metadata note: the reviewer model was reported by the coordinating session; its reasoning effort was not passed on.
🤖 Generated with Claude Code