Skip to content

feat(adb): add UI Automator discovery, waits and actions - #3004

Open
3QL wants to merge 143 commits into
morluto:mainfrom
3QL:feat/adb-ui-automation
Open

3QL wants to merge 143 commits into
morluto:mainfrom
3QL:feat/adb-ui-automation

Conversation

@3QL

@3QL 3QL commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds package-scoped UI inspection, discovery and waits through shared CLI/MCP workflows using an operator-started UI Automator runner.

  • Actions remain unshipped: perform_adb_ui_action is absent from normal CLI/MCP registration and the public catalog. Only experiments/adb-ui/mcp.mjs binds the proposal; npm excludes experiment and runner sources. Maintainer mutation-scope approval remains pending.
  • Definitive refusals stay definitive: the transport distinguishes uncertain handoff, acceptance and refusal. A busy reply remains a capacity refusal through cleanup recovery; genuinely unknown outcomes retain replay safeguards.
  • Reconciles main at 3ce311757, adopts upstream comparison and fixture repairs, and removes the unrelated JavaScript patch from this PR’s final diff.
  • Preserves shared input-error projection, display observations, Evidence provenance and MCP cleanup ownership.

Validation — 2c8149173

Runtime validation was performed at 5f746544d; 2c8149173 is a documentation-only follow-up.

  • The 22 failed CDP/HTTP comparisons reproduce on exact CI base f2db494bf. Upstream fixes preserve uncertainty for incomplete captures and retain positive change-detection assertions. All selected comparison tests now pass.
  • 984 focused tests across 62 files covered successfully: 940 tests in 61 files passed. After replacing a brittle recursive diagnostic-count assertion with checks of the documented error fields, all 44 runner tests passed.
  • npm run check, npm run docs:check, test discovery, 18 experiment/lifecycle tests and installed-package verification passed.
  • The package inventory contains 2,319 files, excluding runner, experiment and test sources.
  • After the commit hook normalized an equivalent ADB numeric regex, five affected tests and static/docs checks passed again.
  • GitHub reports the main conflicts resolved. Current-head CI is not yet verified green.

Verification limits

No full local-suite pass or new Android runtime run is claimed. Earlier API 36 evidence predates this reconciliation. Native runner contention, physical devices/OEMs, older Android and native Windows/macOS UI behavior remain unverified.

Pinned main also has independent CI failures. An isolated JavaScript reference-lifetime test exceeded a bounded 30-second run, and a separate stored-getter provenance probe fails on main. Their evidence is retained separately from this UI change.

Coordination with #3840

#3840 covers wait_adb_boot and trace_android_resource_references; resource IDs from UI observations can feed tracing against a caller-selected APK.

Original scope request and historical follow-up

Maintainer scope decision remains pending before integration. This capability observes and mutates a caller-selected target application's UI (including text replacement and key events), although the helper itself is operator-built and does not inject code into the target process. Please decide whether REA should integrate this interactive capability under the documented operator-owned boundary, and define any limits for supported targets/actions, sensitive text, focus/identity, and permission dialogs. The existing implementation exposes no automatic permission-dialog watcher, arbitrary shell command, or caller-authored code. The prior PR body reported approval relayed by the human owner; this draft does not treat that report as the maintainer decision required for integration.

Current follow-up evidence

Input-submission uncertainty is now recorded at the shared owned-command stdin handoff, rather than before a command can launch. Definitive pre-handoff cancellation remains cancellation. Recovered action outcomes have their own durable owner, independent of remote request cleanup, so a lost forget acknowledgement or later cancellation cannot discard them. A matching fresh inspection clears the exact unknown request from both its gate and durable map; unrelated outcomes remain retained. The direct unknown→matching inspect→next action regression verifies there is no extra stale refusal.

The runner/owned-command set passed 67 tests, fixture lifecycle tests passed 12/12, and the final inspection-clearing runner suite passed 38/38, all on Node 24.18.0/npm 11.16.0. check:fast and push gates passed. Independent review found the stale-map issue and the final patch fixes it; no device/emulator was run.

The installer-fixture finding is already structurally prevented: the fixture awaits exact command-owner settlement before package reconciliation; unsuccessful settlement prevents inventory/uninstall and retains its lease/journal. Late-install and retained-owner regressions passed in the 12-test fixture suite. A stale mock was updated to the current unparsed_lines Evidence contract. This evidence does not supply the pending maintainer scope decision.

The older lifecycle findings are also covered by the current owners: CLI execution delegates to finishAnalysisCommand, which combines operation and close failures while preserving partial observations; receiver-setup failure closes the socket and retains cleanup as a suppressed cause; terminal runner completions are bounded before being retained so status/cancel envelopes remain releasable. These are source-derived ownership checks plus the scoped regression evidence above, not a real Android runtime reproduction.

