Skip to content

Read agent-device's acquirability verdict when picking an emulator port - #89

Open
thymikee wants to merge 8 commits into
expo:mainfrom
thymikee:agent-device-claim-verdict
Open

thymikee wants to merge 8 commits into
expo:mainfrom
thymikee:agent-device-claim-verdict

Conversation

@thymikee

@thymikee thymikee commented Nov 17, 2026 •

Copy link
Copy Markdown

Summary

We want Explore to use agent-device directly, without workarounds. This removes one: counting claims to guess whether agent-device would refuse a port.

agent-device's device status --json now answers that question itself (devices[].acquirable, with blockedBy as the typed reason). Explore reads it instead of adding claims.length + hiddenStaleClaims.

Before: skip the port if claims.length + hiddenStaleClaims > 0.
After: skip the port if any devices[].acquirable === false.

{ "claims": [], "hiddenStaleClaims": 1,
  "devices": [{ "acquirable": false, "blockedBy": "owner-process-still-running" }] }

One behaviour is more correct: a stale claim whose owner died is reclaimable, so its port is no longer skipped. Claims agent-device still refuses stay skipped.

4 files changed. No visible change. No change to usage.

Stacked on #87: review after it. The diff includes #87's commits until it merges.

Validation

  • Head: 4d96f81, rebased on agent-device 0.21.40: read typed refusals, and press the dismiss control back names #87's 0.21.40 pin. The probes ran on a private Android 15 emulator (emulator-5570) with 0.21.39. The claim inspection behind device status is the same in 0.21.40.
  • Probed device status --json in four states: no claim (devices: []), live owner (acquirable: false, live-owner), dead owner (acquirable: true, and open from another state dir succeeded), owner state dir gone (hidden as stale, acquirable: false, and open failed with DEVICE_IN_USE).
  • Skip-this-port, old count vs new verdict, in the same order: false/false, true/true, true/false (dead owner), true/true. The helper is now agentDeviceRefuses.
  • build, typecheck and eslint pass. test:node: 1687 pass, 29 fail, all "required evidence comparison did not run" (same as main). One test added for the reclaimable claim.
  • No end-to-end replay: the Wallet example is iOS and this path is Android.
  • Explore's CI needs maintainer approval for fork PRs.

🤖 Generated with Claude Code


🟢 Devin Review found nothing to fix · View findings

Devin Review

thymikee and others added 2 commits November 17, 2026 15:31
…rol back names

0.21.39 no longer says "in-app back control is not available" or "Unable to dismiss the iOS
keyboard", so the fallbacks Explore keyed on those messages would never run. They now read
error.details.reason:

- back: on iOS, agent-device presses the navigation bar back button, else swipes from the left
  edge, and refuses with back_swipe_no_change when nothing changed. It lists the screen's dismiss
  controls (Close, Cancel, Back) in details.dismissControls without pressing them. Explore presses
  the one it names when its label is safe by Explore's destructive and external rules, requires
  the destination to change, and otherwise swipes a sheet down as before.
- keyboard dismiss refuses with keyboard_dismiss_unavailable; the return-key fallback keys on it.
- the remote /health refusal is remote_daemon_unavailable with dispatched "no", which is what
  Explore inferred from the message before resending.

The other controller's bridge gives the same reasons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As in source-driven capture, explore:binary compares the screen before and after it presses the
dismiss control agent-device named, and fails the back with agent-device's refusal when nothing
changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T15:19:33.958861Z c442b3e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c442b3e59b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/capture/route-capture.ts Outdated
await command(["press", control.selector, "--level", "full", "--json"], signal);
for (let attempt = 0; attempt < 4; attempt++) {
await sleep(500, undefined, { signal: liveSignal(signal) });
if (observerIdentity((await readSnapshot(signal)).snapshot.nodes) !== observerIdentity(before)) return { via: "dismiss-control" };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Accept same-route dismissals after pressing the control

When the named Close/Cancel control dismisses a modal implemented as component-local state on the current route, the observer emitted by src/capture/observer.ts retains the same navigation label and rectangle, so this check never recognizes the successful dismissal. The press has already mutated the UI, but back then falls through to sheetDismissGesture(before) using stale pre-press geometry or throws the original refusal; the agent records a failed action and may retry or derail the capture. Verify the actual accessibility/modal state in addition to observerIdentity before reporting failure.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch. This code comes from #87 (this PR stacks on it), so I fixed it there in d18339d, and this branch is rebased on it. A press now counts as back when the route changes or when the pressed control is gone from the screen. That covers a modal kept in a screen's own state. If neither happens, back fails with AGENT_DISMISS_CONTROL_FAILED and never falls through to the sheet swipe, because the press may already have changed the UI. Two tests in ci-map.test.mjs cover the same-route close and the "pressed, nothing changed" case, which asserts that no swipe follows.

…ipes after a press

A modal kept in a screen's own state keeps the route when its Close control dismisses it, so the
destination check alone read that as a failure and fell through to the sheet swipe-down with the
geometry read before the press. A press now counts when the route changes or the pressed control
is gone. If neither happens, back fails with AGENT_DISMISS_CONTROL_FAILED instead of swiping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee
thymikee force-pushed the agent-device-claim-verdict branch from c442b3e to 379a04c Compare November 17, 2026 15:23
…eaving the screen

The pressed control disappearing counted as back, but a confirmation such as "Discard changes?"
also hides it while the screen stays. The control leaving now counts only when no alert took its
place; otherwise back fails with AGENT_DISMISS_CONTROL_FAILED.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee
thymikee force-pushed the agent-device-claim-verdict branch from 379a04c to 574fd18 Compare November 17, 2026 15:28
A "Discard changes?" confirmation after the press changes the screen, and can hide the route
observer, so either signal alone read it as having left. Both code paths now require that no
alert is showing before a press counts as back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee
thymikee force-pushed the agent-device-claim-verdict branch from 574fd18 to aec1709 Compare November 17, 2026 16:39
agent-device names a dismiss control by its identifier when it has
one, and its label may then be empty. The press check matched only
the label, so a button with no label was never seen and the press
counted as leaving even when the modal stayed. It now matches the
control the way agent-device named it, and the control leaving counts
only when it was on screen before the press.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee
thymikee force-pushed the agent-device-claim-verdict branch from aec1709 to 4b1abc4 Compare November 19, 2026 15:27
thymikee and others added 2 commits November 19, 2026 17:03
0.21.40 adds the keyboard fix found while testing this bump: keyboard
dismiss no longer presses the return key, so on a field whose return
key is Done it refuses with keyboard_dismiss_unavailable instead of
submitting the form. The typed reasons Explore reads are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The local Android path counted every claim and every hidden stale claim
on a serial and skipped the port when the count was above zero, because
agent-device refused some stale claims. device status now answers the
question itself: devices[].acquirable says whether a new session could
take the device, and blockedBy names the reason.

Explore skips a port only when that verdict is false. A claim whose owner
died is reclaimable, so its port is no longer skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee
thymikee force-pushed the agent-device-claim-verdict branch from 4b1abc4 to 4d96f81 Compare November 19, 2026 16:28

This branch has not been deployed

No deployments
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.

1 participant