Skip to content

fix: press the jade emulator buttons again when one is dropped - #47

Merged
ovitrif merged 2 commits into
mainfrom
fix/jade-press-retry
Nov 27, 2026
Merged

ovitrif merged 2 commits into
mainfrom
fix/jade-press-retry

Conversation

@ovitrif

@ovitrif ovitrif commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Description

./scripts/jade-emulator press now 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 front turns press 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_each drives the press command. The fixture's own setup keeps its existing presses.
  • Screen reads use the same stalled-socket retry as frame(), now shared as read_display_retrying.
  • A press with no visible effect (such as right at 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 left on the interactive emulator: each press changed the screen and was sent once.
  • Simulated a dropped press and a stalled screen read against the fixture's press command: the read is retried, the dropped press is sent again, and the sequence ends on the intended screen.
  • The fixture has no test suite, so these checks were run by hand.

Models used

  • Planning/scoping: Not used
  • Implementation: Claude Opus 5.5 (reasoning: medium)
  • Review: Gemini 4 Neon (reasoning: high)
  • Review rounds: 1

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
@ovitrif ovitrif self-assigned this Nov 27, 2026
@ovitrif
ovitrif requested review from a team, ben-kaufman and piotr-iohk and removed request for a team November 27, 2026 15:13

@talosmachina talosmachina left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 plus BUTTON_ADVANCE_TIMEOUT_S (3 s) of polling before retrying, the same window type_pin already 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 by press that does that, but could not exercise it without running the emulator.
  • One websocket per button instead of one per sequence: press() still waits DRAIN_S before closing each connection, so the drop its comment describes does not come back; type_pin already 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 (right at 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 piotr-iohk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@ovitrif
ovitrif requested review from jvsena42 and removed request for ben-kaufman November 27, 2026 16:24
@ovitrif

ovitrif commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator Author

Requested review from @jvsena42 instead of @ben-kaufman, who is away for a few days.

@jvsena42 jvsena42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 front cannot 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 into read_display_retrying with the same behaviour.
  • The only cost is in the test fixture: a press with no effect, like right at 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

@ovitrif

ovitrif commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator Author

Merging: approved at 45ebdf7 with no open threads.

@ovitrif
ovitrif merged commit 8685ebd into main Nov 27, 2026
@ovitrif
ovitrif deleted the fix/jade-press-retry branch November 27, 2026 16:46
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.

4 participants