Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45b513bdce | ||
|
|
ab337ca7f8 | ||
|
|
60b43a682e | ||
|
|
5bf0fd1bfe |
@@ -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,9 +456,13 @@ 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
|
||||
- Chrome → grey, in the history block too: the kind label at the head of a mechanical row, and the `From` on a comment's author line. Both name their row rather than holding a value, which is what grey already says. The label was orange, which means Status everywhere else, so an `owner` or `tags` label claimed a meaning belonging to the value beside it
|
||||
- **A value in the history block takes the colour it has in the metadata table three lines above.** A status is orange, a tags entry goes through the same `tag_cells` the Tags field does, a campaign codename takes `tag_color` bare the way `Codename` does, and `_Not set_`, `_None_` and `_missing_` are grey. An owner stays plain: a person's name is the one value the palette has no meaning for, and spending a colour on the field that needs it least is how a colour stops meaning anything. The block's job is to be scanned, and it is not worth scanning if it has a palette of its own to learn first
|
||||
- History actor → its name through `tag_color`, the way a campaign codename is. Not a new meaning for a reserved colour but the existing use of the tag slots, a name that groups rows: one writer is one colour in every entry it wrote, so a reader sees who has been working a ticket without reading the same name four times. `claude`, `opencode` and a person each get their own
|
||||
- History timestamp → cyan, and its own span. It shared one with the actor while the two were formatted as `name (time)`, which spent the timestamp's colour on a name. The parentheses are plain: they are punctuation, not chrome with something to say
|
||||
- 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
|
||||
- Campaign label with no codename → grey. The label is then the short id, and grey keeps a reserved meaning off a `TAG_COLORS` slot in the one case where it would land on one: red is the uuid's everywhere else, and grey already means what a reader skips, which is what a campaign with no codename has to say for itself
|
||||
- **The palette splits in two: seven colours that each mean one thing, and `TAG_COLORS`, the eight a tag may be drawn in.** A tag in red would read as a uuid, in green as a title, in grey as an unset value, so the tag slots are reserved as a list rather than picked at the call site. Do not assign a new meaning to a colour in `TAG_COLORS`, and do not draw a tag in one outside it
|
||||
@@ -460,6 +473,8 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- Grey is indexed colour 8 in the 256-colour form, not SGR 90 or 37. Both of those failed on a real palette: 90 leans on the bright-black slot and 37 can sit on top of the default foreground. `\x1b[38;5;8m` is byte for byte what crossterm emits for ratatui's `Color::DarkGray`, the grey frig and pantop use for dimmed rows
|
||||
|
||||
### Code Organization
|
||||
- **`change` and `split_change` are a pair, and they live beside each other in `history.rs`.** The mechanical body is stored as one string, `before → after`, so painting the halves means splitting it, and the separator is a constant the writer and the reader share. A renderer with its own copy of the spacing would go on splitting on a separator the writer no longer emits, and would say so by drawing a whole body as one half. The split is `split_once`, so a value carrying the arrow itself keeps it
|
||||
- **The history block indents by who is talking.** A comment's body sits at four spaces and the reason under a mechanical row at two; the author line stays at column 0 and is told from a mechanical row by its `From` and its colour instead. The rule a reader learns is that an indented line is somebody's own words and a line of values at column 0 is the tool reporting itself
|
||||
- **`history.rs` owns the log end to end**: the path, the kinds, the parse, the write, the count and the render. It came out of `util.rs` and `handlers.rs`, where the reader, the writer, the counter and the renderer sat in three files and one of them was 5,500 lines. The test for the reason is the module doc: a reader asking what an entry is has one file to open, the way `campaign.rs` and `tag.rs` answer their own questions
|
||||
- The body's painters return cells, not strings: `ordered_cells`, `inline_cells`, `metadata_cells`, `metadata_value_cells`, `tag_cells` and `push_heading`. `content_trim_colored` is the CLI entry point and `paint_cells` is the only thing that writes an escape. `colorize_line` is gone: it was a `pub` alias for the bold pass with one caller, and the only thing it added was asking the terminal
|
||||
- **`inline_cells` walks the line once for both inline markers**, `**bold**` and `[text](url)`, rather than running one pass over the output of the other. A second pass would be scanning text that already holds escape sequences, and `\x1b[36m` carries an opening bracket, so the link scan would take the escape for markup. The source is the only string in which either marker means what it says. It was `colorize_bold` while links lived in a branch of their own in `content_parts`; that branch is gone, which is also what gives the criteria text and the metadata `Other` rows their links, since those already went through this function
|
||||
|
||||
Generated
+1
-1
@@ -1503,7 +1503,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "worklane"
|
||||
version = "0.30.0"
|
||||
version = "0.31.3"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assert_cmd",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "worklane"
|
||||
version = "0.30.0"
|
||||
version = "0.31.3"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -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>
|
||||
|
||||
+53
-19
@@ -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.
|
||||
|
||||
@@ -99,6 +127,11 @@ is never left half-marked. A criterion already in the state you asked for is rep
|
||||
unchanged rather than refused, and a call that would change nothing writes nothing. Both
|
||||
apply to `uncheck` exactly as they do to `check`.
|
||||
|
||||
**Say why on the unusual moves:** `worklane mv 1b78a24 --status backlog -f --reason "the
|
||||
first plan was wrong"`. The reason is recorded inside the history entry beside the
|
||||
transition it explains and rendered indented under its row, in `show` and on the board.
|
||||
Optional on every move; a refused or no-op move records nothing even with one.
|
||||
|
||||
## Filing a ticket
|
||||
|
||||
```
|
||||
@@ -159,7 +192,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 +209,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 +221,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
|
||||
|
||||
@@ -285,7 +319,7 @@ HISTORY
|
||||
status backlog → committed claude (2026-08-24 12:45:00)
|
||||
|
||||
From claude (2026-08-24 13:10:22)
|
||||
The offset was never passed to the widget.
|
||||
The offset was never passed to the widget.
|
||||
|
||||
owner _Not set_ → Ansho Rei claude (2026-08-24 13:11:04)
|
||||
|
||||
|
||||
+7
-3
@@ -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(),
|
||||
|
||||
@@ -230,6 +230,11 @@ pub enum Command {
|
||||
|
||||
#[arg(long, help = ACTOR_HELP)]
|
||||
actor: Option<String>,
|
||||
|
||||
/// Why the ticket moved, recorded in the history entry beside the transition
|
||||
/// it explains. Prose, so it takes a leading hyphen
|
||||
#[arg(long, allow_hyphen_values = PROSE)]
|
||||
reason: Option<String>,
|
||||
},
|
||||
|
||||
/// Replace fields on an existing ticket
|
||||
|
||||
+1
-1
@@ -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}");
|
||||
}
|
||||
|
||||
+90
-11
@@ -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`.
|
||||
@@ -560,10 +607,20 @@ pub fn cmd_mv(
|
||||
target: Status,
|
||||
force: bool,
|
||||
actor: &Option<String>,
|
||||
reason: &Option<String>,
|
||||
start: &Path,
|
||||
) -> Result<()> {
|
||||
let target_status = target.as_str();
|
||||
|
||||
// A reason is one fact on one line, which is how the renderer draws it, so a
|
||||
// newline smuggled in through the shell collapses with the whitespace around it.
|
||||
// All blank means none, rather than an empty field in the log.
|
||||
let reason = reason
|
||||
.as_deref()
|
||||
.map(str::split_whitespace)
|
||||
.map(|words| words.collect::<Vec<_>>().join(" "))
|
||||
.unwrap_or_default();
|
||||
|
||||
let worklane_dir = find_worklane_dir(start)?;
|
||||
let (current_status, title, resolved) = resolve_ticket(ticket_id, &worklane_dir)?;
|
||||
|
||||
@@ -573,7 +630,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(¤t_status, Color::Orange),
|
||||
@@ -581,7 +644,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 +660,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(¤t_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)?;
|
||||
@@ -633,13 +707,14 @@ pub fn cmd_mv(
|
||||
|
||||
// After the move, never before: an entry for a move that was refused would be a log
|
||||
// of things that did not happen. The no-op above returns without one for the same
|
||||
// reason.
|
||||
// reason, and without its --reason with it.
|
||||
write_entry(
|
||||
&worklane_dir,
|
||||
&parse_ticket_field(&resolved, "ID"),
|
||||
Kind::Status,
|
||||
&change(¤t_status, target_status),
|
||||
&resolve_actor(actor.as_deref()),
|
||||
&reason,
|
||||
)?;
|
||||
|
||||
println!(
|
||||
@@ -676,6 +751,7 @@ pub fn cmd_comment(
|
||||
Kind::Comment,
|
||||
body,
|
||||
&resolve_actor(actor.as_deref()),
|
||||
"",
|
||||
)?;
|
||||
|
||||
println!("Comment added to '{}' ({})", title, filename);
|
||||
@@ -924,6 +1000,7 @@ pub fn cmd_set(args: &SetArgs, start: &Path) -> Result<()> {
|
||||
&parse_ticket_field(&content, "Tags"),
|
||||
),
|
||||
&resolve_actor(args.actor.as_deref()),
|
||||
"",
|
||||
)?;
|
||||
}
|
||||
|
||||
@@ -982,6 +1059,7 @@ pub fn cmd_chown(args: &ChownArgs, start: &Path) -> Result<()> {
|
||||
&parse_ticket_field(&content, "Owner"),
|
||||
),
|
||||
&resolve_actor(args.actor.as_deref()),
|
||||
"",
|
||||
)?;
|
||||
|
||||
let verb = match user {
|
||||
@@ -1543,7 +1621,7 @@ pub fn cmd_assign(
|
||||
Some(old) => CampaignIndex::load(&worklane_dir)?
|
||||
.get(&old)
|
||||
.map(|was| was.name().to_string())
|
||||
.unwrap_or_else(|| "_missing_".to_string()),
|
||||
.unwrap_or_else(|| MISSING.to_string()),
|
||||
};
|
||||
write_entry(
|
||||
&worklane_dir,
|
||||
@@ -1551,6 +1629,7 @@ pub fn cmd_assign(
|
||||
Kind::Campaign,
|
||||
&change(&before, campaign.name()),
|
||||
&resolve_actor(actor.as_deref()),
|
||||
"",
|
||||
)?;
|
||||
|
||||
println!(
|
||||
|
||||
+385
-82
@@ -23,7 +23,10 @@ use std::path::{Path, PathBuf};
|
||||
use anyhow::{Result, anyhow};
|
||||
use chrono::Local;
|
||||
|
||||
use crate::util::{Cell, Color, TIMESTAMP_FORMAT, paint_cells, should_use_colors};
|
||||
use crate::util::{
|
||||
Cell, Color, MISSING, TIMESTAMP_FORMAT, is_unknown_value, paint_cells, should_use_colors,
|
||||
tag_cells, tag_color,
|
||||
};
|
||||
|
||||
/// Where a ticket's history lives, under the board.
|
||||
///
|
||||
@@ -123,6 +126,10 @@ pub struct Entry {
|
||||
pub time: String,
|
||||
/// A comment's text, or the before and after of the field a mechanical entry names.
|
||||
pub body: String,
|
||||
/// Why a mechanical entry happened, as `mv --reason` gave it. Empty for every entry
|
||||
/// that carries no such field, which is all of them but a reasoned move — including
|
||||
/// every entry written before reasons existed.
|
||||
pub reason: String,
|
||||
}
|
||||
|
||||
/// Rename an old `comments` directory to `history`, before anything reads or writes it.
|
||||
@@ -187,12 +194,23 @@ fn parse_entry(filename: &str, content: &str) -> Entry {
|
||||
})
|
||||
.unwrap_or("");
|
||||
|
||||
// A missing reason is legitimate rather than unreadable, which is why this does not
|
||||
// share the `unknown` fallback the two fields above carry: every entry written
|
||||
// before `mv --reason` existed has none.
|
||||
let reason = content
|
||||
.lines()
|
||||
.find_map(|line| line.strip_prefix("**Reason**:"))
|
||||
.map(str::trim)
|
||||
.unwrap_or_default()
|
||||
.to_string();
|
||||
|
||||
Entry {
|
||||
filename: filename.to_string(),
|
||||
kind,
|
||||
author: field("Author"),
|
||||
time: field("Time"),
|
||||
body: body.to_string(),
|
||||
reason,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,19 +285,27 @@ pub fn count_comments(board: &Path, uuid: &str) -> usize {
|
||||
///
|
||||
/// A comment's file is byte for byte what `comment` wrote before the kinds existed, so
|
||||
/// nothing has to be rewritten and a board can be read by either version.
|
||||
fn entry_content(kind: Kind, body: &str, author: &str, time: &str) -> String {
|
||||
format!(
|
||||
///
|
||||
/// The optional reason rides after **Time**, so the two fields every entry has always
|
||||
/// carried keep their places and an older binary reading this file finds its body and
|
||||
/// fields exactly where they were. Empty writes no line, which is what keeps a reasoned
|
||||
/// entry and one without reading as the same shape minus the field.
|
||||
fn entry_content(kind: Kind, body: &str, author: &str, time: &str, reason: &str) -> String {
|
||||
let mut content = format!(
|
||||
"{}\n\
|
||||
{}\n\
|
||||
\n\
|
||||
**Author**: {}\n\
|
||||
**Time**: {}\n\
|
||||
",
|
||||
{}\n\
|
||||
\n\
|
||||
**Author**: {}\n\
|
||||
**Time**: {}\n",
|
||||
kind.marker(),
|
||||
body,
|
||||
author,
|
||||
time
|
||||
)
|
||||
);
|
||||
if !reason.is_empty() {
|
||||
content.push_str(&format!("**Reason**: {}\n", reason));
|
||||
}
|
||||
content
|
||||
}
|
||||
|
||||
/// Write an entry under the first free name derived from the stamp.
|
||||
@@ -318,12 +344,16 @@ fn write_new(dir: &Path, stem: &str, content: &str) -> Result<String> {
|
||||
/// move that was refused would be a log of things that did not happen. The cost of that
|
||||
/// order is that a failed write here leaves the edit in place and reports the failure,
|
||||
/// which is the right way round — the ticket is the record and this is the story of it.
|
||||
///
|
||||
/// `reason` is the why [`Kind::Status`] can carry, from `mv --reason`; every other kind
|
||||
/// passes the empty slice and gets no field written.
|
||||
pub fn write_entry(
|
||||
board: &Path,
|
||||
uuid: &str,
|
||||
kind: Kind,
|
||||
body: &str,
|
||||
author: &str,
|
||||
reason: &str,
|
||||
) -> Result<String> {
|
||||
adopt_comments(board)?;
|
||||
|
||||
@@ -332,18 +362,38 @@ pub fn write_entry(
|
||||
|
||||
let now = Local::now();
|
||||
let stem = format!("{}_{}", now.format(ENTRY_FILE_FORMAT), kind.slug());
|
||||
let content = entry_content(kind, body, author, &now.format(TIMESTAMP_FORMAT).to_string());
|
||||
let content =
|
||||
entry_content(kind, body, author, &now.format(TIMESTAMP_FORMAT).to_string(), reason);
|
||||
|
||||
write_new(&dir, &stem, &content)
|
||||
}
|
||||
|
||||
/// What joins the two halves of a mechanical body, and the only thing that tells them
|
||||
/// apart.
|
||||
///
|
||||
/// Spelled once, beside the writer that puts it in and the reader that takes it out, so
|
||||
/// the two cannot disagree about where one value ends and the next begins. A renderer
|
||||
/// carrying its own copy of the spacing would go on splitting on a separator this one no
|
||||
/// longer writes, and would say so by drawing a whole body as one half.
|
||||
const CHANGE_SEPARATOR: &str = " → ";
|
||||
|
||||
/// What a mechanical entry records: the field before the edit and after it.
|
||||
///
|
||||
/// The values as the ticket holds them, sentinels included, so `_Not set_` reads the way
|
||||
/// the field it came from does rather than being translated into a word this module
|
||||
/// invented.
|
||||
pub fn change(before: &str, after: &str) -> String {
|
||||
format!("{} → {}", before, after)
|
||||
format!("{}{}{}", before, CHANGE_SEPARATOR, after)
|
||||
}
|
||||
|
||||
/// The before and after of a mechanical body, or `None` for a body not shaped as one.
|
||||
///
|
||||
/// Everything [`change`] writes splits, but an entry read off a board is whatever the
|
||||
/// file holds, and a body that does not split is drawn whole rather than as a half of
|
||||
/// something. `split_once`, so a value that carries the arrow itself keeps it: only the
|
||||
/// first separator is the one this module wrote.
|
||||
fn split_change(body: &str) -> Option<(&str, &str)> {
|
||||
body.split_once(CHANGE_SEPARATOR)
|
||||
}
|
||||
|
||||
pub fn format_history(entries: &[Entry]) -> String {
|
||||
@@ -355,6 +405,67 @@ pub fn format_history_with(entries: &[Entry], colored: bool) -> String {
|
||||
paint_cells(&history_cells(entries), colored)
|
||||
}
|
||||
|
||||
/// How far the reason under a mechanical row sits from the margin.
|
||||
///
|
||||
/// One step, which is where a comment's body used to sit too. It stays here because the
|
||||
/// reason belongs to the row above it: it is read as part of that transition, not as an
|
||||
/// entry of its own.
|
||||
const REASON_INDENT: &str = " ";
|
||||
|
||||
/// How far a comment's body sits from the margin.
|
||||
///
|
||||
/// One step deeper than a reason, so the column says who is talking: a line indented this
|
||||
/// far is somebody's own words and a line of values at column 0 is the tool reporting
|
||||
/// itself. The author line stays at column 0 and is told from a mechanical row by its
|
||||
/// `From` and its colour instead, which is the trade this shape accepts.
|
||||
const COMMENT_INDENT: &str = " ";
|
||||
|
||||
/// The cells one value in a mechanical body is drawn as, per the Color Guideline.
|
||||
///
|
||||
/// Keyed on the kind, because the kind is what says which field the value came from: the
|
||||
/// same word is a status in one entry and a tag in another, and nothing in the value
|
||||
/// itself could tell them apart. Every meaning here is the one the value already carries
|
||||
/// in the metadata table three lines above, which is the whole point — the block is not
|
||||
/// worth scanning if it has a palette of its own to learn first.
|
||||
fn value_cells(kind: Kind, value: &str) -> Vec<Cell> {
|
||||
// The sentinels first, whichever field they stand in. `_Not set_` in a tag colour
|
||||
// would read as a campaign somebody named that, and grey is what an absent value is
|
||||
// drawn in everywhere else. `_missing_` joins them here rather than in
|
||||
// `is_unknown_value`: the field was set, and what it pointed at is gone.
|
||||
if is_unknown_value(value) || value == MISSING {
|
||||
return vec![Cell::colored(value, Color::Grey)];
|
||||
}
|
||||
|
||||
match kind {
|
||||
Kind::Status => vec![Cell::colored(value, Color::Orange)],
|
||||
Kind::Tags => tag_cells(value),
|
||||
// The codename in the colour that groups it everywhere else, and without the `~`
|
||||
// a card's label carries: the kind at the head of the row has already said what
|
||||
// this is, which is the same reason the `Codename` field takes the colour bare.
|
||||
Kind::Campaign => vec![Cell::colored(value, tag_color(value))],
|
||||
// A name is a value the palette has no meaning for, and spending one on the field
|
||||
// that needs it least is how a colour stops meaning anything. `Comment` is here
|
||||
// for the compiler: a comment's body is not a value and never reaches this.
|
||||
Kind::Owner | Kind::Comment => vec![Cell::plain(value)],
|
||||
}
|
||||
}
|
||||
|
||||
/// Who wrote an entry and when, as two spans rather than one.
|
||||
///
|
||||
/// The actor through `tag_color`, the way a campaign codename is drawn. Not a new meaning
|
||||
/// for a reserved colour but the existing use of the tag slots — a name that groups rows
|
||||
/// — and it is what lets a reader see who has been working a ticket without reading the
|
||||
/// same name four times. Cyan goes back to meaning the timestamp alone, which is what it
|
||||
/// means everywhere else; it covered the name too while the two were one string.
|
||||
fn stamp_cells(entry: &Entry) -> Vec<Cell> {
|
||||
vec![
|
||||
Cell::colored(entry.author.as_str(), tag_color(&entry.author)),
|
||||
Cell::plain(" ("),
|
||||
Cell::colored(entry.time.as_str(), Color::Cyan),
|
||||
Cell::plain(")"),
|
||||
]
|
||||
}
|
||||
|
||||
/// The block laid out once, as [`Cell`]s: the CLI paints them and the board turns the
|
||||
/// same ones into styled spans, so the two views cannot draw two different blocks.
|
||||
pub fn history_cells(entries: &[Entry]) -> Vec<Cell> {
|
||||
@@ -369,28 +480,54 @@ pub fn history_cells(entries: &[Entry]) -> Vec<Cell> {
|
||||
|
||||
for entry in entries {
|
||||
cells.push(Cell::plain("\n"));
|
||||
let stamp = format!("{} ({})", entry.author, entry.time);
|
||||
|
||||
match entry.kind {
|
||||
// As it has always read: a header naming who said it, then the text.
|
||||
Kind::Comment => {
|
||||
cells.push(Cell::colored(format!("From {}", stamp), Color::Cyan));
|
||||
// Grey on the word, for the reason the kind label is grey: `From` names
|
||||
// the line, it is not a value in it.
|
||||
cells.push(Cell::colored("From", Color::Grey));
|
||||
cells.push(Cell::plain(" "));
|
||||
cells.extend(stamp_cells(entry));
|
||||
cells.push(Cell::plain("\n"));
|
||||
if !entry.body.is_empty() {
|
||||
cells.push(Cell::plain(format!(" {}", entry.body)));
|
||||
cells.push(Cell::plain(format!("{}{}", COMMENT_INDENT, entry.body)));
|
||||
}
|
||||
cells.push(Cell::plain("\n"));
|
||||
}
|
||||
// One line: a field change is one fact and a paragraph for it would bury the
|
||||
// comments it sits between.
|
||||
// comments it sits between. A reason grows an indented line under the row,
|
||||
// the way a comment's text sits under its From header, so it reads as
|
||||
// attached to the transition it explains rather than as the next entry.
|
||||
_ => {
|
||||
let padding = Kind::LABEL_WIDTH.saturating_sub(entry.kind.slug().chars().count());
|
||||
cells.push(Cell::colored(entry.kind.slug(), Color::Orange));
|
||||
// Grey, as chrome. It was orange, which means Status everywhere else, so
|
||||
// an `owner` or `tags` label claimed a meaning belonging to the value
|
||||
// beside it. The label is not a value at all: it names the row, which is
|
||||
// what grey already says.
|
||||
cells.push(Cell::colored(entry.kind.slug(), Color::Grey));
|
||||
// Measured on the unpainted label and carried in a cell of its own, the
|
||||
// rule the metadata table follows: measuring a painted string counts its
|
||||
// escapes towards its width, which tilts the column when colour is on and
|
||||
// not when it is off.
|
||||
cells.push(Cell::plain(format!("{} ", " ".repeat(padding))));
|
||||
cells.push(Cell::plain(entry.body.clone()));
|
||||
|
||||
match split_change(&entry.body) {
|
||||
Some((before, after)) => {
|
||||
cells.extend(value_cells(entry.kind, before));
|
||||
cells.push(Cell::plain(CHANGE_SEPARATOR));
|
||||
cells.extend(value_cells(entry.kind, after));
|
||||
}
|
||||
None => cells.extend(value_cells(entry.kind, &entry.body)),
|
||||
}
|
||||
|
||||
cells.push(Cell::plain(" "));
|
||||
cells.push(Cell::colored(stamp, Color::Cyan));
|
||||
cells.extend(stamp_cells(entry));
|
||||
cells.push(Cell::plain("\n"));
|
||||
if !entry.reason.is_empty() {
|
||||
cells.push(Cell::plain(format!("{}{}", REASON_INDENT, entry.reason)));
|
||||
cells.push(Cell::plain("\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -401,7 +538,32 @@ pub fn history_cells(entries: &[Entry]) -> Vec<Cell> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::util::{Fixture, paint};
|
||||
use crate::util::{Fixture, NOT_SET, paint};
|
||||
|
||||
/// One entry, spelled the way a file on the board holds it.
|
||||
fn entry(kind: &str, body: &str, author: &str, time: &str) -> Entry {
|
||||
let marker = format!("**{}{}**", kind[..1].to_uppercase(), &kind[1..]);
|
||||
parse_entry(
|
||||
&format!("20260824_120000_000000_{kind}"),
|
||||
&format!("{marker}\n{body}\n\n**Author**: {author}\n**Time**: {time}\n"),
|
||||
)
|
||||
}
|
||||
|
||||
/// What a painted block reads as once the escapes are taken off, so a test can
|
||||
/// measure a column without counting sequences that occupy none.
|
||||
fn strip_escapes(text: &str) -> String {
|
||||
let mut out = String::with_capacity(text.len());
|
||||
let mut rest = text;
|
||||
while let Some(at) = rest.find('\x1b') {
|
||||
out.push_str(&rest[..at]);
|
||||
match rest[at..].find('m') {
|
||||
Some(end) => rest = &rest[at + end + 1..],
|
||||
None => return out,
|
||||
}
|
||||
}
|
||||
out.push_str(rest);
|
||||
out
|
||||
}
|
||||
|
||||
fn board() -> Fixture {
|
||||
Fixture::new("worklane-history")
|
||||
@@ -411,7 +573,8 @@ mod tests {
|
||||
fn an_entry_names_its_kind_in_the_file_and_in_the_filename() {
|
||||
let board = board();
|
||||
let filename =
|
||||
write_entry(&board, "uuid", Kind::Status, "committed → reviewing", "claude").unwrap();
|
||||
write_entry(&board, "uuid", Kind::Status, "committed → reviewing", "claude", "")
|
||||
.unwrap();
|
||||
|
||||
assert!(filename.ends_with("_status.md"), "was {filename}");
|
||||
|
||||
@@ -420,6 +583,37 @@ mod tests {
|
||||
assert_eq!(entries[0].kind, Kind::Status);
|
||||
assert_eq!(entries[0].body, "committed → reviewing");
|
||||
assert_eq!(entries[0].author, "claude");
|
||||
assert_eq!(entries[0].reason, "");
|
||||
}
|
||||
|
||||
/// One file, one event, its explanation: the reason rides in the entry that records
|
||||
/// the transition it explains, as a field after **Time**, and round-trips.
|
||||
#[test]
|
||||
fn a_reason_is_recorded_in_the_file_and_read_back() {
|
||||
let board = board();
|
||||
let filename = write_entry(
|
||||
&board,
|
||||
"uuid",
|
||||
Kind::Status,
|
||||
"reviewing → backlog",
|
||||
"claude",
|
||||
"sent back: the first plan was wrong",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let content = fs::read_to_string(history_dir(&board, "uuid").join(filename)).unwrap();
|
||||
assert!(
|
||||
content.ends_with("**Reason**: sent back: the first plan was wrong\n"),
|
||||
"{content}"
|
||||
);
|
||||
// The fields every reader keys off keep their places above it
|
||||
assert!(content.contains("**Time**:"), "{content}");
|
||||
assert!(content.find("**Author**").unwrap() < content.find("**Reason**").unwrap());
|
||||
|
||||
let entries = read_history(&board, "uuid").unwrap();
|
||||
assert_eq!(entries.len(), 1);
|
||||
assert_eq!(entries[0].body, "reviewing → backlog");
|
||||
assert_eq!(entries[0].reason, "sent back: the first plan was wrong");
|
||||
}
|
||||
|
||||
/// The stamp leads the name and is fixed width, so the kind that follows it cannot
|
||||
@@ -464,7 +658,7 @@ mod tests {
|
||||
/// is what lets an old board be read without a migration.
|
||||
#[test]
|
||||
fn a_comment_file_is_shaped_as_it_always_was() {
|
||||
let content = entry_content(Kind::Comment, "A body", "claude", "2026-08-24 12:00:00");
|
||||
let content = entry_content(Kind::Comment, "A body", "claude", "2026-08-24 12:00:00", "");
|
||||
assert_eq!(
|
||||
content,
|
||||
"**Comment**\nA body\n\n**Author**: claude\n**Time**: 2026-08-24 12:00:00\n"
|
||||
@@ -535,10 +729,10 @@ mod tests {
|
||||
#[test]
|
||||
fn only_comments_are_counted() {
|
||||
let board = board();
|
||||
write_entry(&board, "uuid", Kind::Comment, "said", "claude").unwrap();
|
||||
write_entry(&board, "uuid", Kind::Status, "backlog → committed", "claude").unwrap();
|
||||
write_entry(&board, "uuid", Kind::Owner, "_Not set_ → alice", "claude").unwrap();
|
||||
write_entry(&board, "uuid", Kind::Tags, "bug → bug, cli", "claude").unwrap();
|
||||
write_entry(&board, "uuid", Kind::Comment, "said", "claude", "").unwrap();
|
||||
write_entry(&board, "uuid", Kind::Status, "backlog → committed", "claude", "").unwrap();
|
||||
write_entry(&board, "uuid", Kind::Owner, "_Not set_ → alice", "claude", "").unwrap();
|
||||
write_entry(&board, "uuid", Kind::Tags, "bug → bug, cli", "claude", "").unwrap();
|
||||
|
||||
assert_eq!(read_history(&board, "uuid").unwrap().len(), 4);
|
||||
assert_eq!(count_comments(&board, "uuid"), 1);
|
||||
@@ -553,75 +747,185 @@ mod tests {
|
||||
assert_eq!(kind_from_stem("20260820_143012_123456_status_01"), Kind::Status);
|
||||
}
|
||||
|
||||
/// The other half of the pair below: with colour off the block is words and spaces,
|
||||
/// and the flag is the only thing that decides. A renderer that painted regardless
|
||||
/// would pass the pin and fail here.
|
||||
#[test]
|
||||
fn a_mechanical_entry_renders_as_one_line_and_a_comment_as_it_did() {
|
||||
fn a_mechanical_entry_renders_as_one_line_and_a_comment_under_its_author() {
|
||||
let entries = vec![
|
||||
parse_entry(
|
||||
"20260824_120000_000000_status",
|
||||
"**Status**\ncommitted → reviewing\n\n**Author**: claude\n**Time**: 2026-08-24 12:00:00\n",
|
||||
),
|
||||
parse_entry(
|
||||
"20260824_120001_000000_comment",
|
||||
"**Comment**\nThe offset was never passed\n\n**Author**: Ansho Rei\n**Time**: 2026-08-24 12:00:01\n",
|
||||
entry("status", "committed → reviewing", "claude", "2026-08-24 12:00:00"),
|
||||
entry("owner", "_Not set_ → alice", "claude", "2026-08-24 12:00:01"),
|
||||
entry("tags", "bug → bug, cli", "claude", "2026-08-24 12:00:02"),
|
||||
entry("campaign", "_Not set_ → v1", "claude", "2026-08-24 12:00:03"),
|
||||
entry(
|
||||
"comment",
|
||||
"The offset was never passed",
|
||||
"Ansho Rei",
|
||||
"2026-08-24 12:00:04",
|
||||
),
|
||||
];
|
||||
|
||||
let rendered = format_history_with(&entries, false);
|
||||
assert!(rendered.contains("HISTORY"), "{rendered}");
|
||||
assert!(
|
||||
rendered.contains("status committed → reviewing claude (2026-08-24 12:00:00)\n"),
|
||||
"{rendered}"
|
||||
);
|
||||
for row in [
|
||||
"status committed → reviewing claude (2026-08-24 12:00:00)\n",
|
||||
"owner _Not set_ → alice claude (2026-08-24 12:00:01)\n",
|
||||
"tags bug → bug, cli claude (2026-08-24 12:00:02)\n",
|
||||
"campaign _Not set_ → v1 claude (2026-08-24 12:00:03)\n",
|
||||
] {
|
||||
assert!(rendered.contains(row), "missing {row:?} in {rendered}");
|
||||
}
|
||||
// The body sits a step deeper than a reason does, and the author line did not move
|
||||
assert!(
|
||||
rendered
|
||||
.contains("From Ansho Rei (2026-08-24 12:00:01)\n The offset was never passed"),
|
||||
.contains("From Ansho Rei (2026-08-24 12:00:04)\n The offset was never passed"),
|
||||
"{rendered}"
|
||||
);
|
||||
assert!(!rendered.contains('\x1b'), "colour off still painted: {rendered:?}");
|
||||
}
|
||||
|
||||
/// The pin for the cells conversion: `show` prints the block exactly as it printed
|
||||
/// it before, every painted run spelled out, the way
|
||||
/// `show_prints_the_same_body_it_printed_before_the_cells_conversion` pins the body.
|
||||
/// The pin: `show` prints the block byte for byte, every painted run spelled out, the
|
||||
/// way `show_prints_the_same_body_it_printed_before_the_cells_conversion` pins the
|
||||
/// body.
|
||||
///
|
||||
/// Updated once since, deliberately: `campaign` widened the label column from 6 to
|
||||
/// 8, and the campaign row itself joined the pin (f774a33).
|
||||
/// Rewritten twice, deliberately. `campaign` widened the label column from 6 to 8 and
|
||||
/// put its own row in the pin (f774a33). Then 2733b10 painted the values: the label
|
||||
/// went grey as chrome, each value took the meaning it carries in the metadata table,
|
||||
/// and the actor and the timestamp came apart into two spans.
|
||||
///
|
||||
/// Every kind is here rather than a representative one, since what each row proves is
|
||||
/// different: status is the orange it is three lines above, tags go through the same
|
||||
/// `tag_cells` the Tags field does, campaign takes its codename's colour, owner is the
|
||||
/// one value the palette says nothing about, and the sentinel in the owner row is grey
|
||||
/// on the same side of an arrow whose other side is not.
|
||||
#[test]
|
||||
fn show_prints_the_same_history_it_printed_before_the_cells_conversion() {
|
||||
fn colour_on_paints_every_value_by_what_the_kind_says_it_is() {
|
||||
let entries = vec![
|
||||
parse_entry(
|
||||
"20260824_120000_000000_status",
|
||||
"**Status**\ncommitted → reviewing\n\n**Author**: claude\n**Time**: 2026-08-24 12:00:00\n",
|
||||
),
|
||||
parse_entry(
|
||||
"20260824_120001_000000_comment",
|
||||
"**Comment**\nThe offset was never passed\n\n**Author**: Ansho Rei\n**Time**: 2026-08-24 12:00:01\n",
|
||||
),
|
||||
parse_entry(
|
||||
"20260824_120002_000000_campaign",
|
||||
"**Campaign**\n_Not set_ → v1\n\n**Author**: claude\n**Time**: 2026-08-24 12:00:02\n",
|
||||
entry("status", "committed → reviewing", "claude", "2026-08-24 12:00:00"),
|
||||
entry(
|
||||
"comment",
|
||||
"The offset was never passed",
|
||||
"Ansho Rei",
|
||||
"2026-08-24 12:00:01",
|
||||
),
|
||||
entry("campaign", "_Not set_ → v1", "claude", "2026-08-24 12:00:02"),
|
||||
entry("owner", "_Not set_ → alice", "claude", "2026-08-24 12:00:03"),
|
||||
entry("tags", "bug → bug, cli", "claude", "2026-08-24 12:00:04"),
|
||||
];
|
||||
|
||||
let stamp = |actor: &str, time: &str| {
|
||||
format!(
|
||||
"{} ({})",
|
||||
paint(actor, tag_color(actor), true),
|
||||
paint(time, Color::Cyan, true)
|
||||
)
|
||||
};
|
||||
let expected = format!(
|
||||
"\n{}\n{}\n\n{} committed → reviewing {}\n\n{}\n The offset was never passed\n\n{} _Not set_ → v1 {}\n",
|
||||
"\n{}\n{}\n\n{} {} → {} {}\n\n{} {}\n The offset was never passed\n\n{} {} → {} {}\n\n{} {} → alice {}\n\n{} {} → {}, {} {}\n",
|
||||
paint("HISTORY", Color::Orange, true),
|
||||
"─".repeat(20),
|
||||
paint("status", Color::Orange, true),
|
||||
paint("claude (2026-08-24 12:00:00)", Color::Cyan, true),
|
||||
paint("From Ansho Rei (2026-08-24 12:00:01)", Color::Cyan, true),
|
||||
paint("campaign", Color::Orange, true),
|
||||
paint("claude (2026-08-24 12:00:02)", Color::Cyan, true),
|
||||
paint("status", Color::Grey, true),
|
||||
paint("committed", Color::Orange, true),
|
||||
paint("reviewing", Color::Orange, true),
|
||||
stamp("claude", "2026-08-24 12:00:00"),
|
||||
paint("From", Color::Grey, true),
|
||||
stamp("Ansho Rei", "2026-08-24 12:00:01"),
|
||||
paint("campaign", Color::Grey, true),
|
||||
paint(NOT_SET, Color::Grey, true),
|
||||
paint("v1", tag_color("v1"), true),
|
||||
stamp("claude", "2026-08-24 12:00:02"),
|
||||
paint("owner", Color::Grey, true),
|
||||
paint(NOT_SET, Color::Grey, true),
|
||||
stamp("claude", "2026-08-24 12:00:03"),
|
||||
paint("tags", Color::Grey, true),
|
||||
paint("bug", tag_color("bug"), true),
|
||||
paint("bug", tag_color("bug"), true),
|
||||
paint("cli", tag_color("cli"), true),
|
||||
stamp("claude", "2026-08-24 12:00:04"),
|
||||
);
|
||||
|
||||
assert_eq!(format_history_with(&entries, true), expected);
|
||||
assert_eq!(format_history_with(&[], true), paint("No history yet.", Color::Grey, true));
|
||||
}
|
||||
|
||||
/// The actor groups its rows: one writer is one colour wherever it wrote, and it is
|
||||
/// not the timestamp's. Asserted through `tag_color` rather than against a literal,
|
||||
/// so the row has to use the mapping and not a colour that happens to match it today.
|
||||
#[test]
|
||||
fn the_actor_is_one_colour_in_every_entry_and_the_timestamp_keeps_cyan() {
|
||||
let entries = vec![
|
||||
entry("status", "backlog → committed", "claude", "2026-08-24 12:00:00"),
|
||||
entry("comment", "Said something", "claude", "2026-08-24 12:00:01"),
|
||||
entry("owner", "_Not set_ → alice", "Ansho Rei", "2026-08-24 12:00:02"),
|
||||
];
|
||||
|
||||
let rendered = format_history_with(&entries, true);
|
||||
let painted = paint("claude", tag_color("claude"), true);
|
||||
assert_eq!(rendered.matches(&painted).count(), 2, "{rendered}");
|
||||
assert!(
|
||||
rendered.contains(&paint("Ansho Rei", tag_color("Ansho Rei"), true)),
|
||||
"{rendered}"
|
||||
);
|
||||
// Two writers, two colours, and neither of them cyan: that is the timestamp's
|
||||
assert_ne!(tag_color("claude"), tag_color("Ansho Rei"));
|
||||
for time in [
|
||||
"2026-08-24 12:00:00",
|
||||
"2026-08-24 12:00:01",
|
||||
"2026-08-24 12:00:02",
|
||||
] {
|
||||
assert!(rendered.contains(&paint(time, Color::Cyan, true)), "{rendered}");
|
||||
}
|
||||
assert!(!rendered.contains(&paint("claude (", Color::Cyan, true)), "still one span");
|
||||
}
|
||||
|
||||
/// The reason is the row's, so it renders indented under the row it explains and
|
||||
/// before whatever entry follows, in both renderers — this is the one layout they
|
||||
/// share. Paired with the pin above: an entry without a reason renders exactly as
|
||||
/// it always did.
|
||||
#[test]
|
||||
fn a_reason_renders_indented_under_its_row() {
|
||||
let entries = vec![
|
||||
parse_entry(
|
||||
"20260824_120000_000000_status",
|
||||
"**Status**\nreviewing → backlog\n\n**Author**: claude\n**Time**: 2026-08-24 \
|
||||
12:00:00\n**Reason**: sent back, the first plan was wrong\n",
|
||||
),
|
||||
entry("comment", "And why.", "Ansho Rei", "2026-08-24 12:00:01"),
|
||||
];
|
||||
|
||||
let expected = format!(
|
||||
"\n{}\n{}\n\n{} {} → {} {} ({})\n sent back, the first plan was wrong\n\n{} {} ({})\n And why.\n",
|
||||
paint("HISTORY", Color::Orange, true),
|
||||
"─".repeat(20),
|
||||
paint("status", Color::Grey, true),
|
||||
paint("reviewing", Color::Orange, true),
|
||||
paint("backlog", Color::Orange, true),
|
||||
paint("claude", tag_color("claude"), true),
|
||||
paint("2026-08-24 12:00:00", Color::Cyan, true),
|
||||
paint("From", Color::Grey, true),
|
||||
paint("Ansho Rei", tag_color("Ansho Rei"), true),
|
||||
paint("2026-08-24 12:00:01", Color::Cyan, true),
|
||||
);
|
||||
|
||||
assert_eq!(format_history_with(&entries, true), expected);
|
||||
assert!(
|
||||
format_history_with(&entries, false)
|
||||
.contains("claude (2026-08-24 12:00:00)\n sent back, the first plan was wrong"),
|
||||
"colour off lost the reason: {}",
|
||||
format_history_with(&entries, false)
|
||||
);
|
||||
}
|
||||
|
||||
/// Padded to the longest of the four, so every body starts in the same column
|
||||
/// however short the label above it is.
|
||||
///
|
||||
/// Run both ways, which is the whole point of the pairing: the padding is measured on
|
||||
/// the unpainted label and carried in a cell of its own, so the column a value lands
|
||||
/// in cannot depend on the colour decision. Measuring a painted label would count its
|
||||
/// escapes towards its width and tilt the table with colour on and not with it off,
|
||||
/// which is exactly the bug the metadata table already learned.
|
||||
#[test]
|
||||
fn the_mechanical_labels_are_aligned() {
|
||||
fn the_mechanical_labels_are_aligned_with_colour_on_and_off() {
|
||||
let bodies = [
|
||||
("status", "backlog → committed"),
|
||||
("owner", "_Not set_ → alice"),
|
||||
@@ -630,28 +934,27 @@ mod tests {
|
||||
];
|
||||
let entries: Vec<Entry> = bodies
|
||||
.into_iter()
|
||||
.map(|(kind, body)| {
|
||||
let marker = format!("**{}{}**", kind[..1].to_uppercase(), &kind[1..]);
|
||||
parse_entry(
|
||||
&format!("20260824_120000_000000_{kind}"),
|
||||
&format!(
|
||||
"{marker}\n{body}\n\n**Author**: claude\n**Time**: 2026-08-24 12:00:00\n"
|
||||
),
|
||||
)
|
||||
})
|
||||
.map(|(kind, body)| entry(kind, body, "claude", "2026-08-24 12:00:00"))
|
||||
.collect();
|
||||
|
||||
let rendered = format_history_with(&entries, false);
|
||||
let columns: Vec<usize> = bodies
|
||||
.into_iter()
|
||||
.map(|(_, body)| rendered.find(body).expect("body missing"))
|
||||
.map(|at| {
|
||||
let line_start = rendered[..at].rfind('\n').map_or(0, |nl| nl + 1);
|
||||
at - line_start
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(columns.len(), 4);
|
||||
assert!(columns.windows(2).all(|pair| pair[0] == pair[1]), "{rendered}");
|
||||
let columns = |colored: bool| -> Vec<usize> {
|
||||
// Stripped before it is measured, so an escape counts for the nothing it
|
||||
// occupies on screen and the two renderings are compared on what a reader sees
|
||||
let rendered = strip_escapes(&format_history_with(&entries, colored));
|
||||
bodies
|
||||
.into_iter()
|
||||
.map(|(_, body)| rendered.find(body).expect("body missing"))
|
||||
.map(|at| {
|
||||
let line_start = rendered[..at].rfind('\n').map_or(0, |nl| nl + 1);
|
||||
at - line_start
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
|
||||
let plain = columns(false);
|
||||
assert_eq!(plain.len(), 4);
|
||||
assert!(plain.windows(2).all(|pair| pair[0] == pair[1]), "{plain:?}");
|
||||
assert_eq!(columns(true), plain, "the colour decision moved the column");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
+10
-5
@@ -57,9 +57,13 @@ fn main() -> Result<()> {
|
||||
let worklane_dir = find_worklane_dir(&start)?;
|
||||
cmd_show(&id, &worklane_dir)
|
||||
}
|
||||
Some(Command::Mv { ticket, status, force, actor }) => {
|
||||
cmd_mv(&ticket, status, force, &actor, &start)
|
||||
}
|
||||
Some(Command::Mv {
|
||||
ticket,
|
||||
status,
|
||||
force,
|
||||
actor,
|
||||
reason,
|
||||
}) => cmd_mv(&ticket, status, force, &actor, &reason, &start),
|
||||
Some(Command::Set(args)) => cmd_set(&args, &start),
|
||||
Some(Command::Append(args)) => cmd_append(&args, &start),
|
||||
Some(Command::Relate(args)) => cmd_relate(&args, &start),
|
||||
@@ -238,8 +242,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
|
||||
|
||||
+353
-125
@@ -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]
|
||||
@@ -4973,6 +5120,11 @@ mod tests {
|
||||
///
|
||||
/// Paired the way the guideline demands: a renderer that dropped every colour would
|
||||
/// pass the no-escape half, so the presence is asserted beside it.
|
||||
///
|
||||
/// The spans it looks for are 2733b10's: the label went grey as chrome, the values
|
||||
/// took the meanings they carry in the metadata table, and the actor came away from
|
||||
/// the timestamp so a name is one colour and cyan is the stamp's alone. Asserted on
|
||||
/// the board as well as in `show`, because these are the cells both render.
|
||||
#[test]
|
||||
fn the_history_block_is_styled_in_the_overlay_and_no_escape_reached_it() {
|
||||
let dir = board_dir();
|
||||
@@ -5000,17 +5152,16 @@ mod tests {
|
||||
assert_eq!(span_color(&heading, "HISTORY"), Some(Color::Orange.into()));
|
||||
|
||||
let from = body_line(detail, "From bob");
|
||||
assert_eq!(
|
||||
span_color(&from, "From bob (2026-08-21 12:00:01)"),
|
||||
Some(Color::Cyan.into())
|
||||
);
|
||||
assert_eq!(span_color(&from, "From"), Some(Color::Grey.into()));
|
||||
assert_eq!(span_color(&from, "bob"), Some(tag_color("bob").into()));
|
||||
assert_eq!(span_color(&from, "2026-08-21 12:00:01"), Some(Color::Cyan.into()));
|
||||
|
||||
let change = body_line(detail, "backlog → committed");
|
||||
assert_eq!(span_color(&change, "status"), Some(Color::Orange.into()));
|
||||
assert_eq!(
|
||||
span_color(&change, "claude (2026-08-21 12:00:00)"),
|
||||
Some(Color::Cyan.into())
|
||||
);
|
||||
assert_eq!(span_color(&change, "status"), Some(Color::Grey.into()));
|
||||
assert_eq!(span_color(&change, "backlog"), Some(Color::Orange.into()));
|
||||
assert_eq!(span_color(&change, "committed"), Some(Color::Orange.into()));
|
||||
assert_eq!(span_color(&change, "claude"), Some(tag_color("claude").into()));
|
||||
assert_eq!(span_color(&change, "2026-08-21 12:00:00"), Some(Color::Cyan.into()));
|
||||
|
||||
// The other half: the colour arrived as styles, not as bytes.
|
||||
assert!(
|
||||
@@ -5020,6 +5171,34 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
/// The board and `show` share one layout, so the reason a move carries renders
|
||||
/// indented under the row it explains in the overlay too — attached to its
|
||||
/// transition rather than sitting apart like a comment.
|
||||
#[test]
|
||||
fn the_detail_view_renders_a_reason_under_its_row() {
|
||||
let dir = board_dir();
|
||||
let uuid = "11111111-0000-4000-8000-000000000000";
|
||||
write_ticket(&dir, "backlog", uuid, "First one", "");
|
||||
|
||||
let history = crate::history::history_dir(&dir, uuid);
|
||||
std::fs::create_dir_all(&history).unwrap();
|
||||
std::fs::write(
|
||||
history.join("20260821_120000_000000_status.md"),
|
||||
"**Status**\nreviewing → backlog\n\n**Author**: claude\n**Time**: 2026-08-21 \
|
||||
12:00:00\n**Reason**: sent back, wrong approach\n",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut board = one_board(&dir);
|
||||
board.toggle_detail();
|
||||
let plain = board.detail.as_ref().expect("no detail").plain();
|
||||
|
||||
let expected = "status reviewing → backlog claude (2026-08-21 12:00:00)\n sent back, wrong \
|
||||
approach";
|
||||
assert!(plain.contains(expected), "{plain}");
|
||||
assert!(!plain.contains('\x1b'), "escapes reached the detail view: {plain:?}");
|
||||
}
|
||||
|
||||
/// The reported bug: the modal showed a description, criteria and a metadata
|
||||
/// table belonging to a ticket it never named.
|
||||
#[test]
|
||||
@@ -5522,8 +5701,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 +5818,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 +6539,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 +7742,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 +8164,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 +8184,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 +8241,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 +9181,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 +9192,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
|
||||
|
||||
+90
-23
@@ -1006,7 +1006,11 @@ fn metadata_value_cells(name: &str, value: &str, campaign: &[Cell]) -> Vec<Cell>
|
||||
/// holds come back unchanged. `bug, cli` and `bug,cli` are both written by hand at some
|
||||
/// point, and a cell that normalised them would be the display quietly disagreeing with
|
||||
/// the file it is showing.
|
||||
fn tag_cells(value: &str) -> Vec<Cell> {
|
||||
///
|
||||
/// Shared with the history block, which draws the two halves of a tags entry through it:
|
||||
/// a tag list is a tag list wherever it is printed, and the alternative was a second
|
||||
/// splitter that would drift from this one the first time either changed.
|
||||
pub(crate) fn tag_cells(value: &str) -> Vec<Cell> {
|
||||
let mut cells = Vec::new();
|
||||
|
||||
for (index, piece) in value.split(',').enumerate() {
|
||||
@@ -1091,6 +1095,15 @@ pub const NOT_SET: &str = "_Not set_";
|
||||
/// distinction `add` already makes and clearing has to keep.
|
||||
pub const NONE: &str = "_None_";
|
||||
|
||||
/// What stands in for something the board no longer holds.
|
||||
///
|
||||
/// Not an unset value, so [`is_unknown_value`] does not read it: a field pointing at a
|
||||
/// campaign that has been removed is set, and what it is set to is gone. Drawn in the
|
||||
/// same grey all the same, which is what it shares with an unset value and why the
|
||||
/// spelling is a constant — the relations block writes it, `assign` records it in a
|
||||
/// history entry, and the two have to be the same word for the third place to paint it.
|
||||
pub const MISSING: &str = "_missing_";
|
||||
|
||||
/// Whether a field holds one of the two markers that mean it holds nothing.
|
||||
///
|
||||
/// The two constants and nothing else. `-None-` and `-Not set-` were accepted here from
|
||||
@@ -1437,7 +1450,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 +1461,7 @@ const METADATA_ORDER: [&str; 12] = [
|
||||
COMMITTED_ON_FIELD,
|
||||
SUBMITTED_ON_FIELD,
|
||||
COMPLETED_ON_FIELD,
|
||||
DISCARDED_ON_FIELD,
|
||||
CAMPAIGN_FIELD,
|
||||
"Status",
|
||||
];
|
||||
@@ -1532,6 +1546,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 +2211,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.
|
||||
///
|
||||
@@ -2239,7 +2260,7 @@ pub fn reference_cells(uuid: &str, name: Option<&str>) -> Vec<Cell> {
|
||||
|
||||
match name {
|
||||
Some(name) => cells.push(Cell::plain(name)),
|
||||
None => cells.push(Cell::colored("_missing_", Color::Grey)),
|
||||
None => cells.push(Cell::colored(MISSING, Color::Grey)),
|
||||
}
|
||||
|
||||
cells
|
||||
@@ -2288,11 +2309,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 +2699,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 +2741,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 +2753,7 @@ impl Status {
|
||||
Status::Committed => "committed",
|
||||
Status::Reviewing => "reviewing",
|
||||
Status::Done => "done",
|
||||
Status::Discarded => "discarded",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2730,15 +2762,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 +2925,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 +2942,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 +3137,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 +3166,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 +3181,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 +4195,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 +5257,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.
|
||||
|
||||
@@ -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}");
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
|
||||
+257
@@ -1144,3 +1144,260 @@ 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}");
|
||||
}
|
||||
|
||||
/// Prose takes a leading hyphen, so a reason that reads like a flag is stored as the
|
||||
/// content it is rather than refused or swallowed. The cost of that bargain is that a
|
||||
/// genuinely mistyped flag here lands in the log too.
|
||||
#[test]
|
||||
fn a_reason_takes_a_leading_hyphen_as_content() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"Hyphen Reason",
|
||||
"Prose trap.",
|
||||
"bbbb2222",
|
||||
"alice",
|
||||
"_Not set_",
|
||||
"",
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args([
|
||||
"mv",
|
||||
"bbbb2222",
|
||||
"--status",
|
||||
"committed",
|
||||
"--reason",
|
||||
"-not-a-flag",
|
||||
])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let dir = worklane.join("history").join("bbbb2222");
|
||||
let entry = fs::read_dir(&dir)
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| fs::read_to_string(e.path()).unwrap())
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
assert!(entry.contains("**Reason**: -not-a-flag\n"), "{entry:?}");
|
||||
}
|
||||
|
||||
@@ -114,6 +114,94 @@ fn mv_writes_a_status_entry() {
|
||||
assert!(entry.contains("**Author**: claude"), "{entry:?}");
|
||||
}
|
||||
|
||||
/// One file, one event, its explanation: `--reason` rides in the status entry that
|
||||
/// records the transition it explains, as a field after **Time**, and `show` renders it
|
||||
/// indented under the row rather than as a paragraph of its own.
|
||||
#[test]
|
||||
fn the_reason_travels_with_its_transition() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane, "reviewing");
|
||||
|
||||
run(
|
||||
&temp,
|
||||
&[
|
||||
"mv",
|
||||
UUID,
|
||||
"--status",
|
||||
"backlog",
|
||||
"-f",
|
||||
"--reason",
|
||||
"sent back: the first plan was wrong",
|
||||
],
|
||||
);
|
||||
|
||||
let entry = only_entry(&worklane, "status");
|
||||
assert!(entry.starts_with("**Status**\nreviewing → backlog\n"), "{entry:?}");
|
||||
assert!(
|
||||
entry.ends_with("**Reason**: sent back: the first plan was wrong\n"),
|
||||
"{entry:?}"
|
||||
);
|
||||
|
||||
let out = run(&temp, &["show", UUID]);
|
||||
let stdout = String::from_utf8(out.stdout).unwrap();
|
||||
|
||||
let moved = stdout.find("reviewing → backlog").expect("the move is missing");
|
||||
let reason = stdout
|
||||
.find("\n sent back: the first plan was wrong")
|
||||
.expect("the reason is missing");
|
||||
// Attached means the very next line: nothing, not even a blank line, between.
|
||||
assert!(
|
||||
!stdout[moved..reason].contains('\n'),
|
||||
"the reason is detached from its row:\n{stdout}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The unusual moves are exactly the ones that need a why, so a refused one must not
|
||||
/// log one either: the entry is written after the edit, and there was no edit.
|
||||
#[test]
|
||||
fn a_refused_move_writes_no_reason_either() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane, "reviewing");
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"mv",
|
||||
UUID,
|
||||
"--status",
|
||||
"backlog",
|
||||
"--reason",
|
||||
"this move never happened",
|
||||
],
|
||||
);
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert_eq!(entries(&worklane), vec![], "a refused move logged its reason");
|
||||
}
|
||||
|
||||
/// Same for the move that changes nothing.
|
||||
#[test]
|
||||
fn a_no_op_move_writes_no_reason_either() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane, "committed");
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"mv",
|
||||
UUID,
|
||||
"--status",
|
||||
"committed",
|
||||
"--reason",
|
||||
"nothing moved",
|
||||
],
|
||||
);
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
assert_eq!(entries(&worklane), vec![], "a no-op move logged its reason");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chown_writes_an_owner_entry() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user