perf(android): share one post-press focus read between the escape guard and the dialog check
Summary
A local Android press (also click, longpress, hover) read focus before the dispatch, then separately for the escape guard and the after-command dialog check.
The readiness wrapper now takes one post-dispatch blocking-dialog read and shares it. If the session app is focused with no dialog, that read answers both checks. If it names another package, the escape guard reads only the foreground, and the after-command check acts on the shared read. If it names no package, the guard reads only the foreground (the shared read already asked the helper), and the after-command check reads again after the guard, as on main. Outcomes do not change.
Before / after
Post-dispatch reads, counted at the adapter seam:
| case | base | head |
|---|---|---|
| clear, dumps-only | 2 dumps | 1 |
| clear, live helper | 2 focus requests | 1 |
| permission prompt, dumps-only | 3 dumps | 2 |
| launcher refusal, dumps-only | 2 dumps | 2 |
| unknown focus, dumps-only | 10 dumps | 8 |
The longpress cold-helper ledger passes (worst case at or below main).
Validation
Head a3f270f. interaction-touch-android-press-focus-reads.test.ts asserts the counts, the permission warning, the launcher refusal's typed details, and that a blocking dialog appearing during the guard's reads after an unknown focus is reported. The readiness tests and the longpress ledger pass. CI is pending.
š¤ Generated with Claude Code