Add hot reload and hot restart custom actions#72
Draft
paulocagol wants to merge 1 commit into
Draft
Conversation
Implement `get_dap_custom_actions` to expose Flutter hot reload and hot restart as custom debug actions. Hot reload triggers both on toolbar click and on file save; hot restart is toolbar-only. Also fix device selection by passing `-d <device_id>` via `toolArgs` in the launch configuration. Depends on zed-industries/zed#51873 (custom debug actions Extension API). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
We require contributors to sign our Contributor License Agreement, and we don't have @paulocagol 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'. |
8 tasks
Author
|
@cla-bot check |
|
We require contributors to sign our Contributor License Agreement, and we don't have @paulocagol 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'. |
|
The cla-bot has been summoned, and re-checked this pull request! |
Author
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
rwrz
added a commit
to rwrz/zed-flutter
that referenced
this pull request
May 4, 2026
Three new tasks reachable from the pubspec gutter button (default device / macOS / Chrome) plus a documented keymap snippet that binds cmd-r, cmd-shift-r, cmd-q to terminal::SendText for hot reload, hot restart, and quit while the terminal pane is focused. This is a workaround until zed#51873 + zed-extensions/dart#72 land and expose the DAP-based hot reload as a proper toolbar button. CLAUDE.md documents the rationale. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 7, 2026
MrSubidubi
marked this pull request as draft
May 27, 2026 10:59
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.
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
Flutter/Dart applications
trigger: Both)trigger: Toolbar)-d <device_id>viatoolArgsDepends on: zed-industries/zed#51873 (custom debug actions Extension API).
Both PRs are intended to be reviewed and merged together.
Test plan
buttons appear in toolbar
device_id: "macos"launches on macOS)Release Notes: