Skip to content

Add a RootsTrackingSupport mixin for servers, use it from DartAnalyzerSupport #85

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

Merged
merged 4 commits into from
Apr 25, 2025

Conversation

jakemac53
Copy link
Contributor

This mixin will be used by anything that wants to look at what the current roots are, so we can share that logic across them.

Likely we will want to add this to various other tools (like the command line tools).

Copy link

PR Health

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

);
} else {
if (supportsRootsChanged) {
rootsListChanged!.listen((event) {
Copy link
Contributor

Choose a reason for hiding this comment

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

double checking: does this listener need to be cancelled anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The controller for this stream gets cancelled when the client disconnects so no it shouldn't be necessary

);
expect(
server.roots,
completion(unorderedEquals([b, c, d])),
Copy link
Contributor

Choose a reason for hiding this comment

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

what happened to root a?

Copy link
Contributor Author

@jakemac53 jakemac53 Apr 25, 2025

Choose a reason for hiding this comment

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

It gets removed later on line 53 - this is an async expectation for a future that doesn't complete until the completer gets completed on line 55.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically the point of this is to test that if we get a roots changed event while we are currently listing roots, we won't ever surface the intermediate state, we will wait for the nest listRoots call.

@@ -21,14 +21,21 @@ base mixin DartCliSupport on ToolsSupport, LoggingSupport
implements ProcessManagerSupport {
@override
FutureOr<InitializeResult> initialize(InitializeRequest request) {
String? unsupportedReason;
if (request.capabilities.roots == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: since each tool specifies roots as an input parameter, do we need to require roots for this?

Copy link
Contributor Author

@jakemac53 jakemac53 Apr 25, 2025

Choose a reason for hiding this comment

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

Sure for now I can just remove this instead of making it not throw.

Longer term we might want to still enforce that we will only run these tools inside one of the specified roots, just to keep the AI on the rails. As an example, what if it somehow gets into the pub cache and starts trying to edit files or run commands 😱 .

@auto-submit auto-submit bot merged commit a1b441d into main Apr 25, 2025
24 checks passed
@auto-submit auto-submit bot deleted the consistent-root-configs branch April 25, 2025 17:20
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.

2 participants