Author readiness

Human owner: @3QL

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

me added 2 commits October 13, 2026 21:17
Read the complete window-manager report so Android 16 display-scoped focus is visible. Retain producer declarations and leave missing, null or conflicting values unresolved instead of selecting the first.

Verified with 71 focused parser/provider/CLI/MCP tests and a real API 36 emulator workflow. This fixes existing observation semantics without registering UI mutation tools.
Add an unshipped hierarchy projection, source-built probe app and real emulator workflow for tap, ASCII text, swipe and key-event dispatch. Exercise existing CLI/MCP focus and screenshot operations with selected-device checks and verified fixture removal.

Nine experiment tests and the live API 36 workflow pass. Type/lint, knip, changed-file formatting and docs gates pass; full check is blocked by two unchanged upstream formatting failures. Public UI interaction contracts remain pending maintainer scope review.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-21T19:23:04.975572Z
We couldn’t complete this review. Comment @codex review to try again.
811977b New commits
ℹ️ 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.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[High impact] The reviewed changes appear safe to merge, with public input actions still withheld pending the maintainer scope decision.

Summary

Adds Android UI inspection, element discovery and waits through shared CLI/MCP workflows and an operator-started UI Automator runner.

  • Android UI tools can inspect an app and wait for matching elements.
  • An experiment can send typed input actions to a selected app’s UI.
  • ADB UI requests keep their place in line while uncertain outcomes are recovered.
  • Windows resolves provider commands from the captured search path.
  • Package checks cover tool catalogs larger than one search page.
  • Shared schema and test support changes leave product behavior unchanged.

Diagram

sequenceDiagram
  participant Caller as CLI or MCP caller
  participant Service as Shared ADB service
  participant Provider as ADB provider
  participant Runner as Operator-started runner
  participant Records as Evidence records
  Caller->>Service: UI request
  Service->>Service: Check input and copy caller choices
  Service->>Provider: Parsed request with defaults
  Provider->>Provider: Wait for turn and reconcile cleanup
  Provider->>Provider: Start shared ADB server
  Provider->>Runner: Prepare request
  Provider->>Runner: Send body through private stdin
  Provider->>Runner: Poll completion
  Runner-->>Provider: Observation or refusal
  Provider->>Runner: Acknowledge completed request
  Provider-->>Service: Result or retained partial facts
  Service-->>Records: Evidence with caller choices
  Service-->>Caller: Result and recovery guidance
Loading

Reviews (113) · Last reviewed commit: "fix(adb): preserve UI inputs and shared-..." · Reviewed by Greptile

Comment thread experiments/adb-ui/verify.mjs Resolved
Comment thread experiments/adb-ui/verify.mjs Resolved
Comment thread experiments/adb-ui/verify.mjs Resolved
Comment thread experiments/adb-ui/verify.mjs Resolved
Comment thread experiments/adb-ui/hierarchy.mjs Resolved

@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: 801ad3060a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread experiments/adb-ui/verify.mjs Resolved
Comment thread experiments/adb-ui/verify.mjs Resolved
Comment thread experiments/adb-ui/verify.mjs Resolved
Comment thread src/adb/AdbShellOutput.ts Resolved
Comment thread experiments/adb-ui/verify.mjs Resolved
Comment thread experiments/adb-ui/verify.mjs Resolved
me added 2 commits October 13, 2026 22:08
Track window-manager section ownership instead of combining every focus declaration. Embedded historical display/window headings remain historical until the live policy boundary; only live display/window sections contribute observations.

Addresses the ANR focus review on morluto#3004. Verified with 72 focused ADB parser/provider/CLI/MCP tests, generated-doc checks and a real Android 16/API 36 emulator workflow. Older saved-ANR layouts are covered by producer-format regressions rather than a real older device.
Inspect and install one owned APK snapshot, require complete package inventory, and record the cleanup owner before the install can mutate Android. Reconcile uncertain installs, propagate cancellation through MCP, and retain primary errors with failed cleanup owners and independent cleanup deadlines.

Reuse canonical adb selection and validate derived input points against the control and current screenshot dimensions. Addresses the remaining verifier review findings on morluto#3004.

Seventeen experiment tests pass, including real in-memory MCP cancellation. Real API 36 UI verification passed; a different APK was refused before installation, and verifier-only SIGINT after Android committed an install still removed the fixture and proved absence. Full check remains blocked by the two recorded unchanged upstream formatting issues.

@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: 8a1e608f1a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread experiments/adb-ui/fixture.mjs Resolved
Comment thread experiments/adb-ui/fixture.mjs Resolved
Comment thread experiments/command-scope.mjs Resolved
@morluto morluto added area: runtime Process capture and runtime observation enhancement New feature or request labels Oct 13, 2026
@kaoru0822-kitauji kaoru0822-kitauji added the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

CI-fix track: I didn't push a merge, because the conflict with main is a design choice rather than a mechanical one.

src/adb/AdbProvider.ts, AdbShellOutput.ts and adbToolContracts.ts conflict on how window focus is read:

  • This PR: one full dumpsys window, parsing only live display/window sections (excluding saved ANR state) and reporting observedLines.
  • Main (newer): dumpsys window windows, falling back to dumpsys window displays when neither mCurrentFocus nor mFocusedApp is declared, with a matching limitation and tool description.

Combining them means choosing one parser contract, and the focus change is separate from this PR's UI hierarchy/input prototype, which also needs a maintainer scope decision under the contribution rules for input injection. Suggested path: rebase onto main keeping main's focus reader, and propose the live-section/ANR exclusion as its own change if it's still needed. The failing Static checks, Docs Generation and test shards on this PR came from main's state at the time.

@kaoru0822-kitauji kaoru0822-kitauji removed the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
me added 2 commits October 14, 2026 19:12
Resolve morluto#3004's parser-contract conflicts by adopting main's scoped windows/displays reader and its tests. Drop the prototype branch's superseded full-dump focus implementation and documentation; the remaining contribution is the unshipped UI experiment. Runtime build passed after updating locked dependencies.
Acquire a persistent OS-account serial/package lease before admission. Retain the lease and package identity whenever command settlement, reconciliation or session cleanup is unresolved, and verify file identity before releasing admission.

Expose the command-scope settlement barrier to the fixture owner so late installers cannot commit after a false absence claim. Preserve full stop results and cleanup reasons through aggregated failures. Addresses the three follow-up reviews on morluto#3004.

Validated 70 focused ADB provider/CLI/MCP tests, 22 experiment tests, full check, generated-doc checks and test discovery. A real API 36 two-verifier race refused the contender before install and verified cleanup after owner-only SIGINT; the merged UI workflow also passed. Native incomplete-stop behavior remains scripted coverage.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread experiments/adb-ui/verify.mjs Resolved
Share the fixture's module-relative REA entrypoint across installation, MCP startup and CLI focus inspection instead of resolving two launches against the caller's directory. Preserve caller-relative APK and output paths.

Addresses morluto#3004 review 4274171615. Reproduced the old verifier launching a shadow scripts/rea.mjs from a foreign working directory; verified the fix starts this checkout's MCP server, snapshots the caller-selected APK and invokes this checkout's CLI. Ten existing fixture lifecycle tests and npm run check pass.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@3QL
3QL marked this pull request as draft October 14, 2026 18:47
Expose snapshot-scoped UI inspection, element discovery, condition waits and eight input primitives through shared CLI/MCP contracts. Package the operator-owned AndroidX runner source and preserve request cancellation, uncertain delivery, reply capacity and sensitive-text semantics.

Verify native Views and Compose on Android 16/API 36, 98 focused tests, fixture lifecycle checks, schema conversion, static/docs gates and installed-package workflows.
@3QL
3QL marked this pull request as ready for review October 15, 2026 03:01
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread src/adb/AdbUiRunner.ts Resolved
@3QL 3QL changed the title feat(adb): prototype UI hierarchy and input workflows feat(adb): add UI Automator discovery and actions Oct 15, 2026
Register pending remote requests at the owned process launch boundary and release them only on proven no-start failures. Keep uncertain execution and delivery owned, and remove redundant UI-side ownership preparation.

Reproduce pre-launch cancellation and spawn-refusal cleanup wedges, then verify a later UI call succeeds in the same session. 140 focused tests passed with one Darwin-only skip; static and docs checks passed.

@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: 2302c7449a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Compare password and action-capability state at the shared node validation boundary. Reuse the validated node and projected usability facts instead of implicitly refreshing again after comparison.

Add a real emulator regression for in-place disabled, moved, detached and password transitions. The pinned UI Automator getter already refreshes retained nodes; source, AAR bytecode and the unchanged baseline confirm that behavior. Verify fresh password redaction, ordinary text preservation, native/Compose workflows, 23 focused tests and 15 lifecycle tests.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

3QL added 2 commits November 16, 2026 21:49
Keep MCPorter root derivation in ClientConfigRoots and recheck caller
cancellation immediately after debugger-start listener registration.

