Skip to content

refactor: move the adb primitives from localnet to device - #48

Merged
beeman merged 1 commit into
mainfrom
beeman/move-adb-primitives-to-device
Sep 4, 2026
Merged

refactor: move the adb primitives from localnet to device#48
beeman merged 1 commit into
mainfrom
beeman/move-adb-primitives-to-device

Conversation

@beeman

@beeman beeman commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #47, now merged; this branch is rebased onto it and carries only the adb move.

adb is a device concern, but its primitives live in localnet/data-access because localnet needed them first. Device then grew its own commands on top and had to reach back into localnet to get them — including device/data-access/device-types.ts, whose ConnectedDevice extends AdbDevice made device's own type file depend on localnet's.

The command-factory series (#41, #45, #46) made this visible: with each feature's imports in its own file, playground-feature-serve.ts alone showed six imports into localnet, five of them for adb.

What moved

To device/data-access/:

  • adb-reverse.ts — whole (listAdbReverses, parseAdbReverses, parseTcpPort, createAdbReverse, removeAdbReverse)
  • list-adb-devices.ts — whole (listAdbDevices, parseAdbDevices, isUsableDevice)
  • openUrlOnDevice — split out of probe-device-port.ts into open-url-on-device.ts
  • AdbDependencies, AdbDevice, AdbDeviceState, AdbReverseEntry — out of localnet-types.ts into device-types.ts, next to the ConnectedDevice that extends one of them

probeDevicePort and parseProbeExitCode stay in localnet: they take a ResolvedLocalnetPort and exist to prove a validator port is reachable from a device, so that file needed splitting rather than moving. localnet imports the two adb types it still references; it re-exports nothing.

What this buys — direction, not edge count

Being precise, because the totals do not improve: 35 non-core cross-feature imports before, 39 after, across 7 edges either way. Splitting combined imports adds statements.

What changes is the arrow:

edge before after
device -> localnet 15 0
localnet -> device 0 19
playground -> localnet 7 3
playground -> device 3 7

Device no longer depends on localnet at all. adb primitives sit in the feature whose domain they are, and localnet, playground and emulator consume them as ordinary consumers.

No cycle is introduced. The only mutual pair in src/ is device <-> emulator, and it is byte-identical on origin/main — it comes from #40's shared tweak UI plus list-connected-devices.ts reading emulator AVD names.

Tests

The seven adb parser tests move from test/localnet.test.ts to test/device.test.ts with the code. parseTcpPort is still imported by the localnet suite, where it drives the fake adb harness rather than being the subject under test. parseContainerStatus and parseProbeExitCode stay behind with their code.

Verification

bun run ci — build, lint, tsc -b --noEmit, 487 pass / 0 fail. Also 487/0 under a pseudo-TTY.

Exercised against a live emulator rather than only through stubs, covering the moved listing, reverse and intent paths:

  • device list --json[{ "serial": "emulator-5554", "state": "device", "name": "solana-mobile" }]
  • device open 8081 --no-forwardOpened http://localhost:8081 on solana-mobile (emulator-5554)
  • localnet status --json → reports engine surfpool and its rpc url

No changeset: the solana-mobile bin and the ./templates export are unchanged.

Noted, not addressed

doctor/data-access/check-android-devices.ts has its own parseAdbDevices and AdbDevice type, unrelated to these and with a different shape (it carries a kind). Two independent adb-device parsers is worth a look, but consolidating them is a behavioural question about what doctor reports, not part of this move.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 88 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 3817b403-d727-4640-884e-ee0733390002

📥 Commits

Reviewing files that changed from the base of the PR and between 3c91bc9 and 7abeaad.

📒 Files selected for processing (26)
  • src/device/data-access/adb-reverse.ts
  • src/device/data-access/device-types.ts
  • src/device/data-access/install-apk.ts
  • src/device/data-access/list-adb-devices.ts
  • src/device/data-access/list-connected-devices.ts
  • src/device/data-access/open-url-on-device.ts
  • src/device/data-access/tune-device.ts
  • src/device/device-feature-install.ts
  • src/device/device-feature-list.ts
  • src/device/device-feature-open.ts
  • src/device/device-feature-tune.ts
  • src/device/ui/device-ui-select-open-url.ts
  • src/localnet/data-access/apply-forwards.ts
  • src/localnet/data-access/localnet-types.ts
  • src/localnet/data-access/plan-forwards.ts
  • src/localnet/data-access/probe-device-port.ts
  • src/localnet/data-access/watch-forwards.ts
  • src/localnet/localnet-feature-check.ts
  • src/localnet/localnet-feature-forward.ts
  • src/localnet/localnet-feature-start.ts
  • src/localnet/localnet-feature-status.ts
  • src/localnet/localnet-feature-stop.ts
  • src/localnet/ui/localnet-ui-render-forwards.ts
  • src/playground/playground-feature-serve.ts
  • test/device.test.ts
  • test/localnet.test.ts

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

@changeset-bot

changeset-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 7abeaad

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

adb is a device concern, but its primitives lived in `localnet/data-access` because localnet needed them first. Device then grew its own commands on top and had to reach back into localnet for them — including `device/data-access/device-types.ts`, whose `ConnectedDevice extends AdbDevice` made device's own type file depend on localnet's. The command-factory series made this visible: `playground-feature-serve.ts` alone carried six imports into localnet, five of them for adb.

Moved to `device/data-access`: `adb-reverse.ts` and `list-adb-devices.ts` whole, and `openUrlOnDevice` split out of `probe-device-port.ts` into `open-url-on-device.ts`. `probeDevicePort` and `parseProbeExitCode` stay in localnet, since they take a `ResolvedLocalnetPort` and exist to prove a validator port is reachable. The `AdbDependencies`, `AdbDevice`, `AdbDeviceState` and `AdbReverseEntry` contracts move from `localnet-types.ts` into `device-types.ts`, next to the `ConnectedDevice` that extends one of them; localnet imports the two it still references rather than re-exporting anything.

The edge count does not drop — this is about direction. `device -> localnet` goes from 15 imports to none, and device no longer depends on localnet at all; localnet, playground and emulator now consume device's adb contracts as ordinary consumers. No dependency cycle is introduced: the only mutual pair in `src/` is `device <-> emulator`, which predates this change and comes from #40's shared tweak UI plus `list-connected-devices.ts` reading emulator AVD names.

The seven adb parser tests move from `test/localnet.test.ts` to `test/device.test.ts` with the code. `parseTcpPort` is still imported by the localnet suite, where it drives the fake adb harness rather than being the thing under test. `parseContainerStatus` and `parseProbeExitCode` stay behind.

No behaviour change: 487 tests pass with and without a TTY, and `device list --json`, `device open`, and `localnet status --json` were each run against a live emulator, exercising the moved listing, reverse and intent paths end to end.
@beeman
beeman force-pushed the beeman/move-adb-primitives-to-device branch from 6c46831 to 7abeaad Compare September 4, 2026 00:50
@pkg-pr-new

pkg-pr-new Bot commented Sep 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

bun add https://pkg.pr.new/solana-mobile/solana-mobile-cli/solana-mobile@48

commit: 7abeaad

@beeman
beeman added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit 6c33233 Sep 4, 2026
7 checks passed
@beeman
beeman deleted the beeman/move-adb-primitives-to-device branch September 4, 2026 01:29
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