Compare commits

...
2 Commits
Author SHA1 Message Date
Ansho Rei 60b43a682e (a136d13) Draw the discarded column behind a three-state visibility rotation, and bump to 0.31.1 2026-08-25 03:33:38 +02:00
Ansho ReiandClaude Fable 5 5bf0fd1bfe (451fb83) Add a discarded status for work that will not be done, and bump to 0.31.0
The flow ended at done, so a ticket that turned out to be a duplicate or
obsolete had nowhere to go: it sat in the backlog or was deleted by hand,
which destroyed the record and left every relation to it dangling. Discarded
is a fifth status with its own directory, keeping the invariant that the
filename, the Status field and the directory agree, and keeping done meaning
the work landed.

Entering it is allowed from any status without -f, because discarding is not
a stage of work. Discarded sits last in Status::ALL, which is what makes the
rest fall out rather than needing cases: nothing follows it, so a discard
clears no stamp and a ticket abandoned from reviewing keeps the journey it
made, and every move out is a backward move, so un-discarding needs -f.

The two dependency guards now look opposite ways. check_blockers asks what a
ticket waits on and gates work moves; check_dependents asks who waits on it
and gates the discard, because those plans depended on work about to be
declared never-happening. Both skip targets that are themselves terminal.

Status::FLOW is the four stages the board draws, so a discarded column on
screen stays a136d13's ticket and done stays the last drawn column. Every
tree walker keeps using Status::ALL, or a discarded ticket would be
unaddressable.

