Skip to content

Add ADB network device connection support - #9950

Closed
s546126 wants to merge 3 commits into
stablyai:mainfrom
s546126:claude/adb-network-device-connection-ultecg
Closed

s546126 wants to merge 3 commits into
stablyai:mainfrom
s546126:claude/adb-network-device-connection-ultecg

Conversation

@s546126

@s546126 s546126 commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds first-class support for connecting a locally reachable Android device or cloud phone by ADB TCP address in Settings > Mobile Emulator, feeding the existing inventory → EmulatorBridge → scrcpy pipeline (no second backend, no new video transport):

  • New ADB Device Connection section (between Availability and Default Device): one persisted host:port address, Connect/Disconnect, explicit status (disconnected / connecting / connected / unauthorized / offline / failed), reachability help text and an ADB-exposure security warning. Success is verified via adb devices -l state=device, never inferred from adb connect text or exit code.
  • Platform-tools-only hosts are now valid: SDK discovery requires only adb; the emulator/avdmanager binaries moved behind an optional avdTools capability, so connected-device workflows work without Android Studio while full-SDK AVD flows are unchanged.
  • Lifecycle ownership: pane close / app quit stop the scrcpy helper only — the shared adb server keeps its connections; only the explicit Settings Disconnect runs adb disconnect. adb emu kill is guarded to local emulator-\d+ serials; TCP/USB serials can never receive it from any teardown path.
  • Routing fix: a host:port serial is classified as Android before the ownsDevice/platform fallback in EmulatorBridge, so an offline 127.0.0.1:5555 on macOS routes to Android with actionable "connect it in Settings" guidance instead of falling through to iOS or AVD boot. Connect (RPC) is the only code path that ever runs adb connect.
  • Additive RPC (emulator.adbConnect / adbDisconnect / adbConnectionStatus, local runtime only), additive emulator_adb_* error codes, one persisted setting mobileEmulatorAdbAddress, default-device hygiene that only clears a default pointing at the previous network serial, and docs/skill updates.

Also submitted upstream as #9950. The branch is rebased onto upstream main (334027cfd): 4 commits, 121e61297 → 34703f26c → a78b1a865 → 1597ffa6c. This fork's main predates the Android/scrcpy backend, so the diff shown here vs the fork's main includes upstream history; the upstream PR shows the clean 4-commit diff.

Screenshots

No screenshots available from this headless environment — the new section reuses the existing settings primitives (SettingsRow/Label/Input/Button/Badge with existing status tokens). UI behavior is covered by component tests.

Testing

  • pnpm typecheck (all three tsc projects pass, re-run after the rebase onto upstream main)
  • pnpm test for all touched areas: src/main/emulator, emulator RPC methods, settings components/shared defaults — 962 tests pass post-rebase, including new suites for endpoint grammar, connect/disconnect/status polling, emu-kill guards, bridge routing regression (offline 127.0.0.1:5555 on darwin → Android), lifecycle (tab close/app quit never disconnect), single in-flight op, defaults/hygiene, and stale-response guarding
  • oxlint clean on touched files; the branch's own i18n keys verified present in all five locale catalogs after the rebase conflict resolution
  • pnpm lint full: verify:skill-bundle-manifest cannot pass on this fork (upstream release tags absent; also fails on the clean base — see the CI-triage comment below). verify:localization-catalog currently fails on upstream main itself (pre-existing upstream drift in e.g. sleep-worktree-flow.ts), reproduced on a clean upstream checkout — intentionally not papered over in this PR
  • pnpm build not run in this environment
  • Added regression tests for every lifecycle/routing guarantee above

No live smoke test against a real reachable ADB endpoint was run; verification is via mocked-runner tests.

AI Review Report

Implemented via a staged multi-agent workflow: each stage (SDK capability split → endpoint grammar + guards → connection manager → RPC → settings UI → docs) was implemented, then independently reviewed by a stronger reviewer model that re-ran tests/typecheck and specifically hunted for: auto-connect paths outside the Connect RPC, emu kill guard gaps, success inferred without adb devices -l, error-code mutations, parser/serial-recognition grammar divergence, over-engineering, and scope creep. All blocking findings were fixed in-loop. Cross-platform was explicitly checked: SDK discovery paths for macOS/Linux/Windows incl. adb.exe/emulator.exe/avdmanager.bat via path.join (unit-tested per platform), no shortcut/label changes, no shell-specific commands.

