Compare commits

..
3 Commits
Author SHA1 Message Date
Ansho Rei 3892afe819 (2e05015) Show the campaign standing on its picker row, and bump to 0.32.21 2026-09-01 13:42:51 +02:00
Ansho ReiandClaude Opus 5 c81838efc6 Sort the backlog by due date, then priority
The backlog was the one column priority governed alone, which sat a p1
nobody had promised above a p3 due tomorrow. It has no entry stamp, so it
now takes the due date as the date `by_status_order` keys on: soonest
first, undated below every dated one, and priority then title as the
tiebreak, which is still the whole order among the undated ones.

`TicketItem::due_key` is where a due becomes an orderable date. Only a
plain `YYYY-MM-DD` counts, which is all `--due` has accepted since
daa0e79, with `due_date` cutting a legacy datetime back to its date.
Free text answers `None` and sinks with the unset ones rather than
sorting on its spelling: a due nobody can place on a calendar is
unknown, the same reading a missing stamp already gets.

The comparator stays the single function keyed on `Status`, so `ls`,
`ls --ids`, the board's columns and `campaign::members` move together.
The All tab keeps `by_priority_then_title`: that merge spans statuses,
so no single date governs it.

`ls_listed_tickets_sorted_alphabetically` gave its three tickets three
different due dates while asserting title order. They share one now, so
the case still tests the tiebreak it names rather than the new order.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-01 01:10:41 +02:00
Ansho ReiandClaude Opus 5 cd7c99fe39 (d5a8a3f) Add make check, one command for fmt, clippy and the suite, and bump to 0.32.20
AGENTS.md pins `cargo fmt --check` and `cargo clippy --all-targets` as
clean, and 83d31cd is what happens when only memory enforces that: fmt
drifted to about 160 places across every file with the tool installed and
configured by default the whole time.

The decision the ticket wanted, taken: mechanise it, as one command. Not
CI, which a single-author tool with no pipeline anywhere does not want,
and not a hook, which is a per-clone opt-in the way `blame.ignoreRevsFile`
is and so cannot be relied on either. What was missing was never a
mechanism, it was one name to type: "remember to run fmt, clippy and the
tests" becomes `make check`.

Cheapest first, so a formatting slip is reported in a second rather than
after the suite. `-D warnings` is what turns clippy's opinion into an exit
code, since a warning printed into a wall of cargo output is unread rather
than clean. Verified each gate fails on its own: a misformatted function
and a `&Vec<u8>` parameter each exit 2 before the tests run.