Align lifecycle, doctor, XML and MCP presentation assertions with their
producing contracts. Share exact ps-inventory execution matching across
offline verifiers, retaining execution and historical-PID access restrictions.
Honor system ps selection independently of the caller's PATH.

Validate focused boundary suites and historical-PID policy regressions.
Real syscall-traced EVM inspection with restricted PATH confirms /bin/ps
selection and the repaired trace classifier. Full native crash/layout
verification remains delegated to their configured CI environments.
Merge pinned main and migrate UI discovery to its CLI, schema, diagnostics and resource owners. Preserve canonical serial-format errors, late Evidence, cancellation and stdin cleanup; keep UI mutation unregistered.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread experiments/adb-ui/mcp.mjs Resolved
Comment thread docs/development/tool-design.md Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Preserve serialized UI/device admission and local-only client probes while reusing upstream retained artifact cleanup retries. Keep one Grok catalog accumulator, reject changing schemas across pages, retain targeted queries through partial replies and report their exact values. Model start-server in the ADB fixture and permit only independent status polling during local version checks.

Validation: 247 provider/UI/Grok tests; check:fast, architecture guards and docs:check passed. Host Node 24.22.2/npm 11.19.1 differs from pinned 24.22.1/npm 11.16.0. Native Windows/macOS, real Android and native Grok were not rerun.
Comment thread experiments/command-scope.mjs Resolved
3QL added 3 commits November 17, 2026 22:39
Allow the experiment to opt into batch PATH selection and wrap selected .bat/.cmd commands through the shared windowsBatchCommand owner with verbatim arguments. Default provider lookup remains image-only. Reject unsafe batch tokens before preparation or launch. Correct obsolete advertisedInputDialect guidance to describe the shared presenter.

Validation: 95 lookup, composition, preparation and apktool configuration tests; rebuilt runtime and 25 experiment/lease/fixture tests; check:fast, docs:check and diff checks passed. Windows lookup and cmd invocation were simulated on Linux; native Windows and real Android signing remain unverified.
Reconcile the overlapping JSON-input cancellation tests by retaining upstream's acknowledged streamed-read cancellation and subsequent-read control together with the branch's undefined/null physical-failure cases for buffered and streamed reads.

Validation: 263 affected JSON cancellation, ADB provider/UI, Grok discovery and Windows executable selection tests passed; check:fast, docs:check and diff checks passed. Real Android, native Windows/macOS and native Grok checks were not rerun.
Merge current main, retain its representative JSON-input boundary workflows and the ADB-specific malformed-input case, and remove the superseded unused command matrix. Preserve filesystem cancellation and physical-failure coverage.

Validation: 30 JSON-input CLI and filesystem cancellation tests passed; check:fast, docs:check and diff checks passed. The preceding merge passed 263 affected ADB/UI, cancellation and discovery tests. Real Android/native-host checks were not rerun.
…tream

Merge upstream's handler simplification and bind both test-only and unshipped experiment consumers through createEvidenceToolHandler with the exact action contract. Include the Windows command lookup/batch suite in normal Vitest ownership. Correct the numeric-limit permission fixture to restrict copied src directories, the guard's actual scan owner, without touching repository permissions.

Validation: 119 UI boundary tests and 6 experiment/permission boundary cases passed, including five Node suites and required source scan permission/missing-directory refusals; check:fast, test discovery, docs:check and diff checks passed. Controlled Windows command tests do not establish native Windows behavior. Real Android/native-host/Grok checks were not rerun.
Comment thread experiments/command-scope.test.mjs Resolved
3QL added 3 commits November 18, 2026 01:11
Skip only the child.kill SIGINT delivery case on Windows, where Node terminates the child without invoking its signal handler. Keep the Windows executable lookup, batch wrapping and unsafe-token regressions enabled in the normal experiment suite.

Validation: all five experiment Node suites passed through their Vitest boundary owner on Linux; check:fast and diff checks passed. Native Windows signal or launcher behavior was not rerun.
Merge current main and replace the superseded copied-source permission fixture with upstream's minimal source inventory. Retain the real unreadable root/nested and missing-source checks plus its discovered-reader control.

Validation: required-source permission and all five UI experiment Node suites passed through their Vitest owners; check:fast, docs:check and diff checks passed. Real Android/native Windows/macOS checks were not rerun.
Comment thread src/adb/AdbProvider.ts Resolved
Comment thread src/domain/adb/adbEvidenceParameters.ts Resolved
Comment thread src/adb/AdbUiRunner.ts Resolved
@3QL 3QL closed this Nov 21, 2026
@3QL 3QL reopened this Nov 21, 2026
@3QL

3QL commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

@morluto can you merge this now?Thnx!!

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

area: runtime Process capture and runtime observation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants