Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3892afe819 | ||
|
|
c81838efc6 |
@@ -29,7 +29,7 @@
|
||||
- Metadata fields parsed by `parse_ticket_field()`: `ID`, `Priority`, `Tags`, `Due`, `Owner`, `Created At`, `Committed On`, `Submitted On`, `Completed On`, `Discarded On`, `Campaign`, `Status`. The last five are the ones no ticket is born with: `add` writes none of them, so they are inserted on demand, against `METADATA_ORDER`, which is also what keeps `Status` last
|
||||
- The four stamps are `mv`'s, written by `set_status_stamp` from `Status::stamp_field`, and they **accumulate**: entering a status writes its field, re-entering restamps, and arriving anywhere removes the fields of every status *after* the target. One arrival rule keyed off `Status::ALL`, not a case per move, which is why a backward move truncates the journey at the target (`done` back to `reviewing` drops `Completed On`, anything back to `backlog` drops all three) and a forward skip under `-f` stamps only where it lands rather than fabricating the stages it jumped. A ticket that walks the whole flow ends with `Created At`, `Committed On`, `Submitted On` and `Completed On` side by side, so presence means *got this far and has not been sent back past it*, not *is here now* — `Status` is what says where it is. Not the history log either: these answer how far and when, once per stage, and every change along the way is the log's. `backlog` has no stamp, `Created At` already answers for it
|
||||
- **`Discarded` is last in `Status::ALL`, and that placement is what makes the stamp rule fall out right.** Nothing sits after it, so a discard clears nothing: a ticket abandoned from reviewing keeps `Committed On` and `Submitted On`, and the file still says how far it got before it was dropped. It also makes every move out of discarded a backward move, so un-discarding needs `-f` without a rule of its own. `Discarded On` is its stamp, and `Completed On` stays untouched, because a discarded ticket was never done
|
||||
- **Each status column is ordered by its own entry stamp, through `by_status_order`.** Priority is the clock in the backlog and that column keeps priority then title; past it the question changes, so committed sorts by `Committed On` ascending, reviewing by `Submitted On` ascending, and done and discarded by their stamp descending. Said once: the head of every column is what the reader acts on next. An unstamped ticket sinks below every stamped one in its column, because a missing time is unknown rather than ancient and unknown must not claim the head of a queue; equal stamps and both-unstamped fall through to `by_priority_then_title`. One function keyed on the `Status`, taken by both `cmd_ls` branches, `list_ids`, `columns_of` and `campaign::members`, which is why those loops walk `Status::ALL` rather than `status_dirs()`. The stamps are read in `collect_ticket_items`' existing pass, the rule `criteria` and `tags` already hold, and compared as strings: `%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
|
||||
- **Each status column is ordered by its own date, through `by_status_order`.** Past the backlog that date is the entry stamp, so committed sorts by `Committed On` ascending, reviewing by `Submitted On` ascending, and done and discarded by their stamp descending. The backlog has no stamp of its own, so it sorts by `Due` ascending, through `TicketItem::due_key`. Said once: the head of every column is what the reader acts on next, and in the backlog that is the nearest deadline rather than the loudest priority — priority alone sat a p1 nobody had promised above a p3 due tomorrow. A ticket carrying no date sinks below every dated one in its column, because a missing time is unknown rather than ancient and unknown must not claim the head of a queue; equal dates and both-undated fall through to `by_priority_then_title`, which is still the whole order among undated backlog tickets. One function keyed on the `Status`, taken by both `cmd_ls` branches, `list_ids`, `columns_of` and `campaign::members`, which is why those loops walk `Status::ALL` rather than `status_dirs()`. The dates are read in `collect_ticket_items`' existing pass, the rule `criteria` and `tags` already hold, and compared as strings: `%Y-%m-%d %H:%M:%S` and `%Y-%m-%d` are both lexicographic in chronological order, so nothing parses a date at sort time. `due_key` answers `None` for a `Due` that is not a plain `YYYY-MM-DD` after `due_date` has cut a legacy datetime back — free text is unknown, not a date, and sorting on its spelling would rank it against real deadlines
|
||||
- Format: `**Field Name**: value`
|
||||
- Ticket structure: `# Title` → `## Description` → `## Acceptance Criteria` → `## Implementation Plan` → `## Metadata`
|
||||
- A **campaign** file carries `ID`, `Codename`, `Owner` and `Created At`, in that order, and no `Status`. `Codename` sits directly under the ID because that is what it is, a second way to say which campaign this is; it is written by `campaign add --codename` alone and is `_Not set_` when the flag was not given. It is not in `METADATA_ORDER`, which is the anchor list for the *upsert* on a ticket, and nothing upserts a campaign
|
||||
@@ -451,7 +451,7 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- **`Tab` owns the selection**, `column`, `card` and `offsets`, not `Board`. Sharing them across projects would point the selection at whatever unrelated ticket sat at the same place in the tab you switched to. `Board::current()` is the tab in view, and `visibility` stays on the board because it is a preference about the flow rather than about a project
|
||||
- The tabs are fixed for the run: a project cannot be added or dropped without restarting, so `Board::new` builds the tab list once and `reload` only refills each tab's columns. `reload` clamps **every** tab, and `select_tab` clamps again on arrival, because done may have been hidden while another tab was in view
|
||||
- The merge tab goes **first** and is where the view opens: it is the reason to monitor several boards at once. It is materialised in `reload`, from the cards already read, rather than computed per draw — the same reason the criteria count is filled in `collect_ticket_items`
|
||||
- The merge is **sorted**, through `by_priority_then_title` in `util.rs`, not concatenated. An overview whose order depended on the order of the arguments would bury one project's p1 under another's p5. It keeps priority then title where every other column takes `by_status_order`: the merge spans statuses, so no single entry stamp governs it
|
||||
- The merge is **sorted**, through `by_priority_then_title` in `util.rs`, not concatenated. An overview whose order depended on the order of the arguments would bury one project's p1 under another's p5. It keeps priority then title where every other column takes `by_status_order`: the merge spans statuses, so no single date governs it
|
||||
- `Card` wraps a `TicketItem` with the project it came from, `Some` only on the merge tab. Decided at reload rather than passed down to `card_lines` as a "which tab is this" flag. `TicketItem` is therefore `Clone`: the merge holds a second copy rather than re-reading every tree
|
||||
- **The project follows the id, on the card and on the overlay border.** Across boards the id is not an address: two projects can hold the same title, and seven characters do not say where they live. `project_label` takes what the row has left after the mark and the id and ends in an ellipsis, and it is measured before the due date, so on the merge the project wins the narrow column and the date is what `corner_line` drops
|
||||
- `tab` and `shift+tab` cycle rather than clamp, unlike the cards and columns: a row of tabs is a ring, and there is no end of a list to run off. Both were free of every other binding — the columns took `hjkl` and the arrows
|
||||
|
||||
Generated
+1
-1
@@ -1503,7 +1503,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "worklane"
|
||||
version = "0.32.20"
|
||||
version = "0.32.21"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assert_cmd",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "worklane"
|
||||
version = "0.32.20"
|
||||
version = "0.32.21"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -8,7 +8,7 @@ Worklane is a local Kanban flow for agentic software development.
|
||||
| `worklane` or `worklane tui [path...]` | Opens the board: one column per status, redrawn when the tree changes. Read only. Opens with done and discarded hidden, their counts in the footer; `d` rotates hide both, show done, show both, and back around. Arrows or `hjkl` to move, `enter` for detail, `pgup`/`pgdn` to scroll an open ticket or the campaign frame, whichever the selection is on, with a page indicator on its border while there is more of it than fits, `/` to jump to the first ticket whose id or title matches, `y` to copy the selected ticket's short id to the clipboard, `c` to pick a campaign and filter the columns to its members, `q` to close whatever is open and then to quit. A card carries its campaign beside its tags, marked `~` and bold, and a comment count in its bottom right corner, the number then `❞` in cyan, before the criteria count and absent entirely when nobody has commented; while one is selected a frame above the columns names it, shows three rows of its description and says how far it has got, and `q` on its border gives the whole board back; up from the top card of a column moves the selection to that frame, where the scroll keys page through the description, `enter` gives it half the board and takes the rows back again, and down returns to the column it came from, leaving the frame at whatever height it was. Each path opens the first `.worklane` at or above it, the working directory by default. Several paths are monitored together, as a tab per project plus an `all` tab that merges them, with `tab` and `shift+tab` between them |
|
||||
| `worklane init` | Creates `.worklane/` with backlog, committed, reviewing, done, discarded directories |
|
||||
| `worklane add` | Creates a ticket in backlog with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--owner`, `--priority` flags. `--due` takes `YYYY-MM-DD` and refuses anything else at parse time |
|
||||
| `worklane ls [status]` | Lists tickets, sorted by priority then title. Optional positional status, and `--priority <1-5>`, `--tag <tag>` and `--campaign <campaign>`, which compose in any combination. `--tag` matches a whole value of the comma-separated Tags field, case sensitively, so `--tag bug` does not list a ticket tagged `bugfix` or one tagged `Bug`. `--ids` prints one ticket per line as its short id, a tab and its title, unstyled, done included, for a script or a completion |
|
||||
| `worklane ls [status]` | Lists tickets, each column in its own order: the backlog by due date, soonest first, then priority then title, with an undated ticket below every dated one; committed and reviewing by when the ticket entered them, oldest first; done and discarded newest first. Optional positional status, and `--priority <1-5>`, `--tag <tag>` and `--campaign <campaign>`, which compose in any combination. `--tag` matches a whole value of the comma-separated Tags field, case sensitively, so `--tag bug` does not list a ticket tagged `bugfix` or one tagged `Bug`. `--ids` prints one ticket per line as its short id, a tab and its title, unstyled, done included, for a script or a completion |
|
||||
| `worklane show <id>` | Shows ticket by UUID prefix (4+ chars), title substring, or filename substring. A campaign is addressed the same way, plus its exact codename, which wins over all three. Ends with the ticket's history: every comment on it and every change to its status, owner or tags, oldest first, each naming who made it |
|
||||
| `worklane mv <id> --status <target> [-f]` | Moves ticket between statuses. Default: forward only, one stage at a time. `-f` bypasses both restrictions. `--status discarded` is exempt and reachable from anywhere, for a ticket that will not be done; leaving `discarded` is a backward move and needs `-f`. Discarding is refused while open tickets are blocked by the ticket, `-f` overrides. Records a `status` entry in the ticket's history, after the move: a refused or no-op move records nothing. `--actor` names the writer of that entry |
|
||||
| `worklane set <ticket>` | Replaces fields with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--priority`. At least one required. Changing the title renames the file, keeping the UUID. `--clear <field>` returns a field to unset instead, repeatable, taking `due`, `tags`, `priority`, `description`, `acceptance` or `plan`, and writing back exactly what `add` writes for a field it was never given. No `title`, which addresses the ticket, and no `owner`, which is `chown`'s. Replacing and clearing the same field in one call is refused. `--tags` records a `tags` entry in the ticket's history, with the tags before and after, and it is the only field of this command's that is logged; `--actor` names the writer of that entry |
|
||||
|
||||
+111
-6
@@ -5081,12 +5081,14 @@ fn no_campaign_line(count: usize, selected: bool) -> Line<'static> {
|
||||
])
|
||||
}
|
||||
|
||||
/// One picker row: `(1b78a24) ~beaver What the campaign is for`.
|
||||
/// One picker row: `(1b78a24) ~beaver What the campaign is for 0/1`.
|
||||
///
|
||||
/// The highlight is `REVERSED`, the way a selected card is, so the row reads the same
|
||||
/// whatever colours are already on it. The summary is grey because it is context around the
|
||||
/// two things being chosen between, and it is cut with an ellipsis rather than dropped: half
|
||||
/// a sentence still says what a campaign is about, which is not true of half an id.
|
||||
/// a sentence still says what a campaign is about, which is not true of half an id. The
|
||||
/// standing trails it, grey like a card's criteria count, so how far each campaign has got
|
||||
/// is on the list rather than only on the frame.
|
||||
fn picker_line(campaign: &CampaignRow, selected: bool, width: u16) -> Line<'static> {
|
||||
let emphasis = match selected {
|
||||
true => Modifier::REVERSED,
|
||||
@@ -5121,9 +5123,28 @@ fn picker_line(campaign: &CampaignRow, selected: bool, width: u16) -> Line<'stat
|
||||
));
|
||||
}
|
||||
|
||||
// The standing, `2/3`, is what the reader picks a campaign by, so it is reserved
|
||||
// before the prose is cut, the way a corner is: half a count reads as the wrong
|
||||
// number, so the whole of it drops when the row will not hold it. A campaign with no
|
||||
// members shows nothing, the way a card with no criteria spends no corner on it.
|
||||
let used_base = spans_width(&spans);
|
||||
let standing = match campaign.standing.total {
|
||||
0 => None,
|
||||
_ => {
|
||||
let text = format!("{}/{}", campaign.standing.done, campaign.standing.total);
|
||||
let room = (width as usize).saturating_sub(used_base + 2);
|
||||
if text.chars().count() <= room {
|
||||
Some(text)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
};
|
||||
let standing_w = standing.as_ref().map_or(0, |text| text.chars().count() + 2);
|
||||
|
||||
// What the campaign is *called* takes the row first, and the prose takes what is left.
|
||||
// Under three characters there is nothing left to say, the bargain `project_label` makes.
|
||||
let used = spans_width(&spans);
|
||||
let used = used_base + standing_w;
|
||||
let summary = match campaign.summary().is_empty() {
|
||||
true => campaign.title.as_str(),
|
||||
false => campaign.summary(),
|
||||
@@ -5140,6 +5161,14 @@ fn picker_line(campaign: &CampaignRow, selected: bool, width: u16) -> Line<'stat
|
||||
));
|
||||
}
|
||||
|
||||
if let Some(text) = standing {
|
||||
spans.push(Span::raw(" "));
|
||||
spans.push(Span::styled(
|
||||
text,
|
||||
Style::default().fg(Color::Grey.into()).add_modifier(emphasis),
|
||||
));
|
||||
}
|
||||
|
||||
Line::from(spans)
|
||||
}
|
||||
|
||||
@@ -9175,9 +9204,9 @@ approach";
|
||||
.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.
|
||||
/// Every column past the backlog 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();
|
||||
@@ -9218,6 +9247,29 @@ approach";
|
||||
assert_eq!(column_titles(&board, 3), ["Newer", "Older"]);
|
||||
}
|
||||
|
||||
/// The backlog is the column with no entry stamp, so the due date is what orders it.
|
||||
/// Every ticket here is a p2, so the due is doing all of the work, and the undated
|
||||
/// one trails both dated ones rather than sitting among them.
|
||||
#[test]
|
||||
fn the_backlog_column_is_ordered_by_the_due_date() {
|
||||
let dir = board_dir();
|
||||
let card = |uuid: &str, title: &str, due: &str| {
|
||||
let path = write_ticket(&dir, "backlog", uuid, title, "");
|
||||
let body = std::fs::read_to_string(&path)
|
||||
.unwrap()
|
||||
.replace("- **Due**: 2026-12-31", &format!("- **Due**: {due}"));
|
||||
std::fs::write(&path, body).unwrap();
|
||||
};
|
||||
|
||||
card("11111111-0000-4000-8000-000000000000", "Later", "2026-09-03");
|
||||
card("22222222-0000-4000-8000-000000000000", "Undated", "_Not set_");
|
||||
card("33333333-0000-4000-8000-000000000000", "Sooner", "2026-09-01");
|
||||
|
||||
let board = boards(&[("only", &dir)]);
|
||||
|
||||
assert_eq!(column_titles(&board, 0), ["Sooner", "Later", "Undated"]);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
@@ -12645,6 +12697,59 @@ approach";
|
||||
assert!(footer(&board, 100, 24).contains("↵ view"), "the footer is the board's");
|
||||
}
|
||||
|
||||
/// The list is where a campaign is chosen from, so how far each has got belongs on the
|
||||
/// row rather than only on the frame: `0/2` after the summary, where a card draws its
|
||||
/// criteria count.
|
||||
#[test]
|
||||
fn the_picker_rows_carry_the_standing() {
|
||||
let dir = board_dir();
|
||||
let mut board = campaign_board(&dir);
|
||||
board.open_picker(PickerKind::Campaign, SCREEN);
|
||||
|
||||
let rows = picker_rows(&board, 100, 24);
|
||||
// V1 holds two open members, so two done of two held is not reached.
|
||||
let v1 = &rows[row_with(&rows, short_id(V1))];
|
||||
assert!(v1.contains("0/2"), "{v1:?}");
|
||||
// BEAVER holds one open member.
|
||||
let beaver = &rows[row_with(&rows, short_id(BEAVER))];
|
||||
assert!(beaver.contains("0/1"), "{beaver:?}");
|
||||
}
|
||||
|
||||
/// A campaign with no members has no standing to show, the way a card with no criteria
|
||||
/// spends no corner on it: the row ends at the summary.
|
||||
#[test]
|
||||
fn a_picker_row_with_no_members_shows_no_standing() {
|
||||
let dir = board_dir();
|
||||
write_campaign(&dir, V1, "First public release", "v1", "For a public tag.");
|
||||
|
||||
let mut board = one_board(&dir);
|
||||
board.open_picker(PickerKind::Campaign, SCREEN);
|
||||
|
||||
let rows = picker_rows(&board, 100, 24);
|
||||
let row = &rows[row_with(&rows, short_id(V1))];
|
||||
assert!(!row.contains('/'), "a blank campaign claimed a standing: {row:?}");
|
||||
}
|
||||
|
||||
/// The standing gives way before the identity and the prose, and goes whole: half a
|
||||
/// count reads as the wrong number, the rule a corner drops itself by.
|
||||
#[test]
|
||||
fn a_campaign_row_drops_the_standing_whole_when_it_will_not_fit() {
|
||||
let dir = board_dir();
|
||||
write_campaign(&dir, V1, "First public release", "v1", "Everything for a public tag.");
|
||||
write_member_card(&dir, "In v1", "cli", V1);
|
||||
|
||||
let mut board = one_board(&dir);
|
||||
board.open_picker(PickerKind::Campaign, SCREEN);
|
||||
|
||||
let full = picker_rows(&board, 100, 24);
|
||||
let wide = &full[row_with(&full, short_id(V1))];
|
||||
assert!(wide.contains('/'), "no standing on a wide row: {wide:?}");
|
||||
|
||||
let narrow = picker_rows(&board, 14, 24);
|
||||
let tight = &narrow[row_with(&narrow, short_id(V1))];
|
||||
assert!(!tight.contains('/'), "a count given up in pieces: {tight:?}");
|
||||
}
|
||||
|
||||
/// A campaign with no codename shows the id once, not twice: the row already opens
|
||||
/// with it, so the card's fallback would say nothing the second time.
|
||||
#[test]
|
||||
|
||||
+145
-25
@@ -3323,7 +3323,8 @@ impl TicketItem {
|
||||
/// A slot per status rather than a lookup by field name, so a fifth status carrying
|
||||
/// a stamp is a compile error here the way it is in [`Status::stamp_field`].
|
||||
/// Backlog has none: nothing stamps it, and `Created At` is not an entry time, so
|
||||
/// every ticket in that column answers `None` and the whole order is the fallback.
|
||||
/// every ticket in that column answers `None` and [`TicketItem::due_key`] is what
|
||||
/// orders it instead.
|
||||
fn entry_stamp(&self, status: Status) -> Option<&str> {
|
||||
match status {
|
||||
Status::Backlog => None,
|
||||
@@ -3333,6 +3334,22 @@ impl TicketItem {
|
||||
Status::Discarded => self.discarded_on.as_deref(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The date the ticket is due, or `None` for one carrying nothing orderable.
|
||||
///
|
||||
/// What the backlog is sorted on, standing in for the entry stamp the column does
|
||||
/// not have. `YYYY-MM-DD` only, so lexicographic order is chronological order and
|
||||
/// the comparison stays a string comparison like the stamps'. `--due` has refused
|
||||
/// anything else since daa0e79, and [`due_date`] cuts a datetime written before
|
||||
/// that, or by hand, back to its date.
|
||||
///
|
||||
/// Free text answers `None` rather than sorting on its spelling. A due nobody can
|
||||
/// place on a calendar is unknown, the same reading a missing stamp gets, and
|
||||
/// unknown must not claim a place in a queue ordered by time.
|
||||
fn due_key(&self) -> Option<&str> {
|
||||
let date = due_date(&self.due);
|
||||
is_ymd(date).then_some(date)
|
||||
}
|
||||
}
|
||||
|
||||
/// The stamp a ticket carries for a status, or `None` for one it has not reached.
|
||||
@@ -3538,8 +3555,7 @@ pub fn collect_ticket_items(status_path: impl AsRef<Path>) -> Result<Vec<TicketI
|
||||
Ok(items)
|
||||
}
|
||||
|
||||
/// The order the backlog is read in, and the tiebreak every other column falls back to:
|
||||
/// priority first, title second.
|
||||
/// The tiebreak every column falls back to: priority first, title second.
|
||||
///
|
||||
/// Named and exported because the board's All tab merges several boards' columns into
|
||||
/// one and has to land in one order. A merge sorted a second way would put a p1 below a
|
||||
@@ -3554,36 +3570,46 @@ pub fn by_priority_then_title(a: &TicketItem, b: &TicketItem) -> std::cmp::Order
|
||||
|
||||
/// The order one status column is read in, keyed on the status.
|
||||
///
|
||||
/// Priority is the clock in the backlog, and that column keeps exactly the order it has
|
||||
/// always printed. Past the backlog the question changes: committed asks what has waited
|
||||
/// longest, reviewing what was handed over first, done what just landed. The head of
|
||||
/// every column is therefore what the reader acts on next, which is ascending by entry
|
||||
/// stamp in committed and reviewing and descending in done and discarded, the way a
|
||||
/// changelog reads.
|
||||
/// Every column asks the same question, what the reader acts on next, and answers it
|
||||
/// with the one date it has. Committed asks what has waited longest, reviewing what was
|
||||
/// handed over first, done what just landed: ascending by entry stamp in committed and
|
||||
/// reviewing, descending in done and discarded, the way a changelog reads. The backlog
|
||||
/// carries no entry stamp, so what heads it is the date the work is wanted by, soonest
|
||||
/// first. Priority ran that column alone until then, which sat a p1 nobody had promised
|
||||
/// above a p3 due tomorrow.
|
||||
///
|
||||
/// A ticket with no stamp sinks below every stamped one in its column. 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 come free from the string
|
||||
/// comparison and put every legacy ticket first on data nothing verified.
|
||||
/// A ticket with no date sinks below every dated one in its column, whether that date is
|
||||
/// a stamp or a due. A missing time is unknown, not ancient, and unknown must not claim
|
||||
/// the head of a queue ahead of a deadline somebody can point at. Reading absence as the
|
||||
/// epoch would come free from the string comparison and put every legacy ticket first on
|
||||
/// data nothing verified.
|
||||
///
|
||||
/// The comparison is a string comparison. The stamp format is `%Y-%m-%d %H:%M:%S`, where
|
||||
/// lexicographic order is chronological order, the same property `Due` already relies
|
||||
/// on, so there is no date parsing at sort time. Equal stamps happen, `mv` writes whole
|
||||
/// seconds, and they fall through to priority and title like everything else.
|
||||
/// The comparison is a string comparison. The stamp format is `%Y-%m-%d %H:%M:%S` and a
|
||||
/// due is `%Y-%m-%d`, both of which order lexicographically the way they order
|
||||
/// chronologically, so there is no date parsing at sort time. Equal dates happen, `mv`
|
||||
/// writes whole seconds and a due has no time at all, and they fall through to priority
|
||||
/// and title like everything else.
|
||||
pub fn by_status_order(status: Status, a: &TicketItem, b: &TicketItem) -> std::cmp::Ordering {
|
||||
let by_stamp = match (a.entry_stamp(status), b.entry_stamp(status)) {
|
||||
// One pair, so the rules below are written once. Which date a column is keyed on is
|
||||
// the only thing that changes with the status.
|
||||
let (left, right) = match status {
|
||||
Status::Backlog => (a.due_key(), b.due_key()),
|
||||
_ => (a.entry_stamp(status), b.entry_stamp(status)),
|
||||
};
|
||||
|
||||
let by_date = match (left, right) {
|
||||
(Some(left), Some(right)) => match status {
|
||||
Status::Done | Status::Discarded => right.cmp(left),
|
||||
_ => left.cmp(right),
|
||||
},
|
||||
(Some(_), None) => std::cmp::Ordering::Less,
|
||||
(None, Some(_)) => std::cmp::Ordering::Greater,
|
||||
// Both unstamped, which is every ticket in the backlog: the fallback is the
|
||||
// whole order there rather than a tiebreak.
|
||||
// Neither carries one, which is every undated ticket in the backlog: the
|
||||
// fallback is the whole order between them rather than a tiebreak.
|
||||
(None, None) => std::cmp::Ordering::Equal,
|
||||
};
|
||||
|
||||
by_stamp.then_with(|| by_priority_then_title(a, b))
|
||||
by_date.then_with(|| by_priority_then_title(a, b))
|
||||
}
|
||||
|
||||
/// The environment variable that keeps a test's fixture directory on disk.
|
||||
@@ -4649,6 +4675,16 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// A listed ticket carrying a due value, which is what the backlog column is ordered
|
||||
/// by. Built off [`listed`] rather than beside it, so a field added to `TicketItem`
|
||||
/// is still filled in one place.
|
||||
fn due_on(title: &str, level: u8, status: Status, due: &str) -> TicketItem {
|
||||
TicketItem {
|
||||
due: due.to_string(),
|
||||
..listed(title, level, status, None)
|
||||
}
|
||||
}
|
||||
|
||||
/// Sorted the way the column is read, titles out, so a case reads as the order it
|
||||
/// asserts rather than as a pair of comparisons.
|
||||
fn ordered(status: Status, mut items: Vec<TicketItem>) -> Vec<String> {
|
||||
@@ -4656,11 +4692,11 @@ mod tests {
|
||||
items.into_iter().map(|item| item.title).collect()
|
||||
}
|
||||
|
||||
/// The backlog is the one column priority still governs, and it prints exactly what
|
||||
/// it always has: the stamps a ticket carries from an earlier trip through the flow
|
||||
/// do not reach it, because backlog has no stamp of its own to sort on.
|
||||
/// Undated backlog tickets keep exactly the order the column always printed: the
|
||||
/// stamps a ticket carries from an earlier trip through the flow do not reach it,
|
||||
/// because backlog has no stamp of its own to sort on.
|
||||
#[test]
|
||||
fn the_backlog_keeps_priority_then_title() {
|
||||
fn undated_backlog_tickets_keep_priority_then_title() {
|
||||
let items = vec![
|
||||
listed("zebra", 5, Status::Backlog, None),
|
||||
listed("alpha", 1, Status::Backlog, None),
|
||||
@@ -4670,6 +4706,90 @@ mod tests {
|
||||
assert_eq!(ordered(Status::Backlog, items), ["alpha", "beta", "zebra"]);
|
||||
}
|
||||
|
||||
/// The due date is the backlog's clock, so the soonest deadline heads the column the
|
||||
/// way the oldest wait heads committed. Priority is deliberately inverted against the
|
||||
/// dates here: a p1 due last is still listed last.
|
||||
#[test]
|
||||
fn the_backlog_lists_the_soonest_due_date_first() {
|
||||
let items = vec![
|
||||
listed("undated", 1, Status::Backlog, None),
|
||||
due_on("last", 1, Status::Backlog, "2026-09-03"),
|
||||
due_on("first", 5, Status::Backlog, "2026-09-01"),
|
||||
due_on("middle", 3, Status::Backlog, "2026-09-02"),
|
||||
];
|
||||
|
||||
assert_eq!(ordered(Status::Backlog, items), ["first", "middle", "last", "undated"]);
|
||||
}
|
||||
|
||||
/// A due nobody promised must not outrank one somebody did, whatever the priorities
|
||||
/// say. This is the case the column got wrong before: the p1 sat on top.
|
||||
#[test]
|
||||
fn a_dated_backlog_ticket_sorts_above_an_undated_one_of_any_priority() {
|
||||
let items = vec![
|
||||
listed("undated", 1, Status::Backlog, None),
|
||||
due_on("dated", 5, Status::Backlog, "2026-09-01"),
|
||||
];
|
||||
|
||||
assert_eq!(ordered(Status::Backlog, items), ["dated", "undated"]);
|
||||
}
|
||||
|
||||
/// A due carries no time, so two tickets wanted on the same day is the common case
|
||||
/// rather than the rare one, and it falls through to priority and title.
|
||||
#[test]
|
||||
fn backlog_tickets_sharing_a_due_date_fall_back_to_priority_then_title() {
|
||||
let same = "2026-09-01";
|
||||
let items = vec![
|
||||
due_on("zebra", 1, Status::Backlog, same),
|
||||
due_on("beta", 3, Status::Backlog, same),
|
||||
due_on("alpha", 3, Status::Backlog, same),
|
||||
];
|
||||
|
||||
assert_eq!(ordered(Status::Backlog, items), ["zebra", "alpha", "beta"]);
|
||||
}
|
||||
|
||||
/// `--due` has taken `YYYY-MM-DD` and nothing else since daa0e79, but a file written
|
||||
/// before that or by hand can hold a datetime or free text. The datetime sorts on the
|
||||
/// date inside it; the free text is unknown rather than a date, and sinks with the
|
||||
/// unset ones instead of sorting on its spelling.
|
||||
#[test]
|
||||
fn a_backlog_due_that_is_not_a_plain_date_sorts_on_what_can_be_read_from_it() {
|
||||
let items = vec![
|
||||
due_on("prose", 1, Status::Backlog, "next friday"),
|
||||
due_on("unset", 1, Status::Backlog, NOT_SET),
|
||||
due_on("datetime", 5, Status::Backlog, "2026-09-01 09:30:00"),
|
||||
];
|
||||
|
||||
assert_eq!(ordered(Status::Backlog, items), ["datetime", "prose", "unset"]);
|
||||
}
|
||||
|
||||
/// The due is the backlog's clock and only the backlog's. Past it the entry stamp is
|
||||
/// the question, and a deadline set on a committed ticket does not reorder the queue
|
||||
/// of what has waited longest.
|
||||
#[test]
|
||||
fn a_due_date_does_not_reorder_a_column_past_the_backlog() {
|
||||
for status in [
|
||||
Status::Committed,
|
||||
Status::Reviewing,
|
||||
Status::Done,
|
||||
Status::Discarded,
|
||||
] {
|
||||
let soon = TicketItem {
|
||||
due: "2026-09-01".to_string(),
|
||||
..listed("soon", 1, status, Some("2026-08-02 09:00:00"))
|
||||
};
|
||||
let items = vec![
|
||||
soon,
|
||||
listed("later", 1, status, Some("2026-08-01 09:00:00")),
|
||||
];
|
||||
|
||||
let expected = match status {
|
||||
Status::Done | Status::Discarded => ["soon", "later"],
|
||||
_ => ["later", "soon"],
|
||||
};
|
||||
assert_eq!(ordered(status, items), expected, "{status:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Committed and reviewing are queues: the head is what has waited longest, which is
|
||||
/// where the reader picks next from.
|
||||
#[test]
|
||||
|
||||
+81
-2
@@ -114,14 +114,16 @@ fn ls_with_invalid_status_fails() {
|
||||
.failure();
|
||||
}
|
||||
|
||||
/// Title is the last tiebreak, so the three share a due date and a priority: anything
|
||||
/// else here would be testing the due order instead, which has its own case.
|
||||
#[test]
|
||||
fn ls_listed_tickets_sorted_alphabetically() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket(&worklane, "backlog", "Zebra", "alice", "2026-06-01");
|
||||
create_ticket(&worklane, "backlog", "Apple", "bob", "2026-07-01");
|
||||
create_ticket(&worklane, "backlog", "Mango", "charlie", "2026-08-01");
|
||||
create_ticket(&worklane, "backlog", "Apple", "bob", "2026-06-01");
|
||||
create_ticket(&worklane, "backlog", "Mango", "charlie", "2026-06-01");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
@@ -744,6 +746,32 @@ fn create_stamped_ticket(
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// A backlog ticket with the due date that column is ordered by.
|
||||
///
|
||||
/// Backlog only, the way [`create_stamped_ticket`] is one status at a time: the due is
|
||||
/// what stands in for an entry stamp in the one column that has none, and `_Not set_`
|
||||
/// passed here is the undated case rather than a separate helper.
|
||||
fn create_due_ticket(
|
||||
worklane_dir: &std::path::Path,
|
||||
title: &str,
|
||||
uuid: &str,
|
||||
priority: &str,
|
||||
due: &str,
|
||||
) {
|
||||
let body = format!(
|
||||
"# {title}\n\n## Metadata\n\n- **ID**: {uuid}\n- **Priority**: {priority}\n\
|
||||
- **Tags**: test\n- **Due**: {due}\n- **Owner**: alice\n\
|
||||
- **Status**: backlog\n"
|
||||
);
|
||||
fs::write(
|
||||
worklane_dir
|
||||
.join("backlog")
|
||||
.join(format!("{uuid}_{}.md", slug(title))),
|
||||
body,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn positions(stdout: &str, titles: [&str; 3]) -> Vec<usize> {
|
||||
titles
|
||||
.iter()
|
||||
@@ -828,6 +856,57 @@ fn ls_orders_done_by_the_newest_entry_stamp() {
|
||||
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{stdout}");
|
||||
}
|
||||
|
||||
/// The backlog has no entry stamp, so the due date is its clock and the soonest deadline
|
||||
/// heads the column. The p1 here is due last and is listed last, which is exactly what
|
||||
/// priority alone got wrong.
|
||||
#[test]
|
||||
fn ls_orders_the_backlog_by_the_soonest_due_date() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let at = |n: u8| format!("dddd000{n}-0000-0000-0000-000000000001");
|
||||
create_due_ticket(&worklane, "Soonest", &at(1), "5", "2026-09-01");
|
||||
create_due_ticket(&worklane, "Latest", &at(2), "1", "2026-09-03");
|
||||
create_due_ticket(&worklane, "Between", &at(3), "3", "2026-09-02");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(["ls", "backlog"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
|
||||
let seen = positions(&stdout, ["Soonest", "Between", "Latest"]);
|
||||
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{stdout}");
|
||||
|
||||
// The overview lists the same column, so it has to agree with the narrowed listing
|
||||
// rather than falling back to priority for the same tickets.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).arg("ls");
|
||||
let overview = get_stdout(&mut cmd);
|
||||
|
||||
let seen = positions(&overview, ["Soonest", "Between", "Latest"]);
|
||||
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{overview}");
|
||||
}
|
||||
|
||||
/// A due nobody promised must not outrank one somebody did. The undated ticket here is
|
||||
/// the most urgent of the three and still trails both, and among the dated ones the
|
||||
/// equal due falls through to priority.
|
||||
#[test]
|
||||
fn ls_sinks_an_undated_backlog_ticket_below_the_dated_ones() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let at = |n: u8| format!("eeee000{n}-0000-0000-0000-000000000001");
|
||||
create_due_ticket(&worklane, "Undated", &at(1), "1", "_Not set_");
|
||||
create_due_ticket(&worklane, "Urgent", &at(2), "3", "2026-09-01");
|
||||
create_due_ticket(&worklane, "Relaxed", &at(3), "5", "2026-09-01");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(["ls", "backlog"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
|
||||
let seen = positions(&stdout, ["Urgent", "Relaxed", "Undated"]);
|
||||
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{stdout}");
|
||||
}
|
||||
|
||||
/// A missing stamp is unknown, not ancient, so it sinks below every stamped ticket
|
||||
/// rather than claiming the head of the queue. Every ticket on a board older than the
|
||||
/// stamps is one of these.
|
||||
|
||||
Reference in New Issue
Block a user