flutter / devtools

Performance tools for Flutter
https://flutter.dev/docs/development/tools/devtools/
BSD 3-Clause "New" or "Revised" License
1.58k stars 324 forks source link

Refactor VS Code sidebar to make more generic and align with new DTD APIs #7918

Closed DanTup closed 3 months ago

DanTup commented 3 months ago

I'm working on supporting the Sidebar over DTD. The full in-progress change is at https://github.com/flutter/devtools/pull/7919 but it's getting quite large since the DTD API is slightly different (better) than the postMessage one and we should support both for some transition period (to handle old editor plugin versions). The plan is to build the new DTD APIs and then just provide wrappers around the postMessage API to make it the same (so the sidebar code can just work against one interface).

This PR takes all the non-DTD implementation from that PR which is basically a refactor of the postMessage classes, the sidebar (to use the new DTD-like APIs) and tests (again, to use the new DTD-like APIs). This will make the next PRs smaller because they're just adding the DTD implementation without changing the sidebar implementation, tests etc.

There are some differences in how the APIs work.. the new API will get getDevices() and then deviceAdded events, whereas the postMessage API just sends a devicesUpdated event with the full set of devices on every change (and always sends an initial set as part of initialization). The wrapper (PostMessageEditorClient) handles these differences.

A summary of the changes:

DanTup commented 3 months ago

@kenzieschmoll @CoderDake I have a mostly-working sidebar over DTD (in the mock editor... haven't done any real Dart-Code side yet) in https://github.com/flutter/devtools/pull/7919 though it still needs some tweaks.

Since the change is quite large, I'm trying to split it up. This one adds the new DTD API interface, but doesn't use DTD yet. It just wraps the old postMessage API to behave like the new DTD one, allowing the sidebar code itself to be updated for the new API but still work with the existing postMessage API from VS Code. This is essentially a no-op refactor, but it means implementing the DTD part will not involve changes to some of these tests and the sidebar UI code.

DanTup commented 3 months ago

@kenzieschmoll I also added a readme with some notes to try and make things a little clearer.