From 2bfc8708544346813f413dec569edb02876b48c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Sat, 12 Sep 2026 14:54:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=8D=E7=94=A8=E5=88=86=E7=A6=BB=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E5=B7=B2=E9=80=89=E6=89=B9=E6=AC=A1=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 让批次校验和应用使用同一份已选节点,避免重复选择造成目标漂移。 --- .../src/ui_editor/commands/separation/mod.rs | 11 ++++++++++- .../ui_editor/commands/separation/workflow/mod.rs | 1 + .../commands/separation/workflow/patch.rs | 15 ++++----------- 3 files changed, 15 insertions(+), 12 deletions(-) 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 d6400e05d..3bb71b767 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 @@ -259,9 +259,14 @@ mod tests { let paths = HashMap::new(); for note in ["第一次意见", "第二次意见", "最后一次意见"] { + let batch_nodes = next_image_batch(&separation, &separation.trees[0]) + .into_iter() + .cloned() + .collect::>(); apply_batch_patch( &mut separation, 0, + &batch_nodes, &[BindingDecision::NeedRework { to_node: id.clone(), advice: note.to_string(), @@ -343,7 +348,11 @@ mod tests { }, }]; let paths = HashMap::from([(id.clone(), "ui/.sidecar/cut.png".to_string())]); - apply_batch_patch(&mut state, 0, &decisions, &paths, (1, 1)).unwrap(); + let batch_nodes = next_image_batch(&state, &state.trees[0]) + .into_iter() + .cloned() + .collect::>(); + apply_batch_patch(&mut state, 0, &batch_nodes, &decisions, &paths, (1, 1)).unwrap(); assert_eq!(state.bound[0].node_id, id); assert_eq!(state.trees[0].root.children.len(), 1); } diff --git a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow/mod.rs b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow/mod.rs index 960cc7ee9..181964feb 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow/mod.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow/mod.rs @@ -243,6 +243,7 @@ pub(crate) async fn separate_ui_impl( patch::apply_batch_patch( &mut separation, tree_index, + &batch_nodes, &binding.decisions, &cut_paths, processed_dimensions, diff --git a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow/patch.rs b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow/patch.rs index 42985ac4f..39618548b 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow/patch.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow/patch.rs @@ -1,4 +1,3 @@ -use super::batch::next_image_batch; use crate::ui_editor::commands::separation::{ validate_binding_response, BindingDecision, BindingResp, BoundNode, ProblematicNode, SeparationNode, SeparationState, MAX_REWORK_COUNT, @@ -9,6 +8,7 @@ use std::collections::HashMap; pub fn apply_batch_patch( state: &mut SeparationState, tree_index: usize, + batch_nodes: &[SeparationNode], decisions: &[BindingDecision], cut_paths: &HashMap, processed_dimensions: (u32, u32), @@ -19,16 +19,9 @@ pub fn apply_batch_patch( decisions.len(), cut_paths.len() ); - let batch_nodes = { - let tree = state - .trees - .get(tree_index) - .ok_or_else(|| "separation tree 索引无效".to_string())?; - next_image_batch(state, tree) - .into_iter() - .cloned() - .collect::>() - }; + if state.trees.get(tree_index).is_none() { + return Err("separation tree 索引无效".to_string()); + } let batch = batch_nodes.iter().collect::>(); validate_binding_response( &BindingResp {