diff --git a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/prompt/extract.rs b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/prompt/extract.rs index e0059e2b9..9b6e7a2ed 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/prompt/extract.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/prompt/extract.rs @@ -45,7 +45,7 @@ pub(crate) fn gen_extract_prompt( state: &SeparationState, tree: &SeparationTree, batch: &[&SeparationNode], -) -> String { +) -> Result { let mut result = r#" This is a UI design image, not a normal photo/illustration. Extract it strictly as UI elements/layers, not as a generic foreground/background extraction. Treat distinct UI element as its own layer with hard, clean, pixel-accurate edges and full transparency outside the element. @@ -78,12 +78,12 @@ pub(crate) fn gen_extract_prompt( ui_layer_tree: project_node(&tree.root, &target_ids, &terminal_ids, &mut index), }; let yaml = serde_yaml::to_string(&document) - .expect("UI separation extract prompt projection must be serializable"); + .map_err(|error| format!("UI separation extract prompt projection failed: {error}"))?; result.push_str("```yaml\n"); result.push_str(&yaml); result.push_str("```\n"); - result + Ok(result) } fn project_node( 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 8c492b9b6..b145d8e9b 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 @@ -127,7 +127,7 @@ pub(crate) async fn separate_ui_impl( break; } let batch = batch_nodes.iter().collect::>(); - let prompt = gen_extract_prompt(&separation, current_tree, &batch); + let prompt = gen_extract_prompt(&separation, current_tree, &batch)?; app_log!( "ui_separation.batch_start tree_index={} batch_index={} nodes={} area_px={} image_edit_dimension_px={} prompt_chars={} rework_total={}", tree_index, batch_index, batch.len(), batch_area_px, image_edit_dimension_px,