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

feat(core): workspace watcher #5200

Merged
merged 10 commits into from
Mar 1, 2025
Merged

Conversation

arendjr
Copy link
Contributor

@arendjr arendjr commented Feb 25, 2025

Summary

🎉

(it keeps the workspace in the daemon in sync with the FS)

Test Plan

Test added.

@github-actions github-actions bot added A-CLI Area: CLI A-Core Area: core A-Project Area: project A-LSP Area: language server protocol labels Feb 25, 2025
@arendjr arendjr marked this pull request as draft February 25, 2025 15:50
Copy link

codspeed-hq bot commented Feb 25, 2025

CodSpeed Performance Report

Merging #5200 will not alter performance

Comparing arendjr:workspace-watcher (a79b116) with main (8d9d282)

Summary

✅ 97 untouched benchmarks

@@ -204,3 +193,23 @@ impl Projects {
!is_feature_included
}
}

#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved this block because it was annoying that the definition was in the middle between the Projects definition and its implementation.

@arendjr arendjr marked this pull request as ready for review February 26, 2025 15:53
@arendjr arendjr requested review from a team February 26, 2025 15:53
Fixes + test

Fix Windows tests (no need for snapshots)
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

That's awesome! Thank you for implementing this 🥇

I left some questions because the PR description doesn't cover much. Also some here:

  • how do we handle symbolic links?
  • is there some documentation that we can provide to our maintainers on how to debug things? A file watcher is a hassle, so we should at least give as much information as possible to our maintainers (me included! 🤣 ) to how to debug things and test things

@@ -555,7 +559,7 @@ pub struct OpenFileParams {
pub project_key: ProjectKey,
pub path: BiomePath,
pub content: FileContent,
pub version: i32,
pub version: Option<i32>,
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason behind this change? Maybe we should document it, so we know when the version should be provided

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yes, I'll add a comment for that! Basically, it doesn't really make sense to provide except in the LSP use case where versions are explicitly specified. We used to provide 0 everywhere else anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm thinking now I'll just move the version into the FileContent enum, so you only can provide it when also explicitly providing the content.

Comment on lines 632 to 711
pub(super) fn update_service_data_with_added_or_updated_path(
&self,
path: &Utf8Path,
) -> Result<(), WorkspaceError> {
let path = BiomePath::from(path);
if path.is_manifest() {
self.update_project_layout_for_added_or_changed_path(&path)?;
}

self.update_dependency_graph_for_paths(&[path], &[]);

Ok(())
}

pub(super) fn update_service_data_with_removed_path(
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we can unify these functions by using an enum to distinguish when a file is added/updated/removed:

enum Signal<'a> {
	AddOrUpdate(&'a Utf8Path),
	Remove(&'a Utf8Path)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a WatcherSignalKind. Saves a bit of duplication indeed :)

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
@arendjr
Copy link
Contributor Author

arendjr commented Feb 27, 2025

@ematipico I've added a CONTRIBUTING.md for biome_service with some pointers on debugging the watcher.

Regarding symlinks, I wouldn't be surprised if there are some bugs lurking there, probably more related to the scanner in general, than the watcher specifically. I'm not even sure how to go about testing all such scenarios except to see what users report 😅

@ematipico
Copy link
Member

Yeah I suppose we will have to roll up our sleeves and start fixing cases reported by the users as we go :)

@arendjr arendjr merged commit 3836afd into biomejs:main Mar 1, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: CLI A-Core Area: core A-LSP Area: language server protocol A-Project Area: project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants