Compare commits

..
1 Commits
Author SHA1 Message Date
Ansho ReiandClaude Opus 5 41a65f95b2 (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) <noreply@anthropic.com>
2026-08-22 00:20:16 +02:00
3 changed files with 32 additions and 3 deletions
Generated
+1 -1
View File
@@ -1494,7 +1494,7 @@ dependencies = [
[[package]]
name = "worklane"
version = "0.11.0"
version = "0.11.1"
dependencies = [
"anyhow",
"assert_cmd",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "worklane"
version = "0.11.0"
version = "0.11.1"
edition = "2024"
[dependencies]
+30 -1
View File
@@ -1706,7 +1706,13 @@ pub fn display_ticket_items(items: &[TicketItem]) {
}
pub fn collect_ticket_items(status_path: impl AsRef<Path>) -> Result<Vec<TicketItem>> {
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<TicketItem> = 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", "");