(1845355) Order each status column by its entry stamp, and bump to 0.23.0

Every view read its rows out of `collect_ticket_items`, which sorts by
`by_priority_then_title` because it sees one directory and no status. That
is the right order for the backlog, where priority is the clock. Past the
backlog the question changes: committed asks what has waited longest,
reviewing what was handed over first, done what just landed. All four
columns answering the first question is why a finished p5 sat above the p1
nobody had read yet.

So each column takes its own order, through one `by_status_order` keyed on
the `Status` rather than four comparators at four call sites. Backlog
delegates to the comparator it already used. Committed sorts by
`Committed On` ascending and reviewing by `Submitted On` ascending, so the
longest wait is at the head where the reader picks next from; done sorts by
`Completed On` descending, newest first, the way a changelog reads.
Ascending twice and once descending is one rule said three ways: the head of
every column is what the reader acts on next.

A ticket carrying no stamp sinks below every stamped one in its column and
falls back to priority then title among its own kind, as do equal stamps --
`mv` writes whole seconds, so a tie is real. A missing time is unknown, not
ancient, and unknown must not claim the head of a queue ahead of a wait
somebody can point at. Reading absence as the epoch would have come free
from the comparison and put every ticket filed before f460853 first.

The comparison is a string comparison. `%Y-%m-%d %H:%M:%S` is lexicographic
in chronological order, the property `Due` already relies on, so nothing
parses a date at sort time. The stamps are read on the pass
`collect_ticket_items` already makes over each file, the rule `criteria` and
`tags` already hold, and never per comparison.

Both `cmd_ls` branches, `list_ids`, `columns_of` and `campaign::members`
take it, which is why those loops walk `Status::ALL` rather than
`status_dirs()`: the directory name does not say which stamp governs it. The
merge tab keeps priority then title outright and is pinned there -- it spans
statuses, so no single stamp governs it. `cmd_tags` is left alone; it counts
into a `BTreeMap` and never reads an order.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ansho Rei
2026-08-23 12:58:34 +02:00
co-authored by Claude Opus 5
parent eae411ab50
commit cbc20848f6
9 changed files with 621 additions and 39 deletions
+97 -3
View File
@@ -1157,12 +1157,14 @@ fn span_of(cell: Cell) -> Span<'static> {
fn columns_of(worklane_dir: &Path) -> (Vec<Column>, CampaignIndex) {
let campaigns = CampaignIndex::load(worklane_dir).unwrap_or_default();
let mut columns: Vec<Column> = status_dirs()
// Over `Status::ALL` rather than the names: each column is ordered by its own entry
// stamp, so the build needs the status itself and not just the directory to read.
let mut columns: Vec<Column> = Status::ALL
.into_iter()
.map(|status| {
// An absent or unreadable directory is an empty column, not a missing one:
// the four statuses are the shape of the board.
let cards = collect_ticket_items(worklane_dir.join(status))
let mut cards: Vec<Card> = collect_ticket_items(worklane_dir.join(status.as_str()))
.unwrap_or_default()
.into_iter()
.map(|ticket| Card {
@@ -1172,7 +1174,8 @@ fn columns_of(worklane_dir: &Path) -> (Vec<Column>, CampaignIndex) {
blocked: false,
})
.collect();
Column { status, cards }
cards.sort_by(|a, b| by_status_order(status, &a.ticket, &b.ticket));
Column { status: status.as_str(), cards }
})
.collect();
@@ -4530,6 +4533,97 @@ mod tests {
assert!(top.contains("backlog (1)"), "{top}");
}
/// The titles of one column, top to bottom, which is the order the reader acts on.
fn column_titles(board: &Board, at: usize) -> Vec<String> {
board.current().columns[at]
.cards
.iter()
.map(|card| card.ticket.title.clone())
.collect()
}
/// Each column is ordered by its own entry stamp, not by priority: committed is the
/// longest wait first, done is what just landed first. Every ticket here is a p2, so
/// the stamp is doing all of the work.
#[test]
fn a_column_is_ordered_by_the_stamp_the_ticket_entered_it_with() {
let dir = board_dir();
let stamp = |field: &str, at: &str| format!("- **{field}**: 2026-08-0{at} 09:00:00\n");
write_ticket(
&dir,
"committed",
"11111111-0000-4000-8000-000000000000",
"Waited",
&stamp("Committed On", "1"),
);
write_ticket(
&dir,
"committed",
"22222222-0000-4000-8000-000000000000",
"Fresh",
&stamp("Committed On", "3"),
);
write_ticket(
&dir,
"done",
"33333333-0000-4000-8000-000000000000",
"Older",
&stamp("Completed On", "1"),
);
write_ticket(
&dir,
"done",
"44444444-0000-4000-8000-000000000000",
"Newer",
&stamp("Completed On", "3"),
);
let board = boards(&[("only", &dir)]);
assert_eq!(column_titles(&board, 1), ["Waited", "Fresh"]);
assert_eq!(column_titles(&board, 3), ["Newer", "Older"]);
}
/// The merge spans statuses, so no single stamp governs it and it keeps priority then
/// title. Pinned on done, where the column order and the merge order disagree: the
/// board would put the newest first and the merge puts the p1 first.
#[test]
fn the_merge_keeps_priority_then_title_where_a_column_would_use_the_stamp() {
let (first, second) = (board_dir(), board_dir());
let card = |dir: &Path, uuid: &str, title: &str, level: u8, day: u8| {
let path = write_ticket(dir, "done", uuid, title, "");
let body = std::fs::read_to_string(&path)
.unwrap()
.replace("- **Priority**: 2", &format!("- **Priority**: {level}"))
.replace(
"- **Status**: done\n",
&format!("- **Completed On**: 2026-08-0{day} 09:00:00\n- **Status**: done\n"),
);
std::fs::write(&path, body).unwrap();
};
// Both on one board, so that board's own column can be read for the other
// order. The urgent one finished first, so stamp and priority disagree.
card(&first, "11111111-0000-4000-8000-000000000000", "Urgent", 1, 1);
card(&first, "22222222-0000-4000-8000-000000000000", "Later", 5, 3);
// A second board, which is what makes the merge tab exist at all.
card(&second, "33333333-0000-4000-8000-000000000000", "Other", 3, 2);
let mut board = boards(&[("alpha", &first), ("beta", &second)]);
assert_eq!(
column_titles(&board, 3),
["Urgent", "Other", "Later"],
"the merge sorted by stamp"
);
// The board the cards came from orders that column by the stamp, so the two
// really are two orders rather than one that happens to agree.
board.select_tab(1, SCREEN);
assert_eq!(column_titles(&board, 3), ["Later", "Urgent"]);
}
/// A tab per project, plus the merge, and the merge is where the view opens: it is
/// the reason to monitor several boards at once.
#[test]