Skip to content

feat: add Flutter-style device selector - #11

Merged
teoboetti merged 1 commit into
masterfrom
feature/device-selector
Oct 19, 2026
Merged

teoboetti merged 1 commit into
masterfrom
feature/device-selector

Conversation

@teoboetti

Copy link
Copy Markdown
Owner

Summary

A device selector modelled on the Flutter extension's (Dart-Code device_manager.ts):

  • Status bar item (far right): shows the selected device, e.g. Pixel_7_API_34 (android emulator), iPhone 17 (ios simulator), Pixel 8 (android), or No Device. The tooltip shows how many devices are connected. Clicking it runs React Native: Select Device.
  • Picker ("Select a device to use"):
    • Available Devices lists everything running.
    • Offline Emulators has Start <AVD> rows (each with a cold-boot variant) and Start <iOS simulator> rows.
    • The list refreshes live while the picker is open.
  • Starting a device reuses the existing boot-and-wait code. Once the device connects it becomes the selected one. After booting a simulator it opens DeviceHub (Xcode 27+) or Simulator.app.
  • Selection rules follow Flutter's defaults:
    • The selection is saved per workspace.
    • A newly connected device becomes selected, unless the current device is one you picked.
    • Your picked device is re-selected when it reconnects.
  • F5: for Android and iOS launch configs, target is filled from the selected device when the config leaves it open: empty, or simulator/device when the device type matches. An explicit target always wins. A platform mismatch logs a one-line note and falls back to the existing behaviour. launch.json is never written.

Changes

  • New src/extension/deviceSelector.ts: pure helpers plus the DeviceSelector class (refresh, picker, launching, resolveDebugConfiguration).
  • New reactNative.selectDevice command and FailedToSelectDevice error code.
  • AndroidTargetManager.launchSimulator and IOSTargetManager.launchSimulator are now public. Android takes a coldBoot flag (-no-snapshot-load).
  • Removed DeviceStatusIndicator; the new status bar item replaces it.

Refreshing

  • Every 5 s, only while the window is focused, plus immediately on focus and when the picker opens.
  • Physical iPhones (xctrace, about 2.5 s per call) refresh every 6th tick and when the picker opens.
  • Failures, such as a missing SDK, are logged once per source.

Testing

  • 22 new unit tests: status bar text, picker items, selection rules, the F5 target rule, Android device mapping, and the cold-boot argument.
  • npm test: 496 passing, 0 failing.
  • npx gulp lint: clean.
  • Installed as a dev VSIX in VSCodium and checked by hand.

Known limitations

  • A physical iPhone can take up to about 30 s to appear in the status bar. It appears at once in the picker.
  • Configs where the extension already saved a target into launch.json keep using it. Delete that line to let the selector drive.
  • Android emulators are listed with emulator from PATH, as the existing "Launch Android Emulator" command does.

Status bar item (right side) shows the selected device and opens a picker
listing running devices and offline emulators/simulators. Starting an
offline Android emulator (normal or cold boot) or iOS simulator selects it
once it connects. The selection is saved per workspace and fills `target`
for Android/iOS launch configs that leave it open (empty, "simulator" or
"device"); an explicit target still wins.

- add DeviceSelector and the reactNative.selectDevice command
- make Android/iOS launchSimulator public; add Android cold boot flag
- open DeviceHub (Xcode 27+) or Simulator.app after booting a simulator
- remove DeviceStatusIndicator, replaced by the new status bar item
@teoboetti
teoboetti merged commit c142b25 into master Oct 19, 2026
1 check passed
@teoboetti
teoboetti deleted the feature/device-selector branch October 19, 2026 14:35
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