Repository navigation
fix: press the jade emulator buttons again when one is dropped - #47
Conversation
On a busy host the emulator can drop a press, and the next ones land on the wrong screen: a dropped front before right front opens Scan QR instead of Log Out, and the stuck camera blocks every request. The press command now sends one button at a time and presses again, up to three times, when the screen does not change. Verified: press right left left on the interactive emulator (each press changed the screen); a simulated dropped press is pressed again and a press with no effect stops after three tries
The press check reads the display through the same retry frame() uses, so one stalled read on a busy host no longer ends a press sequence, and each poll reads the screen once. Verified: simulated stalled read and dropped press against the fixture's press command
talosmachina
left a comment
There was a problem hiding this comment.
No findings. ./scripts/jade-emulator press now sends one button at a time through the new press_each, re-reads the screen after each and presses again (up to three times) when it shows no change; frame() and the new path share read_display_retrying. Reviewed 45ebdf7, full tier, static.
Build skipped: talos-pr-run could not confirm the author's permission on this repo and fails closed, so nothing from the branch was run here. The repo reports no CI checks on this branch.
Merge confidence: 4/5, no findings, but the change has no test or CI run, and one candidate (a delayed redraw read as a dropped press) was ruled out only narrowly.
What I checked, and 4 candidates I ruled out
Read in full: scripts/jade-fixture.py (press, press_each, type_pin, frame, read_display_retrying, read_display, select_key, setup, the command dispatch), docs/jade-emulator.md
Call sites traced: press_each is reached only from the press command; setup, point_at_pinserver, ask_for_passphrase, type_pin, select_key and type_passphrase still call press directly, as the body says. frame() keeps its retry behaviour through the extracted helper (same attempts, same exceptions, same 1 s sleep).
Ruled out
- A press that registers late is sent twice: each attempt allows the 1.25 s
press()drain plusBUTTON_ADVANCE_TIMEOUT_S(3 s) of polling before retrying, the same windowtype_pinalready relies on for its digit presses. A double press needs the firmware to redraw more than about 4 s after the input; I found no screen reached bypressthat does that, but could not exercise it without running the emulator. - One websocket per button instead of one per sequence:
press()still waitsDRAIN_Sbefore closing each connection, so the drop its comment describes does not come back;type_pinalready opens one connection per attempt. - A screen that changes by itself (spinner, transition) hides a dropped press: the check then behaves like the old fire-and-forget path, never worse than base.
- No-op presses (
rightat a list end): retried three times and logged, as documented; they had no effect the first time, so repeating them changes nothing beyond about 12 s of extra time.
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR diff against its merge base, at 45ebdf7.
No new actionable code findings.
No actionable code findings. ./scripts/jade-emulator press sends one button per connection, compares the framebuffer, and sends that button again, up to three times, only while the screen stays the same. Setup, PIN entry, and passphrase entry still call press() directly. frame() keeps the same three-attempt stalled-socket retry through read_display_retrying.
Validation: Source review at 45ebdf7, including the Jade 1.0.41 firmware this image builds (dd45a7dc). On the logout, sign, and verify screens a delivered press returns from the button wait and repaints before the retry window (the 1.25s drain inside press() plus up to 3s of polling), so those steps are sent once. A press that leaves the pixels unchanged, such as right on the brightness carousel already at Max, is sent three times and does not change the value. python3 -m py_compile scripts/jade-fixture.py succeeded. This review did not start the emulator. The fixture has no automated tests, and this branch has no project CI check that runs it. The author reports a manual press right left left run and a simulated dropped press and stalled read.
Caller sequences checked in bitkit-android at 7cc4f4dc: press front right front, press front, and press right front. Those app journeys were not reviewed.
Suggested additional test cases:
- Interactive emulator, unlocked dashboard. Run
./scripts/jade-emulator press front right front. The device opens Session, highlights Log Out, and locks. The log does not say it is pressing a button again. - Interactive emulator on Send Transaction with X selected. Run
./scripts/jade-emulator press front. The app stays on the sign screen and no payment is sent. Start signing again and run./scripts/jade-emulator press right front. The payment succeeds, and each of those buttons is logged once.
Reviewer model: grok-4.7
Reasoning effort: xhigh
|
Requested review from @jvsena42 instead of @ben-kaufman, who is away for a few days. |
jvsena42
left a comment
There was a problem hiding this comment.
Approving at 45ebdf7. No findings.
Checked:
- Retries are bounded: at most 3 presses per button. Each attempt is the press (1.25 s including the drain) plus up to 3 s of polling, and every screen read keeps its own retry and timeout. A press that never changes the screen is logged and the command still exits 0.
- A retry fires only when the screen is unchanged for about 4.25 s after a press. On the screens the journeys drive (Session → Log Out, passing Output, signing or declining on Send Transaction, Verify Address), a press that lands redraws at once, so it is sent once. A second
frontcannot approve a signature twice, because the Jade approves one request per signature. - PIN, passphrase and setup still call
press()directly. The screen-read retry moved intoread_display_retryingwith the same behaviour. - The only cost is in the test fixture: a press with no effect, like
rightat the end of a list, now takes about 13 s.
Device gate: no device check needed (test-fixture script, no app change).
Reviewer model: Opus 5.5 (claude-opus-5-5) coordinating and primary review
Reasoning effort: Not exposed
|
Merging: approved at 45ebdf7 with no open threads. |
Description
./scripts/jade-emulator pressnow sends one button at a time and checks the device screen after each. A press that leaves the screen unchanged is pressed again, up to three times.On a busy host the emulator can drop a press, and the rest of the sequence then lands on the wrong screen. For example, a dropped first
frontturnspress front right front(Session, then Log Out) into opening Scan QR. The camera never starts in the emulator, so the device then blocks every request and the app times out. This happened in Jade journey runs for synonymdev/bitkit-ios#1441 and synonymdev/bitkit-android#2149.press_eachdrives thepresscommand. The fixture's own setup keeps its existing presses.frame(), now shared asread_display_retrying.rightat the end of a list) is sent three times and logged. That is harmless, since it had no effect in the first place.QA Notes
press right left lefton the interactive emulator: each press changed the screen and was sent once.presscommand: the read is retried, the dropped press is sent again, and the sequence ends on the intended screen.Models used
Claude Opus 5.5(reasoning:medium)Gemini 4 Neon(reasoning:high)