Skip to content

Replace Tokio Thread File Watcher with LSP Client File Watcher #7147

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 13 commits into from
May 5, 2025

Conversation

JoshuaBatty
Copy link
Member

@JoshuaBatty JoshuaBatty commented May 5, 2025

Description

This PR replaces our custom Tokio-based thread watcher for Forc.toml files with the built-in LSP didChangeWatchedFiles notification system. The changes:

  • Remove the Tokio thread-based file watching system and associated cleanup code
  • Implement client-side file watching registration during initialization
  • Handle Forc.toml file changes through the LSP notification protocol
  • Update tests to use the new notification system
  • Simplify manifest syncing with a direct approach

This approach is more efficient as it leverages the client's native file watching capabilities rather than spawning a separate thread. The PR maintains the same functionality while reducing resource usage and complexity.

Note: This doesn't yet implement the recompilation on Forc.toml changes as mentioned in issue #7103, but adds a TODO placeholder for that functionality.

This PR is a precursor to #7139

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@JoshuaBatty JoshuaBatty requested a review from a team as a code owner May 5, 2025 01:04
@JoshuaBatty JoshuaBatty changed the title sync manifest changes using did_change_watched_files instead of in a tokio thread sync manifest changes using did_change_watched_files instead of in a tokio thread May 5, 2025
@JoshuaBatty JoshuaBatty marked this pull request as draft May 5, 2025 01:04
@JoshuaBatty JoshuaBatty self-assigned this May 5, 2025
@JoshuaBatty JoshuaBatty added the language server LSP server label May 5, 2025
@JoshuaBatty JoshuaBatty changed the title sync manifest changes using did_change_watched_files instead of in a tokio thread Replace Tokio Thread File Watcher with LSP Client File Watcher May 5, 2025
Copy link

codspeed-hq bot commented May 5, 2025

CodSpeed Performance Report

Merging #7147 will not alter performance

Comparing josh/didChangeWatchedFiles (8599f19) with master (1c885cf)

Summary

✅ 22 untouched benchmarks

@JoshuaBatty JoshuaBatty force-pushed the josh/didChangeWatchedFiles branch from 4d0b9a3 to e0a4646 Compare May 5, 2025 03:34
@JoshuaBatty JoshuaBatty marked this pull request as ready for review May 5, 2025 04:00
@JoshuaBatty JoshuaBatty requested a review from a team as a code owner May 5, 2025 04:00
@JoshuaBatty JoshuaBatty requested a review from a team May 5, 2025 05:09
Copy link
Contributor

@IGI-111 IGI-111 left a comment

Choose a reason for hiding this comment

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

Always nice to see a PR with net negative line count!

@IGI-111 IGI-111 merged commit 804d6df into master May 5, 2025
41 checks passed
@IGI-111 IGI-111 deleted the josh/didChangeWatchedFiles branch May 5, 2025 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants