(e41802b) Show a ticket's tags on its tui card, and bump to 0.12.1

The Tags field was invisible on the board: a card carried the mark, the short id,
the due date, the owner and the criteria count, and nothing said a ticket was
tagged bug without opening it.

TicketItem gains a tags field, filled in collect_ticket_items through parse_tags
where the file is already being read, for the reason the criteria count is: the
board draws them on every card, and asking per card would re-read every ticket
body on every draw. parse_tags splits the comma-separated field into whole
trimmed values, so a caller asking for bug is not answered by bugfix, and reads
absent, _None_ and empty as one answer. That is step one of 2f3796e5, lifted here
because the board cannot read the field before it exists.

The row sits under the title, dimmed like the owner and the count, each tag
prefixed with # so it does not read as a third line of the title. It is dropped
whole when the column will not hold it, the rule a corner follows, and an
untagged ticket spends no row at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ansho Rei
2026-08-22 01:07:40 +02:00
co-authored by Claude Opus 5
parent 5b0bac9c2d
commit 91bbc19c32
5 changed files with 162 additions and 3 deletions
+44
View File
@@ -902,6 +902,26 @@ pub fn parse_campaign(content: &str) -> Option<String> {
}
}
/// The tags a ticket carries, from the comma-separated field.
///
/// Whole values, trimmed: the field is written as `bug, frontend` by `add` and as
/// `bug,frontend` by hand, and a caller asking whether a ticket is tagged `bug` must
/// not be answered by a ticket tagged `bugfix`. Absent, unset and empty are one
/// answer, as they are for [`parse_campaign`]: no tags.
pub fn parse_tags(content: &str) -> Vec<String> {
let value = parse_ticket_field(content, "Tags");
if is_unknown_value(&value) {
return Vec::new();
}
value
.split(',')
.map(str::trim)
.filter(|tag| !tag.is_empty())
.map(str::to_string)
.collect()
}
/// The metadata fields in the order `add` writes them, with `Campaign` in its place
/// among them.
///
@@ -1809,6 +1829,13 @@ pub struct TicketItem {
/// Read here for the reason `criteria` is: `ls --campaign` filters on what this
/// pass already produced, rather than reading every ticket a second time to ask.
pub campaign: Option<String>,
/// The tags the ticket carries, split out of the comma-separated field, or empty
/// for an untagged one.
///
/// Read here for the reason `criteria` is: the board draws them on every card, and
/// asking per card would re-read every ticket body on every draw rather than on the
/// tick that changed something.
pub tags: Vec<String>,
/// The file this came from. The listing ignores it; the TUI opens it for the
/// detail view rather than resolving the ticket a second time.
pub path: std::path::PathBuf,
@@ -1965,6 +1992,7 @@ pub fn collect_ticket_items(status_path: impl AsRef<Path>) -> Result<Vec<TicketI
priority: parse_priority(&content),
criteria: progress,
campaign: parse_campaign(&content),
tags: parse_tags(&content),
path: e.path(),
})
})
@@ -2377,6 +2405,22 @@ mod tests {
fs::remove_dir_all(&dir).unwrap();
}
/// Whole values, so a filter or a card cannot confuse two tags that share a prefix.
#[test]
fn parse_tags_splits_on_commas_and_keeps_whole_values() {
let content = "# T\n\n## Metadata\n\n- **Tags**: bug, frontend,bugfix\n";
assert_eq!(parse_tags(content), vec!["bug", "frontend", "bugfix"]);
}
/// Absent, unset and empty are one answer: no tags.
#[test]
fn parse_tags_reads_an_unset_or_missing_field_as_none() {
assert_eq!(parse_tags("# T\n\n## Metadata\n\n- **Tags**: _None_\n"), Vec::<String>::new());
assert_eq!(parse_tags("# T\n\n## Metadata\n\n- **Tags**:\n"), Vec::<String>::new());
assert_eq!(parse_tags("# T\n\n## Metadata\n\n- **Owner**: alice\n"), Vec::<String>::new());
assert_eq!(parse_tags("# T\n\n## Metadata\n\n- **Tags**: , ,\n"), Vec::<String>::new());
}
#[test]
fn collect_ticket_items_lists_only_md_files() {
let dir = std::env::temp_dir().join(format!("worklane-stray-{}", uuid::Uuid::new_v4()));