Security Audit

  • Input handling: the address is validated by a strict pure grammar (hostname/IPv4 + port 1..65535; rejects URLs, credentials, paths, whitespace/control bytes; bracketed IPv6 explicitly unsupported) before any process execution; RPC inputs are zod-validated.
  • Command execution: all adb invocations go through the existing execFile-based AndroidCommandRunner with arg arrays (no shell interpolation); the validated address is passed as a single argv element.
  • The UI warns that ADB grants shell/install/debug access and must not be exposed to untrusted networks; Orca never opens/forwards ports itself (VPN/tunnels remain the user's concern).
  • IPC: renderer receives typed, renderer-safe status objects (no raw errors/stacks). No secrets, no new dependencies, no SSH/remote-runtime code touched.

Notes

  • emu kill guard: TCP/USB serials never receive it; local AVD shutdown behavior unchanged.
  • A later Orca launch reflects real shared adb state passively (status is read-only); nothing auto-connects on startup/availability/pane-open.
  • Known minors (documented, deliberate): currentAddress() insertion-order nuance is unobservable in v1's single-address model; a failed disconnect drops the address→serial mapping before surfacing the residual entry (mapping is address==serial today).
  • Follow-up candidates: IPv6 support, multiple saved addresses, auto-reconnect — all explicitly out of v1 scope.

ELI5

You can connect a phone or device over ADB network (host:port) in Settings → Mobile Emulator. Connect/disconnect and status feed the same emulator pipeline as USB devices—no separate video stack.

@s546126
s546126 force-pushed the claude/adb-network-device-connection-ultecg branch from 1d1ca14 to 1597ffa Compare July 22, 2026 15:01
@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

  • Last reviewed commit: 19b93004e4203dfdbe89f7e3d654fca8be305a44
  • Latest commit, not reviewed: bec52b7

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Adds host:port ADB endpoint validation and connection lifecycle management with polling, authorization, disconnect, status, serial tracking, and concurrency handling. Updates Android SDK discovery and backend behavior to support platform-tools-only environments and remote devices. Exposes ADB operations through the bridge, runtime, and RPC layers. Adds Settings UI controls, persisted address configuration, localization, tests, and updated Android guidance.

Merge Risk: ⚪ Minimal · up to a8019

The PR adds ADB network-device connection support and routes it through the existing Android pipeline. No actionable merge-blocking risk remains; the outstanding items are limited to comment brevity and confirming localization-catalog conventions.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.81% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: support for ADB network device connections.
Description check ✅ Passed The description clearly covers scope, rationale, testing, UI behavior, security, limitations, and upstream context, with only minor template deviations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

🧹 Nitpick comments (1)
src/main/emulator/backends/android-emulator-backend.ts (1)

172-186: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Extend the network-serial guard to resolveDeviceId, not just the boot path.

android-avd-boot.ts's bootAndroidDevice now special-cases isAdbNetworkSerial(deviceOrName) to fail with an actionable "not connected, connect it in Settings > Mobile Emulator" message. resolveDeviceId here — used by tap, gesture, type, button, exec, installApp, launchApp, setPermission, accessibilityTree, logcat, and shutdownDevice — has no equivalent guard, so any of those calls against a configured-but-disconnected network address instead get the boot-oriented "is not running. Boot it first." message, which is misleading (there is nothing to "boot").

♻️ Proposed fix
   async resolveDeviceId(deviceOrName: string): Promise<string> {
     const sdk = this.requireSdk()
     const running = await listRunningAdbDevices(this.runner, sdk)
     if (running.some((device) => device.serial === deviceOrName)) {
       return deviceOrName
     }
     const serial = await findRunningAvdSerial(this.runner, sdk, deviceOrName, running)
     if (serial) {
       return serial
     }
+    if (isAdbNetworkSerial(deviceOrName)) {
+      throw new EmulatorError(
+        'emulator_adb_not_connected',
+        `ADB device ${deviceOrName} is not connected. Connect it in Settings > Mobile Emulator.`
+      )
+    }
     throw new EmulatorError(
       'emulator_device_not_found',
       `Android device "${deviceOrName}" is not running. Boot it first.`
     )
   }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4fbf01bd-2fb0-4c56-a539-1a11aec0354a

📥 Commits

Reviewing files that changed from the base of the PR and between 334027c and 1d1ca1488a6368543a4166e7287dfc7f7d628058.

📒 Files selected for processing (41)
  • docs/android-emulation.md
  • skill-guides/orca-emulator-android.md
  • skills/orca-emulator-android/SKILL.md
  • src/cli/bundled-skill-guides.ts
  • src/main/emulator/android/adb-device-connection.test.ts
  • src/main/emulator/android/adb-device-connection.ts
  • src/main/emulator/android/adb-network-endpoint.test.ts
  • src/main/emulator/android/adb-network-endpoint.ts
  • src/main/emulator/android/android-avd-boot.test.ts
  • src/main/emulator/android/android-avd-boot.ts
  • src/main/emulator/android/android-capability-operations.test.ts
  • src/main/emulator/android/android-device-inventory.test.ts
  • src/main/emulator/android/android-device-inventory.ts
  • src/main/emulator/android/android-input-commands.test.ts
  • src/main/emulator/android/android-screen-size-cache.ts
  • src/main/emulator/android/android-sdk-discovery.test.ts
  • src/main/emulator/android/android-sdk-discovery.ts
  • src/main/emulator/backends/android-emulator-backend.test.ts
  • src/main/emulator/backends/android-emulator-backend.ts
  • src/main/emulator/emulator-bridge.test.ts
  • src/main/emulator/emulator-bridge.ts
  • src/main/emulator/emulator-errors.ts
  • src/main/runtime/orca-runtime-emulator-adb.ts
  • src/main/runtime/orca-runtime-emulator.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/emulator.test.ts
  • src/main/runtime/rpc/methods/emulator.ts
  • src/renderer/src/components/settings/MobileEmulatorAdbConnection.test.tsx
  • src/renderer/src/components/settings/MobileEmulatorAdbConnection.tsx
  • src/renderer/src/components/settings/MobileEmulatorSettingsPane.tsx
  • src/renderer/src/components/settings/mobile-emulator-adb-default-device-hygiene.test.ts
  • src/renderer/src/components/settings/mobile-emulator-adb-default-device-hygiene.ts
  • src/renderer/src/components/settings/mobile-emulator-search.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/constants.test.ts
  • src/shared/constants.ts
  • src/shared/types.ts

Comment thread docs/android-emulation.md Resolved
Comment thread skill-guides/orca-emulator-android.md Resolved

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 73d372e1-664a-4095-9414-a976b2779bff

📥 Commits

Reviewing files that changed from the base of the PR and between 1d1ca1488a6368543a4166e7287dfc7f7d628058 and 1597ffa6c07d3e188db002e9499ffb342f4b21a1.

📒 Files selected for processing (4)
  • docs/android-emulation.md
  • skill-guides/orca-emulator-android.md
  • skills/orca-emulator-android/SKILL.md
  • src/cli/bundled-skill-guides.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/cli/bundled-skill-guides.ts
  • docs/android-emulation.md
  • skill-guides/orca-emulator-android.md

Comment thread skills/orca-emulator-android/SKILL.md Resolved
@AmethystLiang
AmethystLiang requested a review from OrcaWin July 22, 2026 17:03
@s546126 s546126 changed the title Claude/adb network device connection ultecg Add ADB network device connection suppor Jul 22, 2026
@s546126 s546126 changed the title Add ADB network device connection suppor Add ADB network device connection support Jul 22, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 969d60ef-8e4b-4fec-a630-717ff16d8ce2

📥 Commits

Reviewing files that changed from the base of the PR and between f87a1e968c1e74461a38ffefa75be406036ef303 and 19b93004e4203dfdbe89f7e3d654fca8be305a44.

📒 Files selected for processing (13)
  • docs/android-emulation.md
  • resources/skills/current-manifest.json
  • resources/skills/release-mapping.json
  • resources/skills/snapshot-registry.json
  • skill-guides/orca-emulator-android.md
  • skills/orca-emulator-android/SKILL.md
  • src/cli/bundled-skill-guides.ts
  • src/main/emulator/android/android-avd-boot.ts
  • src/main/emulator/android/android-sdk-state.ts
  • src/main/emulator/backends/android-emulator-backend.test.ts
  • src/main/emulator/backends/android-emulator-backend.ts
  • src/main/emulator/emulator-availability.test.ts
  • src/main/emulator/emulator-errors.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/main/emulator/emulator-errors.ts
  • src/cli/bundled-skill-guides.ts
  • docs/android-emulation.md
  • src/main/emulator/backends/android-emulator-backend.test.ts
  • skill-guides/orca-emulator-android.md
  • src/main/emulator/backends/android-emulator-backend.ts

Comment thread resources/skills/release-mapping.json Outdated
Comment on lines +579 to +586
"appVersion": "1.4.150-rc.0",
"skills": {
"computer-use": 5,
"linear-tickets": 7,
"orca-cli": 35,
"orca-emulator": 4,
"orca-emulator-android": 2,
"orca-linear": 5,

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Map orca-emulator-android to revision 3 for this release.

Line 585 still points 1.4.150-rc.0 to revision 2, while resources/skills/current-manifest.json and resources/skills/snapshot-registry.json declare the newly shipped snapshot as revision 3. The runtime provenance builder will therefore have no released-app entry for revision 3.

Proposed fix
-        "orca-emulator-android": 2,
+        "orca-emulator-android": 3,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"appVersion": "1.4.150-rc.0",
"skills": {
"computer-use": 5,
"linear-tickets": 7,
"orca-cli": 35,
"orca-emulator": 4,
"orca-emulator-android": 2,
"orca-linear": 5,
"appVersion": "1.4.150-rc.0",
"skills": {
"computer-use": 5,
"linear-tickets": 7,
"orca-cli": 35,
"orca-emulator": 4,
"orca-emulator-android": 3,
"orca-linear": 5,

@nwparker nwparker added the enhancement New feature or request label Jul 27, 2026
@cursor
cursor Bot force-pushed the claude/adb-network-device-connection-ultecg branch from 19b9300 to a801920 Compare August 19, 2026 05:39
@cursor
cursor Bot requested a review from brennanb2025 as a code owner August 19, 2026 05:39
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
src/main/emulator/android/adb-network-endpoint.ts (1)

1-2: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reduce multi-line explanatory comments.

Keep only the non-obvious rationale. Use one concise line where possible.

  • src/main/emulator/android/adb-network-endpoint.ts#L1-L2: compress the parser scope comment.
  • src/main/emulator/android/adb-network-endpoint.ts#L19-L22: compress the IPv4 validation rationale.
  • src/main/emulator/android/adb-network-endpoint.ts#L30-L33: compress the parser contract comment.
  • src/main/emulator/android/adb-network-endpoint.ts#L87-L89: compress the serial-routing comment.
  • src/main/emulator/backends/android-emulator-backend.ts#L90-L91: replace the public-field implementation detail with a concise contract comment.
  • src/main/emulator/backends/android-emulator-backend.ts#L110-L111: compress the platform-tools rationale.
  • src/main/emulator/backends/android-emulator-backend.ts#L149-L150: compress the availability-message rationale.
  • src/main/emulator/backends/android-emulator-backend.ts#L184-L185: compress the offline-device routing rationale.
  • src/main/emulator/backends/android-emulator-backend.ts#L225-L227: compress the shutdown safety rationale.

As per coding guidelines, “Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b48aed6e-e7a6-4365-ad0c-1612b002bf53

📥 Commits

Reviewing files that changed from the base of the PR and between 9b5538d and a8019204c38c039ae455443b0be6620026bed437.

📒 Files selected for processing (41)
  • skill-guides/orca-emulator-android.md
  • src/cli/bundled-skill-guides.ts
  • src/main/emulator/android/adb-device-connection.test.ts
  • src/main/emulator/android/adb-device-connection.ts
  • src/main/emulator/android/adb-network-endpoint.test.ts
  • src/main/emulator/android/adb-network-endpoint.ts
  • src/main/emulator/android/android-avd-boot.test.ts
  • src/main/emulator/android/android-avd-boot.ts
  • src/main/emulator/android/android-capability-operations.test.ts
  • src/main/emulator/android/android-device-inventory.test.ts
  • src/main/emulator/android/android-device-inventory.ts
  • src/main/emulator/android/android-input-commands.test.ts
  • src/main/emulator/android/android-screen-size-cache.ts
  • src/main/emulator/android/android-sdk-discovery.test.ts
  • src/main/emulator/android/android-sdk-discovery.ts
  • src/main/emulator/android/android-sdk-state.ts
  • src/main/emulator/backends/android-emulator-backend.test.ts
  • src/main/emulator/backends/android-emulator-backend.ts
  • src/main/emulator/emulator-availability.test.ts
  • src/main/emulator/emulator-bridge.test.ts
  • src/main/emulator/emulator-bridge.ts
  • src/main/emulator/emulator-errors.ts
  • src/main/runtime/orca-runtime-emulator-adb.ts
  • src/main/runtime/orca-runtime-emulator.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/emulator.test.ts
  • src/main/runtime/rpc/methods/emulator.ts
  • src/renderer/src/components/settings/MobileEmulatorAdbConnection.test.tsx
  • src/renderer/src/components/settings/MobileEmulatorAdbConnection.tsx
  • src/renderer/src/components/settings/MobileEmulatorSettingsPane.tsx
  • src/renderer/src/components/settings/mobile-emulator-adb-default-device-hygiene.test.ts
  • src/renderer/src/components/settings/mobile-emulator-adb-default-device-hygiene.ts
  • src/renderer/src/components/settings/mobile-emulator-search.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/constants.test.ts
  • src/shared/constants.ts
  • src/shared/global-settings-types.ts
🚧 Files skipped from review as they are similar to previous changes (34)
  • src/shared/constants.test.ts
  • src/shared/constants.ts
  • src/renderer/src/components/settings/mobile-emulator-adb-default-device-hygiene.test.ts
  • src/main/emulator/emulator-availability.test.ts
  • src/main/emulator/android/android-device-inventory.test.ts
  • src/main/emulator/android/android-screen-size-cache.ts
  • src/main/runtime/rpc/methods/emulator.ts
  • src/cli/bundled-skill-guides.ts
  • src/renderer/src/components/settings/mobile-emulator-adb-default-device-hygiene.ts
  • src/main/emulator/emulator-errors.ts
  • src/main/emulator/android/android-device-inventory.ts
  • src/renderer/src/components/settings/MobileEmulatorSettingsPane.tsx
  • src/main/emulator/android/android-sdk-state.ts
  • src/renderer/src/i18n/locales/en.json
  • src/main/emulator/android/android-capability-operations.test.ts
  • src/renderer/src/i18n/locales/es.json
  • src/main/emulator/android/android-input-commands.test.ts
  • src/main/runtime/orca-runtime-emulator.ts
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/components/settings/mobile-emulator-search.ts
  • src/main/emulator/android/adb-device-connection.test.ts
  • src/main/emulator/android/adb-network-endpoint.test.ts
  • src/main/emulator/emulator-bridge.ts
  • src/main/runtime/rpc/methods/emulator.test.ts
  • src/main/emulator/android/android-sdk-discovery.ts
  • skill-guides/orca-emulator-android.md
  • src/main/runtime/orca-runtime-emulator-adb.ts
  • src/main/emulator/android/android-sdk-discovery.test.ts
  • src/renderer/src/components/settings/MobileEmulatorAdbConnection.test.tsx
  • src/main/emulator/backends/android-emulator-backend.test.ts
  • src/renderer/src/i18n/locales/ko.json
  • src/main/emulator/emulator-bridge.test.ts
  • src/renderer/src/components/settings/MobileEmulatorAdbConnection.tsx
  • src/main/emulator/android/adb-device-connection.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@cursor
cursor Bot force-pushed the claude/adb-network-device-connection-ultecg branch 2 times, most recently from 216b6c6 to 44ea795 Compare August 31, 2026 15:32
@greptile-apps

greptile-apps Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[High risk] Adds network device connection to Android emulator backend.

The PR appears safe to merge; the previous default-device cleanup issue is fixed and there are no new findings.

Findings

  1. P1 Default cleanup depends on status ▶

Summary

The PR adds a saved ADB network address and Connect/Disconnect controls in Mobile Emulator settings, using the existing Android device inventory and scrcpy pipeline.

  • Platform-tools-only installations can use connected devices without AVD tooling.
  • Network serials route to Android, while teardown preserves shared ADB connections.
  • The previous default-device cleanup finding is fixed: changing the saved address now falls back to the previous address when status has not arrived.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Settings: Connect host:port"] --> B["Local emulator.adbConnect RPC"]
  B --> C["adb connect"]
  C --> D["Verify state via adb devices -l"]
  D --> E["Android inventory and EmulatorBridge"]
  E --> F["Existing scrcpy pipeline"]
  G["Settings: Disconnect"] --> H["Stop helper and clear session"]
  H --> I["adb disconnect"]
Loading

Reviews (3) · Last reviewed commit: "chore: retrigger CI against fast-forward..."

Comment on lines +182 to +183
const previousSerial =
lastStatusRef.current.address === (previous || null) ? lastStatusRef.current.serial : null

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Default cleanup depends on status

When the user replaces the saved address before the initial status request completes, lastStatusRef still contains null and the old network serial is not cleared as the default device, causing subsequent emulator actions to target the disconnected previous device.

Suggested change
const previousSerial =
lastStatusRef.current.address === (previous || null) ? lastStatusRef.current.serial : null
const previousSerial =
lastStatusRef.current.address === (previous || null)
? lastStatusRef.current.serial
: previous || null

Knowledge Base Used:

@cursor
cursor Bot force-pushed the claude/adb-network-device-connection-ultecg branch from 44ea795 to d31d08b Compare September 1, 2026 15:17
@cursor
cursor Bot force-pushed the claude/adb-network-device-connection-ultecg branch from dcbcd76 to fcacb55 Compare September 2, 2026 15:29
@cursor
cursor Bot force-pushed the claude/adb-network-device-connection-ultecg branch from fcacb55 to 673e30e Compare September 7, 2026 15:27
@cursor
cursor Bot force-pushed the claude/adb-network-device-connection-ultecg branch from 2c2b50b to 1fd2892 Compare September 9, 2026 15:08
@cursor
cursor Bot force-pushed the claude/adb-network-device-connection-ultecg branch from 29eb764 to 17c0c1d Compare September 10, 2026 15:40
@cursor
cursor Bot force-pushed the claude/adb-network-device-connection-ultecg branch from 17c0c1d to a72fa8c Compare September 11, 2026 15:33
@cursor
cursor Bot force-pushed the claude/adb-network-device-connection-ultecg branch from a41bc1a to d32480a Compare September 21, 2026 15:35
@cursor
cursor Bot force-pushed the claude/adb-network-device-connection-ultecg branch from 77c9ca4 to 40e5c2d Compare September 25, 2026 14:58
@cursor
cursor Bot force-pushed the claude/adb-network-device-connection-ultecg branch from 4e9e080 to 748effe Compare September 28, 2026 15:07
@cursor
cursor Bot force-pushed the claude/adb-network-device-connection-ultecg branch from ca1708a to 2dfcc41 Compare September 30, 2026 14:59
@cursor
cursor Bot force-pushed the claude/adb-network-device-connection-ultecg branch 3 times, most recently from 2b3c7af to df9c261 Compare October 16, 2026 15:07
cursoragent and others added 2 commits October 19, 2026 15:01
Connect an Android device or cloud phone by host:port from Mobile Emulator
settings. adb connect stays explicit, and replacing the saved address clears a
default device that pointed at the previous network serial even when connection
status has not returned yet.

Rebased onto current main. Upstream no longer ships the skill release map, so
the android guide update stays in the bundled skill guide.

Co-authored-by: s546126 <[email protected]>
Current main moved the RPC error class out of the client module. The ADB
connection pane still imported it from the old path, so a missing method
crashed the instanceof check instead of showing the unsupported state.
@cursor
cursor Bot force-pushed the claude/adb-network-device-connection-ultecg branch from df9c261 to 5ce91e1 Compare October 19, 2026 15:01
Upstream no longer removes every adb forward on helper stop, because
--remove-all ignores -s and would drop other devices. Disconnect still
clears the session before adb disconnect.
@AmoabaKelvin

Copy link
Copy Markdown
Collaborator

Thanks for this. Issue #32126 needed the adb-only SDK discovery on its own, so we landed that as a small fix in #37128, which adds the PATH adb lookup and credits you as co-author. The ADB network connection feature in this PR is still a separate question from that fix.

@s546126

s546126 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Closing as the PATH adb discovery fix for #32126 landed on main in #37128 (thanks @AmoabaKelvin!).

@s546126 s546126 closed this Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants