Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an API to create extensions for the devtools #1632

Closed
simc opened this issue Feb 14, 2020 · 16 comments
Closed

Provide an API to create extensions for the devtools #1632

simc opened this issue Feb 14, 2020 · 16 comments
Assignees
Labels
devtools extensions Issues related to DevTools extensions highly-requested P1 high priority issues at the top of the work list, actively being worked on.
Milestone

Comments

@simc
Copy link

simc commented Feb 14, 2020

It would be very helpful if there was a way to create custom extensions for the devtool. For example, I'd like to write an extension to inspect the contents of the Hive DB. But I think there are many interesting extensions, the community could create.

The Stetho tool from Facebook allows something similar for the Chrome DevTools.

And the flipper tool also has a very powerful way to create extensions. It even allows creating custom UI.

@devoncarew devoncarew added this to the Backlog milestone Mar 3, 2020
@britannio
Copy link

britannio commented Apr 13, 2020

Few use cases

  • Monitoring network activity for a network package e.g. dio or graphql
  • Tracking state changes in Redux
  • Creating custom dashboards with key metrics for your app
  • Inspecting databases as @leisim suggested
  • ...

@cedvdb
Copy link

cedvdb commented Dec 23, 2021

The use cases are legion tbh, any kind of inspection of state is useful there. whatever state.

I would also like the possibility to have extension, but if that's not planned if there was a message bus mechanism where one could start another app that connects to that bus and display the required information with a desktop app it would be nice.

Let me rephrase this, if extensions is not planned, it would be nice to have the ability to:

  • start a flutter app that emits messages.
  • start another app that displays those messages.

Certainly this is doable today but my guess is that the process will be too involved (development wise) to not be solving 2 problems (making the extension + make a communication mechanism).

@simc
Copy link
Author

simc commented Jan 9, 2022

It would even be helpful to allow third parties to access an active debugging session without requiring the user to find the websocket link in the logs.

My use cases:

@simc
Copy link
Author

simc commented Jan 24, 2022

@kenzieschmoll Is there something we could help with to make this happen? Or are there alternatives? Riverpod and Provider are integrated into devtools. Can anyone submit an extension?

@jacob314
Copy link
Contributor

Here's a link to our in progress design on supporting Flutter DevTools Plugins. Comments appreciated! https://docs.google.com/document/d/1BWX8YQ962Vsx-EUDuDHRG7RX94fJlZSDRu299YRwasE/edit

@simc
Copy link
Author

simc commented Jan 24, 2022

@jacob314 Wow that is incredible 😍 can't wait to build some plugins

@rrousselGit
Copy link
Contributor

👋
Out of curiosity, when could this be made available and is there anything we can do to help? 🙏

I'm asking because I'm honestly considering making my own plugin mechanism through a custom VScode extension which would allow folks to contribute tabs.
I was considering a VScode extension because it enables the plugin mechanism to access the full VScode API.
So plugins could provide custom commands or implement their own "open a file at a given offset".

But if we're going to have plugins in a reasonable timeframe, this project may not be worth it anymore (since an official solution would have a bigger reach)

@jacob314
Copy link
Contributor

@kenzieschmoll is in the process of kicking this effort back off. VSCode API integration is interesting and we have use cases like editing Flutter widget properties where that would be helpful as well. It would be great to have you collaborate on the implementation of the official solution for this.

@rrousselGit
Copy link
Contributor

It's a bit unclear to me on what I could do to help. Do you have anything more specific?

Honestly, I wouldn't mind contributing to various aspects of the plugin mechanism. VScode API or not.

@kenzieschmoll
Copy link
Member

Hi @rrousselGit. I'm going to prioritize working on this design. I will keep you posted when I have some more specific details to share. Thanks!

@kenzieschmoll
Copy link
Member

The design for this feature is out for review:

  1. Flutter Developer Tooling Plugins. This doc aims to design a solution for DevTools and IDE plugins

Related:

  1. Dash Tooling Plugin Strategy. This doc aims to drive alignment on the "big hooks" for plugins across the broader flutter ecosystem. There is some overlap with the first doc, but this doc also involves some elements to drive consistency across analyzer and flutter tools plugins.

@kenzieschmoll kenzieschmoll added the devtools extensions Issues related to DevTools extensions label May 16, 2023
@kenzieschmoll
Copy link
Member

kenzieschmoll commented May 23, 2023

I've been working on a prototype to provide a proof of concept for the above designs.

Screencast link: https://screencast.googleplex.com/cast/NTk2MzgyOTQ4MjYxODg4MHxiODFhYjFiOC0yNA
Or watch video: DevTools Plugins Prototype.webm

This work is subject to change and needs a lot of cleanup, but early & rough prototype available with the combination of the following changes:

For testing, I am running app_that_uses_foo from here, which imports the foo_package from the same repo: https://github.com/kenzieschmoll/test_apps/tree/main/tooling_plugins, and I am connecting that app to devtools, built and served with dart devtools/tool/build_e2e.dart.

Note: for this to work properly, the app_that_uses_foo/.dart_tool/package_config.json entry for "foo_package" needs to use an absolute path, not a relative one:

    {
      "name": "foo_package",
      "rootUri": "../../foo_package", // Change to an absolute path
      "packageUri": "lib/",
      "languageVersion": "3.1"
    },

@kenzieschmoll
Copy link
Member

kenzieschmoll commented Jul 19, 2023

Implementation Tracker

DevTools app [COMPLETE]

Task list

package:devtools_extensions [COMPLETE]

Task list

package:devtools_app_shared [COMPLETE]

Task list

package:extension_discovery [COMPLETE]

Task list

package:devtools_server [COMPLETE]

Task list

Extensions land well

Task list

open questions / edge cases to consider

  1. What if a user manually edits the devtools_options.yaml file? Maybe we should ask the analysis server to watch this file and notify DevTools on changes (by proxy of the Dart tooling daemon eventually).
  2. Should we watch the package_config.json file? Should the watch logic exist somewhere in package:extension_discovery? @jonasfj

@jonasfj
Copy link
Member

jonasfj commented Jul 20, 2023

Initial draft for a package:extension_discovery in dart-lang/tools#129

@rrousselGit
Copy link
Contributor

Cool! Tell me whenever there's something I can play with :)

auto-submit bot pushed a commit that referenced this issue Jul 28, 2023
This endpoint manages reading and writing to/from the `devtools_options.yaml` file. This file will store DevTools extension activation states and will live in a project's root directory (similar to `analysis_options.yaml`).

Example `devtools_options.yaml` file:
```
extensions:
  - foo: true
  - bar: false
```
In this scenario:
- the devtools extension for `package:foo` has been enabled by the user 
- the devtools extension for `package:bar` has been disabled by the user
- the devtools extension for some other `package:baz` has been neither enabled nor disabled (meaning that DevTools should prompt the user to activate).

This API will be consumed by DevTools app in a follow up PR.

work towards #1632
@kenzieschmoll
Copy link
Member

kenzieschmoll commented Sep 26, 2023

This work has landed! Anyone wanting to write a DevTools extension should follow the instructions at https://pub.dev/packages/devtools_extensions. Extension support in DevTools just landed in the Dart SDK and should be available on Flutter master by the end of the week. This will be included in the next Flutter beta and stable releases. In the meantime, you can still develop your extension using the simulated DevTools environment described in the instructions.

package:provider has already published a DevTools extension for version 6.1.0-dev.1.

We are working on setting up a Discord channel specific to DevTools extension authors, but in the meantime you can reach out on Github or on the #hackers-devtools channel on the Flutter discord.

We are eager to hear early feedback on this feature and your input on how we can improve it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devtools extensions Issues related to DevTools extensions highly-requested P1 high priority issues at the top of the work list, actively being worked on.
Projects
None yet
Development

No branches or pull requests

8 participants