diff --git a/server/src/chat/commands/overview.rs b/server/src/chat/commands/overview.rs index f16a7911..8bc7c789 100644 --- a/server/src/chat/commands/overview.rs +++ b/server/src/chat/commands/overview.rs @@ -105,58 +105,13 @@ fn find_story_merge_commit(root: &std::path::Path, num_str: &str) -> Option Option { - // Try content store first. - for id in crate::db::all_content_ids() { - let file_num = id.split('_').next().unwrap_or(""); - if file_num == num_str - && let Some(c) = crate::db::read_content(&id) - { - return crate::io::story_metadata::parse_front_matter(&c) - .ok() - .and_then(|m| m.name); - } - } - - // Fallback: filesystem scan. - let stages = [ - "1_backlog", - "2_current", - "3_qa", - "4_merge", - "5_done", - "6_archived", - ]; - for stage in &stages { - let dir = root.join(".huskies").join("work").join(stage); - if !dir.exists() { - continue; - } - if let Ok(entries) = std::fs::read_dir(&dir) { - for entry in entries.flatten() { - let path = entry.path(); - if path.extension().and_then(|e| e.to_str()) != Some("md") { - continue; - } - if let Some(stem) = path.file_stem().and_then(|s| s.to_str()) { - let file_num = stem - .split('_') - .next() - .filter(|s| !s.is_empty() && s.chars().all(|c| c.is_ascii_digit())) - .unwrap_or(""); - if file_num == num_str { - return std::fs::read_to_string(&path).ok().and_then(|c| { - crate::io::story_metadata::parse_front_matter(&c) - .ok() - .and_then(|m| m.name) - }); - } - } - } - } - } - None + let (_, _, _, content) = crate::chat::lookup::find_story_by_number(root, num_str)?; + let content = content?; + crate::io::story_metadata::parse_front_matter(&content) + .ok() + .and_then(|m| m.name) } /// Return the `git show --stat` output for a commit.