From 41a65f95b22043d0b167065528d59d83eb568ee0 Mon Sep 17 00:00:00 2001 From: Ansho Rei Date: Sat, 22 Aug 2026 00:20:16 +0200 Subject: [PATCH] (2ec6508) Filter status directories to md files in ls, and bump to 0.11.1 A status directory is a plain directory, so anything can land in it. `collect_ticket_items` read every entry it could, so a stray `notes.txt` was listed as `(notes) _No title_` and counted in the per-status summary beside the real tickets. The extension check is the one every other scan of a status directory already makes: `resolve_ticket`, `RelationIndex::load`, `find_ticket_file` and the tui's `digest` all skip a non-md path. This was the only reader without it, so the fix is to join them rather than to invent a rule. Subdirectories were already excluded, but by accident: `read_to_string` fails on a directory and `filter_map` dropped it. The filter now refuses them on the extension, and the test keeps a subdirectory in place so a later change to how the file is read cannot bring them back. The count needed nothing. It comes from `collect_ticket_items().len()` since the priority filter was added, so filtering the source fixed both the rows and the number in one place. Co-Authored-By: Claude Opus 5 (1M context) --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/util.rs | 31 ++++++++++++++++++++++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8b8331a..91fb52d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1494,7 +1494,7 @@ dependencies = [ [[package]] name = "worklane" -version = "0.11.0" +version = "0.11.1" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index 95b3d73..34709b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "worklane" -version = "0.11.0" +version = "0.11.1" edition = "2024" [dependencies] diff --git a/src/util.rs b/src/util.rs index 5e63fbd..b8a4591 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1706,7 +1706,13 @@ pub fn display_ticket_items(items: &[TicketItem]) { } pub fn collect_ticket_items(status_path: impl AsRef) -> Result> { - let entries: Vec<_> = fs::read_dir(status_path)?.filter_map(|e| e.ok()).collect(); + let entries: Vec<_> = fs::read_dir(status_path)? + .filter_map(|e| e.ok()) + // A status directory is a plain directory, so anything can be dropped in it. + // Without the extension a stray notes.txt was listed as a titleless ticket and + // counted in the summary alongside the real ones. + .filter(|e| e.path().extension().is_some_and(|ext| ext == "md")) + .collect(); let mut items: Vec = entries .iter() @@ -2152,6 +2158,29 @@ mod tests { fs::remove_dir_all(&dir).unwrap(); } + #[test] + fn collect_ticket_items_lists_only_md_files() { + let dir = std::env::temp_dir().join(format!("worklane-stray-{}", uuid::Uuid::new_v4())); + fs::create_dir_all(&dir).unwrap(); + + fs::write( + dir.join("11111111-0000-4000-8000-000000000001.md"), + "# Real\n\n## Metadata\n\n- **Owner**: alice\n", + ) + .unwrap(); + fs::write(dir.join("notes.txt"), "# Stray\n").unwrap(); + // A directory read_to_string happened to reject, so it was already skipped by + // accident. Kept here so the extension filter is what keeps it out. + fs::create_dir_all(dir.join("subdir")).unwrap(); + + let items = collect_ticket_items(&dir).unwrap(); + let titles: Vec<&str> = items.iter().map(|item| item.title.as_str()).collect(); + + assert_eq!(titles, vec!["Real"], "{titles:?}"); + + fs::remove_dir_all(&dir).unwrap(); + } + #[test] fn a_section_rule_matches_the_width_of_its_name() { let rendered = content_trim_colored("# T\n\n## Description\nbody\n", "");