Skip to content

Conversation

Dixzz
Copy link

@Dixzz Dixzz commented Jun 20, 2025

🧩 Summary

This PR integrates Dart Debug Adapter Protocol (DAP) support into zed-extensions/dart, allowing interactive debugging sessions directly within Zed via dart debug_adapter

IMPORTANT

Make sure you have: in project path .zed/debug.json

[
  {
    "label": "Debug Flutter App",
    "adapter": "Dart", // DO NOT EDIT
    "type": "flutter",
    "program": "lib/main.dart",
    "args": ["--web-port=9090"]
  }
]

Steps shown:

  1. Launch Debug Flutter App task in Zed using F4 or command pallet debugger: start
  2. Hit breakpoint at main.dart
  3. Inspect variable frames
  4. Step through code

📸 Screenshots

Description Image
Debug session launched screenshot1

All supported schema for .zed/debug.json config

{
    "adapter": {
      "type": "string",
      "enum": ["Dart"]
    },
    "type": {
      "type": "string",
      "enum": ["dart", "flutter"],
      "description": "Debug Flutter or Dart file"
    },
    "label": {
      "type": "string",
      "description": "Human-readable name for this debug configuration",
      "examples": ["Launch Dart App", "Debug Main", "Dart Console"]
    },
    "program": {
      "type": "string",
      "description": "Path to the Dart file to debug",
      "examples": ["lib/main.dart", "bin/main.dart", "test/example_test.dart"]
    },
    "args": {
      "type": "array",
      "description": "Arguments passed to the Dart program.",
      "items": {
        "type": "string"
      },
      "default": []
    },
    "device_id": {
      "type": "string",
      "examples": ["chrome", "edge", "<android-id>", "<ios-id>"]
    },
    "platform": {
      "type": "string",
      "examples": ["web", "desktop"]
    },
    "stopOnEntry": {
      "type": "boolean",
      "description": "Pause debugger on entry.",
      "default": false
    }
  }

This comment was marked as resolved.

@Dixzz

This comment was marked as resolved.

@cla-bot cla-bot bot added the cla-signed label Jun 20, 2025

This comment was marked as resolved.

@Dixzz
Copy link
Author

Dixzz commented Jun 20, 2025

Tested on:
Zed Preview: v0.192.3-pre
Flutter Version: Flutter 3.29.3

@Dixzz Dixzz mentioned this pull request Jun 21, 2025
@maxdeviant maxdeviant changed the title support debug/flutter adapter, update zed deps Support debug/flutter adapter, update Zed dependencies Jun 23, 2025
@aikins01
Copy link

@Dixzz I'd like to take over working on this

@dario-valles
Copy link

Any way I can help on this? I really would like to see this live! @Dixzz @aikins01 ?

Dixzz added 2 commits July 23, 2025 23:14
Align the name of adapter with standards
@Dixzz
Copy link
Author

Dixzz commented Jul 23, 2025

@aikins01 @dario-valles
There aren't any implementation at this moment but we can work on it at our pace

  1. fvm custom path for flutter SDK binaries
  2. Cross platform support (windows, mac, linux) when debugger is active (currently tested on Linux)

@felipecarvalho
Copy link

Any way I can help on this? I really would like to see this live! @Dixzz @aikins01 ?

Me too, we need this feature 🎉

@caturbgs
Copy link

Is there any ETA for this PR? 👀👀

@fstof
Copy link

fstof commented Aug 1, 2025

I tested now on Zed 0.197.3
Installed this PR extension

I can't say that it works for me.
Hitting F4 shows the debug tasks as specified in debug.json but they do nothing

Plain dart as well as flutter apps do not start up
Here is my .zed/debug.json

[
  {
    "label": "Debug Flutter App",
    "adapter": "dart",
    "type": "flutter",
    "program": "lib/main.dart",
    "args": ["--web-port=9090"]
  },
  {
    "adapter": "dart",
    "type": "dart",
    "label": "Launch Dart App",
    "program": "lib/plain.dart",
    "stopOnEntry": false
  }
]

Am I missing something?

@dcrebbin
Copy link

dcrebbin commented Aug 6, 2025

Any updates on this

@peet0r
Copy link

peet0r commented Aug 10, 2025

Confirmed this PR is functional on Zed 0.198.5 when the following is added to .zed/debug.json in my flutter project:

{
    "label": "Debug Flutter App",
    "adapter": "Dart",
    "type": "flutter",
    "program": "lib/main.dart",
    "args": ["--web-port=9090", "-d", "macos"]
  }

Please note the device was set to macos so update for your device[s].

How much testing to we need to undertake to get this merged?

@peet0r
Copy link

peet0r commented Aug 10, 2025

I guess I should compile a few readme improvements...I'll push those shortly.

@Dixzz
Copy link
Author

Dixzz commented Aug 11, 2025

I tested now on Zed 0.197.3 Installed this PR extension

I can't say that it works for me. Hitting F4 shows the debug tasks as specified in debug.json but they do nothing

Plain dart as well as flutter apps do not start up Here is my .zed/debug.json

[
  {
    "label": "Debug Flutter App",
    "adapter": "dart",
    "type": "flutter",
    "program": "lib/main.dart",
    "args": ["--web-port=9090"]
  },
  {
    "adapter": "dart",
    "type": "dart",
    "label": "Launch Dart App",
    "program": "lib/plain.dart",
    "stopOnEntry": false
  }
]

Am I missing something?

Please provide:

Logs of flutter doctor
Zed version used
Platform you're running on

@peet0r
Copy link

peet0r commented Aug 11, 2025

FYI @Dixzz @fstof, the change from dart -> Dart tricked me during setup. When using dart with zed --foreground the logs were silent, which was confusing

@vleeuwenmenno
Copy link

vleeuwenmenno commented Aug 13, 2025

I can confirm the same issue as @fstof, I can see the debug targets but spawning them does nothing.

image
[
  {
    "label": "Debug Flutter App",
    "adapter": "dart",
    "type": "flutter",
    "program": "lib/main.dart",
    "args": ["--web-port=9090"]
  }
]

On 801b322 for this extension (dart) and Flutter version 3.32.8

❯ zed --version
Zed 0.198.5 – /usr/lib/zed/zed-editor

EDIT: Can confirm it does work with the correct adapter name 😅

[
  {
    "label": "Debug Flutter App",
    "adapter": "Dart",
    "type": "flutter",
    "program": "lib/main.dart",
    "args": ["--web-port=9090"]
  }
]

@Dixzz
Copy link
Author

Dixzz commented Aug 13, 2025

Thank you @vleeuwenmenno I've updated the same

@fstof
Copy link

fstof commented Aug 15, 2025

I can also confirm the capitalisation fixed it

Thanks

[EDIT]
I think the issue is the linter / schema specifies "dart" and warns when using "Dart" on the adapter

@fstof
Copy link

fstof commented Aug 17, 2025

One more crucial thing i think is missing here.
The ability to specify the current working directory. Like the .zed/tasks.json allows "cwd" and zed folder variables (like $ZED_WORKTREE_ROOT) I think this adapter would need the same.

Copy link

@fstof fstof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes worked for me... Use it... or don't

Thank you for working on this. We all really appreciate it

"description": "Path to the Dart file to debug",
"examples": ["lib/main.dart", "bin/main.dart", "test/example_test.dart"]
},
"args": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the cwd property

    "cwd": {
      "type": "string",
      "description": "Path to the working directory"
    },

.get("platform")
.and_then(|v| v.as_str())
.unwrap_or("web");
let cwd = Some(worktree.root_path());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updating the cwd to use the user configured one

        let cwd = user_config
            .get("cwd")
            .and_then(|v| v.as_str())
            .map(|s| s.to_string())
            .or_else(|| Some(worktree.root_path()));

@mark-nicepants
Copy link

I tried it, works on mac with "Dart" as adapter name, but with said lint warning.

@aesmail
Copy link

aesmail commented Aug 20, 2025

@Dixzz using macOS here, this is amazing! Can't wait for this to be merged even with a minimum feature-set. We (the community) can help and improve on it gradually.

@bubnov
Copy link

bubnov commented Aug 22, 2025

@Dixzz is there something blocking the PR? Is it awaited for QA or maybe somebody from the zed team needs to be mentioned?

Copy link
Contributor

@osiewicz osiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
@Dixzz is there anything you'd like to follow up with?

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.