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 {