diff --git a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/mod.rs b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/mod.rs index edef9453e..708d3c191 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/mod.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/mod.rs @@ -92,6 +92,21 @@ mod tests { "image" ); } + + #[test] + fn construction_uses_distinct_root_id_for_root_image() { + let image = Component::Image(ImageComponent { + target_graphic: None, + image_type: ImageType::Simple { + preserve_aspect: false, + }, + }); + let root = node("root-image", vec![image], vec![]); + let result = construct_separation_state(&state(root)); + let tree = &result.unprocessed_trees[0]; + assert_ne!(tree.root.id, tree.root.children[0].id); + assert_eq!(tree.root.children[0].id.as_str(), "root-image"); + } #[test] fn binding_validation_requires_exact_batch_coverage() { let node = SeparationNode { diff --git a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/tree.rs b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/tree.rs index 25b7cf6f3..45c93dbec 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/tree.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/tree.rs @@ -85,7 +85,14 @@ pub fn construct_separation_state(state: &State) -> SeparationState { (!children.is_empty()).then(|| SeparationTree { src_ui_design: tree.src_ui_design.clone(), root: SeparationNode { - id: tree.root.id.clone(), + // The synthetic root must never share an ID with a real + // UI node. A single-image design may use the original + // tree root as an eligible separation leaf. + id: NodeId::new(format!( + "separation-root-{}", + uuid::Uuid::new_v4().simple() + )) + .expect("synthetic separation root id is valid"), global_pos_x_px: 0, global_pos_y_px: 0, width_px: image.pixel_size.x.max(0.0).round() as u32,