From 345d36cda5b748d202eb5c63169545c5fe29348f Mon Sep 17 00:00:00 2001 From: Joe Date: Sat, 7 Mar 2026 14:41:17 -0600 Subject: [PATCH] Refactor VFS event logging and streamline ServeSession watch setup - Changed VFS event logging from INFO to DEBUG level for better performance and reduced verbosity during normal operations. - Removed unnecessary project folder variable and redundant watch calls in ServeSession, enhancing clarity and efficiency in the watch setup process. --- src/change_processor.rs | 15 ++++++--------- src/serve_session.rs | 13 +++++-------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/change_processor.rs b/src/change_processor.rs index 26806e4d..28f2f112 100644 --- a/src/change_processor.rs +++ b/src/change_processor.rs @@ -657,14 +657,11 @@ impl JobThreadContext { } fn handle_vfs_event(&self, event: VfsEvent) -> Vec { - // Log EVERY VFS event at INFO level for diagnostics. - // This is intentionally verbose — it is critical for debugging - // file watcher desync issues (e.g., rapid delete+recreate). match &event { - VfsEvent::Create(path) => log::info!("VFS event: CREATE {}", self.display_path(path)), - VfsEvent::Write(path) => log::info!("VFS event: WRITE {}", self.display_path(path)), - VfsEvent::Remove(path) => log::info!("VFS event: REMOVE {}", self.display_path(path)), - _ => log::info!("VFS event: OTHER {:?}", event), + VfsEvent::Create(path) => log::debug!("VFS event: CREATE {}", self.display_path(path)), + VfsEvent::Write(path) => log::debug!("VFS event: WRITE {}", self.display_path(path)), + VfsEvent::Remove(path) => log::debug!("VFS event: REMOVE {}", self.display_path(path)), + _ => log::debug!("VFS event: OTHER {:?}", event), } // Check if this event should be suppressed (one-shot, from API syncback). @@ -699,7 +696,7 @@ impl JobThreadContext { self.vfs .commit_event(&event) .expect("Error applying VFS change"); - log::info!( + log::debug!( "VFS event SUPPRESSED (API syncback echo): {}", self.display_path(path) ); @@ -726,7 +723,7 @@ impl JobThreadContext { #[cfg(target_os = "windows")] if let VfsEvent::Write(ref path) = event { if path.is_dir() { - log::info!( + log::debug!( "VFS event SKIPPED (directory WRITE, deferring to file events): {}", self.display_path(path) ); diff --git a/src/serve_session.rs b/src/serve_session.rs index f3235b1c..b6e555c4 100644 --- a/src/serve_session.rs +++ b/src/serve_session.rs @@ -370,7 +370,6 @@ impl ServeSession { vfs.clear_prefetch_cache(); let patch_start = Instant::now(); - let project_folder = root_project.folder_location().to_path_buf(); let watch_ignore_rules = root_project.path_ignore_rules(); std::thread::scope(|s| { s.spawn(|| { @@ -386,6 +385,11 @@ impl ServeSession { // watches are required because kqueue directory watches // only fire for structural changes, not child content edits. let passes_ignore = |entry: &walkdir::DirEntry| -> bool { + if let Some(name) = entry.file_name().to_str() { + if matches!(name, ".git" | ".hg" | ".svn") { + return false; + } + } watch_ignore_rules .iter() .all(|rule: &PathIgnoreRule| rule.passes(entry.path())) @@ -393,7 +397,6 @@ impl ServeSession { vfs.set_watch_recursive(false); for root in &path_roots { for entry in WalkDir::new(root) - .follow_links(true) .into_iter() .filter_entry(&passes_ignore) .flatten() @@ -402,8 +405,6 @@ impl ServeSession { watch_count += 1; } } - let _ = vfs.watch(&project_folder); - watch_count += 1; vfs.set_watch_recursive(true); } else { // Linux/Windows: inotify uses a single FD for all watches, @@ -415,10 +416,6 @@ impl ServeSession { let _ = vfs.watch(root); watch_count += 1; } - vfs.set_watch_recursive(false); - let _ = vfs.watch(&project_folder); - vfs.set_watch_recursive(true); - watch_count += 1; } log::debug!( "Set up {} watches in {:.1?}",