fix: handle typed trezor device busy#1065
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Greptile SummaryThis PR improves Android handling for locked or busy Trezor devices.
Confidence Score: 5/5This looks safe to merge.
|
| Filename | Overview |
|---|---|
| app/src/main/java/to/bitkit/repositories/TrezorRepo.kt | Updates Trezor connect, auto-reconnect, error mapping, and xpub-fetch handling for typed busy failures. |
| app/src/main/java/to/bitkit/viewmodels/TransferViewModel.kt | Routes transfer-side busy and cancellation failures before wrapped reconnect or funding error handling. |
| app/src/main/java/to/bitkit/ui/sheets/hardware/HwConnectViewModel.kt | Shows the unlock prompt for busy connect failures and keeps the generic message for other failures. |
| app/src/main/java/to/bitkit/utils/TrezorErrorPresenter.kt | Adds shared user-facing Trezor error message selection. |
| app/src/main/java/to/bitkit/ext/TrezorExceptionExt.kt | Adds typed busy-error detection across throwable cause chains. |
Reviews (4): Last reviewed commit: "fix: classify typed trezor errors in tra..." | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0f534a1398
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Fail fast on DeviceBusy during BLE reconnect and connect retries. Block pairing when xpub reads exhaust transient retries (iOS parity). Fix TrezorErrorPresenter fallback evaluation order. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: afca19993c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Stop auto-reconnect retries on device busy. Preserve actual transient cause on xpub exhaustion instead of synthesizing DeviceBusy. Rethrow cancellations from connect and auto-reconnect via runSuspendCatching. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2d8ee03585
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Typed TrezorException variants like Timeout carry blank messages, so string-marker matching missed them in both the transient xpub classifier and the connect retry check. Co-authored-by: Cursor <cursoragent@cursor.com>
Refs #1030
Companion to synonymdev/bitkit-ios#617.
This PR adds Android parity for typed Trezor
DeviceBusyhandling introduced in bitkit-core 0.3.9. Locked or busy Trezor errors now map to a friendly unlock prompt instead of raw technical strings, and transient busy failures retry automatically during connect and xpub fetch.Description
isTrezorDeviceBusy()that walks the cause chain forTrezorException.DeviceBusy(including when wrapped inAppError).TrezorErrorPresenterused by connect and transfer flows.TrezorRepoconnect retry logic and adds bounded xpub-fetch retries during pairing.hardware__device_busyin the hardware connect sheet and TO_SPENDING transfer errors.Out of scope for this PR (remaining #1030 work): passphrase wallets, BLE ping/backoff polish, phone-lock-during-broadcast network recovery.
Preview
N/A
QA Notes
Manual Tests
regression:Cancel on Trezor during TO_SPENDING sign: no error toast, flow returns to sign screen.regression:Trezor powered off → connect sheet: generic connect error, not busy message.regression:TO_SPENDING happy path with unlocked Trezor: funding tx broadcasts and channel order progresses.Note: on-device QA did not surface typed
DeviceBusyin logs — locked Trezor often hits the compose/sign wait path instead. Unit tests cover the typed busy classification.Automated Checks
TrezorExceptionExtTest.kt.TrezorErrorPresenterTest.kt.TrezorRepoTest.kt.HwConnectViewModelTest.kt.TransferViewModelTest.kt.TransferViewModelTest,TrezorRepoTest,TrezorExceptionExtTestpass;just lintpasses.Made with Cursor