mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Update logging levels in Rojo plugin and enhance test plans
- Promoted sync-related logging from Debug/Trace to Info level across multiple files, ensuring visibility of changes in the Studio output console. - Added a new plan for expanding the connected mode test suite to cover multi-step scenarios and round-trip identity verification. - Introduced a plan to fix stale tree desynchronization by implementing a validation mechanism on plugin connection. - Created a plan to bump sync logging to Info level, detailing todos for various components in the plugin. This update improves the clarity of logs and enhances testing coverage for connected mode scenarios.
This commit is contained in:
parent
2cc1726975
commit
316d7ea70e
17 changed files with 2443 additions and 1553 deletions
|
|
@ -23,6 +23,9 @@ use crate::{
|
|||
snapshot_middleware::snapshot_from_vfs,
|
||||
};
|
||||
|
||||
/// Set to `true` to validate on plugin connect (useful for testing, do not enable on production).
|
||||
const VALIDATE_TREE_ON_CONNECT: bool = false;
|
||||
|
||||
/// Contains all of the state for a Rojo serve session. A serve session is used
|
||||
/// when we need to build a Rojo tree and possibly rebuild it when input files
|
||||
/// change.
|
||||
|
|
@ -142,6 +145,7 @@ impl ServeSession {
|
|||
Arc::clone(&message_queue),
|
||||
tree_mutation_receiver,
|
||||
Arc::clone(&suppressed_paths),
|
||||
root_project.folder_location().to_path_buf(),
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
|
|
@ -259,6 +263,67 @@ impl ServeSession {
|
|||
.map(|rules| rules.ignore_hidden_services())
|
||||
.unwrap_or(true)
|
||||
}
|
||||
|
||||
/// Re-snapshots the project tree from the real filesystem and patches
|
||||
/// the in-memory tree to correct any drift caused by missed VFS watcher
|
||||
/// events. Called on plugin connect to guarantee the tree is fresh.
|
||||
///
|
||||
/// Skipped on freshly-started sessions (< 5 s) where the tree is
|
||||
/// guaranteed correct and the VFS watcher should handle all changes.
|
||||
///
|
||||
/// Controlled by [`VALIDATE_TREE_ON_CONNECT`]; set that constant to
|
||||
/// `false` to disable this entirely during testing.
|
||||
pub fn validate_tree(&self) -> Vec<AppliedPatchSet> {
|
||||
if !VALIDATE_TREE_ON_CONNECT {
|
||||
log::debug!("Tree validation skipped (VALIDATE_TREE_ON_CONNECT = false)");
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
// On a freshly-started session the tree was just built from the
|
||||
// filesystem and cannot be stale. Skip validation to avoid racing
|
||||
// with the VFS watcher on early file changes.
|
||||
const MIN_SESSION_AGE: std::time::Duration = std::time::Duration::from_secs(5);
|
||||
if self.start_time.elapsed() < MIN_SESSION_AGE {
|
||||
log::debug!(
|
||||
"Tree validation skipped (session age {:.1?} < {:.1?})",
|
||||
self.start_time.elapsed(),
|
||||
MIN_SESSION_AGE
|
||||
);
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
let start = Instant::now();
|
||||
let start_path = self.root_project.folder_location();
|
||||
let instance_context = InstanceContext::new();
|
||||
|
||||
let snapshot = match snapshot_from_vfs(&instance_context, &self.vfs, start_path) {
|
||||
Ok(s) => s,
|
||||
Err(e) => {
|
||||
log::error!("Tree validation snapshot error: {:?}", e);
|
||||
return Vec::new();
|
||||
}
|
||||
};
|
||||
|
||||
let mut tree = self.tree.lock().unwrap();
|
||||
let root_id = tree.get_root_id();
|
||||
let patch_set = compute_patch_set(snapshot, &tree, root_id);
|
||||
|
||||
if patch_set.removed_instances.is_empty()
|
||||
&& patch_set.added_instances.is_empty()
|
||||
&& patch_set.updated_instances.is_empty()
|
||||
{
|
||||
log::info!(
|
||||
"Tree validation complete (no corrections needed) in {:.1?}",
|
||||
start.elapsed()
|
||||
);
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
log::info!("Tree validation found stale state, applying corrections");
|
||||
let applied = apply_patch_set(&mut tree, patch_set);
|
||||
log::info!("Tree validation complete in {:.1?}", start.elapsed());
|
||||
vec![applied]
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue