perf(android): share one post-press focus read between the escape guard and the dialog check

Merged
TH
3d ago
+375-13

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:

casebasehead
clear, dumps-only2 dumps1
clear, live helper2 focus requests1
permission prompt, dumps-only3 dumps2
launcher refusal, dumps-only2 dumps2
unknown focus, dumps-only10 dumps8

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