diff --git a/src/api/scan.rs b/src/api/scan.rs index bea75a0f..0e2adcb6 100644 --- a/src/api/scan.rs +++ b/src/api/scan.rs @@ -1354,42 +1354,37 @@ async fn get_pipeline_progress_handler( if face_traced > 0 { pp.update_stage("face_tracing", 1.0, "completed", None); } - if tkg_node_count > 0 { - pp.update_stage( - "tkg_nodes", - 1.0, - "completed", - Some(format!("{} nodes", tkg_node_count)), - ); - } - if tkg_edge_count > 0 { - pp.update_stage( - "tkg_edges", - 1.0, - "completed", - Some(format!("{} edges", tkg_edge_count)), - ); - } - if relationship_count > 0 { - pp.update_stage( - "rule2_ingestion", - 1.0, - "completed", - Some(format!("{} chunks", relationship_count)), - ); - } + // Update TKG stages - mark completed even if 0 results (A-10 fix) + // This ensures overall_progress can reach 1.0 for files with no faces/relationships + pp.update_stage( + "tkg_nodes", + 1.0, + "completed", + Some(format!("{} nodes", tkg_node_count)), + ); + pp.update_stage( + "tkg_edges", + 1.0, + "completed", + Some(format!("{} edges", tkg_edge_count)), + ); + pp.update_stage( + "rule2_ingestion", + 1.0, + "completed", + Some(format!("{} chunks", relationship_count)), + ); - // Handle music-only files: if processors and rule1 completed, tkg_nodes has nodes but no edges/relationships - // Mark face_dedup, tkg_edges and rule2_ingestion as "completed (no faces)" to reach 100% - if processors_done && tkg_node_count > 0 && tkg_edge_count == 0 { - pp.update_stage("face_dedup", 1.0, "completed", Some("no faces".to_string())); - pp.update_stage("tkg_edges", 1.0, "completed", Some("no faces".to_string())); - pp.update_stage( - "rule2_ingestion", - 1.0, - "completed", - Some("no faces".to_string()), - ); + // Handle files with processors done but no TKG data + // Mark face_dedup as completed with appropriate reason (A-10 fix) + if processors_done { + if tkg_node_count == 0 { + // No faces detected or no embeddings generated + pp.update_stage("face_dedup", 1.0, "completed", Some("no faces".to_string())); + } else if tkg_edge_count == 0 { + // Faces detected but no relationships + pp.update_stage("face_dedup", 1.0, "completed", Some("no relationships".to_string())); + } } // Check VLM summary progress from trace_profiles @@ -1409,27 +1404,37 @@ async fn get_pipeline_progress_handler( .await .unwrap_or(0); - if vlm_total > 0 { - let vlm_progress = if vlm_done > 0 { - vlm_done as f64 / vlm_total as f64 + // Update VLM summary stage - mark completed even if 0 results (A-10 fix) + let vlm_status = if vlm_total == 0 { + "completed" + } else if vlm_done == vlm_total { + "completed" + } else { + "running" + }; + + let vlm_progress = if vlm_total == 0 { + 1.0 // Completed with 0 results + } else if vlm_done > 0 { + vlm_done as f64 / vlm_total as f64 + } else { + 0.0 + }; + + pp.update_stage( + "vlm_summary", + vlm_progress, + vlm_status, + if vlm_total == 0 { + Some("no traces".to_string()) } else { - 0.0 - }; - let status = if vlm_done == vlm_total { - "completed" - } else { - "running" - }; - pp.update_stage( - "vlm_summary", - vlm_progress, - status, - Some(format!("{}/{}", vlm_done, vlm_total)), - ); - } + Some(format!("{}/{}", vlm_done, vlm_total)) + }, + ); // Check face dedup from actual face_cluster.json content - if processors_done && tkg_node_count > 0 { + // Always check if processors_done, regardless of tkg_node_count (A-10 fix) + if processors_done { let output_dir = crate::core::config::OUTPUT_DIR.as_str(); let face_cluster_path = format!("{}/{}.face_cluster.json", output_dir, file_uuid); if std::path::Path::new(&face_cluster_path).exists() {