util::is_open replaces three spellings of "not done and not discarded",
across mv, ls and the campaign standing. The board's blocked mark goes
through it as well: that path was only accidentally correct, since a
discarded blocker is absent from the FLOW columns, and drawing the column
later would have diverged it from what mv allows.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-24 19:44:14 +02:00
15 changed files with 848 additions and 191 deletions
+22 -13
View File
@@ -25,16 +25,25 @@
## Ticket File Format
- Filenames: `<uuid_v4>_<slug>.md`
- The slug is the title through `slug()`: lowercased, alphanumerics plus `-` and `_` kept, spaces turned into dashes. `Ticket 06` lands as `<uuid>_ticket-06.md`. Derive fixture filenames through `slug()`, never by hand
- Metadata fields parsed by `parse_ticket_field()`: `ID`, `Priority`, `Tags`, `Due`, `Owner`, `Created At`, `Committed On`, `Submitted On`, `Completed On`, `Campaign`, `Status`. The last four 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 three 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
- **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 by `Completed On` 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
- 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
- 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
- History entries stored in `.worklane/history/<ticket_uuid>/<stamp>_<kind>.md`, with the kind's marker (`**Comment**`, `**Status**`, `**Owner**`, `**Tags**`, `**Campaign**`), then the body, then `**Author**` and `**Time**`. See The History Log
## Status Workflow
`backlog` → `committed` → `reviewing` → `done`
`backlog` → `committed` → `reviewing` → `done`, and `discarded` off to one side
- **`Status::ALL` is every directory that can hold a ticket, and that is the only list left.** It is what the tree walkers want: `status_dirs`, `RelationIndex::load`, `collect_ticket_items`' callers, `cmd_tags`, `list_ids`, the resolver, the digest and the board's own columns all have to see a discarded ticket or it becomes unaddressable. There was a second list, `FLOW`, the four stages work moves through, which used to be what the board drew from; a136d13 drew the discarded column behind a visibility prefix instead, which took FLOW's last reader away, so it is gone. Hiding is decided by `Visibility`, never by leaving a status out of the walk: what is drawn changes, what is read does not. The prefix property survives on the order alone — done and discarded are deliberately the last two in `ALL` — and `the_terminal_columns_are_last_in_the_order_drawn` pins it
- **Discarding is not a stage, so the walk rules do not apply to entering it.** `mv --status discarded` is allowed from any status with no `-f`, because a backlog ticket that turns out to be a duplicate should not have to be walked through committed and reviewing to be abandoned. Leaving it needs `-f`, which comes free from the backward-move rule
- **The two dependency guards look opposite ways, and `mv` picks by direction.** `check_blockers` asks what this ticket waits on and gates work moves; `check_dependents` asks who waits on this ticket and gates the discard. A ticket being abandoned owes nothing to its own blockers, but the tickets blocked *by* it recorded a dependency on work that is about to be declared never-happening, so those plans get a look before the ground moves. `-f` is the caller saying they looked. Both name every offender rather than the first, and both skip targets that are themselves done or discarded
- **Discarded satisfies a block the way done does.** There is nothing left to wait for, and whether the dependent still makes sense was asked at discard time by the guard above, which is what makes it safe to pass here rather than a second place to re-ask
- **Both terminal statuses are hidden by default and counted anyway.** `ls` leaves done and discarded out of the decorated listing and keeps them in the summary counts, and `--ids` and the status positional still reach both: a ticket nobody will work still has to be nameable by a completion or a script
- **A campaign counts a discarded member as finished.** The work was decided out of the campaign rather than left in it, and counting it outstanding would hold a campaign open forever over a ticket nobody will ever do
- **`mv` creates the target directory before moving into it.** A board made before a status existed has no directory for it, and the first move into one is the wrong place to refuse. `init` gets all five from `status_dirs()`
**How to use worklane is in `assets/SKILL.md`, not here.** That document is what
`worklane install-skill` ships, so it is the one place the flow, the move-as-you-work
@@ -45,7 +54,7 @@ and this file is for what someone changing worklane's own code needs.
## Testing
- Run: `cargo test`
- Tests use `assert_cmd` and `assert_fs` for CLI testing
- `setup_worklane()` creates temp `.worklane/` with all four 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
- `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)
- **Every unit-test fixture directory goes through `util::Fixture`, and nothing calls `remove_dir_all` at the end of a test.** `Fixture::new(prefix)` makes a uuid-named directory under the system temp dir and its `Drop` removes it, which is the only shape that also runs when an assertion fails — a trailing line does not, and a failing test is exactly when a fixture is most likely to be stranded. That was b74dc5a: `/tmp` reached 18363 of these and filled the disk, failing a link step and then a `git add` with "No space left on device", an error naming neither the tests nor what they left behind
- **`Fixture` derefs to `Path` and also implements `AsRef<Path>`**, because the two reach different call sites: a parameter typed `&Path` is a coercion site and one bound by `impl AsRef<Path>` is not. `Fixture::child(name)` points the fixture at a directory inside itself while still removing the parent, which is the tree `project_tree` needs. The prefix earns its place on the one path that is ever left behind, which is why this is a small guard rather than `assert_fs::TempDir` — that names its directories `.tmpXXXXXX`, which says nothing about whose they are
@@ -245,7 +254,7 @@ and this file is for what someone changing worklane's own code needs.
- **A card names its campaign on the label row, before the tags, in bold.** `labels_line` draws both, `CAMPAIGN_MARK` (`~`) for the campaign and `#` for a tag, and the campaign takes the row's width first: two cards in one campaign is what a reader looking for a campaign is looking for, and the tags are the context around it. So a row too narrow for both drops the tags whole and keeps the campaign, the order `corner_line` and `project_label` already follow, and a campaign the row will not hold at all goes whole too. A ticket in neither spends no row, so **a ticket in no campaign renders exactly as it did before campaigns reached the card**
- **`Card::campaign` is a resolved `Cell`, not a uuid**, settled at reload the way `project` and `blocked` are. `TicketItem::campaign` already carries the uuid off the pass that builds the card; the name is in another directory, so `columns_of` reads `CampaignIndex` once per project and hands it to every card. Never per draw, the rule `criteria` and `tags` already hold. The merge carries the resolved cell rather than looking it up again, for the reason it carries `blocked`: a campaign is addressed inside one `.worklane`, so a merged lookup could answer one project's uuid with another project's campaign
- **A campaign the board does not hold labels nothing**, the answer `mark_blocked` gives a dangling blocker. `campaign_cells` renders that case as `_missing_` because a metadata table is a place to report a dangling reference; a card is not
- **`c` opens the campaign picker, and taking a campaign filters the tab's columns to its members.** Not a fifth tab: a campaign groups across the flow, so the shape of the answer is the four statuses with fewer cards in them, which is what `campaign show` already answers the question in. Every column is kept, empty ones included. The filter is applied in `reload`, where the columns are built, so nothing downstream has to ask whether a campaign is selected — the board simply holds fewer cards, and `first_match`, `done_count` and the copy key all keep working unchanged
- **`c` opens the campaign picker, and taking a campaign filters the tab's columns to its members.** Not a fifth tab: a campaign groups across the flow, so the shape of the answer is the statuses with fewer cards in them, which is what `campaign show` already answers the question in. Every column is kept, empty ones included. The filter is applied in `reload`, where the columns are built, so nothing downstream has to ask whether a campaign is selected — the board simply holds fewer cards, and `first_match`, `column_count` and the copy key all keep working unchanged
- **`Tab::campaign` is a uuid on the tab, not on the `Board`.** A campaign belongs to one `.worklane`, so a filter carried onto another project's tab would empty it and say nothing about why. It is looked up by uuid rather than held as an index, and a selection whose campaign has left the board is cleared by `reload` rather than left filtering the board to nothing
- **The frame above the columns has two heights, and `Chrome` is what every measurement takes.** `Chrome::campaign` is an `Option<FrameSize>`, not a bool: `None` for a tab showing the whole board, and `Collapsed` or `Expanded` for one filtered to a campaign, because both heights have to be measured the same way by everything that measures the board. `frame_rows` grew a row, so the two bools that decide the geometry became one `Chrome`, copied from `Board::chrome`: adjacent same-typed parameters are what the Rust Style rule warns about, and the draw and `follow_selection` have to measure one answer or a keypress scrolls against a board the next frame does not draw. The row indices are named (`TAB_ROW`, `CAMPAIGN_ROW`, `BOARD_ROW`, `FOOTER_ROW`), since an index written out by hand goes on meaning what it used to
- **The whole description is carried off the one read, and the cut is on the view.** `section_prose` replaced `section_opening`, which cut to the opening line at read time: the campaign file is only in hand while the campaigns directory is being read, so what that read has to carry is everything a view might want, and `CampaignRow::summary` takes the one line the picker draws back off it. Two fields, one cut from the other, are two strings free to come from different reads of the same file
@@ -287,15 +296,15 @@ and this file is for what someone changing worklane's own code needs.
- `tags` is a field on `TicketItem`, filled in `collect_ticket_items` through `parse_tags`, for the reason the criteria count is. `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 the same answer
- **A held-up card carries `BLOCKED_MARK`, `×`, after its id, in brightred.** The constant lives in `util.rs` and the relations block draws the same one, since both say the same word. A ticket waiting on an open blocker looked exactly like one that is ready, and the board is where the next thing to pick up is chosen. Not a fourth circle from Geometric Shapes: those belong to the priority meter two cells away and would read as part of that ramp. The multiplication sign is Latin-1, like the middle dot the unset priority draws, so it renders wherever the meter does
- **The mark goes after the id, not before it.** Ahead of the id it would push every id in the column out of line whenever one card was blocked, which costs more than one card's state is worth. It is measured before the project label and the due date, so both give way to it: those are context for a ticket somebody can start, and this is the one thing on a card that says not to. Dropped whole when the row cannot hold the identity and the mark together, the rule a corner follows
- **`blocked` is on `Card`, not on `TicketItem`.** The answer lives on two tickets at once, so no card can reach it alone, and it is settled at reload the way `project` is. What `collect_ticket_items` fills is the ticket's own `uuid` and its `blockers`, both read off the file it is already holding; `mark_blocked` then walks the four columns once for a uuid-to-status map and once to answer every card. No file is read twice and nothing is asked per draw
- **`blocked` is on `Card`, not on `TicketItem`.** The answer lives on two tickets at once, so no card can reach it alone, and it is settled at reload the way `project` is. What `collect_ticket_items` fills is the ticket's own `uuid` and its `blockers`, both read off the file it is already holding; `mark_blocked` then walks the columns once for a uuid-to-status map and once to answer every card. No file is read twice and nothing is asked per draw
- **A blocker the board does not hold marks nothing**, the answer `mv` already gives a dangling uuid. A Relations section that cannot be parsed reads as no blockers, the exception `detail_of` makes for the same reason: `show` and `mv` are where a hand-edited file is reported, and a board that will not draw because one ticket is malformed is the worse failure
- **The merge carries the flag rather than recomputing it.** `relate` resolves its target inside one `.worklane`, so a blocker in another project is not a relation anything can record; resolving over the merged columns would let one project's uuid match another project's ticket. That is b8ce18c's fourth plan step and the answer is no
- `project_label` takes the width the row has already spent, measured off the spans, rather than adding up the widths those spans are supposed to have. The hand-written version left out the space after the priority mark, so a cut label was handed one cell more than the column had; `the_project_label_leaves_the_row_inside_the_column` pins it
- `due_date` cuts a due value back to its date only when it has one. The field is not validated (daa0e79), so it can hold a time or free text, and taking the first word regardless would turn "next friday" into "next"
- **Done is hidden until `d` asks for it.** Not a new opinion: `ls` already counts done in its summary and leaves it out of the listing. Done only grows, so a quarter of the width was going to the column least often read. The footer carries its count while it is hidden, which is the board's version of that summary line
- **Hiding is a change to what is drawn, never to what is read.** `reload` still scans the done directory and `digest` still watches it, so the footer count is right and revealing the column needs no rescan. Do not "optimise" that into a conditional scan
- `visible()` returns a prefix of `columns`, not a filter, which is what keeps `column` and `offsets` valid as indices into either. It is derived from where `DONE` actually sits rather than assuming the last slot, and `the_done_column_is_last` pins the assumption. A status inserted after done would otherwise hide two columns in silence
- Hiding the column under the selection moves the selection to the last drawn column and **closes an open detail view**. The alternative, refreshing the modal onto whichever ticket the selection landed on, swaps what someone is reading without saying so, which is how a person acts on the wrong ticket. Showing done again is a no-op for the selection, since a column is appended rather than inserted
- **The terminal columns are hidden until `d` asks for them, one step at a time.** Not a new opinion: `ls` already counts both in its summary and leaves them out of the listing. Done only grows, so a quarter of the width was going to the column least often read, and discarded arriving made it two. So `d` rotates three states — hide both, show done, show both, and back around — through the `Visibility` enum on `Board`, discarded last in the rotation because it is the least likely thing to be looking for. The footer names what the *next* press does and carries the count of the column still hidden, which is the board's version of that summary line. Hiding is a prefix of the columns: done and discarded are the last two in what the board draws, so revealing either appends it and the columns before keep their indices
- **Hiding is a change to what is drawn, never to what is read.** `reload` still scans the done and discarded directories and `digest` still watches them, so the footer counts are right and revealing either column needs no rescan. Do not "optimise" that into a conditional scan
- `visible()` returns a prefix of `columns`, not a filter, which is what keeps `column` and `offsets` valid as indices into either. It is derived from where `DONE` and `DISCARDED` actually sit rather than assuming positions, and `the_terminal_columns_are_last_in_the_order_drawn` pins the assumption. A status inserted after discarded would otherwise hide two columns in silence
- Hiding the column under the selection moves the selection to the last drawn column and **closes an open detail view**. The alternative, refreshing the modal onto whichever ticket the selection landed on, swaps what someone is reading without saying so, which is how a person acts on the wrong ticket. Showing another column is a no-op for the selection, since a column is appended rather than inserted
- The choice is not remembered between runs. worklane has no config file and one flag is not a reason to start one; if it should persist, that is its own ticket
- **Assert a column heading against the top border row, not the whole screen.** The footer names done too, so `screen.contains("done (0)")` passes on the footer whether the column is drawn or not. Three tests went vacuous that way the moment done was hidden; `headings()` and `footer()` exist so the next one does not. `headings()` locates the row through `board_area()` rather than taking row zero, since the tab row sits above it when more than one board is monitored
@@ -363,7 +372,7 @@ and this file is for what someone changing worklane's own code needs.
- `worklane tui <path>...` takes any number of paths, each resolved through `find_worklane_dir` the way the working directory is: the first `.worklane` at or above it. No path is the working directory, so a bare `worklane` and `worklane tui` are unchanged
- The failure **names the path** that had no board, since with several arguments "No .worklane directory found" does not say which one was wrong. Only when a path was given: a bare `worklane` has no path to name and keeps the message every other command gives, which is what its integration test asserts
- Two paths inside one project resolve to the same `.worklane` and are monitored once. `projects()` dedupes on the resolved directory, not on the argument
- **`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 `show_done` stays on the board because it is a preference about the flow rather than about a project
- **`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
@@ -447,7 +456,7 @@ and this file is for what someone changing worklane's own code needs.
- Unknown values (`_None_`, `_Not set_`) → grey (38;5;8)
- Priority ramp → brightred (1), red (2), orange (3), cyan (4), grey (5). Green is deliberately absent: it means title
- Relation kind mark → brightred `×` blocked by and blocks, cyan `→` relates to, orange `←` regression of and regressed by. A small ramp inside one column, the way the priority meter is: the mark says which kind of edge the row is, so none of these three is a colour standing in for the uuid or the title beside it. Brightred on the cross rather than red, because the id one cell to its right is red and the two would blend. It is the colour and the glyph a held-up card already carries, which is the point: one vocabulary for blocking
- Relation status mark → grey `○` backlog, orange `◐` committed, cyan `◐` reviewing, green `●` done, grey `?` for a target the board does not hold. The second ramp in that column: the shape says how far the target has got and the colour tells the two middle stages apart, since both are half circles. **Green is here and deliberately absent from the priority ramp**, where it would sit on a whole line and read as a title; on a one-cell mark with no title behind it, it is the obvious colour for finished and nothing else wants it. Orange keeps the meaning it already has, Status, and grey keeps unset for the one row with no status to show
- Relation status mark → grey `○` backlog, orange `◐` committed, cyan `◐` reviewing, green `●` done, grey `●` discarded, grey `?` for a target the board does not hold. Discarded takes the full circle of done in the grey of the untouched pile: nothing is left to do, and it is not an achievement. The *pair* is what has to be unique, which is the same bargain the two half circles already take, and `every_status_has_a_mark` pins it against `status_dirs`. The second ramp in that column: the shape says how far the target has got and the colour tells the two middle stages apart, since both are half circles. **Green is here and deliberately absent from the priority ramp**, where it would sit on a whole line and read as a title; on a one-cell mark with no title behind it, it is the obvious colour for finished and nothing else wants it. Orange keeps the meaning it already has, Status, and grey keeps unset for the one row with no status to show
- Markdown link → cyan, markers and url kept. Not a new meaning for the colour: the plan numbers, the criterion numbers and the `relates to` mark are already cyan inside a rendered body, and a link is the same kind of thing, a pointer the reader may follow rather than a value. The url is not hidden behind the text the way a renderer would hide it, because `show` prints to a terminal worklane cannot assume will make it clickable, and a link whose target cannot be read is worse than a long line
- Chrome → grey. The footer's key names, a rendered `[ ]`, and the overlay's page indicator. Not a new slot: grey already means "what a reader skips", which is the other half of the unset-value meaning, and none of these is a value. The indicator in orange would read as the title it faces across the overlay, in cyan as a timestamp, and in the priority ramp's colours as a level
- Campaign label → its codename through `tag_color`, bold, marked `~`. The colour is what groups a campaign across the cards that carry it, which is exactly what a tag's colour is for, and one word is one colour in every view because `tag_color` is a pure function of it. The mark and the bold are what tell it from a tag on a row that holds both: the mark is not `#`, or the row would read as a list of tags with a stranger in it, and not `@`, which reads as a person on every board anyone has used. `Codename` in a metadata table takes the colour without the mark, since the field name has already said what it is
Generated
+1 -1
View File
@@ -1503,7 +1503,7 @@ dependencies = [
[[package]]
name = "worklane"
version = "0.30.0"
version = "0.31.1"
dependencies = [
"anyhow",
"assert_cmd",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "worklane"
version = "0.30.0"
version = "0.31.1"
edition = "2024"
[dependencies]
+4 -4
View File
@@ -5,12 +5,12 @@ Worklane is a local Kanban flow for agentic software development.
## Commands
| Command | Description |
|---------|-------------|
| `worklane` or `worklane tui [path...]` | Opens the board: four status columns, redrawn when the tree changes. Read only. Opens on backlog, committed and reviewing; `d` shows or hides done, whose count stays in the footer either way. 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 directories |
| `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 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. 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 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 |
| `worklane append <ticket>` | Adds to a section with `--description`, `--acceptance`, `--plan`. At least one required. The description gains a paragraph; list items go on the end, steps numbered on from the last |
| `worklane relate <ticket>` | Records an edge to another ticket with `--blocked-by`, `--regression-of` or `--relates-to`, each repeatable. At least one required. Only the ticket named is written; `show` derives the other end by scanning. `mv` refuses to move a ticket blocked by one that is not done, unless `-f` |
@@ -51,7 +51,7 @@ asks worklane for the one thing only the board knows:
```
worklane show <TAB> every ticket, id and title, done included
worklane mv <TAB> the same, then --status <TAB> for the four
worklane mv <TAB> the same, then --status <TAB> for the five
worklane chown alice <TAB> the ticket, which is the second argument here
worklane chown --clear <TAB> the ticket, which the flag carries here
worklane relate x --blocked-by <TAB>
+47 -18
View File
@@ -1,6 +1,6 @@
---
name: worklane
description: Manage tickets on a local worklane kanban board with the `worklane` CLI, backed by markdown files in a `.worklane/` directory. Use whenever you need to file, find, read, update, comment on or move a ticket, when asked what is on the board or what to pick up next, and when reporting work you are not going to do in the change at hand. Covers the four statuses, how a ticket is addressed, what belongs in each section, and the argument traps that silently swallow a flag.
description: Manage tickets on a local worklane kanban board with the `worklane` CLI, backed by markdown files in a `.worklane/` directory. Use whenever you need to file, find, read, update, comment on or move a ticket, when asked what is on the board or what to pick up next, and when reporting work you are not going to do in the change at hand. Covers the five statuses, how a ticket is addressed, what belongs in each section, and the argument traps that silently swallow a flag.
---
# worklane
@@ -20,7 +20,7 @@ a person, not for you: it takes over the screen and does not return until quit.
## The flow
`backlog` → `committed` → `reviewing` → `done`
`backlog` → `committed` → `reviewing` → `done`, with `discarded` off to one side
**Move the ticket as you work it, not afterwards.** `worklane mv <id> --status committed`
before writing any code, and `--status reviewing` once it is done and the tests pass. The
@@ -35,11 +35,39 @@ skipping move, for correcting a mistake.
A move is also refused while the ticket is blocked by one that is not done yet, see
[Relating tickets](#relating-tickets).
`mv` stamps the time as it goes: `Committed On`, `Submitted On` and `Completed On`, one
field for the status the ticket is in now, shown by `show` among the rest of the
metadata. Only the current one is kept, so the stamp says how long the ticket has been
where it is, not how long each earlier stage took. Nothing else writes them, and moving
a ticket back removes the stamp of the status it left.
`mv` stamps the time as it goes: `Committed On`, `Submitted On`, `Completed On` and
`Discarded On`, shown by `show` among the rest of the metadata. They **accumulate**, so a
ticket that walked the whole flow carries all of them side by side and the journey is
legible; presence means it got that far and has not been sent back past it, not that it
is there now, which is what `Status` says. Moving a ticket back drops the stamps of every
stage after where it lands.
## Discarding a ticket
`worklane mv <id> --status discarded` is where a ticket goes that will not be done: a
duplicate, something obsolete, something that turned out to be wrong. It keeps the record
and the relations, which deleting the file by hand would destroy.
```
worklane mv 1b78a24 --status discarded
```
Reachable from any status and needs no `-f`, because discarding is not a stage of work: a
backlog ticket does not have to be walked through `committed` to be abandoned. **Say why
in a comment before you discard it.** The status records that it will not happen and
nothing records what was decided, and that is the question somebody asks in six months.
What it means everywhere else:
- `ls` leaves it out of the listing and keeps it in the counts, the way it treats `done`.
`ls discarded` and `--ids` still reach it
- A campaign counts a discarded member as **finished**: the work left the campaign rather
than sitting in it unfinished
- A discarded ticket **blocks nothing**, so a ticket waiting on it can move
- Discarding a ticket that open tickets are blocked by is **refused**, naming them: their
plans depended on this work, so they need a look first. `-f` says you looked
- Getting it back is a backward move, so it needs `-f`:
`worklane mv 1b78a24 --status backlog -f`
## Reading the board
@@ -54,7 +82,7 @@ worklane show 1b78a24 # one ticket, body and history
`ls` prints a seven-character id per ticket. That is what you address it by.
`worklane ls --ids` prints the same tickets as an id, a tab and a title, one per line and
unstyled, with done included and the filters still applying. That is the form to parse
unstyled, with done and discarded included and the filters still applying. That is the form to parse
when you want the ids themselves: `worklane ls --ids | cut -f1`. The decorated listing is
for reading, not for cutting up.
@@ -159,7 +187,7 @@ one command here that does not start with the ticket. The user is free text and
checked against nothing. Swap the two and the call fails, because the username has to
resolve as a ticket. `--clear` replaces both arguments with the ticket alone.
`worklane init` creates `.worklane/` with the four status directories and the campaigns
`worklane init` creates `.worklane/` with the five status directories and the campaigns
directory beside them, for a repo that has no board yet.
## Relating tickets
@@ -176,9 +204,10 @@ on B. **Only one side is stored**, on the ticket you name, and `show` derives th
end for the ticket at the far side, so never record both directions.
`--blocked-by` is enforced: `mv` refuses to move a ticket while a ticket it is blocked by
is not in `done`, whichever move it is, and names every open blocker. `-f` moves it
anyway, beside the backward and skipping moves it already allows. The other two kinds are
reference data and never refuse anything.
is not in `done` or `discarded`, whichever move it is, and names every open blocker. `-f`
moves it anyway, beside the backward and skipping moves it already allows. It is enforced
from the other end too: discarding a ticket that open tickets are blocked by is refused,
naming them. The other two kinds are reference data and never refuse anything.
Recording a relation the ticket already holds reports no change. A ticket cannot relate
to itself, and a target that later disappears shows as `_missing_` rather than silently
@@ -187,15 +216,15 @@ going away.
`show` marks each row twice, kind then status. The kind is `×` for `blocked by` and
`blocks`, `→` for `relates to`, `←` for `regression of` and `regressed by`; both
directions of one kind carry one mark, and the label is what says which end you are on.
The status is the target's own: `○` backlog, `◐` committed or reviewing, `●` done, and
`?` for a target the board no longer holds. So `blocked by × ● (1b78a24)` is a blocker
The status is the target's own: `○` backlog, `◐` committed or reviewing, `●` done or
discarded, and `?` for a target the board no longer holds. So `blocked by × ● (1b78a24)` is a blocker
that is finished and `blocked by × ○ (1b78a24)` is one nobody has started. The board
draws the same block.
Colour is what tells committed from reviewing, since both are `◐`, and **your output is a
pipe, so you do not get the colour**. Read `◐` as under way, and if it matters which
stage, `worklane show` on that target says so in its Status field. `●` and `○` are
unambiguous without it, which are the two answers usually being asked for.
Colour is what tells committed from reviewing apart, and done from discarded, since each
pair shares a glyph, and **your output is a pipe, so you do not get the colour**. Read
`◐` as under way and `●` as nothing left to do, and if it matters which of the two,
`worklane show` on that target says so in its Status field. `○` is unambiguous without it.
## Campaigns
+7 -3
View File
@@ -207,11 +207,11 @@ pub fn resolved_for(content: &str, worklane_dir: &Path) -> Result<Resolved> {
})
}
/// The members of a campaign, grouped by status in flow order.
/// The members of a campaign, grouped by status in flow order, discarded last.
///
/// Read through `collect_ticket_items`, the source `ls` and the board already use, so
/// there is no second parser and the rows print the way every other listing does.
/// Empty groups are kept: a campaign's shape is the four statuses, and a caller that
/// Empty groups are kept: a campaign's shape is the statuses, and a caller that
/// wants only the filled ones can say so.
pub fn members(worklane_dir: &Path, uuid: &str) -> Result<Vec<(&'static str, Vec<TicketItem>)>> {
let mut grouped = Vec::new();
@@ -251,9 +251,13 @@ pub struct Standing {
impl Standing {
pub fn of(grouped: &[(&'static str, Vec<TicketItem>)]) -> Self {
Self {
// Discarded counts as finished: the work was decided out of the campaign,
// not left in it, and one abandoned ticket must not hold a campaign open
// forever. The same predicate `mv` gates on, so "nothing outstanding" means
// one thing across the tool.
done: grouped
.iter()
.filter(|(status, _)| *status == DONE)
.filter(|(status, _)| !is_open(status))
.map(|(_, items)| items.len())
.sum(),
total: grouped.iter().map(|(_, items)| items.len()).sum(),
+1 -1
View File
@@ -568,7 +568,7 @@ mod tests {
status.as_str()
);
}
assert!(script.contains("-a 'backlog committed reviewing done' -d status"));
assert!(script.contains("-a 'backlog committed reviewing done discarded' -d status"));
for shell in ["fish", "bash", "zsh", "elvish", "powershell"] {
assert!(script.contains(shell), "the shell positional is never offered {shell}");
}
+73 -9
View File
@@ -113,11 +113,12 @@ pub fn cmd_ls(args: &LsArgs, worklane_dir: &Path) -> Result<()> {
println!(" [{}] {} {}", status.to_uppercase(), count, label);
}
// Show all tickets except done grouped by status. Over `Status::ALL` rather
// than the names, because each column is ordered by its own entry stamp and the
// comparator is keyed on the status, not on the directory it was read from.
// Show all tickets except the two terminal statuses, grouped by status. Over
// `Status::ALL` rather than the names, because each column is ordered by its own
// entry stamp and the comparator is keyed on the status, not on the directory it
// was read from.
for status in Status::ALL {
if status.as_str() == DONE {
if !is_open(status.as_str()) {
continue;
}
let status_path = worklane_dir.join(status.as_str());
@@ -524,7 +525,10 @@ fn check_blockers(worklane_dir: &Path, content: &str, title: &str) -> Result<()>
for blocker in &blockers {
match index.get(&blocker.target) {
Some(target) if target.status == DONE => {}
// Discarded satisfies a block the way done does: there is nothing left to
// wait for. Whether the dependent still makes sense was asked when the
// blocker was discarded, which is `check_dependents`' refusal.
Some(target) if !is_open(&target.status) => {}
Some(target) => open.push(format!(
" ({}) {} [{}]",
color_text(short_id(&target.uuid), Color::Red),
@@ -552,6 +556,49 @@ fn check_blockers(worklane_dir: &Path, content: &str, title: &str) -> Result<()>
))
}
/// Refuse discarding a ticket while open tickets are blocked by it.
///
/// The mirror of [`check_blockers`], asked at the other end of the edge: those tickets
/// recorded a dependency on work that is about to be declared never-happening, so their
/// plans need a look before the ground moves. `-f` is the caller saying they looked.
///
/// Tickets already done or discarded do not hold it up: a dependency that was satisfied
/// or abandoned is nobody's plan anymore.
fn check_dependents(worklane_dir: &Path, uuid: &str, title: &str) -> Result<()> {
let index = RelationIndex::load(worklane_dir)?;
// Every open dependent, not the first, for the reason `check_blockers` names them
// all.
let waiting: Vec<String> = index
.iter()
.filter(|ticket| is_open(&ticket.status))
.filter(|ticket| {
ticket
.relations
.iter()
.any(|relation| relation.kind == RelationKind::BlockedBy && relation.target == uuid)
})
.map(|ticket| {
format!(
" ({}) {} [{}]",
color_text(short_id(&ticket.uuid), Color::Red),
ticket.title,
color_text(&ticket.status, Color::Orange),
)
})
.collect();
if waiting.is_empty() {
return Ok(());
}
Err(anyhow!(
"Cannot discard '{}' while open tickets are blocked by it:\n{}\nUse --force (-f) to discard it anyway.",
color_text(title, Color::Green),
waiting.join("\n"),
))
}
/// A status is a [`Status`] rather than a string, so an unknown one is clap's to refuse
/// and nothing here has to check. What is left is the order of the flow, which is
/// `Status::ALL`.
@@ -573,7 +620,13 @@ pub fn cmd_mv(
.unwrap();
let target_idx = Status::ALL.iter().position(|status| *status == target).unwrap();
if !force && target_idx < current_idx {
// Discarding is not a stage of work, so the walk rules below do not apply to
// entering it: a ticket is abandoned from wherever it stands. They do apply to
// leaving it, which with discarded last in `Status::ALL` is always a backward move,
// so un-discarding needs `-f` with no rule of its own.
let discarding = target == Status::Discarded;
if !force && !discarding && target_idx < current_idx {
return Err(anyhow!(
"Cannot move backward from {} to {}. Use --force (-f) to allow.",
color_text(&current_status, Color::Orange),
@@ -581,7 +634,7 @@ pub fn cmd_mv(
));
}
if !force && target_idx != current_idx + 1 && target_idx != current_idx {
if !force && !discarding && target_idx != current_idx + 1 && target_idx != current_idx {
return Err(anyhow!(
"Can only move one stage forward at a time. Use --force (-f) to skip stages."
));
@@ -597,14 +650,25 @@ pub fn cmd_mv(
// After the no-op above, so a ticket is never refused for a move it is not making,
// and behind `force`, which is where the other two overrides of a rule the board
// keeps true already live.
// keeps true already live. The two guards look opposite ways: a ticket being worked
// must not run ahead of what it waits on, and a ticket being abandoned owes nothing
// to its own blockers but must not be pulled out from under the tickets waiting on
// it.
if !force {
check_blockers(&worklane_dir, &resolved, &title)?;
match discarding {
true => check_dependents(&worklane_dir, &parse_ticket_field(&resolved, "ID"), &title)?,
false => check_blockers(&worklane_dir, &resolved, &title)?,
}
}
let current_path = worklane_dir.join(&current_status);
let target_path = worklane_dir.join(target_status);
// A board created before a status existed has no directory for it, and the first
// move into one is the wrong place to refuse. Idempotent for every board that has
// it.
fs::create_dir_all(&target_path)?;
// Updated before the file is even located, so a ticket without a Status field is
// refused for that reason rather than for whatever the lookup notices first.
let content = set_status_field(&resolved, target_status, &title)?;
+3 -2
View File
@@ -238,8 +238,9 @@ fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()>
// columns took hjkl and the arrows.
KeyCode::Tab => board.select_tab(1, screen),
KeyCode::BackTab => board.select_tab(-1, screen),
// Free of the other bindings, and the footer names it in both states.
KeyCode::Char('d') => board.toggle_done(screen),
// Free of the other bindings, and the footer names what the next press
// does in every state of the rotation.
KeyCode::Char('d') => board.rotate_visibility(screen),
// An ordinary single-shot action like the rest: it opens the prompt, and
// from the next keypress on `search_key` above has the keyboard. A `/`
// typed into an open prompt is taken there as a character, and one pressed
+312 -116
View File
@@ -1,4 +1,6 @@
//! The board as four columns, redrawn when the tree underneath it moves.
//! The board as one column per status, redrawn when the tree underneath it moves. The
//! two terminal columns are hidden until `d` reveals them, one step of the rotation at
//! a time.
//!
//! Modelled on frig's TUI: event poll on a short timeout so timed work still runs when
//! nobody is typing, state refreshed on a tick, and the terminal restored whatever
@@ -494,29 +496,31 @@ impl Tab {
self.campaigns.iter().find(|row| row.uuid == uuid)
}
/// The columns that are drawn: all of them, or everything up to done.
/// The columns that are drawn: all of them, or everything up to the reach of the
/// visibility.
///
/// A prefix rather than a filter, which is what keeps `column` and `offsets` usable
/// as indices into either. Taken from where done actually is instead of assuming the
/// last slot, with a test pinning done as last so the two cannot drift apart.
fn visible(&self, show_done: bool) -> &[Column] {
&self.columns[..self.visible_count(show_done)]
/// as indices into either. Taken from where done and discarded actually sit instead
/// of assuming positions, with `the_terminal_columns_are_last_in_the_order_drawn`
/// pinning the order so the two cannot drift apart.
fn visible(&self, visibility: Visibility) -> &[Column] {
&self.columns[..self.visible_count(visibility)]
}
fn visible_count(&self, show_done: bool) -> usize {
if show_done {
return self.columns.len();
}
match self.columns.iter().position(|column| column.status == DONE) {
Some(index) => index,
fn visible_count(&self, visibility: Visibility) -> usize {
match visibility.next_reveal() {
Some(status) => self
.columns
.iter()
.position(|column| column.status == status)
.unwrap_or(self.columns.len()),
None => self.columns.len(),
}
}
/// Keep the selection on a card that exists, after the board changes under it.
fn clamp(&mut self, show_done: bool) {
let visible = self.visible_count(show_done);
fn clamp(&mut self, visibility: Visibility) {
let visible = self.visible_count(visibility);
if visible == 0 {
self.column = 0;
self.card = 0;
@@ -878,6 +882,44 @@ fn tag_matches(tag: &TagRow, query: &str) -> bool {
.is_some_and(|annotation| annotation.to_lowercase().contains(&query))
}
/// How much of the flow's tail is drawn: neither terminal column, done alone, or both.
///
/// The states are cumulative rather than independent, which is what keeps hiding a
/// prefix of the columns and the selection arithmetic that rests on it working
/// unchanged. `d` walks the rotation in this order and wraps; discarded sits last in
/// it because it is the least likely thing to be looking for. The default is the
/// board's opening state, the opinion `ls` holds: both are counted everywhere and
/// drawn nowhere until asked for.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Visibility {
#[default]
Neither,
Done,
Both,
}
impl Visibility {
/// The next state of the rotation, wrapping back to hidden from the top.
fn advance(self) -> Self {
match self {
Visibility::Neither => Visibility::Done,
Visibility::Done => Visibility::Both,
Visibility::Both => Visibility::Neither,
}
}
/// The status whose column this state reveals on the next press, which is also the
/// boundary the drawn prefix stops short of: everything before it is on screen.
/// Nothing left to reveal means nothing is hidden.
fn next_reveal(self) -> Option<&'static str> {
match self {
Visibility::Neither => Some(DONE),
Visibility::Done => Some(DISCARDED),
Visibility::Both => None,
}
}
}
/// What is on screen.
pub struct Board {
/// The monitored boards as tabs, the merge first when there is more than one.
@@ -894,11 +936,11 @@ pub struct Board {
pub picker: Option<Picker>,
/// What the last action said, until the next keypress takes it away.
pub notice: Option<Notice>,
/// Whether the done column is drawn. Off at startup, and not remembered between
/// runs: worklane has no config file, and one flag is not a reason to start one.
/// Board-wide rather than per tab: it is a preference about the flow, not about a
/// project.
pub show_done: bool,
/// How many of the terminal columns are drawn. Hidden at startup, and not
/// remembered between runs: worklane has no config file, and one flag is not a
/// reason to start one. Board-wide rather than per tab: it is a preference about
/// the flow, not about a project.
pub visibility: Visibility,
pub should_quit: bool,
projects: Vec<Project>,
digest: u64,
@@ -928,7 +970,7 @@ impl Board {
search: None,
picker: None,
notice: None,
show_done: false,
visibility: Visibility::default(),
should_quit: false,
projects,
digest: 0,
@@ -1073,7 +1115,7 @@ impl Board {
// columns is not a thing statuses do, but the resize keeps the two in step
// regardless; `resize` both pads and truncates.
tab.offsets.resize(tab.columns.len(), 0);
tab.clamp(self.show_done);
tab.clamp(self.visibility);
}
self.digest = digest_of(&self.projects);
@@ -1097,11 +1139,11 @@ impl Board {
/// The columns of the tab in view that are drawn.
pub fn visible(&self) -> &[Column] {
self.current().visible(self.show_done)
self.current().visible(self.visibility)
}
fn visible_count(&self) -> usize {
self.current().visible_count(self.show_done)
self.current().visible_count(self.visibility)
}
/// Move to another tab, cycling at either end.
@@ -1109,8 +1151,8 @@ impl Board {
/// Tabs cycle where the cards and columns clamp: a ring is what a row of tabs is
/// everywhere else, and there is no bottom of a list to run out of. The tab keeps
/// its own selection, so all this has to do is check that the selection is still on
/// a card that exists — done may have been hidden while another tab was in view —
/// and bring it into the window.
/// a card that exists — terminal columns may have been hidden while another tab was
/// in view — and bring it into the window.
pub fn select_tab(&mut self, delta: isize, screen: Size) {
let count = self.tabs.len() as isize;
if count < 2 {
@@ -1119,28 +1161,31 @@ impl Board {
self.tab = (self.tab as isize + delta).rem_euclid(count) as usize;
let show_done = self.show_done;
self.current_mut().clamp(show_done);
let visibility = self.visibility;
self.current_mut().clamp(visibility);
self.follow_selection(screen);
self.refresh_detail();
}
/// Show or hide the done column.
/// Advance the rotation one step: hide both, show done, show both, and back around.
///
/// `ls` already holds this opinion: it counts done in its summary and leaves it out
/// of the listing. Done only grows, so a quarter of the width goes to the column
/// least often read while the three being worked get squeezed for it.
/// `ls` already holds the opinion the first state takes: it counts both terminal
/// statuses in its summary and leaves them out of the listing. Done only grows, so
/// a quarter of the width went to the column least often read; discarded is the
/// same again, and the least likely thing to be looking for, which is why it is
/// last in the rotation.
///
/// Hiding is a change to what is drawn, never to what is read. The directory stays
/// scanned and stays in the digest, so the count in the footer is right and revealing
/// the column needs no rescan.
pub fn toggle_done(&mut self, screen: Size) {
self.show_done = !self.show_done;
/// Hiding is a change to what is drawn, never to what is read: the directories stay
/// scanned and stay in the digest, so the counts in the footer are right and
/// revealing a column needs no rescan.
///
/// Showing a column appends it, so nothing below is reached and the selection stays
/// exactly where it was. Only the tab in view is corrected: the others are clamped
/// as they are switched to, since a selection nobody is looking at cannot be
/// pointing at anything on screen.
pub fn rotate_visibility(&mut self, screen: Size) {
self.visibility = self.visibility.advance();
// Showing done again appends a column, so nothing below is reached and the
// selection stays exactly where it was. Only the tab in view is corrected: the
// others are clamped as they are switched to, since a selection nobody is
// looking at cannot be pointing at anything on screen.
if self.current().column < self.visible_count() {
return;
}
@@ -1148,8 +1193,8 @@ impl Board {
// Hiding the column the selection is in moves it to the last one still drawn.
// An open detail closes with it: it is showing a ticket that is no longer on the
// board, and quietly swapping it for a different ticket is worse than closing.
let show_done = self.show_done;
self.current_mut().clamp(show_done);
let visibility = self.visibility;
self.current_mut().clamp(visibility);
self.detail = None;
self.offset = 0;
self.follow_selection(screen);
@@ -1177,10 +1222,10 @@ impl Board {
// Bounded by what is drawn, so the selection cannot walk into a hidden column.
let last = visible as isize - 1;
let show_done = self.show_done;
let visibility = self.visibility;
let tab = self.current_mut();
tab.column = (tab.column as isize + delta).clamp(0, last) as usize;
tab.clamp(show_done);
tab.clamp(visibility);
// Entering a column shows the card the selection landed on rather than
// resetting to its top: the card index carries across columns, so a reset
// would open the column with the highlight below the fold whenever it was.
@@ -1998,7 +2043,7 @@ fn span_from(text: impl Into<String>, color: Option<Color>) -> Span<'static> {
Span::styled(text.into(), style)
}
/// The four columns of one board, with each card's campaign already named.
/// The columns of one board, with each card's campaign already named.
///
/// The index is read once here and handed to every card, rather than looked up per card
/// or, worse, per draw: the uuid is on the ticket and the name is in another directory,
@@ -2013,13 +2058,16 @@ fn columns_of(worklane_dir: &Path) -> (Vec<Column>, CampaignIndex, TagIndex) {
// `unwrap_or_default` on the campaigns index already avoids.
let tags = TagIndex::load(worklane_dir).unwrap_or_default();
// 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.
// Over `Status::ALL`: the board draws every status, and hiding the two terminal
// ones is a change to what is drawn, never to what is read. The footer counts are
// read off these columns while the columns are hidden, so revealing one needs no
// rescan. 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.
// every status is the shape of the board.
let mut cards: Vec<Card> = collect_ticket_items(worklane_dir.join(status.as_str()))
.unwrap_or_default()
.into_iter()
@@ -2163,7 +2211,11 @@ fn retain_tag(mut columns: Vec<Column>, tag: Option<&str>) -> Vec<Column> {
/// The cards are already in hand here, and a campaign's members are exactly the cards
/// naming its uuid, so this is what `Standing::of` builds for `campaign ls` without the
/// walk of the status directories that one pays per campaign. Every column, drawn or not:
/// hiding done is a change to what is drawn and never to what is counted.
/// hiding the terminal columns is a change to what is drawn and never to what is counted.
///
/// A discarded member counts as finished, the rule `Standing::of` and `campaign ls`
/// already hold: the work was decided out of the campaign rather than left in it. One
/// spelling of that through [`is_open`], so the two counters cannot drift.
///
/// A campaign nothing names is absent rather than zeroed, which `campaign_rows` reads as
/// the default standing — `no members`, the same answer `campaign show` gives it.
@@ -2178,7 +2230,7 @@ fn standings_of(columns: &[Column]) -> HashMap<&str, Standing> {
let standing = standings.entry(uuid).or_default();
standing.total += 1;
standing.done += usize::from(column.status == DONE);
standing.done += usize::from(!is_open(column.status));
}
}
@@ -2190,7 +2242,7 @@ fn standings_of(columns: &[Column]) -> HashMap<&str, Standing> {
///
/// Every column is kept, empty ones included, for the reason `campaign show` prints every
/// status: a campaign groups across the flow rather than within one status, so the shape of
/// the answer is the four columns and the question is how many are in each. Filtered here,
/// the answer is one column per status and the question is how many are in each. Filtered here,
/// where the columns are built, so nothing downstream has to ask whether a campaign is
/// selected — the board simply holds fewer cards.
fn retain_campaign(mut columns: Vec<Column>, campaign: Option<&str>) -> Vec<Column> {
@@ -2245,21 +2297,25 @@ fn mark_blocked(columns: &mut [Column]) {
for column in columns.iter_mut() {
for card in column.cards.iter_mut() {
card.blocked = card.ticket.blockers.iter().any(|blocker| {
matches!(status_of.get(blocker.as_str()), Some(status) if *status != DONE)
matches!(status_of.get(blocker.as_str()), Some(status) if is_open(status))
});
}
}
}
/// Every board's columns as one set of four, each card labelled with the project it
/// Every board's columns as one set, each card labelled with the project it
/// came from.
///
/// Sorted through `by_priority_then_title`, the order the listing uses, rather than
/// left as one project's column after another's: an overview whose order depended on
/// the argument order would bury a p1 under another project's p5.
fn merge(per_project: &[Vec<Column>], projects: &[Project]) -> Vec<Column> {
status_dirs()
// All five, matching what `columns_of` builds: the merge is indexed beside the
// project tabs, and hiding is decided by the visibility, never by leaving a status
// out here.
Status::ALL
.into_iter()
.map(Status::as_str)
.enumerate()
.map(|(index, status)| {
let mut cards: Vec<Card> = Vec::new();
@@ -3166,11 +3222,13 @@ fn draw_footer(frame: &mut Frame, board: &Board, area: Rect) {
return;
}
// While done is hidden its count goes here, which is the board's version of the
// summary line `ls` prints above a listing that leaves done out.
let done = match board.show_done {
true => "d hide done".to_string(),
false => format!("d show done ({})", done_count(board)),
// The next press names itself here, whichever state the rotation is in, and the
// column it would reveal keeps its count until it is drawn. That is the board's
// version of the summary line `ls` prints above a listing that leaves the terminal
// statuses out.
let d = match board.visibility.next_reveal() {
Some(status) => format!("d show {} ({})", status, column_count(board, status)),
None => "d hide both".to_string(),
};
// Only when there is a tab to move to, since the footer names keys that work.
@@ -3224,13 +3282,13 @@ fn draw_footer(frame: &mut Frame, board: &Board, area: Rect) {
let keys = match (board.detail.is_some(), board.current().focus) {
(true, _) => format!(
" {tabs}←→↑↓ select pgup/pgdn scroll / search y copy id enter/q close {done} {quit} "
" {tabs}←→↑↓ select pgup/pgdn scroll / search y copy id enter/q close {d} {quit} "
),
(false, Focus::Frame) => format!(
" {tabs}↓ board {height} pgup/pgdn scroll / search y copy id {done} {quit} "
" {tabs}↓ board {height} pgup/pgdn scroll / search y copy id {d} {quit} "
),
(false, Focus::Cards) => format!(
" {tabs}←→ column ↑↓ card / search {filter}y copy id enter detail {done} {quit} "
" {tabs}←→ column ↑↓ card / search {filter}y copy id enter detail {d} {quit} "
),
};
@@ -3321,13 +3379,13 @@ fn draw_picker_row(frame: &mut Frame, picker: &Picker, area: Rect) {
frame.set_cursor_position((area.x + at, area.y));
}
/// How many tickets are in done on the tab in view, drawn or not.
fn done_count(board: &Board) -> usize {
/// How many tickets are in one status on the tab in view, drawn or not.
fn column_count(board: &Board, status: &str) -> usize {
board
.current()
.columns
.iter()
.find(|column| column.status == DONE)
.find(|column| column.status == status)
.map_or(0, |column| column.cards.len())
}
@@ -3942,44 +4000,92 @@ mod tests {
}
#[test]
fn the_board_draws_the_four_statuses_as_columns_once_done_is_shown() {
fn the_board_draws_every_status_as_a_column_once_both_are_shown() {
let dir = board_dir();
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
write_ticket(&dir, "committed", "22222222-0000-4000-8000-000000000000", "Second one", "");
write_ticket(&dir, DISCARDED, "55555555-0000-4000-8000-000000000000", "Gone one", "");
let mut board = one_board(&dir);
board.toggle_done(SCREEN);
let row = headings(&board, 120, 20);
board.rotate_visibility(SCREEN);
board.rotate_visibility(SCREEN);
let row = headings(&board, 140, 20);
for heading in ["backlog (1)", "committed (1)", "reviewing (0)", "done (0)"] {
for heading in [
"backlog (1)",
"committed (1)",
"reviewing (0)",
"done (0)",
"discarded (1)",
] {
assert!(row.contains(heading), "no {heading:?} in:\n{row}");
}
}
/// Done only grows, and it is the column least often read. `ls` already leaves it
/// out of its listing while counting it in the summary; this is the same opinion.
/// The terminal columns only grow, and they are the ones least often read. `ls`
/// already leaves them out of its listing while counting them in the summary; the
/// first state of the rotation is the same opinion.
#[test]
fn the_board_opens_with_the_done_column_hidden() {
fn the_board_opens_with_the_terminal_columns_hidden() {
let dir = board_dir();
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
write_ticket(&dir, "done", "44444444-0000-4000-8000-000000000000", "Finished one", "");
write_ticket(&dir, DISCARDED, "55555555-0000-4000-8000-000000000000", "Dropped one", "");
let board = one_board(&dir);
assert!(!board.show_done, "done was drawn at startup");
assert_eq!(board.visibility, Visibility::Neither, "a column was drawn at startup");
let row = headings(&board, 120, 20);
for heading in ["backlog (1)", "committed (0)", "reviewing (0)"] {
assert!(row.contains(heading), "no {heading:?} in:\n{row}");
}
assert!(!row.contains("done"), "done is still a column:\n{row}");
assert!(!row.contains("discarded"), "discarded is still a column:\n{row}");
// Hidden, not unread: the count is right and revealing it needs no rescan.
assert_eq!(board.current().columns.len(), 4);
// Hidden, not unread: the counts are right and revealing either needs no rescan.
assert_eq!(board.current().columns.len(), Status::ALL.len());
assert_eq!(board.visible().len(), 3);
assert_eq!(done_count(&board), 1);
assert_eq!(column_count(&board, DONE), 1);
assert_eq!(column_count(&board, DISCARDED), 1);
let screen = render(&board, 120, 20).join("\n");
assert!(!screen.contains("Finished one"), "a hidden done ticket was drawn");
assert!(!screen.contains("Dropped one"), "a hidden discarded ticket was drawn");
}
/// The rotation itself, one press at a time: hide both, show done, show both, and
/// back to hidden. Done first because it is the more likely thing to be looking
/// for; discarded last because it is the least.
#[test]
fn d_rotates_hidden_then_done_then_both_and_back_to_hidden() {
let dir = board_dir();
write_ticket(&dir, "reviewing", "33333333-0000-4000-8000-000000000000", "Ready", "");
write_ticket(&dir, "done", "44444444-0000-4000-8000-000000000000", "Finished", "");
write_ticket(&dir, DISCARDED, "55555555-0000-4000-8000-000000000000", "Dropped", "");
let mut board = one_board(&dir);
board.rotate_visibility(SCREEN);
assert_eq!(board.visibility, Visibility::Done);
assert_eq!(board.visible().len(), 4);
assert!(headings(&board, 120, 20).contains("done (1)"), "done was not drawn");
assert!(
!render(&board, 120, 20).join("\n").contains("Finished one"),
"a hidden done ticket was drawn"
!render(&board, 140, 20).join("\n").contains("Dropped"),
"discarded came with done"
);
board.rotate_visibility(SCREEN);
assert_eq!(board.visibility, Visibility::Both);
assert_eq!(board.visible().len(), Status::ALL.len());
let row = headings(&board, 140, 20);
assert!(row.contains("discarded (1)"), "{row}");
board.rotate_visibility(SCREEN);
assert_eq!(board.visibility, Visibility::Neither);
assert_eq!(board.visible().len(), 3);
assert!(
!render(&board, 140, 20).join("\n").contains("Finished"),
"done stayed drawn after the wrap"
);
}
@@ -3993,35 +4099,62 @@ mod tests {
assert_eq!(hidden.matches('┌').count(), 3, "{hidden}");
assert!(hidden.ends_with('┐'), "the columns stop short of the edge:\n{hidden}");
board.toggle_done(SCREEN);
board.rotate_visibility(SCREEN);
let shown = headings(&board, 120, 20);
assert_eq!(shown.matches('┌').count(), 4, "{shown}");
assert!(shown.ends_with('┐'), "{shown}");
board.rotate_visibility(SCREEN);
let both = headings(&board, 140, 20);
assert_eq!(both.matches('┌').count(), 5, "{both}");
assert!(both.ends_with('┐'), "{both}");
}
/// Hiding is a prefix of the columns, which only holds while done is last. The
/// board leans on that, so the assumption is pinned rather than assumed.
/// Hiding is a prefix of the columns, which only holds while done and discarded are
/// the last two of what the board draws. The board leans on that, so the assumption
/// is pinned rather than assumed. Discarded being last overall is the other decided
/// order: the stamp arrival rule truncates by `Status::ALL`, so discarded after done
/// is what lets a discard keep the journey the ticket made.
#[test]
fn the_done_column_is_last() {
assert_eq!(status_dirs().last(), Some(&DONE));
fn the_terminal_columns_are_last_in_the_order_drawn() {
let last: Vec<&str> = Status::ALL.iter().map(|status| status.as_str()).collect();
assert_eq!(&last[last.len() - 2..], &[DONE, DISCARDED]);
assert_eq!(status_dirs().last(), Some(&DISCARDED));
}
/// Each state names what the next press does, and a column still hidden keeps its
/// count until it is drawn.
#[test]
fn the_footer_names_the_key_and_carries_the_count_while_done_is_hidden() {
fn the_footer_names_the_next_press_of_d_and_carries_the_hidden_count() {
let dir = board_dir();
for (n, title) in [("44444444", "One"), ("55555555", "Two")] {
write_ticket(&dir, "done", &format!("{n}-0000-4000-8000-000000000000"), title, "");
}
write_ticket(&dir, DISCARDED, "66666666-0000-4000-8000-000000000000", "Three", "");
let mut board = one_board(&dir);
let hidden = footer(&board, 120, 20);
assert!(hidden.contains("d show done (2)"), "{hidden}");
board.toggle_done(SCREEN);
let shown = footer(&board, 120, 20);
assert!(shown.contains("d hide done"), "{shown}");
// With the column drawn, its own heading carries the count.
assert!(!shown.contains("(2)"), "the count is printed twice:\n{shown}");
// Hidden: the next press reveals done, whose count is carried here.
let neither = footer(&board, 120, 20);
assert!(neither.contains("d show done (2)"), "{neither}");
board.rotate_visibility(SCREEN);
// Done shown: the next press reveals discarded, whose count is carried here.
let done = footer(&board, 120, 20);
assert!(done.contains("d show discarded (1)"), "{done}");
board.rotate_visibility(SCREEN);
// Both shown: their own headings carry the counts, so nothing is printed twice.
let both = footer(&board, 140, 20);
assert!(both.contains("d hide both"), "{both}");
assert!(!both.contains("(2)"), "the count is printed twice:\n{both}");
assert!(!both.contains("(1)"), "the count is printed twice:\n{both}");
// And around again.
board.rotate_visibility(SCREEN);
assert_eq!(board.visibility, Visibility::Neither, "the rotation did not wrap");
}
/// The modal footer names it too, since the key works with a ticket open.
@@ -4039,6 +4172,7 @@ mod tests {
}
/// Hiding the column under the selection has to move it, or it points at nothing.
/// Reaching hidden from both shown takes the rest of the rotation.
#[test]
fn hiding_done_under_the_selection_moves_it_to_the_last_visible_column() {
let dir = board_dir();
@@ -4046,11 +4180,16 @@ mod tests {
write_ticket(&dir, "done", "44444444-0000-4000-8000-000000000000", "Finished", "");
let mut board = one_board(&dir);
board.toggle_done(SCREEN);
board.rotate_visibility(SCREEN);
board.select_column(3, SCREEN);
assert_eq!(selected_title(&board), Some("Finished".to_string()));
board.toggle_done(SCREEN);
// Through both, where done stays drawn and the selection stays put...
board.rotate_visibility(SCREEN);
assert_eq!(selected_title(&board), Some("Finished".to_string()));
// ...and back to hidden, where the selection has to move.
board.rotate_visibility(SCREEN);
assert_eq!(board.current().column, 2, "the selection stayed on a column that is gone");
assert_eq!(selected_title(&board), Some("Ready".to_string()));
}
@@ -4065,12 +4204,15 @@ mod tests {
write_ticket(&dir, "done", "44444444-0000-4000-8000-000000000000", "Finished", "");
let mut board = one_board(&dir);
board.toggle_done(SCREEN);
board.rotate_visibility(SCREEN);
board.select_column(3, SCREEN);
board.toggle_detail();
assert!(board.detail.is_some());
board.toggle_done(SCREEN);
board.rotate_visibility(SCREEN);
assert!(board.detail.is_some(), "the detail closed while done was still drawn");
board.rotate_visibility(SCREEN);
assert!(board.detail.is_none(), "{:?}", board.detail);
}
@@ -4082,8 +4224,9 @@ mod tests {
let mut board = one_board(&dir);
board.toggle_detail();
board.toggle_done(SCREEN);
board.toggle_done(SCREEN);
board.rotate_visibility(SCREEN);
board.rotate_visibility(SCREEN);
board.rotate_visibility(SCREEN);
assert!(board.detail.is_some(), "an unrelated detail view was closed");
}
@@ -4101,7 +4244,7 @@ mod tests {
board.select_card(1, SCREEN);
let (column, card) = (board.current().column, board.current().card);
board.toggle_done(SCREEN);
board.rotate_visibility(SCREEN);
assert_eq!((board.current().column, board.current().card), (column, card));
assert_eq!(selected_title(&board), Some("Beta".to_string()));
}
@@ -4117,7 +4260,7 @@ mod tests {
assert_eq!(board.current().column, 2);
assert!(board.selected().is_none(), "the selection reached the done column");
board.toggle_done(SCREEN);
board.rotate_visibility(SCREEN);
board.select_column(9, SCREEN);
assert_eq!(board.current().column, 3);
assert_eq!(selected_title(&board), Some("Finished".to_string()));
@@ -4570,12 +4713,13 @@ mod tests {
let dir = board_dir();
let mut board = one_board(&dir);
assert_eq!(board.current().columns.len(), 4);
assert_eq!(board.current().columns.len(), Status::ALL.len());
board.toggle_done(SCREEN);
let row = headings(&board, 120, 20);
for status in status_dirs() {
assert!(row.contains(&format!("{status} (0)")), "{row}");
board.rotate_visibility(SCREEN);
board.rotate_visibility(SCREEN);
let row = headings(&board, 140, 20);
for status in Status::ALL {
assert!(row.contains(&format!("{} (0)", status.as_str())), "{row}");
}
}
@@ -4586,10 +4730,13 @@ mod tests {
std::fs::remove_dir_all(dir.join(DONE)).unwrap();
let mut board = one_board(&dir);
assert_eq!(board.current().columns.len(), 4);
assert_eq!(board.current().columns.len(), Status::ALL.len());
board.toggle_done(SCREEN);
assert!(headings(&board, 120, 20).contains("done (0)"));
board.rotate_visibility(SCREEN);
board.rotate_visibility(SCREEN);
let row = headings(&board, 140, 20);
assert!(row.contains("done (0)"), "{row}");
assert!(row.contains("discarded (0)"), "{row}");
}
#[test]
@@ -5522,8 +5669,8 @@ mod tests {
assert!(board.search_key(key, SCREEN), "{key:?} was not taken");
}
assert!(!board.show_done, "typing 'd' toggled the done column");
assert!(!board.should_quit, "typing 'q' quit the board");
assert_eq!(board.visibility, Visibility::Neither, "typing 'd' rotated the columns");
assert_eq!(selected_title(&board), before, "an arrow moved the selection");
// The letters landed in the query; the keys that are not characters did not.
assert_eq!(board.search.as_ref().map(|s| s.query.as_str()), Some("dqjh"));
@@ -5639,7 +5786,7 @@ mod tests {
);
board.search_key(typed(KeyCode::Esc), SCREEN);
board.toggle_done(SCREEN);
board.rotate_visibility(SCREEN);
board.open_search();
type_query(&mut board, "delta");
board.search_key(typed(KeyCode::Enter), SCREEN);
@@ -6360,6 +6507,26 @@ mod tests {
assert!(marked_blocked(&one_board(&dir), "The waiter"));
}
/// A discarded blocker holds nothing up, the answer `mv` gives it: there is nothing
/// left to wait for.
///
/// The board and `mv` share `is_open` for this, which is what keeps them from
/// drifting now that the blocker arrives in the map: `columns_of` builds every
/// status, so a rule written as `!= DONE` would mark these cards while `mv` kept
/// letting them move. The fixture writes the directory directly, the way a board
/// that predates a discard would hold one.
#[test]
fn a_discarded_blocker_marks_nothing() {
let dir = board_dir();
std::fs::create_dir_all(dir.join(DISCARDED)).unwrap();
write_ticket(&dir, DISCARDED, BLOCKER, "The blocker", "");
write_ticket(&dir, "backlog", WAITER, "The waiter", &blocked_by(BLOCKER));
assert!(!marked_blocked(&one_board(&dir), "The waiter"));
assert!(!is_open(DISCARDED), "the rule the board and mv share");
assert!(is_open("backlog") && is_open("committed") && is_open("reviewing"));
}
/// The answer `mv` gives a dangling uuid: a bookkeeping fault, not a dependency.
#[test]
fn a_blocker_the_board_does_not_hold_marks_nothing() {
@@ -7543,7 +7710,7 @@ mod tests {
fn picking_a_tag_filters_every_column_to_the_cards_carrying_it() {
let dir = board_dir();
let mut board = tag_board(&dir);
board.show_done = true;
board.visibility = Visibility::Both;
board.select_filter(Filter::Tag("bug".to_string()), SCREEN);
@@ -7965,7 +8132,7 @@ mod tests {
assert!(headings(&board, 100, 24).contains("backlog (1)"), "the board did not draw");
}
/// Selecting a campaign turns the four columns into that campaign's members grouped
/// Selecting a campaign turns the columns into that campaign's members grouped
/// by status, which is the shape `campaign show` already answers the question in.
#[test]
fn selecting_a_campaign_filters_every_column_to_its_members() {
@@ -7985,7 +8152,7 @@ mod tests {
.collect();
assert_eq!(titles, vec!["In v1".to_string(), "Also in v1".to_string()], "{titles:?}");
// Every column is kept, empty ones included: a campaign's shape is the flow.
assert_eq!(board.current().columns.len(), status_dirs().len());
assert_eq!(board.current().columns.len(), Status::ALL.len());
}
/// The frame says which campaign the columns belong to, and how far it has got, from
@@ -8042,11 +8209,40 @@ mod tests {
let mut board = one_board(&dir);
board.select_filter(Filter::Campaign(V1.to_string()), SCREEN);
assert!(!board.show_done, "done is hidden at startup");
assert_eq!(board.visibility, Visibility::Neither, "a column is drawn at startup");
let standing = board.campaign().expect("no campaign selected").standing;
assert_eq!((standing.done, standing.total), (1, 2));
}
/// A member decided out of the campaign counts as finished, the rule `campaign ls`
/// holds: counting it outstanding would hold the campaign open over a ticket nobody
/// will ever do.
#[test]
fn the_standing_counts_a_discarded_member_as_finished() {
let dir = board_dir();
write_campaign(&dir, V1, "First public release", "v1", "For a tag.");
write_ticket(
&dir,
"backlog",
"11111111-0000-4000-8000-000000000000",
"Open one",
&campaign_field(V1),
);
write_ticket(
&dir,
DISCARDED,
"55555555-0000-4000-8000-000000000000",
"Dropped one",
&campaign_field(V1),
);
let mut board = one_board(&dir);
board.select_filter(Filter::Campaign(V1.to_string()), SCREEN);
let standing = board.campaign().expect("no campaign selected").standing;
assert_eq!((standing.done, standing.total), (1, 2), "the discard was not counted");
}
/// The frame takes its three rows off the columns rather than off the footer, and
/// every measurement of the board has to agree about that: a keypress that scrolled
/// against the taller board would put the selection where the draw does not.
@@ -8953,7 +9149,7 @@ mod tests {
"the picker let {code:?} through"
);
}
assert!(!board.show_done, "d reached the done column");
assert_eq!(board.visibility, Visibility::Neither, "d reached the columns");
assert!(board.picker.is_some(), "the picker closed on a key it does not use");
// `/` last, and taken by the picker's own query rather than by the board's prompt:
// the key that searches a list of cards searches this list, and the two must not
@@ -8964,7 +9160,7 @@ mod tests {
// Every other control combination is swallowed and does nothing, or `ctrl-d` would
// reach the arm bound to `d`.
board.picker_key(KeyEvent::new(KeyCode::Char('d'), KeyModifiers::CONTROL), SCREEN);
assert!(!board.show_done, "ctrl-d reached the done column");
assert_eq!(board.visibility, Visibility::Neither, "ctrl-d reached the columns");
}
/// `ctrl-c` is the one key it declines, because a terminal application always honours
+75 -21
View File
@@ -1437,7 +1437,7 @@ pub fn parse_tags(content: &str) -> Vec<String> {
/// Directly after ID, because that is where `campaign_body` writes it, so a campaign given
/// a codename later ends up with the same file as one filed with it. Nothing ever upserts
/// it on a ticket, so its place in a ticket's order costs nothing.
const METADATA_ORDER: [&str; 12] = [
const METADATA_ORDER: [&str; 13] = [
"ID",
CODENAME_FIELD,
"Priority",
@@ -1448,6 +1448,7 @@ const METADATA_ORDER: [&str; 12] = [
COMMITTED_ON_FIELD,
SUBMITTED_ON_FIELD,
COMPLETED_ON_FIELD,
DISCARDED_ON_FIELD,
CAMPAIGN_FIELD,
"Status",
];
@@ -1532,6 +1533,7 @@ fn insert_metadata_field(content: &str, field: &str, value: &str, title: &str) -
pub const COMMITTED_ON_FIELD: &str = "Committed On";
pub const SUBMITTED_ON_FIELD: &str = "Submitted On";
pub const COMPLETED_ON_FIELD: &str = "Completed On";
pub const DISCARDED_ON_FIELD: &str = "Discarded On";
/// Stamp the field of the status being entered and drop the ones after it.
///
@@ -2196,6 +2198,12 @@ impl RelationIndex {
self.tickets.iter().find(|ticket| ticket.uuid == uuid)
}
/// Every ticket the index holds, for a caller asking about the derived direction:
/// which tickets point *at* one, which no single `get` can answer.
pub fn iter(&self) -> impl Iterator<Item = &RelatedTicket> {
self.tickets.iter()
}
/// The relations other tickets hold pointing at `uuid`, as the kind reads from
/// this end and the ticket that holds it.
///
@@ -2288,11 +2296,14 @@ pub const REGRESSION_MARK: &str = "\u{2190}";
/// nobody has picked up, orange for work in hand, cyan for work waiting on a reader,
/// green for done. Green is the one the priority ramp deliberately leaves out because it
/// means a title, and it is safe on a one-cell mark that no title sits behind.
const STATUS_MARKS: [(&str, &str, Color); 4] = [
const STATUS_MARKS: [(&str, &str, Color); 5] = [
("backlog", "\u{25cb}", Color::Grey),
("committed", "\u{25d0}", Color::Orange),
("reviewing", "\u{25d0}", Color::Cyan),
("done", "\u{25cf}", Color::Green),
// The full circle of done in the grey of the untouched pile: nothing is left to do,
// and it is not an achievement. The pair is what is unique, as with the two halves.
("discarded", "\u{25cf}", Color::Grey),
];
/// The mark for a status, or `?` for a target the board no longer holds.
@@ -2675,35 +2686,41 @@ pub fn trim_blank_ends(values: &[String]) -> &[String] {
/// A status, as clap accepts it and as the directory is named.
///
/// An enum rather than the string it was, so an unknown status is a usage error at parse
/// time with the four listed, the way `priority_level` and `iso_date` refuse a bad level
/// time with the five listed, the way `priority_level` and `iso_date` refuse a bad level
/// or date. That is the bargain the scalars already take, see AGENTS.md: nothing is
/// written, the exit code is 2, and no handler has to check. It also gives every shell
/// that completes possible values the four names for free.
/// that completes possible values the five names for free.
///
/// The variants are in flow order, which is the order `mv` reads to decide whether a
/// move goes forward, and the order [`status_dirs`] hands the two views.
/// The variants are in flow order with `Discarded` last, which is the order `mv` reads
/// to decide whether a move goes forward and the order the stamp arrival rule truncates
/// by. Discarded sits after done deliberately: entering it clears nothing, so a ticket
/// discarded from reviewing keeps the journey it made, and leaving it is always a
/// backward move, which is what makes un-discarding need `-f` for free.
#[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)]
pub enum Status {
Backlog,
Committed,
Reviewing,
Done,
Discarded,
}
impl Status {
/// Every status, in flow order. The one list, which [`status_dirs`], `mv` and every
/// caller of [`by_status_order`] read rather than spelling the four names again.
pub const ALL: [Status; 4] = [
/// Every status, in flow order with discarded last. The one list, which
/// [`status_dirs`], `mv`, the board's columns and every caller of
/// [`by_status_order`] read rather than spelling the five names again.
pub const ALL: [Status; 5] = [
Status::Backlog,
Status::Committed,
Status::Reviewing,
Status::Done,
Status::Discarded,
];
/// The field `mv` stamps on entering this status, for the three that have one.
/// The field `mv` stamps on entering this status, for the four that have one.
///
/// Derived from the status rather than spelled at the call site, so the mapping is
/// in one place and a fifth status either brings its own stamp or explicitly has
/// in one place and a new status either brings its own stamp or explicitly has
/// none.
pub const fn stamp_field(self) -> Option<&'static str> {
match self {
@@ -2711,6 +2728,7 @@ impl Status {
Status::Committed => Some(COMMITTED_ON_FIELD),
Status::Reviewing => Some(SUBMITTED_ON_FIELD),
Status::Done => Some(COMPLETED_ON_FIELD),
Status::Discarded => Some(DISCARDED_ON_FIELD),
}
}
@@ -2722,6 +2740,7 @@ impl Status {
Status::Committed => "committed",
Status::Reviewing => "reviewing",
Status::Done => "done",
Status::Discarded => "discarded",
}
}
}
@@ -2730,15 +2749,41 @@ pub fn status_dirs() -> Vec<&'static str> {
Status::ALL.iter().map(|status| status.as_str()).collect()
}
/// The end of the flow, and the one status both views treat differently: `ls` counts it
/// in the summary and leaves it out of the listing, and the board hides its column until
/// asked. Named because that rule now has two readers.
/// The end of the flow, and one of the two statuses both views treat differently: `ls`
/// counts it in the summary and leaves it out of the listing, and the board hides its
/// column until `d` reveals it. Named because that rule now has two readers.
///
/// It is deliberately last in `status_dirs()`. The board leans on that: hiding done drops
/// the final column, so the other three keep their indices and the selection only has to
/// be handled when it is sitting on done itself.
/// Done and discarded are deliberately the last two in [`Status::ALL`], which is what
/// the board builds its columns from: hiding either is then a prefix of that list, so
/// the columns before them keep their indices and the selection only has to be handled
/// when it is sitting on a column that just went away. Discarded after done is also
/// what lets the stamp arrival rule keep a discard's journey.
pub const DONE: &str = Status::Done.as_str();
/// Where a ticket that will not be done ends up: the other terminal status, and the
/// other one `ls` leaves out of the listing and the board keeps off the screen until
/// asked, last in the rotation because it is the least likely thing to be looking for.
///
/// A discarded ticket counts as finished wherever progress is measured, since nothing is
/// left to do, and blocks nothing. What it is not is done: the two directories keep
/// "the work landed" and "the work was abandoned" answerable apart.
pub const DISCARDED: &str = Status::Discarded.as_str();
/// Whether a ticket in this status still has something outstanding.
///
/// The two terminal statuses do not: done landed and discarded never will, so in both
/// cases there is nothing left to wait for and nothing left to plan around. One spelling
/// for all three readers, because `mv` refuses a move on it, refuses a discard on it and
/// the board draws its blocked mark from it, and two views disagreeing about what counts
/// as open would be the difference nobody can explain later.
///
/// Takes the status as a string because that is what the callers hold: the directory a
/// ticket was found in, not a parsed [`Status`]. An unrecognised value reads as open,
/// which is the safe direction: it surfaces rather than silently satisfying a block.
pub fn is_open(status: &str) -> bool {
status != DONE && status != DISCARDED
}
/// Lowest and highest level a ticket can carry. 1 is the most urgent, which is
/// what the `p1` to `p3` tags this replaced already meant.
pub const PRIORITY_RANGE: std::ops::RangeInclusive<u8> = 1..=5;
@@ -2867,6 +2912,8 @@ pub struct TicketItem {
pub submitted_on: Option<String>,
/// The same for done.
pub completed_on: Option<String>,
/// The same for discarded.
pub discarded_on: Option<String>,
}
impl TicketItem {
@@ -2882,6 +2929,7 @@ impl TicketItem {
Status::Committed => self.committed_on.as_deref(),
Status::Reviewing => self.submitted_on.as_deref(),
Status::Done => self.completed_on.as_deref(),
Status::Discarded => self.discarded_on.as_deref(),
}
}
}
@@ -3076,6 +3124,7 @@ pub fn collect_ticket_items(status_path: impl AsRef<Path>) -> Result<Vec<TicketI
committed_on: parse_stamp(&content, Status::Committed),
submitted_on: parse_stamp(&content, Status::Reviewing),
completed_on: parse_stamp(&content, Status::Done),
discarded_on: parse_stamp(&content, Status::Discarded),
})
})
.collect();
@@ -3104,7 +3153,8 @@ pub fn by_priority_then_title(a: &TicketItem, b: &TicketItem) -> std::cmp::Order
/// 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, the way a changelog reads.
/// stamp in committed and reviewing and descending in done and discarded, the way a
/// changelog reads.
///
/// 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
@@ -3118,7 +3168,7 @@ pub fn by_priority_then_title(a: &TicketItem, b: &TicketItem) -> std::cmp::Order
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)) {
(Some(left), Some(right)) => match status {
Status::Done => right.cmp(left),
Status::Done | Status::Discarded => right.cmp(left),
_ => left.cmp(right),
},
(Some(_), None) => std::cmp::Ordering::Less,
@@ -4132,7 +4182,11 @@ mod tests {
_ => None,
},
completed_on: match status {
Status::Done => stamp,
Status::Done => stamp.clone(),
_ => None,
},
discarded_on: match status {
Status::Discarded => stamp,
_ => None,
},
}
@@ -5190,7 +5244,7 @@ Plain line with **bold** and a [link](http://x.test/a).
);
}
assert_eq!(seen.len(), 4, "{seen:?}");
assert_eq!(seen.len(), status_dirs().len(), "{seen:?}");
}
/// An unrecognised value reads as missing rather than as a fifth stage of the flow.
+40
View File
@@ -1703,3 +1703,43 @@ fn a_campaign_with_no_description_section_is_refused() {
assert_eq!(fs::read_to_string(&path).unwrap(), before, "the file was written");
}
}
/// A discarded member counts as finished. The work was decided out of the campaign
/// rather than left in it, and counting it as outstanding would hold the campaign open
/// forever over a ticket nobody will ever do.
#[test]
fn a_discarded_member_counts_as_finished() {
let temp = TempDir::new().unwrap();
let _worklane = board(&temp);
run(&temp, &["assign", "v1 release", MEMBER]);
run(&temp, &["assign", "v1 release", OTHER]);
// Two members, one done and one in the backlog: open and half finished.
let listing = stdout(&run(&temp, &["campaign", "ls"]));
assert!(listing.contains("v1 release | 1/2 done [open]"), "{listing}");
let discarded = run(&temp, &["mv", MEMBER, "--status", "discarded"]);
assert!(discarded.status.success(), "{}", stderr(&discarded));
let listing = stdout(&run(&temp, &["campaign", "ls"]));
assert!(listing.contains("v1 release | 2/2 done [done]"), "{listing}");
}
/// `campaign show` groups the members by status, and a discarded one has a group to
/// land in rather than dropping out of the campaign it belongs to.
#[test]
fn campaign_show_lists_a_discarded_member() {
let temp = TempDir::new().unwrap();
let _worklane = board(&temp);
run(&temp, &["assign", "v1 release", MEMBER]);
assert!(
run(&temp, &["mv", MEMBER, "--status", "discarded"])
.status
.success()
);
let shown = stdout(&run(&temp, &["campaign", "show", "aa11"]));
assert!(shown.contains("The member"), "the discarded member is gone: {shown}");
}
+2 -2
View File
@@ -62,10 +62,10 @@ fn no_other_shell_gets_the_fish_half() {
#[test]
fn fish_is_offered_every_status() {
let out = script("fish");
for status in ["backlog", "committed", "reviewing", "done"] {
for status in ["backlog", "committed", "reviewing", "done", "discarded"] {
assert!(out.contains(status), "fish is never offered {status}");
}
assert!(out.contains("-a 'backlog committed reviewing done' -d status"));
assert!(out.contains("-a 'backlog committed reviewing done discarded' -d status"));
}
#[test]
+44
View File
@@ -903,3 +903,47 @@ fn ls_ids_prints_the_same_order_the_listing_does() {
let seen = positions(&stdout, ["Oldest", "Newest", "Unstamped"]);
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{stdout}");
}
/// Discarded is the other terminal status, so the decorated listing leaves it out the
/// way it leaves done out: it is counted in the summary and not listed. The positional
/// and `--ids` still reach it, since a ticket nobody will work still has to be nameable.
#[test]
fn ls_hides_discarded_but_counts_and_can_name_it() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
temp.child(".worklane")
.child("discarded")
.create_dir_all()
.unwrap();
create_ticket_with_id(
&worklane,
"backlog",
"Still open",
"aaaaaaa1-0000-0000-0000-000000000001",
"bug",
);
create_ticket_with_id(
&worklane,
"discarded",
"Abandoned",
"ccccccc3-0000-0000-0000-000000000003",
"bug",
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).arg("ls");
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Still open"), "{stdout}");
assert!(!stdout.contains("Abandoned"), "discarded was listed: {stdout}");
assert!(stdout.contains("DISCARDED"), "discarded is not counted: {stdout}");
// Nameable both ways, the way done is.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(["ls", "--ids"]);
assert!(get_stdout(&mut cmd).contains("Abandoned"));
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(["ls", "discarded"]);
assert!(get_stdout(&mut cmd).contains("Abandoned"));
}
+216
View File
@@ -1144,3 +1144,219 @@ fn mv_does_not_restamp_a_no_op_move() {
assert_eq!(ticket_at(&worklane, "committed", &filename), before);
}
// ---------------------------------------------------------------- discarded --
/// Discarding is not a stage of work, so it is reachable from wherever the ticket
/// stands and needs no `-f`: a backlog ticket that turns out to be a duplicate should
/// not have to be walked through committed and reviewing to be abandoned.
#[test]
fn mv_discards_from_every_status_without_force() {
for from in ["backlog", "committed", "reviewing", "done"] {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let filename = stamped_ticket(&worklane, from);
let out = move_ticket(&temp, "cccc3333", "discarded", false);
assert!(
out.status.success(),
"discarding from {from}: {}",
String::from_utf8_lossy(&out.stderr)
);
assert!(
worklane.join("discarded").join(&filename).exists(),
"the ticket did not land in discarded from {from}"
);
assert_eq!(md_files(&worklane.join(from)).len(), 0, "left behind in {from}");
}
}
/// The fixture board has the four directories the tool shipped with. The first discard
/// on a board that predates the status creates the fifth rather than refusing.
#[test]
fn mv_creates_the_discarded_directory_on_a_board_that_predates_it() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let filename = stamped_ticket(&worklane, "backlog");
assert!(
!worklane.join("discarded").exists(),
"the fixture already had the directory"
);
let out = move_ticket(&temp, "cccc3333", "discarded", false);
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
assert!(worklane.join("discarded").join(&filename).exists());
}
/// Leaving discarded is a backward move, which is the rule that already needs `-f`.
/// Un-discarding is a correction rather than a stage, so it is allowed under it.
#[test]
fn leaving_discarded_needs_force() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let filename = stamped_ticket(&worklane, "backlog");
assert!(
move_ticket(&temp, "cccc3333", "discarded", false)
.status
.success()
);
let refused = move_ticket(&temp, "cccc3333", "backlog", false);
assert!(!refused.status.success());
assert!(
String::from_utf8_lossy(&refused.stderr).contains("--force"),
"{}",
String::from_utf8_lossy(&refused.stderr)
);
assert!(worklane.join("discarded").join(&filename).exists());
let forced = move_ticket(&temp, "cccc3333", "backlog", true);
assert!(forced.status.success(), "{}", String::from_utf8_lossy(&forced.stderr));
assert!(worklane.join("backlog").join(&filename).exists());
}
/// The guard looks the other way round from `check_blockers`: a ticket being abandoned
/// owes nothing to what it waits on, but the tickets waiting on *it* recorded a
/// dependency on work that is about to be declared never-happening.
#[test]
fn mv_refuses_to_discard_a_ticket_open_tickets_are_blocked_by() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_gated_pair(&worklane, &temp, "backlog");
let out = move_ticket(&temp, "bbbb2222", "discarded", false);
assert!(!out.status.success());
let stderr = String::from_utf8_lossy(&out.stderr);
assert!(stderr.contains("Gated Task"), "the dependent is not named: {stderr}");
assert!(stderr.contains("--force"), "{stderr}");
assert!(
!worklane.join("discarded").exists(),
"a refused discard made the directory"
);
}
/// `-f` is the caller saying they looked at the dependents.
#[test]
fn mv_discards_a_blocked_from_ticket_with_force() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_gated_pair(&worklane, &temp, "backlog");
let out = move_ticket(&temp, "bbbb2222", "discarded", true);
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
}
/// A dependent that is itself finished or abandoned is nobody's plan, so it does not
/// hold up the discard.
#[test]
fn a_done_or_discarded_dependent_does_not_hold_up_a_discard() {
for status in ["done", "discarded"] {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_gated_pair(&worklane, &temp, "backlog");
assert!(
move_ticket(&temp, "aaaa1111", status, true).status.success(),
"the dependent could not be moved to {status}"
);
let out = move_ticket(&temp, "bbbb2222", "discarded", false);
assert!(
out.status.success(),
"a {status} dependent held up the discard: {}",
String::from_utf8_lossy(&out.stderr)
);
}
}
/// A discarded blocker satisfies the block the way a done one does: there is nothing
/// left to wait for. Whether the dependent still makes sense was asked when the blocker
/// was discarded, which is the refusal above.
#[test]
fn a_discarded_blocker_does_not_block() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let filename = create_gated_pair(&worklane, &temp, "backlog");
assert!(
move_ticket(&temp, "bbbb2222", "discarded", true)
.status
.success()
);
let out = move_ticket(&temp, "aaaa1111", "committed", false);
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
assert!(worklane.join("committed").join(&filename).exists());
}
/// Entering discarded clears no stamp, which is what discarded being last in
/// `Status::ALL` buys: a ticket abandoned from reviewing keeps the journey it made, so
/// the log still says how far it got before it was dropped.
#[test]
fn discarding_keeps_the_stamps_the_ticket_already_had() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let filename = stamped_ticket(&worklane, "backlog");
assert!(
move_ticket(&temp, "cccc3333", "committed", false)
.status
.success()
);
assert!(
move_ticket(&temp, "cccc3333", "reviewing", false)
.status
.success()
);
let before = ticket_at(&worklane, "reviewing", &filename);
let committed_on = field(&before, "Committed On").expect(&before);
let submitted_on = field(&before, "Submitted On").expect(&before);
assert!(
move_ticket(&temp, "cccc3333", "discarded", false)
.status
.success()
);
let after = ticket_at(&worklane, "discarded", &filename);
assert_eq!(
field(&after, "Committed On").as_deref(),
Some(committed_on.as_str()),
"{after}"
);
assert_eq!(
field(&after, "Submitted On").as_deref(),
Some(submitted_on.as_str()),
"{after}"
);
assert!(field(&after, "Discarded On").is_some(), "no discard stamp: {after}");
assert!(
field(&after, "Completed On").is_none(),
"a discard claimed the ticket was done"
);
}
/// The other end of the same rule: a forced move back out of discarded truncates the
/// journey at the target the way every backward move does.
#[test]
fn un_discarding_drops_the_discard_stamp() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let filename = stamped_ticket(&worklane, "backlog");
assert!(
move_ticket(&temp, "cccc3333", "discarded", false)
.status
.success()
);
assert!(
move_ticket(&temp, "cccc3333", "committed", true)
.status
.success()
);
let content = ticket_at(&worklane, "committed", &filename);
assert!(field(&content, "Discarded On").is_none(), "{content}");
assert!(field(&content, "Committed On").is_some(), "{content}");
}