Forward device_id via toolArgs so Flutter run honors it#86
Open
FrantisekGazo wants to merge 1 commit intozed-extensions:mainfrom
Open
Forward device_id via toolArgs so Flutter run honors it#86FrantisekGazo wants to merge 1 commit intozed-extensions:mainfrom
FrantisekGazo wants to merge 1 commit intozed-extensions:mainfrom
Conversation
The top-level `deviceId` field in the DAP launch JSON is documented but not actually read by Flutter's DAP (only the comment at flutter_adapter.dart:425 mentions it). Only `toolArgs` are forwarded to `flutter run --machine`. Inject `["-d", device_id]` into `toolArgs` when the user sets `device_id` explicitly, so device selection works. Without this, `device_id: "macos"` (or any other id) is silently ignored and Flutter falls back to its auto-pick logic — yielding either "More than one device connected" errors or launches on the wrong device. Refs zed-extensions#85
|
We require contributors to sign our Contributor License Agreement, and we don't have @FrantisekGazo on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
Author
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #85.
The
device_idfield in.zed/debug.jsonis currently a no-op for Flutter launches. The extension reads it and forwards it asdeviceIdin the DAP launch JSON, but Flutter's DAP (flutter_tools/lib/src/debug_adapters/flutter_adapter.dart) does not actually read that field —grep -r deviceId packages/flutter_tools/lib/src/debug_adapters/returns a single hit and it's a comment. OnlytoolArgsis forwarded toflutter run --machine.This PR injects
["-d", device_id]intotoolArgswhen the user setsdevice_idexplicitly, so device selection actually works.Changes
src/dart.rs: whendevice_idis explicitly present in the user config, append["-d", <id>]to atoolArgsarray in the launch JSON. If the user did not setdevice_id, leavetoolArgsempty so Flutter's auto-pick stays in effect (preserves current behavior for users who don't specify a device).deviceIdJSON field is left in place for forward-compat in case Flutter ever wires it up.versionto0.3.7inextension.toml,Cargo.toml, andCargo.lock.Net diff: ~12 lines.
Verification
DAP-level (hand-built launch requests piped to
flutter debug_adapter, Flutter 3.41.6 stable):{"deviceId": "macos", ...}(current behavior){"toolArgs": ["-d", "macos"], ...}(this PR)End-to-end in Zed 1.1.6 (patched extension installed as a dev extension, Flutter 3.41.6, with an Android emulator + iPhone + macOS desktop + Chrome web all available):
device_id: "macos"→ launches on macOS (previously hijacked to the running emulator)device_id: "emulator-5554"→ launches on the emulatordevice_idset → Flutter's auto-pick selects the emulator (current behavior unchanged)cargo build --target wasm32-wasip1 --release)Related
toolArgsconfig field. That's complementary and would let users pass other flags (--flavor,--dart-define, ...). This PR is the minimal fix specifically fordevice_id.-d <device_id>viatoolArgsmechanism as part of its hot-reload feature.