Completions are inside `cargo test` rather than a target of their own.
d93eca6 put the check that loads the generated script into a real fish
there, so "check tests, check completions" is already one command, and a
second target would be a second thing to remember, which is the problem
this is solving.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 23:56:44 +02:00
8 changed files with 380 additions and 42 deletions
+6 -5
View File
@@ -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
@@ -53,7 +53,8 @@ repo. Do not restate any of it in this file: a second copy is a copy that goes s
and this file is for what someone changing worklane's own code needs.
## Testing
- Run: `cargo test`
- **Run `make check` before committing**: `cargo fmt --check`, then `cargo clippy --all-targets -- -D warnings`, then `cargo test`, cheapest first. That is the whole of the enforcement, and it is deliberate rather than a stopgap: this repo has no CI and does not want any, and a git hook is a per-clone opt-in the way `blame.ignoreRevsFile` is, so neither can be relied on. What was missing was one name to type, so the two rules below are a command and not a memory. `-D warnings` is what makes clippy's opinion an exit code; a warning printed into a wall of cargo output is unread, not clean. The completion checks are inside `cargo test` rather than a target of their own, since a second thing to remember is the problem this solves
- Run one suite: `cargo test`
- Tests use `assert_cmd` and `assert_fs` for CLI testing
- `setup_worklane()` creates temp `.worklane/` with the four flow status folders pre-created, plus `campaigns/` in `cmd_campaign.rs`, which is also where the on-demand creation is tested from a board without it. **The fixtures deliberately do not create `discarded/`**, so every discard test runs against a board that predates the status and `mv_creates_the_discarded_directory_on_a_board_that_predates_it` is not the only thing exercising the on-demand creation
- `create_ticket()` writes fully-formed markdown files directly (no `--` separator for positional args in test commands)
@@ -62,8 +63,8 @@ and this file is for what someone changing worklane's own code needs.
- **`WORKLANE_KEEP_FIXTURES=1 cargo test` keeps the fixtures and prints each path.** Opt-in rather than kept-automatically-on-failure, because the assertions here carry the state they are about: a failing board test prints the rendered rows. The flag is read once when a fixture is made rather than at drop time, so the answer cannot change mid-test, and `Fixture::swept()` turns it off for the three tests that are about the guard itself and must not be failed by a reader's environment
- **Verify a claim about leaked fixtures against a clean temp dir, not against `/tmp`.** `TMPDIR=/tmp/scratch cargo test` then count what is left in it: `/tmp` still holds the historical leak, so counting there measures the past rather than the change
- In `tui.rs`, `write_member_card` is `write_tagged_card` plus a Campaign field and `write_campaign` puts a campaign on disk, creating the campaigns directory as it goes — `board_dir()` deliberately does not, so every test that does not write one is also the test that a board with no campaigns draws. `picker_rows` cuts the picker's list out of the frame by its own geometry, for the reason `overlay_title_row` exists: a card carries the same campaign label, so a search over every row finds the board rather than the list
- **`cargo clippy --all-targets` is clean. Keep it clean**, and do not silence a lint that is pointing at something real. The only two `allow`s in the tree sit on the `create_ticket` fixtures in `cmd_mv.rs` and `cmd_show.rs`, each carrying the reason and what would replace it
- **`cargo fmt --check` is clean too, and `rustfmt.toml` is what makes that affordable.** rustfmt is the formatter here, run it. The config is four stable width settings and nothing else:
- **`cargo clippy --all-targets` is clean, and `make check` is what says so. Keep it clean**, and do not silence a lint that is pointing at something real. The only two `allow`s in the tree sit on the `create_ticket` fixtures in `cmd_mv.rs` and `cmd_show.rs`, each carrying the reason and what would replace it
- **`cargo fmt --check` is clean too, `make check` runs it first, and `rustfmt.toml` is what makes that affordable.** rustfmt is the formatter here, run it. The config is four stable width settings and nothing else:
| setting | value | why |
|---|---|---|
@@ -450,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
View File
@@ -1503,7 +1503,7 @@ dependencies = [
[[package]]
name = "worklane"
version = "0.32.19"
version = "0.32.21"
dependencies = [
"anyhow",
"assert_cmd",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "worklane"
version = "0.32.19"
version = "0.32.21"
edition = "2024"
[dependencies]
+23 -1
View File
@@ -5,15 +5,37 @@
# release cannot end up half-done: no version bump left untagged, no tag without
# a bump.
.PHONY: help patch minor major version release install
.PHONY: help check patch minor major version release install
help:
@echo "make check fmt, clippy and the suite, in that order"
@echo "make patch bump $(CURRENT) -> next patch, amend into HEAD, tag"
@echo "make minor bump $(CURRENT) -> next minor, amend into HEAD, tag"
@echo "make major bump $(CURRENT) -> next major, amend into HEAD, tag"
@echo "make version print the current version"
@echo "make install cargo install --path . && worklane install-skill"
# The one command to run before committing. AGENTS.md pins fmt and clippy as clean and
# 83d31cd is what happens when only memory enforces that: fmt drifted to about 160 places
# across every file with the tool installed and configured the whole time. This is not CI,
# which a single-author tool with no pipeline anywhere does not want, and not a hook, which
# is a per-clone opt-in the way `blame.ignoreRevsFile` is. It is one name to type, so
# "remember to run fmt, clippy and the tests" becomes "run make check".
#
# Cheapest first, so a formatting slip is reported in a second rather than after the suite.
# `--all-targets` on clippy, matching the rule in AGENTS.md, so the tests are linted too.
# `-D warnings` is what makes clippy's opinion an exit code: the rule says clean, and a
# warning printed into a wall of cargo output is not clean, it is unread.
#
# Completions are in the suite rather than a step of their own. `cargo test` sources the
# generated script into a real fish and asks it for candidates, so "check tests, check
# completions" is one command already, and a second target would be a second thing to
# remember. The fish tests skip when fish is not installed, printing that they did.
check:
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test
# Read from the [package] table of Cargo.toml, which is the version the binary
# reports through `--version`, so it is the single source of truth. The name is
# what finds this crate's own entry in Cargo.lock.
+12 -1
View File
@@ -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 |
@@ -88,6 +88,17 @@ the command. A pipe holds 64 KiB, so a listing that fits lands in the buffer who
and the writer never learns the reader left, giving 0. Only output past that gets far
enough to be cut off. Either way nothing is printed to stderr.
## Checking
```sh
make check # cargo fmt --check, clippy -D warnings, cargo test
```
One command, cheapest first, and the whole of what enforces the formatting and lint rules:
there is no CI here and no hook. The completion tests inside it source the generated script
into a real fish and ask it what it would offer, so they skip, saying so, on a machine
without fish.
## Releasing
```sh
+111 -6
View File
@@ -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
View File
@@ -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
View File
@@ -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.