Skip to content

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

Merged
thymikee merged 4 commits into
mainfrom
perf/android-press-single-post-focus
Nov 29, 2026
Merged

thymikee merged 4 commits into
mainfrom
perf/android-press-single-post-focus

Conversation

@thymikee

@thymikee thymikee commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

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

…rd and the dialog check

A successful local press read Android focus three times: the before-command
dialog check, the escape guard, and the after-command dialog check. The last two
ran back to back after the dispatch. When one post-dispatch read proves no
blocking dialog and the session app focused, it now answers both. Any other
answer keeps the current order and separate reads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.70 MB 6.70 MB +507 B
Package (unpacked) 6.69 MB 6.69 MB +507 B
Package (download) 2.04 MB 2.04 MB +149 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 18.8 ms 19.2 ms +0.4 ms
CLI --help 43.6 ms 43.8 ms +0.3 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 6 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@blacksmith-sh

This comment has been minimized.

…nd escape guard

An inconclusive shared read was thrown away, so an unknown focus cost 12
window dumps instead of 10. The after-command check now acts on that read,
and a read that names another focused package answers the escape guard's
app-focus question.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot 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.

Apex Sentinel: 1 new finding on 1a80a72. The verdict and the full list are in the summary comment.

thymikee and others added 2 commits November 29, 2026 16:06
…helper focus requests at the adapter

The daemon press test asserts expectedPackage and foregroundPackage on the
refusal and names its focus-answering fake for what it counts: adapter reads.
platform-android's observation test proves a live helper answers each
blocking-dialog and app-focus read with one focus request and no dump.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ard's own reads

When the shared post-press read names no focused package, the escape guard
reads the foreground, and the after-command check now reads again instead of
acting on the older shared read. The guard skips its app-focus read after a
shared read: the shared read already asked the helper, and the foreground read
repeats the dump fallback. Reads stay at or below main on every path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of a3f270f

Since the review of 1a80a72: 0 new · 0 still open · 1 no longer raised (1 marked fixed)

No open findings.

🔧 1 finding marked fixed in their threads
Finding Fixed by Where
After-command dialog check acts on a read taken seconds before the escape guard's own dumps thymikee a3f270f · reply

Reviewed with this repository's own Sentinel configuration (47e3fbe2758c).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready to merge at a3f270f, and the required checks pass, including Android Smoke Tests, Integration Tests, Coverage, and Lint/Typecheck; the canceled "Body rules" entries are superseded by a passing run and do not touch the changed device route.

Not blocking: these can be taken or left: could the shared read be reused only when its focused package equals the session app's, because a blocking dialog that appears during the guard's later foreground read after a read naming another package is missed and the press returns ok (otherwise the readiness doc comment could state this window and soften "Outcomes do not change"), which would cost one extra dump on routes such as the permission prompt but would also reduce the reuse rule now derived in both the guard and the readiness wrapper (whose unused-today noRead and cross-file description can otherwise stay); the requirement's "one post-dispatch blocking-dialog read" could be narrowed to reads that name the focused package, since unknown, dialog, or package-less clear results read twice with no code change needed; and the Validation section for this device-facing change, which still says CI is pending and records no device run, could cite Android Smoke Tests run 46277003470 (job 141390392755).

These review threads no longer apply and can be resolved: the expected and foreground package assertion is now in the test; the daemon fake is renamed to focusAnswerObservation and an adapter test proves one helper focus request per read; and the unknown-read case now reads again, with only the named-other-package variant left in the note above.

The Android smoke lane (API 36 emulator) passed smoke:automation-system, whose scenario runs press and longpress on an opened app session with the Android helper and asserts fixture state. Not verified here: no tests were run locally, so CI results are relied on and fail-on-base claims come from reading the base code; per-step logs and daemon diagnostics were not inspected, so the read branch that ran is inferred from the code; the permission prompt, launcher refusal, unknown-focus, and dumps-only routes were covered only by tests with fake adb or fake adapters, not on a device; and live post-dispatch read counts and timing were not measured.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 29, 2026
@thymikee
thymikee merged commit 9218b64 into main Nov 29, 2026
21 of 24 checks passed
@thymikee
thymikee deleted the perf/android-press-single-post-focus branch November 29, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant