From aff40f794d58fdbaab5052728c5a2349e59b71c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Wed, 9 Sep 2026 00:38:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=86=E7=A6=BB=E6=A0=91?= =?UTF-8?q?=E5=90=88=E6=88=90=E6=A0=B9=E8=8A=82=E7=82=B9=20ID=20=E5=86=B2?= =?UTF-8?q?=E7=AA=81=20=E9=81=BF=E5=85=8D=E5=8D=95=E5=9B=BE=E6=A0=B9?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E9=87=8D=E5=A4=8D=E8=BF=9B=E5=85=A5=E9=87=8D?= =?UTF-8?q?=E5=81=9A=E8=AE=A1=E6=95=B0=20=E8=A1=A5=E5=85=85=E6=A0=B9?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=9E=84=E9=80=A0=E5=9B=9E=E5=BD=92=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ui_editor/commands/separation/mod.rs | 15 +++++++++++++++ .../src/ui_editor/commands/separation/tree.rs | 9 ++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) 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,