Skip to content

Fix debug adapter config bugs and add missing config options#66

Merged
MrSubidubi merged 3 commits into
zed-extensions:mainfrom
nelsoncampos-cloudwalk:fix/hot-reload-and-rerun-session
Jul 17, 2026
Merged

Fix debug adapter config bugs and add missing config options#66
MrSubidubi merged 3 commits into
zed-extensions:mainfrom
nelsoncampos-cloudwalk:fix/hot-reload-and-rerun-session

Conversation

@nelsoncampos-cloudwalk

@nelsoncampos-cloudwalk nelsoncampos-cloudwalk commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Fix several bugs in the debug adapter configuration and add missing config options.

Bug fixes:

  • type field in DAP config was set to the tool binary name (flutter.bat on Windows) instead of "flutter"/"dart", breaking the debug adapter on Windows
  • stopOnEntry was hardcoded to false, ignoring the user's setting
  • flutterMode was hardcoded to "debug" — now reads from user config (supports debug, profile, release, test)
  • vmServiceUri: null was always included in the config even for launch requests, now only included when provided
  • fvm tasks had "command": "fvm flutter" (space in command), fixed to "command": "fvm" with "flutter" as first arg
  • Typo: "Weather" → "Whether" in schema

New config options:

  • toolArgs — pass arguments to the Flutter/Dart tool (e.g. --flavor, -d chrome)
  • env — environment variables for the debug adapter
  • flutterMode — configurable Flutter mode
  • sendLogsToClient: true — enables debug adapter log forwarding to Zed

@cla-bot cla-bot Bot added the cla-signed label Mar 11, 2026
- Fix `type` field sending "flutter.bat" instead of "flutter" on Windows
- Fix `stopOnEntry` being hardcoded to false, now reads user config
- Fix `flutterMode` being hardcoded to "debug", now configurable
- Fix `vmServiceUri: null` always sent in config, now only when provided
- Fix `fvm` task commands using invalid "fvm flutter" as command
- Add `toolArgs`, `env`, and `flutterMode` config support
- Add `sendLogsToClient: true` for debug log forwarding
- Fix typo "Weather" -> "Whether" in schema

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nelsoncampos-cloudwalk
nelsoncampos-cloudwalk force-pushed the fix/hot-reload-and-rerun-session branch from 4f7cf5e to 1a2e06b Compare March 11, 2026 02:58
@nelsoncampos-cloudwalk nelsoncampos-cloudwalk changed the title Fix debug adapter config bugs and add hot reload tasks Fix debug adapter config bugs and add missing config options Mar 11, 2026

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

Looks good overall, could you please look into the CI issue?

@TateWalker

TateWalker commented Jun 12, 2026

Copy link
Copy Markdown

I'm interested in seeing this PR merged @nelsoncampos-cloudwalk if you could address the changes. Copilot in the runner logs helps explain the fix

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

Thanks!

@MrSubidubi
MrSubidubi merged commit ea81a30 into zed-extensions:main Jul 17, 2026
5 checks passed
MrSubidubi pushed a commit that referenced this pull request Jul 20, 2026
## Summary

Closes #85.

The `device_id` field in `.zed/debug.json` is currently a no-op for
Flutter launches. The extension reads it and forwards it as `deviceId`
in the DAP launch JSON, but Flutter's DAP
(`flutter_tools/lib/src/debug_adapters/flutter_adapter.dart`) does not
read that field — `grep -r deviceId
packages/flutter_tools/lib/src/debug_adapters/` returns a single hit and
it's a comment. Only `toolArgs` is forwarded to `flutter run --machine`.

This PR forwards `device_id` as `["-d", <id>]` in `toolArgs` so device
selection actually works, and defines how it interacts with the
user-facing `toolArgs` option added in #66.

## Changes

- `src/dart.rs`:
- When `device_id` is set explicitly, append `["-d", <id>]` to the
user's `toolArgs` — but only if the user hasn't already passed a device
flag (`-d` / `--device-id`) themselves. In that case the user's
`toolArgs` takes precedence.
- The injection is gated to `flutter` mode only (`dart run` has no `-d`
flag).
- If `device_id` is not set, nothing is injected — Flutter's auto-pick
stays in effect (preserves current behavior for users who don't specify
a device).
- Removed the phantom `"chrome"` default for the `deviceId` JSON field.
It was never read by Flutter's DAP, and now that device selection flows
through `-d`, an unconditional default there would hijack Flutter's
auto-pick. `deviceId` is now emitted only when the user sets it, kept
purely for forward-compat in case Flutter ever wires it up.
- `debug_adapter_schemas/Dart.json`: documented `device_id` and its
precedence relative to `toolArgs`.

## Precedence

| User config | Result |
|---|---|
| `device_id` unset | Flutter auto-picks a device (unchanged) |
| `device_id: "macos"` | `flutter run -d macos` |
| `device_id` set + `-d`/`--device-id` already in `toolArgs` | user's
`toolArgs` wins, no injection |
| `type: "dart"` | no `-d` injection (dart has no device flag) |

## Verification

**DAP-level** (hand-built launch requests piped to `flutter
debug_adapter`, Flutter 3.41.6 stable):

| Launch JSON | Result |
|---|---|
| `{"deviceId": "macos", ...}` (old behavior) | "More than one device
connected", exits |
| `{"toolArgs": ["-d", "macos"], ...}` (this PR) | macOS app launches
successfully |

**End-to-end in Zed** (patched extension installed as a dev extension,
Flutter 3.41.6, with an Android emulator + macOS desktop + Chrome web
all available):

- [x] `device_id: "macos"` → launches on macOS (previously hijacked to
the running emulator)
- [x] No `device_id` set → Flutter's auto-pick selects the emulator
(current behavior unchanged)
- [x] `device_id` + explicit `-d` in `toolArgs` → user's `toolArgs` wins

## Related

- #66 added the user-facing `toolArgs` config field. This PR builds on
it: `device_id` is merged into `toolArgs`, with the user's explicit
device flag taking precedence.
- #72 includes the same `-d <id>` via `toolArgs` mechanism as part of
its hot-reload feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants