Update syncback feature to handle instance pulling from Studio

- Updated the `ServeSession` to implement logic for pulling instances that exist in Studio but not in Rojo's filesystem, creating appropriate files during sync confirmation.
- Introduced a new `encodeInstance` function to serialize Studio instances for transmission, supporting all instance types.
- Modified the `PatchTree` to allow explicit user selection for push/pull/skip actions, enhancing user control during sync operations.
- Added tests for the new encoding functionality and updated existing tests to ensure proper behavior with the new syncback logic.
This commit is contained in:
Joe 2026-01-30 07:18:10 -06:00
parent ace839e46f
commit c7cddb72c2
15 changed files with 3534 additions and 39 deletions

View file

@ -248,6 +248,24 @@ pub struct ReadResponse<'a> {
pub instances: HashMap<Ref, Instance<'a>>,
}
/// Instance data for creating new instances via the write API
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AddedInstance {
/// The parent instance's Ref (must exist in Rojo's tree)
pub parent: Ref,
/// The instance name
pub name: String,
/// The class name (e.g., "ModuleScript", "Script", "LocalScript")
pub class_name: String,
/// Properties to set on the instance
#[serde(default)]
pub properties: HashMap<String, Variant>,
/// Children instances (recursively encoded for hierarchical syncback)
#[serde(default)]
pub children: Vec<AddedInstance>,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WriteRequest {
@ -255,7 +273,7 @@ pub struct WriteRequest {
pub removed: Vec<Ref>,
#[serde(default)]
pub added: HashMap<Ref, ()>,
pub added: HashMap<Ref, AddedInstance>,
pub updated: Vec<InstanceUpdate>,
}