Compare commits

..
11 Commits
Author SHA1 Message Date
Ansho ReiandClaude Opus 5 88918b2f8a (c628759) Show a page indicator on the detail overlay's border, and bump to 0.16.1
The overlay has scrolled since 1b78a24 and nothing said where you were: a long
ticket opened looking exactly like a short one, so the only way to learn there
was more below was to press pgdn and watch whether anything moved.

`pg 2/8` now sits on the bottom right of the border, through
`Block::title_bottom` with a right-aligned line, which spends no text row. That
is the trade the title already makes on the top border, and the two cannot
crowd each other because they are on opposite borders.

Both of the things this had to get right are arithmetic. `wrapped_height` is
now the one measurement: `last_offset` is it less the viewport and
`page_indicator` takes the same two numbers, so the clamp and the indicator
cannot disagree. A second `line_count` call would be a number free to drift,
and an indicator claiming there is more to read where the scroll refuses to
move is worse than none.

The furthest offset is the last page by definition rather than by division. The
clamp stops at the wrapped height less the viewport, which is not a page
boundary, so the final screenful is partial and dividing reads `pg 2/3` at the
bottom of the ticket. The pages are counted in `scroll_step`, a screenful less
the overlap line, because that is the step the keys take: counting whole
screenfuls names a page pgdn cannot land on, and puts a 30 row ticket in a 10
row viewport at `pg 3/3` two rows short of its end.

Grey, the colour the footer keys and a rendered checkbox take, since this says
where you are in the ticket rather than anything about the ticket. Dropped
whole on an overlay too narrow for it and absent entirely when nothing scrolls,
the rules a corner and the tags row already follow.

`page_indicator` is four numbers in and an `Option<String>` out, so the
arithmetic is pinned without a terminal. The drawn tests answer the two things
it cannot: which border it landed on and what colour it reached the screen in.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-22 17:22:41 +02:00
Ansho ReiandClaude Opus 5 6784d80324 Let check and uncheck take several criteria, and bump to 0.16.0
Finishing a ticket means ticking every box, and that was one invocation per
box: each one resolved the ticket, spliced one line and rewrote the file.

The criterion positional is now variadic, so numbers and substrings mix in a
single call, and `all` stands for every criterion on the ticket. `all` is a
keyword checked before the text, the way the index already is, so a criterion
whose own words include "all" is reached by its number or by a longer
substring. `is_all_criteria` sits beside `is_index` for that reason.

`resolve_criteria` resolves every term before a byte is written and refuses the
whole batch on the first term it cannot place, naming it. A call that ticked
what it understood and then failed would leave the ticket half-marked with
nothing in the file to say which half was meant. The offsets are sorted and
deduped, so the report reads in `show`'s order and a criterion named twice, or
by both `all` and its number, is marked once. `set_criterion` becomes
`set_criteria` and takes every line in one pass.

Each named criterion gets a line, printed after the write. One already in the
target state reads `Already checked 2: text` and does not count towards the
write, so a batch where every box is already ticked writes nothing.

The opencode wrapper takes the terms one per line, like the other list
arguments. REVIEW.md gains the one thing a reviewer must not do with this:
reach for `all`, which would erase the implementer's claim on the criteria the
review agreed with.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-22 16:30:40 +02:00
Ansho ReiandClaude Opus 5 ae3ee1bb9e Show the target's status beside the relation kind, and bump to 0.15.2
A row now carries two marks, kind then status: what sort of edge this is, then
how far the ticket at the other end has got. `blocked by × ◐ (6ce2c47) Title`.
Two questions are asked of this block, which rows hold this ticket up and
whether the ones that do are finished, and one glyph could not answer both.

○ not started, ◐ under way, ● finished, in grey, orange, cyan and green: the
shape says how far the target has got and the colour tells the two middle
stages apart, since committed and reviewing are both half circles. Green is the
colour the priority ramp deliberately leaves out because it means a title; on a
one-cell mark with no title behind it nothing else wants it, and it is the
obvious colour for done. Orange keeps the meaning it already has, Status.

These are the priority meter's own circles, and what keeps a status from
reading as a level is width: the meter is always two cells, a status mark is
one. the_status_mark_is_one_cell_where_the_meter_is_two pins both halves, and a
card carries the meter and never a status mark while the block carries the
status mark and never a meter.

The kind mark survives a target the board cannot find and the status mark
cannot, since a kind is read from the ticket's own file and a status from the
board. ? holds the column so the id does not move when one target has gone, and
_missing_ is what says it is gone.

Committed and reviewing are told apart by colour alone, so a pipe cannot tell
them apart: both read as under way. Accepted, since ● and ○ are the two answers
usually wanted and show on the target settles the rest, and assets/SKILL.md now
says so outright rather than leaving an agent to work it out from a colourless
half circle.

RelationTarget is back, carrying the title and the status in one Option because
they come from the same lookup. It went out in 5ae9c7f when nothing read the
status and came back one commit later, which is what a field nothing reads
costs: right at the time, churn either way.

A patch: 0.15.0 was the arrival of a marked relations block and this is still
settling what it marks. Three minors in an hour would read as three features.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-22 15:59:22 +02:00
Ansho ReiandClaude Opus 5 5ae9c7fe00 Mark a relation by its kind rather than its target's status, and bump to 0.15.1
A column of ▁▄▆█ read as undifferentiated blocks. What is worth seeing at a
glance is which kind of edge a row is: × for blocked by and blocks, → for
relates to, ← for regression of and regressed by. The labels are five long words
that blur when one ticket carries several, and the rows holding it up are now
the crosses.

Both directions of a kind carry one mark, since blocked by and blocks are the
same edge read from two ends and the label is what says which end you are on.

× is BLOCKED_MARK, the constant a held-up card already draws, in the same
brightred. On a card it says this ticket is held up, in the block that this edge
is what holds one, which is one word, so one glyph and one definition: the
constant moved to util.rs, where both renderers can reach it. Brightred rather
than the red asked for, because the id one cell to the right is red and the two
would have blended.

The arrows are the ones the footer already draws, so they render wherever it
does, and no_relation_mark_is_a_priority_glyph pins all three against every
level of the meter: the circles belong to priority.

The mark now survives a target the board cannot find, because a kind is read
from the ticket's own file rather than from the board. Only the name is gone,
and `_missing_` in grey is what says so. That is one case fewer than the status
mark had, which needed a `?` for a target with no status to show.

What this gives up is the status: 6ce2c47's motivation was reading whether a
blocker is finished without leaving the overlay, and nothing in the block shows
that now. Its criteria 1 and 3 describe the commit before this one, and the
ticket says so.

RelationTarget went with it. Nothing read the status field once the mark stopped
keying on it, and a field written but never shown is a field that goes stale
unnoticed, so RelationRow carries the kind and the title and the status is one
lookup away on the index if a later ticket wants it.

A patch, not a second minor: 0.15.0 was the arrival of a mark and settling which
glyph it is belongs to that, where a second minor would read as two features.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-22 15:35:24 +02:00
Ansho ReiandClaude Opus 5 ce32b42ae4 (dbf7b61) Guard the overlay's relation colours, and bump to 0.15.0
The mechanism arrived with 6ce2c47, as this ticket said it would: the block is
laid out once as cells, the id carries the red the guideline gives a uuid, and
the board turns the same cells into spans. So the id is red in the overlay
without anything here asking the terminal for a decision, and the three
criteria about what is drawn were true the moment ece201e landed.

What was left is the test the ticket was really about. The naive version of
this, passing true to the body renderers, puts escapes in the paragraph and
draws them as literal bytes, which is 6d327df, and the tests that pin that
assert on content_trim rather than on what detail_of builds.

the_relation_id_is_red_in_the_overlay_and_no_escape_reached_the_body asserts
the id span is red, that something on the row is coloured at all, and that the
body holds no escape byte. The middle one is the pair the Color and Output rule
demands: without it a version that dropped every colour to stay safe would
satisfy the absence. The one character version now fails this test and two
others, checked by making the change and running the suite.

a_missing_target_still_reads_as_missing_in_the_overlay is the same question
asked of a gap: _missing_ in grey, the id still red, and the mark ? in grey
rather than the status orange, so a target the board no longer holds cannot be
dressed up as one it does.

And the decision the ticket asked for, in AGENTS.md: the relations block is the
only coloured part of the overlay body, on purpose. The block earned it by
being where a reader compares several references at once, and by arriving as
rows rather than prose. The rest of the body is e4d0bb7, which is a larger
change than it looks, since every run content_parts paints has to become a cell
while show's output stays byte for byte what it prints today. One coloured
section reads as a decision; two would read as a bug.

The minor is 6ce2c47's, taken here because the pair is one body of work: show
now prints a status mark before each relation id.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-22 15:23:55 +02:00
Ansho ReiandClaude Opus 5 ece201e3ab (6ce2c47) Mark each relation with the status of the ticket it names
The Relations block named each target and said nothing about where it was, so
the question actually asked of it, whether a blocker is finished, meant closing
the overlay and going to find the other ticket. Each row now carries a mark for
its target's status, ahead of the id, where it describes the target rather than
the row.

A rising bar, U+2581 through U+2588 for backlog to done, and ? for a target the
board no longer holds. Not a circle: the cards spend those on the priority
meter two cells from nothing at all, and another circle would be read as a
level. The ramp is also the meaning, so the shape says which status it is.

The colour could not. Every colour in the guideline already means one thing and
the eight tag slots are reserved, so four status colours could only have come
out of something else's meaning. So the shape carries the status and the colour
says only that it is one: orange, which is what Status already means, and grey
on the missing mark, beside the _missing_ that grey already spells. An
unrecognised status reads as missing rather than as a fifth stage, and
every_status_has_a_mark pins the pairing against status_dirs so a status added
later fails a test instead of quietly reading as ?.

The plain text was the real cost. Detail.text was one String drawn by a
Paragraph, deliberately uncoloured because an escape sequence there is drawn as
literal bytes, which is 6d327df. So the block cannot arrive pre-painted.
Resolved.relations is now rows, content_parts returns the body as
BodyPart::Text and BodyPart::Relations with the text painted and the rows
untouched, and the two renderers take it from there: content_trim paints the
rows into escapes, and the board styles the same cells as spans.

One builder, two painters. relation_rows decides which edges there are, what
they are called and which direction leads; relation_cells decides the layout,
the mark and the colours; paint_cells and span_of are the only things that
differ. Cell is the unit both take, the same shape the palette uses to stop a
colour existing for one renderer and not the other. reference_cells is now the
one spelling of a cross reference, shared with the Campaign field.

Detail.body is a ratatui Text and is the only thing measured, so last_offset
and the Paragraph cannot wrap the body two ways. Detail::plain() flattens it
for the suite and is cfg(test): a second representation carried beside the
spans is a second thing to disagree.

show carries the same mark, decided here rather than discovered later. The rows
are one builder so it was free, and two views disagreeing about what a relation
shows is a difference nobody can explain afterwards. That is a change to what
the CLI prints, so the minor goes on the last commit of this pair.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-22 15:20:56 +02:00
Ansho ReiandClaude Opus 5 c437d87e9e (2f3796e) Add a --tag filter to worklane ls, and bump to 0.14.0
Tickets carry a Tags field, but ls could not select on it: finding what is
tagged bug meant reading the board. Step 1 of the plan was already done by
e41802b, which put tags: Vec<String> on TicketItem through parse_tags, so this
is the flag, the filter and the tests.

Whole values, not the field. parse_tags has already split and trimmed the
comma-separated field, so filter_by_tag compares against those values: --tag
bug is not answered by a ticket tagged bugfix, --tag "cli, filter" matches
nothing because the field as written is not itself a tag, and a ticket with no
tags matches none, however it spells it.

Case sensitive, which is the opinion the field already takes everywhere else.
tag_color draws Bug and bug in two colours because they are two tags to the
field, and a filter that folded them would list tickets carrying a tag nobody
asked for while hiding exactly the split a grooming sweep is looking for.

One tag per invocation. Several would have to decide between and and or, and
that decision is its own ticket, along with substring or regex matching and a
tag filter on the board.

A tag nothing carries lists nothing rather than being refused, deliberately
the opposite of --campaign. A campaign is an object that exists or does not,
so it is resolved before anything is read; a tag is free text with no
registry, and refusing an unknown one would mean maintaining a vocabulary the
format does not have. An emptied status keeps the message ls already gives
rather than one per filter naming what excluded them, which is what --priority
and --campaign already do.

The filter goes through filtered, the one call the three collect sites share,
so the counts are filtered by the same set as the rows. Every filter is an
Option and none asked for keeps everything, which is what makes them compose
in any combination. cmd_ls is now at four filters and the directory, two of
them adjacent &Option<String> parameters a caller can swap silently: left as
positionals rather than refactored mid-feature, with AGENTS.md recording that
the next filter takes an LsArgs struct the way add took AddArgs.

assets/PLAN.md said in as many words that there was no tag filter yet, so it
would have been actively wrong. It now says what --tag can and cannot answer:
it finds what is tagged bug, it does not enumerate the vocabulary, which is
the question a grooming sweep starts from. The README's ls row also gained
--campaign, which had never been documented there.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-22 14:54:50 +02:00
Ansho ReiandClaude Opus 5 0ce3fdb246 (0546fc5) Copy the selected id with y in the tui, and bump to 0.13.7
The board is where a ticket is found and the CLI is where it is acted on, and
the only thing joining them was seven characters retyped off the screen. y
reads as yank to the readers a keyboard board is for, and was the letter left
after q, esc, enter, space, hjkl, the arrows, pgup, pgdn, tab, backtab, d and
/ took theirs.

The mechanism was chosen against ssh, which is where a board is often read.
OSC 52 crosses the connection, because it is the terminal at the reader's own
end that owns the clipboard. A crate wants X11 and Wayland libraries at build
time and, on X11, hands the selection to the process that set it: copy an id,
quit, and the paste buffer is empty, which is precisely the flow this key
exists for. Shelling out to wl-copy, xclip or pbcopy is platform sniffing plus
a spawn, and does nothing where none of them is installed. crossterm 0.28 is
what ratatui 0.29 pins and ships no clipboard command, so the sequence and its
base64 are twenty lines in src/clipboard.rs, pinned on the RFC 4648 vectors.

The cost is recorded rather than hidden, in AGENTS.md under The Copy Key: a
terminal that ignores OSC 52 ignores it silently, and tmux needs set-clipboard
on. What clipboard::copy reports is whether the sequence was written, and the
footer says no more than that. There is no reply to read either, since the
query form is refused by most emulators.

What is copied is ticket.id, the seven characters the card already prints and
every command already resolves, decided by Board::copy_text so the string is a
question the suite can ask without a clipboard. None on an empty column: an
empty string would take away whatever the reader had there and give nothing
back. The project is left off even on the merge tab, since a second word would
have to be deleted out of every paste.

Board::copy_selected_id takes the clipboard as an argument, clipboard::copy
from the dispatch and a closure from a test, which is what makes the hit and
the refusal both drivable. A failure is said in the footer rather than
returned: there is nobody above it to handle one, and an error swallowed there
would look exactly like a copy that worked until the paste came out wrong.

Notice is the board's first channel for saying something in words, and it has
to be, because a copy leaves nothing on screen to look at. failed means
nothing reached the clipboard, so an empty column and a refused write are one
answer to the reader, both in brightred like the search's no match. It takes
the whole footer row, since a message squeezed in beside the keys would move
every key in it. Cleared by the next keypress rather than on a timer: no clock
on the board, no wakeup in the loop, and never in tick, which runs four times
a second. clear_notice goes ahead of search_key as well as the arms, because a
key typed into a query is still a key.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-22 14:36:09 +02:00
Ansho ReiandClaude Opus 5 37dbd722e0 (3b16540) Open a search with / in the tui, and bump to 0.13.6
Finding a ticket meant scrolling four columns and reading, which is what the
id and the title are for.

The real work was the input mode: every key in the dispatch was a single-shot
action, and a query needs one that swallows the keys bound to them. That is
Board::search_key, offered every key ahead of the action arms and reporting
what it took. With no prompt open it takes nothing, so every other state's
dispatch is unchanged. On Board for the reason dismiss is: the arm is not
reachable from a test.

ctrl-c is the one key the prompt declines, since a terminal application
always honours it. Every other control combination is swallowed and does
nothing: it must not type its letter, and it must not fall through either,
because the action arms match on the code alone and ctrl-d would reach the
arm bound to d.

first_match runs over every card in the visible columns, in reading order,
not the rows on screen: a query that answered differently on a tall terminal
and a short one is not a search, and the jump scrolls the match into view. A
hidden done column stays out, or the highlight would land on a ticket that is
not on the board. Id and title only, both lowercased.

The jump goes through select_at, extracted as the tail select_card already
used, so follow_selection scrolls the match's own column and refresh_detail
keeps an open overlay on it. Nothing calculates either a second way.

A hit closes the prompt; a miss keeps it open, marked in brightred beside the
query it is about, with the selection untouched, so the query can be
corrected in place rather than retyped from /. The mark clears on the next
edit. An empty query matches nothing rather than everything.

The prompt takes the whole footer row, since the key list it replaces
describes nothing that works while every key goes into the buffer. The real
terminal cursor sits after the query: ratatui shows it only for a frame that
asked, so it is also what says "you are typing" on an empty query. Both
closed footers now name / search.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-22 13:29:30 +02:00
Ansho ReiandClaude Opus 5 4502de7ee3 (e7612de) Close the detail overlay on q instead of quitting, and bump to 0.13.5
q set should_quit outright, so a reader who pressed it to put a ticket away
lost the whole board instead. That is not what q means anywhere else that
lays a document over a list, and esc two arms below already did the right
thing.

The rule is Board::dismiss: close what is open, quit when there is nothing
left to close. On Board rather than in the match arm because the dispatch in
main.rs is not reachable from a test, so a rule written there is a rule
nothing can check. q and esc now share one arm, since two arms carrying one
rule is how a later edit changes it for one key and not the other.

The footer is the other half. Its last slot answers the same question in
both states, how to get out, and with a ticket open the honest answer is
ctrl-c: it is the only key left that quits in one press. Going on saying
q quit there would be 1b78a24 in the other direction, a footer describing a
key by what it used to do. The close entry names both keys as enter/q close
rather than repeating close twice.

Criteria 3 and 7 live in a dispatch no test can reach, so
the_dispatch_gives_q_and_esc_one_arm_and_leaves_ctrl_c_quitting scans
main.rs for them, over whitespace-collapsed source so rustfmt cannot fail
it, the way util.rs is already scanned for colour_text callers.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-22 13:13:58 +02:00
Ansho ReiandClaude Opus 5 a16169ce8c (b8ce18c) Show a blocked marker on the tui card, and bump to 0.13.4
A ticket held up by an open blocker looked exactly like one that is ready,
and the board is where the next thing to pick up is chosen.

The mark is × in brightred, after the short id. Not a fourth Geometric
Shapes glyph: those are the priority meter's, two cells away, and another
circle there reads as part of that ramp. × is Latin-1, like the middle dot
the unset priority draws, so it renders wherever the meter does.

After the id rather than before it, because ahead of it the mark would push
every id in the column out of line whenever one card was blocked. 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.

No scan of the board per tick was needed after all. collect_ticket_items
also reads the ticket's own uuid and the targets of its blocked by lines,
off the file it is already holding, and mark_blocked walks the four columns
once for a uuid-to-status map and once to answer every card. The flag is on
Card rather than TicketItem: the answer is about two tickets at once, so no
card can reach it alone, and it is settled at reload the way project is.

The merge carries each card's flag from the board it came from. relate
resolves its target inside one .worklane, so a blocker in another project is
not a relation anything can record, and recomputing over the merged columns
would let one project's uuid match another project's ticket.

project_label now takes the width the row has actually spent, measured off
the spans, instead of adding up the widths those spans are supposed to have.
The hand-written sum left out the space after the priority mark, so a cut
label was handed one cell more than the column had.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-22 13:02:13 +02:00
18 changed files with 3464 additions and 240 deletions
+20 -10
View File
@@ -425,39 +425,49 @@ export const chown = tool({
/**
* check and uncheck differ only in the verb, so the tool is built once.
*
* The criterion is required here even though the CLI makes it optional: without it the
* CLI prompts, and there is no terminal on this side of the pipe. The CLI answers a
* The criteria are required here even though the CLI makes them optional: without any
* the CLI prompts, and there is no terminal on this side of the pipe. The CLI answers a
* missing criterion with the numbered list on stderr, which run() relays, so the model
* sees the options and can retry with a number.
*
* One value per line, like the other list arguments, and every value goes in one call.
* The CLI resolves them all before it writes, so a bad term costs nothing, and finishing
* a ticket is one tool call rather than one per box.
*/
function checkboxTool(verb: "check" | "uncheck") {
const past = verb === "check" ? "Checked" : "Unchecked";
return tool({
description:
`${past === "Checked" ? "Tick" : "Untick"} one acceptance criterion on a worklane ticket. ` +
"Every other criterion keeps its state. Identify the criterion by its number as shown by show, " +
"or by a substring of its text; a substring matching more than one is an error listing them.",
`${past === "Checked" ? "Tick" : "Untick"} acceptance criteria on a worklane ticket. ` +
"Every criterion not named keeps its state. Identify each one by its number as shown by show, " +
"or by a substring of its text; a substring matching more than one is an error listing them. " +
`Pass several, one per line, to ${verb} them in a single call, or the single word all for every ` +
"criterion on the ticket. If any value cannot be resolved the whole call is refused and nothing " +
"is written, so a partly wrong list never leaves the ticket half-marked.",
args: {
ticket: tool.schema
.string()
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
criterion: tool.schema
criteria: tool.schema
.string()
.describe(
"Criterion number as shown by show, or a substring of its text (required)",
"Criterion numbers as shown by show, or substrings of their text, one per line. " +
"Or the single word all for every criterion (required)",
),
},
async execute(args: Record<string, any>, context: ToolContext) {
if (!args.ticket) {
return `Error running ${verb}: ticket is required`;
}
if (!args.criterion) {
return `Error running ${verb}: criterion is required, give the number or a substring`;
const terms = args.criteria ? itemLines(String(args.criteria)) : [];
if (terms.length === 0) {
return `Error running ${verb}: criteria is required, give the numbers, substrings, or all`;
}
try {
return await run([verb, args.ticket, String(args.criterion)], context);
return await run([verb, args.ticket, ...terms], context);
} catch (err: any) {
return `Error running ${verb}: ${err.message}`;
}
+87 -4
View File
@@ -7,6 +7,7 @@
- `src/util.rs` - the ticket format, resolution, rendering and the palette
- `src/campaign.rs` - the campaign file format, its resolution, its index and its members
- `src/tui.rs` - board state, the change digest, and the ratatui draw
- `src/clipboard.rs` - the OSC 52 write and the base64 it carries, the board's only way out to the clipboard
- `src/install.rs` - the embedded agent assets and the compare-and-refuse install
- `assets/SKILL.md` - the agent skill for the CLI itself, embedded with `include_str!`
- `assets/REVIEW.md` - the agent skill for reviewing a finished ticket, shipped the same way. Assets are named after the role they teach; `SKILL.md` keeps its name because the role it teaches is the CLI
@@ -63,6 +64,15 @@ and this file is for what someone changing worklane's own code needs.
- **A paragraph break in a description is an empty `--description` value.** `cmd_add` joins the values with a single newline, so `-d "First." -d "" -d "Second."` writes the blank line. `trim_blank_ends()` drops blank values at either end, so a break never lands against a section heading, and an all-blank description reads as no description. Interior runs are kept verbatim rather than collapsed
- `--acceptance` and `--plan` are lists, one criterium or step per value, so a blank there is spacing rather than content and the opencode wrapper drops it. Only `--description` preserves blanks
### Filtering the Listing
- **The filters are one call, `filtered`,** because `ls` collects a column in three places (a named status, the counts, and the grouped listing) and three call sites are three chances to apply a different set. Every filter is an `Option` and none asked for keeps everything, which is what makes them compose in any combination without a rule per pair
- **`--tag` matches whole values, not the field.** `parse_tags` has already split the comma-separated field, so the filter compares against those trimmed values: `--tag bug` is not answered by a ticket tagged `bugfix`, and `--tag "cli, filter"` matches nothing, because the field as written is not itself a tag. A ticket with no tags matches none
- **Case sensitive**, the opinion the field already takes: `tag_color` draws `Bug` and `bug` in two colours because they are two tags. A filter that folded them would list tickets carrying a tag nobody asked for, and would hide exactly the split a grooming sweep is looking for
- **One tag per invocation.** Several would have to decide between and and or, and neither reading is obviously right for a board this size. That decision is its own ticket, along with a substring or regex match and a tag filter on the tui
- **A tag nothing carries lists nothing rather than being refused**, which is the opposite of `--campaign`. A campaign is an object that either exists or does not, so it is resolved before anything is read and an unknown one is an error. A tag is free text with no registry: there is nothing to resolve against, and refusing an unknown one would mean maintaining a vocabulary the format deliberately does not have. `assets/PLAN.md` tells the agent to check the spelling when a listing comes back empty, since that is the failure this trades for
- An emptied status keeps the message `ls` already gives, `No tickets in '<status>' status.`, rather than one per filter naming what excluded them. That is pre-existing behaviour for `--priority` and `--campaign`, and one message for every filter is the consistent half of it. If it should name the filter, that is a change to what the CLI prints for three flags at once and belongs in its own ticket
- **`cmd_ls` is now at the boundary the Rust Style rule names:** four filters and the directory. Two of them are adjacent `&Option<String>` parameters, which a caller can swap silently, so the next filter added here takes an `LsArgs` struct the way `add` took `AddArgs`, rather than a fifth positional
### Editing a Ticket
- `set` replaces a field, `append` adds to a section. The verb carries the meaning, so no flag needs a replace-or-append prefix, and `append` only offers the sections that hold multiple lines
- **One field, one writer.** `set` has no `--owner` (that is `chown`'s) and no `--status` (that is `mv`'s). Do not add either
@@ -80,11 +90,16 @@ and this file is for what someone changing worklane's own code needs.
### Checking Off a Criterion
- `check` and `uncheck` are separate commands, not one verb with a flag. They share `CheckArgs` and `cmd_check(args, checked)`
- `criteria()` is scoped to the Acceptance Criteria section and counts only checkbox lines, so a checkbox written into a description is not a criterion and a handwritten line inside the section takes no number
- `set_criterion()` splices only the character between the brackets. Rebuilding the line would normalise its indentation and whatever spacing followed the checkbox
- The criterion argument is an index first, a substring second, so a criterion whose text is literally `2` is reachable only by substring
- `set_criteria()` splices only the character between the brackets, and takes every line in one pass. Rebuilding the line would normalise its indentation and whatever spacing followed the checkbox
- Each criterion term is the keyword `all` first, an index second, a substring third. So a criterion whose text is literally `2` is reachable only by substring, and one whose text merely contains "all" only by its number or a longer substring. `is_all_criteria()` and `is_index()` sit beside each other in `util.rs` for that reason
- **The keyword wins over the text on purpose.** Ticking every box is the reason the word is typed, and a board where `all` sometimes means one criterion and sometimes means the lot would be worse than one that can be addressed another way. `all_is_the_keyword_and_not_a_substring_of_the_text` pins it against its own fixture, so the shared one keeps its three criteria and its numbering
- **A number out of range is a bad index, not a failed substring search**, and says so. `is_index()` makes that distinction
- Any listing of a subset must keep the real numbers, via `numbered_criteria()`. Renumbering the matches from one contradicts the advice to use the number and points at the wrong criterion
- With the criterion omitted: prompt when stdin is a terminal, otherwise return the numbered list as an error. Never prompt unconditionally, the opencode wrapper has no tty and would block on a stdin that never closes. This is the same choice `resolve_ticket` makes for an ambiguous match, and for the same reason
- **The criterion positional is variadic**, so `check <ticket> 1 3 "the footer"` is one call and one write. Variadic rather than a repeated flag: the terms address criteria that are already there, the way the ticket positional does, instead of carrying content the way `--acceptance` does. The prompt path is unchanged and fires on an empty list
- **`resolve_criteria()` resolves every term before a byte is written, and one bad term refuses the whole batch.** A call that ticked the terms it understood and then failed would leave the ticket half-marked with nothing in the file to say which half was meant. It names the offending term alone rather than every failure at once, since each message carries the criteria listing and a batch of them would repeat the list per bad term
- The chosen offsets are sorted and deduped, so the report reads in `show`'s order whatever order the terms arrived in, and a criterion named twice, or by both `all` and its own number, is marked and reported once
- **Every named criterion gets a line, in `show`'s order, printed after the write.** A criterion already in the target state reads `Already checked 2: text` and does not count towards the write, so a batch where every box is already ticked writes nothing, which is the whole-file no-op rule the editing commands keep. The number is on the unchanged line too: without it a batch cannot be read back against `show`
- `show` numbers the criteria as `1. [x] text`, so the index is visible where the ticket is read. The number replaces the list marker rather than joining it
### Relating Tickets
@@ -98,7 +113,7 @@ and this file is for what someone changing worklane's own code needs.
- `ensure_section` inserts against `SECTION_ORDER`, before the first following section that is actually in the file, and adds no blank line that was not already there. A handwritten `## Notes` between the plan and the metadata therefore keeps its place, and Metadata is in that list as an anchor rather than as something anything appends to
- **The blocker check runs on every move**, after the already-in-that-status return and behind `force`. An open blocker is a reason not to start and a reason not to finish, and one rule is easier to hold than a table of which transitions care. A move to the status the ticket is already in is not a move, so it is not refused. `-f` now bypasses three rules, which is the right home for it: each one is a deliberate override of something the board would otherwise keep true
- **A blocker that is not on the board warns and allows the move.** Refusing would wedge the ticket with no way out but `-f`, and a uuid nothing carries is a bookkeeping fault rather than a dependency. The refusal names **every** open blocker, since clearing the one that happened to be printed would leave the ticket blocked
- Left out on purpose: removing a relation, which 4179958 assigns to 74904dc, and a blocked marker on the TUI card, which is its own ticket. Nothing on a card is worth a scan of the board per tick until the card is designed for it
- Left out on purpose: removing a relation, which 4179958 assigns to 74904dc. The blocked marker on the card landed in b8ce18c, and it cost no scan of the board: the blockers ride along on the read that already builds the cards. See The Board View
### Campaigns
@@ -113,7 +128,7 @@ and this file is for what someone changing worklane's own code needs.
- **`Resolved` carries what `content_trim` cannot render from the file.** The relations block and the campaign cell both come from elsewhere on the board. A struct rather than two more parameters, so the next such field is one entry here instead of an edit at every call site
- `campaign show` lists **done** members, unlike `ls`, which leaves the done column out of its listing. What is finished against what is left is the whole question a campaign asks, so hiding half the answer is not an option. `ls --campaign` is the other way round: it is the ordinary board filtered, and keeps every rule `ls` already has
- `campaign ls` scans the status directories **once per campaign** to count members. That is a scan per row rather than one walk reused, and it is deliberate: the map-from-uuid version is worth writing when a board has enough campaigns to notice
- **The TUI gets neither a campaign tab nor a card marker**, for now. The detail view resolves the field because it renders the body, and that is all. A marker on a card would want a campaigns read per reload and the four corners are already spent; same reasoning as the blocked marker, which is also its own ticket
- **The TUI gets neither a campaign tab nor a card marker**, for now. The detail view resolves the field because it renders the body, and that is all. A marker on a card would want a campaigns read per reload, which is more than the blocked mark cost: that one reads the ticket's own Relations section on the pass that already builds the card, and a campaign title is in another directory
- `campaign_body()` builds the file from `DESCRIPTION` and `METADATA_HEADING` rather than its own string literals, so the two file formats cannot drift apart on the spelling of a heading. A campaign has no acceptance criteria (its definition of done is derived), no implementation plan and no Status
- The campaigns directory is created by `init` and **on demand** by `campaign add`, since every board made before campaigns existed has none and a `worklane init` over a live board to get one would be a strange thing to have to do
@@ -130,11 +145,20 @@ and this file is for what someone changing worklane's own code needs.
- The scroll offset is clamped against the *wrapped* line count, from `Paragraph::line_count`, which is why `ratatui` carries the `unstable-rendered-line-info` feature. The paragraph wraps on words, so a clamp on the raw lines would stop short of the end or scroll past it into blank space. Counting the wrapping by hand would only agree with the widget until one of the two changed
- The clamp runs on the keypress and again in the draw. The terminal can be resized between the two, and a tick can shorten the ticket under a reader who is already at the end
- The offset resets when the selection moves and when the modal is closed, so a ticket opens at its top. It deliberately does *not* reset on a tick: an edit elsewhere in the tree must not throw the reader back to the top of what they are reading
- **The overlay carries a page indicator on the bottom right of its border**, `pg 2/8`, so a long ticket does not open looking exactly like a short one. `Block::title_bottom` with a right-aligned `Line`, which spends no text row, the trade the title already makes on the top border. The two cannot crowd each other: they are on opposite borders
- **`wrapped_height` is the one measurement.** `last_offset` is it less the viewport and `page_indicator` takes the same two numbers, so the clamp and the indicator cannot disagree. A second `line_count` call, or a count of the raw lines, is a number free to drift, and an indicator that says there is more to read where the scroll refuses to move is worse than none
- **The furthest offset is the last page by definition, not by division.** The clamp stops at the wrapped height less the viewport, which is not a page boundary, so the final screenful is partial: `offset / step + 1` reads `pg 2/3` at the bottom of a 25 row ticket in a 10 row viewport and claims there is more below
- **The pages are counted in `scroll_step`, a screenful less the overlap line, not in whole screenfuls.** The step is what the keys take, so counting in it names only pages `pgdn` can land on. Counting by screenfuls puts a 30 row ticket in a 10 row viewport at `pg 3/3` two rows short of its end, since three presses are what it takes to get there
- The indicator is dropped whole on an overlay too narrow for it, the rule a corner and the tags row already follow, and absent entirely when nothing scrolls, the way an untagged card spends no row on tags
- `page_indicator` takes four numbers and returns an `Option<String>`, so every case above is pinned without a terminal. The drawn tests exist for the two things arithmetic cannot answer: which border it landed on and what colour it reached the screen in
- **Columns scroll to keep the selected card in view.** `Board::offsets` holds one offset per column, parallel to `columns` and resized in step by `reload`, so a column you leave stays where it was. The keypress aligns the focused column via `follow_selection(screen)`, taking the screen size for the same reason `scroll_detail` does: the visible height belongs to the terminal, which only the caller measures between draws
- Card heights are measured on `card_lines`, never assumed, on both the keypress and the draw side (`card_height`, and the `starts` vec as the cards are built). An alignment that trusted a fixed card height would drift from the renderer the first time the card changed shape
- The draw aligns the focused column again on its own geometry, so a resize between keypress and frame cannot hide the selection, and caps every column against blank space past its last card. The stored value may go stale after a tick shrinks the column; that is fine, because what is drawn is corrected immediately and the next navigation writes the correction back
- Entering another column follows the selection 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 — the opposite of the detail view's reset-on-selection-move, where each ticket genuinely starts at its own top. The index is shared and clamps permanently when a shorter column pulls it down, so a column you return to follows the selection to where it now sits rather than holding your old place
- **The footer names only keys that work.** It read `↑↓ scroll` when nothing scrolled at all, which sends the reader looking for their own mistake. A UI that misdescribes itself is worse than one that is merely incomplete
- **`q` and `esc` are one key: close what is open, quit when there is nothing left to close.** `q` used to set `should_quit` outright, so a reader who pressed it to put a ticket away lost the board instead, which is not what `q` does anywhere else that lays a document over a list. One match arm in `main.rs`, not two: two arms carrying one rule is how a later edit changes it for one key and not the other
- **The rule is `Board::dismiss`, not the match arm.** The dispatch in `main.rs` is not reachable from a test, so anything decided there is undecidable by the suite. The arm is the line that names the keys and nothing else. `the_dispatch_gives_q_and_esc_one_arm_and_leaves_ctrl_c_quitting` scans `main.rs` for what the arm cannot say for itself, over whitespace-collapsed source so rustfmt cannot fail it
- **The footer's last slot always answers how to get out**, and with a ticket open the honest answer is `ctrl-c`, the only key left that quits in one press. Going on saying `q quit` there would be 1b78a24 in the other direction: a footer describing a key by what it used to do
- **The overlay names its ticket on the border, not at the head of the paragraph.** `Board::detail` is a `Detail` carrying the title, the id and the text, because the name has to travel beside the body rather than inside it: `content_trim` drops the `# ` heading on purpose, since `cmd_show` prints it, and anything in the paragraph scrolls away
- `detail_title` cuts the string itself instead of leaving it to ratatui, which truncates an overlong block title at whatever cell it reaches and would take the id with it. Cut against the inner width, so the id survives whole and the name ends in an ellipsis. The id goes first because that is how every other view addresses a ticket
- The detail view renders with colour off. ratatui draws styled spans, so an escape sequence in a paragraph would be printed as literal bytes. `content_trim` and `format_comments_with` take the colour decision for that reason
@@ -146,6 +170,12 @@ and this file is for what someone changing worklane's own code needs.
- The criteria count is a field on `TicketItem`, filled in `collect_ticket_items` where the file is already being read, and counted through `criteria()` so a checkbox in a description is not counted here or numbered by `show`. Do not count per card: that re-reads every ticket body on every draw instead of on the tick that changed something. `None` rather than `[0/0]` for a ticket with no criteria
- **The tags go under the title, dimmed, each prefixed with `#`.** The field was invisible on the board: nothing said a ticket was tagged `bug` without opening it. The marker is what stops the row reading as a third line of the title, since a tag is an ordinary word and the title sits directly above it. The row is dropped whole when the column will not hold it, the rule a corner follows, and an untagged ticket spends no row at all, the way a short title spends no second one
- `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
- **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
@@ -154,6 +184,55 @@ and this file is for what someone changing worklane's own code needs.
- 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
### The Search Prompt
- **`search: Option<Search>` is the whole mode**, the shape `detail` uses: "the prompt is open" and "what is in it" cannot disagree, and closing it leaves nothing to reset. `Search` also carries `missed`, set when enter found nothing and cleared by the next edit, since the message is about the query that missed
- **The prompt swallows every key it is given.** `Board::search_key` runs ahead of the action arms in `main.rs` and reports what it took, rather than every arm below asking whether a search is open. Typing `d` into a query must not toggle done and `q` must not quit; with no prompt open it takes nothing, so the dispatch is unchanged for every other state. The rule is on `Board` for the reason `dismiss` is: the arm is not reachable from a test
- **`ctrl-c` is the one key it declines**, because a terminal application always honours it and a prompt that ate it would leave no way off the board. Every *other* control combination is swallowed and does nothing: it must not type its letter, and it must not fall through either, since the action arms match on the code alone and `ctrl-d` would reach the one bound to `d`
- **Esc is consumed by the search before it can mean anything else**, which is the collision e7612de left behind: `esc` and `q` close the overlay, and both have to lose to an open prompt. It falls out of the pre-branch rather than being ordered by hand
- **`first_match` searches the *visible columns*, every card in them, not the rows on screen.** A query that answered differently on a tall terminal and a short one is not a search, and the jump scrolls the match into view anyway. Hidden columns stay out: with done hidden, a match there would put the highlight on a ticket that is not on the board. Reading order is column by column, then top to bottom
- Id and title only, per 3b16540, both lowercased. The title has to be case insensitive to be worth typing, and giving the id the same treatment lets a pasted id match whatever case it was copied in. An empty or all-space query matches **nothing** rather than everything
- **The jump goes through `select_at`, the tail `select_card` already used.** `follow_selection` scrolls the column the card is in, and the offsets are per column and on the `Tab`, so a jump across columns moves the right one; `refresh_detail` keeps an open overlay on the ticket the selection names. A second version of either is how a jump comes to scroll differently from the arrow keys
- **A hit closes the prompt and a miss keeps it open**, marked, with the selection untouched. The query can then be corrected in place instead of retyped from `/`. Doing nothing visible is what makes a reader retype a query that was already right
- **The prompt takes the whole footer row**, because the key list it replaces describes nothing that currently works while every key is going into the buffer. The typed query is drawn in the default foreground and the keys in grey: one is content, the other is chrome. `no match` is brightred beside the query it is about, since grey chrome is what a reader skips
- **The real terminal cursor goes after the query**, not a glyph standing in for one. ratatui shows the cursor only for a frame that asked for it, so `set_cursor_position` is also what says "you are typing" while the query is still empty. Clamped to the row, so a query longer than the terminal leaves it on the last cell
- Both closed footers name `/`, since the jump works with a ticket open as well: it moves the selection and the overlay follows
- Out of scope on purpose, each its own ticket once the input mode exists: `n` and `N` for the next and previous match, searching the description, tags or owner, regex, and filtering the board down to matches rather than selecting one
### The Copy Key
- **`y` copies the selected card's short id, over OSC 52 written by hand.** The board is where a ticket is found and the CLI is where it is acted on, and the only thing joining them was seven characters retyped off the screen. `y` reads as yank to the readers a keyboard board is for, and was the letter left: `q`, `esc`, `enter`, `space`, `hjkl`, the arrows, `pgup`, `pgdn`, `tab`, `backtab`, `d` and `/` were taken
- **The mechanism was chosen against ssh**, which is where a board is often read. An escape sequence is the only one of the three ways that crosses the connection, since it is the terminal at the reader's end that owns the clipboard. A crate (`arboard` and its kind) wants X11 and Wayland libraries at build time, and on X11 the selection belongs to the process that set it: copy an id, quit, and the paste buffer is empty, which is precisely this flow. Shelling out to `wl-copy`, `xclip` or `pbcopy` is platform sniffing plus a process spawn, and does nothing on a machine where none of them is installed or on the far end of a connection. crossterm 0.28 is what ratatui 0.29 pins and it ships no clipboard command, and the backend types have to match whatever ratatui pins, so a newer crossterm cannot be picked up on its own
- **The cost is paid knowingly: a terminal that ignores OSC 52 ignores it silently**, and tmux needs `set-clipboard on`. What `clipboard::copy` reports is whether the sequence was written, not whether it was honoured, and the footer message says no more than that. There is no reply to read: the query form of OSC 52 is refused by most emulators as a security matter, so nothing better is available to us
- Base64 is twenty lines here rather than a dependency, because the only thing that goes through it is a seven-character id. Pinned on the RFC 4648 vectors, which cover both padding forms, since a wrong encoder would put plausible-looking rubbish on the clipboard
- **`c` and not `p`**: the clipboard proper, not the X11 primary selection, since this is pasted into a command line. Terminated with BEL, which is what tmux documents and what every emulator that implements this at all accepts
- **What is copied is `ticket.id`, the seven characters the card prints**, not the full uuid: they are what stops the retyping and what `show`, `mv` and `comment` all resolve. Decided by `Board::copy_text` rather than inside the arm that copies, so the string is a question the suite can ask without a clipboard. `None` on an empty column, since an empty string would take away whatever the reader had there and give nothing back
- The project is left off even on the merge tab, where the id alone is not an address. This goes onto a clipboard to be pasted into a command line, and a second word in it would have to be deleted every time; running the command in the wrong project fails to resolve rather than acting on the wrong ticket
- **The clipboard is handed to `Board::copy_selected_id` as an argument**, `clipboard::copy` from the dispatch and a closure from a test. That is what makes both answers drivable, and it keeps the terminal write out of the board state
- **A failure is said in the footer, not returned.** There is nobody above it to handle one: the board goes on being drawn, and an error swallowed there would look exactly like a copy that worked until the paste came out wrong
- **`Notice` is the board's one channel for saying something in words**, since a copy leaves nothing on screen to look at. `failed` means "nothing reached the clipboard" rather than "an error occurred", so an empty column and a refused write are one answer to the reader, both in brightred for the reason `no match` is
- **It takes the whole footer row**, on a weaker reason than the prompt's: every key still works while a notice is up. It is that a message squeezed in beside the key list would move every key in it, and the row is the only part of the board that is not a ticket. Drawn after the prompt, which is an input and cannot be covered
- **The notice is cleared by the next keypress, not by a timer.** No clock on the board and no wakeup in the loop, and the moment the reader does anything else the message has been read or was never going to be. Doing nothing leaves it up, which is the one state where it is still worth reading. `Board::clear_notice` runs ahead of `search_key` as well as the arms, since a key typed into a query is still a key, and it must never move into `tick`: the board redraws four times a second and a notice cleared there would never be read
### The Relations Block
- **One builder, two painters.** `relation_rows` decides which edges there are, what they are called and which direction comes first; `relation_cells` decides the layout, the mark and the colours; `paint_cells` turns cells into escapes for the CLI and `span_of` turns the same cells into ratatui spans for the board. Two builders producing one block in two shapes is a pair free to disagree about ordering or padding, which is what this shape exists to prevent
- **`Cell` is the unit both renderers take**: a run of text and the colour it is drawn in, `None` for the default foreground. The same trick as the palette itself, where `Color::ansi()` and `From<Color> for ratatui::style::Color` keep one colour from existing for one renderer and not the other
- **`reference_cells` is the one spelling of a cross reference**, and `reference_cell` is it painted. The relations block and the Campaign field both go through it, so a dangling reference reads the same way wherever it is shown
- **A row carries two marks, kind then status**: what sort of edge this is, then how far the ticket at the other end has got. `blocked by × ◐ (6ce2c47) Title`. Two questions are asked of this block and one glyph could not answer both: which rows hold this ticket up, and whether the ones that do are finished
- The status went through one bad shape first. It was a rising bar, `▁▄▆█`, as the only mark, which read as an undifferentiated column of blocks and left the kind to five long words that blur when a ticket carries several. Then the kind took the column alone and the status was lost. Both, in that order, is the answer
- **Both directions of a kind carry one mark.** `blocked by` and `blocks` are the same edge read from two ends, and the label is what says which end you are on. `both_directions_of_a_kind_carry_one_mark` pins it
- **`×` is `BLOCKED_MARK`, the same constant a held-up card draws**, in the same brightred. On a card it says this ticket is held up and in the block it says this edge is what holds one, which is one word, so one glyph and one definition. It lives in `util.rs` for that reason, not in `tui.rs` where the card is
- **The kind marks stay out of the priority vocabulary**, which owns `●◐○·`, and `no_relation_mark_is_a_priority_glyph` pins that against every level. They are the arrows the footer already draws, so they render wherever it does
- **The status marks are those very circles, and what keeps them from reading as a level is width**: the meter is always two cells and a status mark is one. `the_status_mark_is_one_cell_where_the_meter_is_two` pins both halves. A card carries the meter and never a status mark, and the block carries the status mark and never a meter, so the two never sit in one column
- **Both marks go ahead of the id**, where they describe the target rather than the row. Every row carries both, so nothing is pushed out of line the way the card's blocked mark would have been, which is why that one sits after the id and these before it
- **The kind mark survives a target the board cannot find and the status mark cannot**, since a kind is read from the ticket's own file and a status from the board. `?` holds the column so the id does not move, and `_missing_` in grey is what says the target is gone
- **Committed and reviewing are told apart by colour alone**, both being `◐`, so a pipe cannot tell them apart: `should_use_colors` is false and both read as under way. Accepted, because `●` and `○` are the two answers usually wanted and `show` on the target settles the rest, and `assets/SKILL.md` says so outright rather than leaving an agent to infer it. Do not fix this by giving one of them a colour that means something else
- `RelationTarget` carries the title and the status in one `Option`, because they come from the same lookup and are absent together. It was taken out when the mark keyed on the kind alone and put back one commit later, which is the cost of a field nothing reads: correct at the time, and churn either way
- **`show` and the board carry the same mark**, decided rather than left to be discovered: the rows are one builder, so giving the CLI the mark cost nothing, and two views disagreeing about what a relation shows would be the kind of difference nobody can explain later. That makes it a change to what the CLI prints, so it is a minor
- **`Resolved.relations` is rows, not a rendered block.** That is what lets the board style them: an escape sequence in a ratatui paragraph is drawn as literal bytes (6d327df), so the block cannot arrive pre-painted. `content_parts` hands the text through already painted and the rows through untouched, which is the asymmetry the two renderers need
- **`BodyPart` splits the body rather than building it twice.** Everything outside the relations block is rendered once, by `content_parts`; `content_trim` is that with the rows painted, and the board is that with the rows styled. `Body` is the accumulator, so a caller pushes text and rows without tracking which it pushed last
- **`Detail.body` is a `Text`, and it is the only thing measured.** `last_offset` and the `Paragraph` both take it, so the clamp cannot wrap the body differently from the draw. `Detail::plain()` flattens it for the suite and is `#[cfg(test)]`: a second representation carried alongside the spans is a second thing to disagree
- `detail_body` closes a line only where the text says, so a part that does not end on a newline runs on into the next one. The seam between text and rows is wherever the body put it rather than wherever a part happened to end
- **The relations block is the only coloured part of the overlay body, and that is a decision, not an oversight.** The headings, the plan numbers, the criteria marks, the bold runs and the grey unset values are all painted by `show` and all flat on the board. The block earned its colour because it is where a reader compares several references at once, and because it was already data rather than prose: it arrives as rows for the status mark, so styling it cost nothing extra. Colouring the rest means giving every painted run in `content_parts` the `Cell` treatment, which is a much larger change with no reader's question behind it, and it is its own ticket. Do not paint one more section here without taking that on: two coloured sections and five plain ones reads as a bug, where one clearly does not
### Monitoring Several Boards
- `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
@@ -205,6 +284,9 @@ and this file is for what someone changing worklane's own code needs.
- Title → green (32)
- 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
- 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
- **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
- `tag_color()` is a pure function of the tag string, so the same tag is the same colour on every card, in every view and on every board, with nothing stored. Case sensitive, because `Bug` and `bug` are two different tags to the field and to every search
- **The hash is FNV-1a written out here, not `DefaultHasher`.** std does not promise its output is stable across releases, and a board that repaints itself on a toolchain upgrade has lost the only property the mapping is for. `the_tag_mapping_is_pinned` fails on any change to it, so a repaint is a decision rather than a surprise
@@ -240,6 +322,7 @@ and this file is for what someone changing worklane's own code needs.
- Always ask the user to confirm the bump and its kind before making it — never bump silently, and never skip the question because the answer looks obvious
- Pre-1.0, so: patch for fixes and internal changes, minor for a new command, flag or changed output, major only for a deliberate 1.0
- **Changed output means the CLI's output.** That is the surface scripts and agents read, so a changed listing, message or exit code is a minor. A change to what the board draws is a patch however visible it is, since nothing consumes the frame. See The Board View
- **Settling output that shipped one version ago is a patch**, not a second minor. 0.15.1 changed the relation mark 0.15.0 had just introduced, and 0.15.2 added the status mark beside it: the minor was the arrival of a marked relations block, and settling what it marks belongs to that. Three minors in an hour would tell anyone reading the tags that there were three features
- No bump for docs-only, tests-only or `--fixup` commits
- When one body of work spans several commits, bump once on the final commit rather than on each
- Bump `Cargo.toml` and the `worklane` entry in `Cargo.lock` together, in the commit that carries the bump
Generated
+1 -1
View File
@@ -1494,7 +1494,7 @@ dependencies = [
[[package]]
name = "worklane"
version = "0.13.3"
version = "0.16.1"
dependencies = [
"anyhow",
"assert_cmd",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "worklane"
version = "0.13.3"
version = "0.16.1"
edition = "2024"
[dependencies]
+4 -4
View File
@@ -5,18 +5,18 @@ 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, `q` to quit. 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` 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, whose border carries a page indicator 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, `q` to quit. 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 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>` |
| `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` |
| `worklane show <id>` | Shows ticket by UUID prefix (4+ chars), title substring, or filename substring |
| `worklane mv <id> --status <target> [-f]` | Moves ticket between statuses. Default: forward only, one stage at a time. `-f` bypasses both restrictions |
| `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 |
| `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` |
| `worklane chown <user> <ticket>` | Sets the Owner field, the only command that writes it. Free text, checked against nothing. User first and ticket second, after Unix `chown` |
| `worklane check <ticket> [criterion]` | Ticks one acceptance criterion, by number as shown by `show` or by a substring. Prompts with the numbered list if omitted, or errors with it when there is no terminal |
| `worklane uncheck <ticket> [criterion]` | Unticks one acceptance criterion, addressed the same way |
| `worklane check <ticket> [criteria...]` | Ticks acceptance criteria, each by number as shown by `show` or by a substring. Several in one call, or `all` for every one of them. Prompts with the numbered list if none is given, or errors with it when there is no terminal |
| `worklane uncheck <ticket> [criteria...]` | Unticks acceptance criteria, addressed the same way |
| `worklane comment <ticket> <body>` | Adds a comment to a ticket by UUID or title |
| `worklane install-skill [skill]` | Writes the embedded agent skills to `~/.claude/skills/<skill>/SKILL.md`, which Claude Code and opencode both read. Three ship: `worklane` teaches the CLI, `worklane-review` reviews a finished ticket against the code that claims to close it, `worklane-plan` grooms the board as a whole, its priorities, due dates, tags and campaigns. Every document unless one is named. Leaves a modified copy alone unless `--force`; `--print` writes one to stdout instead and needs the name |
+7 -4
View File
@@ -56,14 +56,17 @@ The last two rows are in the table to be recognised, not used. See the closing s
worklane ls # every status, counts then tickets
worklane ls backlog # one status
worklane ls --priority 1 # the top of the pile
worklane ls --tag bug # one tag's worth of the board
worklane show 1b78a24 # one ticket, with its relations and comments
worklane campaign ls # the goals that already exist
```
`ls` prints the mark, the id, the title, the owner and the due date. It does **not**
print tags, and there is no tag filter yet, so any judgement about tags means reading the
tickets themselves. On a board of a few dozen that is a `show` per ticket and is worth
doing rather than guessing from titles.
print tags, so the vocabulary itself still has to be read off the tickets: `--tag` answers
"what is tagged `bug`" and cannot answer "what tags exist", which is the question a
grooming sweep starts from. Count the vocabulary with a `show` per ticket, then use
`--tag` to check each candidate, and remember that `--tag` matches whole values case
sensitively: `bug` and `Bug` are two answers, which is exactly the split worth reporting.
Read `done` too when the question is about what to do next. What was finished last is the
best evidence of what this board actually moves at, and a plan that ignores it is a wish.
@@ -137,7 +140,7 @@ what is actually used, and show the count before proposing anything. What to rep
that will disagree with it. This board already made that mistake once with priority and
undid it deliberately.
- **An untagged ticket** in a board where everything else is tagged. It is invisible to
every question asked by tag.
every question asked by tag, `worklane ls --tag` included.
Tags are for kind, not for state and not for goal. State is the status directory and the
fields; a goal is a campaign.
+4 -2
View File
@@ -117,12 +117,14 @@ quote `--force` literally. A body of exactly `--` needs its own separator.
## 5. Write the verdict back to the ticket
```
worklane uncheck 1b78a24 2
worklane uncheck 1b78a24 2 5
worklane append 1b78a24 --acceptance "The footer lists only the keys that are bound"
```
Untick every criterion you found unmet, one call each, by the number `show` printed. Do
Untick every criterion you found unmet, by the numbers `show` printed, in one call. Do
it after the comment so there is a written reason on the board before the mark changes.
Do not reach for `all`: a review unticks what it found unmet, and unticking the lot would
erase the implementer's claim on the criteria you agreed with.
**Never tick a criterion.** A tick is the implementer's claim that something is done, and
unticking is the review disagreeing with that claim. A reviewer that also ticks makes
+36 -2
View File
@@ -41,26 +41,47 @@ A move is also refused while the ticket is blocked by one that is not done yet,
worklane ls # every status, counts then tickets
worklane ls backlog # one status
worklane ls --priority 1 # only the most urgent
worklane ls --tag bug # only the tickets carrying that tag
worklane show 1b78a24 # one ticket, body and comments
```
`ls` prints a seven-character id per ticket. That is what you address it by.
The filters compose in any combination, with each other and with the status positional:
`worklane ls backlog --tag bug --priority 1`. `--tag` takes one tag and matches it
against the whole values of the comma-separated `Tags` field, case sensitively, so
`--tag bug` finds neither a ticket tagged `bugfix` nor one tagged `Bug`. A ticket with no
tags matches none. A tag nothing carries lists nothing rather than failing, so when a
listing comes back empty check the spelling against a ticket you know is tagged.
## Working a ticket
```
worklane mv 1b78a24 --status committed
worklane check 1b78a24 3 # tick acceptance criterion 3
worklane check 1b78a24 "the footer describes" # or a substring of it
worklane check 1b78a24 1 3 "the footer" # several in one call
worklane check 1b78a24 all # every criterion on the ticket
worklane uncheck 1b78a24 3
worklane comment 1b78a24 "Found the cause: the offset was never passed to the widget."
worklane mv 1b78a24 --status reviewing
```
Criteria are numbered by `show`. With the criterion omitted, `check` prompts when there
is a terminal and otherwise fails with the numbered list, so **always pass the criterion
Criteria are numbered by `show`. With no criterion given, `check` prompts when there
is a terminal and otherwise fails with the numbered list, so **always pass the criteria
when you are not sitting at a prompt**.
One call takes as many terms as you like, mixing numbers and substrings, and `all` stands
for every criterion on the ticket. Use it when the work is done: it is one write instead
of one per box. `all` is a keyword, checked before the text, so a criterion whose own
words include "all" is reached by its number or by a longer substring.
**Every term is resolved before anything is written.** One term that matches nothing, or
matches more than one criterion, refuses the whole call and names that term, so the ticket
is never left half-marked. A criterion already in the state you asked for is reported
unchanged rather than refused, and a call that would change nothing writes nothing. Both
apply to `uncheck` exactly as they do to `check`.
## Filing a ticket
```
@@ -133,6 +154,19 @@ Recording a relation the ticket already holds reports no change. A ticket cannot
to itself, and a target that later disappears shows as `_missing_` rather than silently
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
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.
## Campaigns
A campaign groups the tickets that have to be finished together: a release, a migration,
+1 -1
View File
@@ -179,7 +179,7 @@ pub fn campaign_cell(content: &str, index: &CampaignIndex, colored: bool) -> Str
/// rather than at each call site.
pub fn resolved_for(content: &str, worklane_dir: &Path, colored: bool) -> Result<Resolved> {
Ok(Resolved {
relations: relations_block(content, worklane_dir, colored)?,
relations: relations_for(content, worklane_dir)?,
campaign: campaign_cell(content, &CampaignIndex::load(worklane_dir)?, colored),
})
}
+90
View File
@@ -0,0 +1,90 @@
//! Putting text on the clipboard of whatever terminal is drawing the board.
//!
//! OSC 52, written by hand, and the reasoning is in AGENTS.md under The Copy Key. The
//! short of it: the board is often being read over ssh, and an escape sequence is the
//! only one of the three ways that crosses the connection. crossterm 0.28 is what
//! ratatui 0.29 pins and it ships no clipboard command, so the sequence and the base64
//! it carries are written here rather than pulled in.
//!
//! The honest limit is that a terminal which ignores OSC 52 ignores it silently: what
//! this reports is whether the sequence was written, not whether it was honoured.
use std::io::Write;
use anyhow::{Context, Result};
/// Ask the terminal to put `text` on the system clipboard.
///
/// `52;c` is the clipboard proper rather than `p`, the X11 primary selection, because
/// this is for pasting into a command line with ctrl-shift-v or cmd-v. Terminated with
/// BEL rather than ST: both are accepted, and BEL is what tmux's `set-clipboard`
/// documents and what every emulator that implements this at all takes.
///
/// Written straight to stdout, which is where ratatui's own frames go, and flushed
/// before returning so a failure belongs to this call rather than to the next draw.
pub fn copy(text: &str) -> Result<()> {
let mut out = std::io::stdout();
write!(out, "\x1b]52;c;{}\x07", base64(text.as_bytes()))
.and_then(|()| out.flush())
.context("could not write to the terminal")
}
/// Standard base64, the alphabet OSC 52 requires, padding included.
///
/// Twenty lines against a dependency: the only thing encoded here is a seven-character
/// id, and the crate would be carried for its own sake.
fn base64(bytes: &[u8]) -> String {
const ALPHABET: &[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
let mut out = String::with_capacity(bytes.len().div_ceil(3) * 4);
for chunk in bytes.chunks(3) {
// The missing bytes of a short chunk read as zero, and the characters they
// would have produced are the ones that become padding below.
let triple = chunk
.iter()
.chain([0u8; 2].iter())
.take(3)
.fold(0u32, |acc, byte| (acc << 8) | u32::from(*byte));
for slot in 0..4 {
match slot <= chunk.len() {
true => out.push(char::from(ALPHABET[(triple >> (18 - 6 * slot) & 0x3f) as usize])),
false => out.push('='),
}
}
}
out
}
#[cfg(test)]
mod tests {
use super::*;
/// The vectors from RFC 4648, which is what a terminal decodes with. Every chunk
/// length is in here, so the padding is covered in both of its forms.
#[test]
fn base64_encodes_the_rfc_vectors() {
assert_eq!(base64(b""), "");
assert_eq!(base64(b"f"), "Zg==");
assert_eq!(base64(b"fo"), "Zm8=");
assert_eq!(base64(b"foo"), "Zm9v");
assert_eq!(base64(b"foob"), "Zm9vYg==");
assert_eq!(base64(b"fooba"), "Zm9vYmE=");
assert_eq!(base64(b"foobar"), "Zm9vYmFy");
}
/// What actually goes on the wire for a short id, which is the whole use.
#[test]
fn base64_encodes_a_short_id() {
assert_eq!(base64(b"0546fc5"), "MDU0NmZjNQ==");
}
/// The high bits reach the end of the alphabet, which an off-by-one in the shift
/// would miss entirely on ascii input.
#[test]
fn base64_reaches_the_whole_alphabet() {
assert_eq!(base64(&[0xff, 0xff, 0xff]), "////");
assert_eq!(base64(&[0xfb, 0xff, 0xfe]), "+//+");
assert_eq!(base64(&[0x00, 0x00, 0x00]), "AAAA");
}
}
+15 -5
View File
@@ -120,6 +120,10 @@ pub enum Command {
#[arg(long, value_parser = priority_level)]
priority: Option<u8>,
/// Only show tickets carrying this tag, matched whole
#[arg(long, value_parser = non_empty)]
tag: Option<String>,
/// Only show the members of this campaign, by UUID or title
#[arg(long, value_parser = non_empty)]
campaign: Option<String>,
@@ -181,10 +185,10 @@ pub enum Command {
paths: Vec<std::path::PathBuf>,
},
/// Tick an acceptance criterion
/// Tick acceptance criteria
Check(CheckArgs),
/// Untick an acceptance criterion
/// Untick acceptance criteria
Uncheck(CheckArgs),
/// Add a comment to a ticket
@@ -448,14 +452,20 @@ impl RelateArgs {
/// because the two read as opposites at the call site and neither needs the other's
/// name to make sense.
///
/// The criterion is optional: without it the criteria are listed and the index asked
/// The criteria are optional: without any the criteria are listed and the index asked
/// for, or, where there is no terminal to ask at, returned as an error carrying the
/// same list.
///
/// Several terms in one call because finishing a ticket means ticking every box, and
/// one invocation per box resolved the ticket and rewrote the file each time. The
/// terms are variadic rather than a repeated flag: they address something that is
/// already there, the way the ticket positional does, instead of carrying content the
/// way `--acceptance` does.
#[derive(clap::Args)]
pub struct CheckArgs {
/// Ticket UUID or title
pub ticket: String,
/// Criterion index as shown by `show`, or a substring of its text. Prompts if omitted
pub criterion: Option<String>,
/// Criterion indexes as shown by `show`, substrings of their text, or `all`. Prompts if omitted
pub criteria: Vec<String>,
}
+135 -57
View File
@@ -40,6 +40,7 @@ pub fn cmd_init(start: &Path) -> Result<()> {
pub fn cmd_ls(
status_filter: &Option<String>,
priority_filter: Option<u8>,
tag_filter: &Option<String>,
campaign_filter: &Option<String>,
worklane_dir: &Path,
) -> Result<()> {
@@ -50,6 +51,7 @@ pub fn cmd_ls(
None => None,
};
let uuid = campaign.as_ref().map(|campaign| campaign.uuid.as_str());
let tag = tag_filter.as_deref();
if let Some(campaign) = &campaign {
println!(
@@ -68,7 +70,7 @@ pub fn cmd_ls(
));
}
let items = filtered(collect_ticket_items(&status_path)?, priority_filter, uuid);
let items = filtered(collect_ticket_items(&status_path)?, priority_filter, uuid, tag);
if items.is_empty() {
println!("No tickets in '{}' status.", status);
@@ -86,7 +88,7 @@ pub fn cmd_ls(
if !status_path.exists() {
continue;
}
let items = filtered(collect_ticket_items(&status_path)?, priority_filter, uuid);
let items = filtered(collect_ticket_items(&status_path)?, priority_filter, uuid, tag);
let count = items.len();
let label = if count == 1 { "ticket" } else { "tickets" };
println!(" [{}] {} {}", status.to_uppercase(), count, label);
@@ -102,7 +104,7 @@ pub fn cmd_ls(
continue;
}
let items = match collect_ticket_items(&status_path) {
Ok(items) => filtered(items, priority_filter, uuid),
Ok(items) => filtered(items, priority_filter, uuid, tag),
Err(_) => continue,
};
if items.is_empty() {
@@ -119,8 +121,38 @@ pub fn cmd_ls(
/// The listing filters in one call, so the three places `ls` collects a column cannot
/// end up applying a different set of them.
fn filtered(items: Vec<TicketItem>, level: Option<u8>, campaign: Option<&str>) -> Vec<TicketItem> {
filter_by_campaign(filter_by_priority(items, level), campaign)
///
/// Every filter is `Option`, and none asked for is everything kept, which is what makes
/// them compose in any combination without a rule per pair.
fn filtered(
items: Vec<TicketItem>,
level: Option<u8>,
campaign: Option<&str>,
tag: Option<&str>,
) -> Vec<TicketItem> {
filter_by_tag(
filter_by_campaign(filter_by_priority(items, level), campaign),
tag,
)
}
/// Keep only the tickets carrying `tag`, or everything when none was asked for.
///
/// Matched against the whole values `parse_tags` split out of the field rather than as a
/// substring of it, so `--tag bug` is not answered by a ticket tagged `bugfix`, and a
/// ticket with no tags matches nothing at all.
///
/// Case sensitive, the opinion the field already takes everywhere else: `tag_color`
/// draws `Bug` and `bug` in two colours because they are two tags, and a filter that
/// folded them would list tickets carrying a tag nobody asked for.
fn filter_by_tag(items: Vec<TicketItem>, tag: Option<&str>) -> Vec<TicketItem> {
match tag {
Some(tag) => items
.into_iter()
.filter(|item| item.tags.iter().any(|carried| carried == tag))
.collect(),
None => items,
}
}
/// Keep only the members of `campaign`, or everything when none was asked for.
@@ -1121,6 +1153,66 @@ fn ask_which_criterion(criteria: &[Criterion], title: &str) -> Result<usize> {
}
}
/// Every criterion the terms name, in the order `show` numbers them and without
/// repeats.
///
/// Resolved before a byte is written, and one bad term refuses the whole batch. A call
/// that ticked the terms it understood and then failed would leave the ticket
/// half-marked, with nothing in the file to say which half the caller meant, and the
/// obvious retry would be reading the ticket back to find out.
///
/// The offending term is named on its own rather than every failure at once: each
/// message carries the criteria listing, so a batch of them would repeat the list per
/// bad term and bury the first one.
fn resolve_criteria(criteria: &[Criterion], terms: &[String], title: &str) -> Result<Vec<usize>> {
let mut chosen: Vec<usize> = Vec::new();
for term in terms {
if is_all_criteria(term) {
chosen.extend(0..criteria.len());
continue;
}
let found = find_criteria(criteria, term);
match found.len() {
1 => chosen.push(found[0]),
0 if is_index(term) => {
return Err(anyhow!(
"'{}' is not one of the {} criteria of '{}':\n{}",
term.trim(),
criteria.len(),
title,
criteria_list(criteria)
));
}
0 => {
return Err(anyhow!(
"No criterion of '{}' matches '{}'. Its criteria are:\n{}",
title,
term,
criteria_list(criteria)
));
}
_ => {
return Err(anyhow!(
"'{}' matches {} criteria of '{}':\n{}\n\nUse the number instead.",
term,
found.len(),
title,
numbered_criteria(criteria, &found)
));
}
}
}
// Sorted so the report reads in the order `show` numbers the criteria whatever
// order the terms arrived in, and deduped so a criterion named twice, or by both
// `all` and its own number, is reported once.
chosen.sort_unstable();
chosen.dedup();
Ok(chosen)
}
pub fn cmd_check(args: &CheckArgs, checked: bool, start: &Path) -> Result<()> {
let worklane_dir = find_worklane_dir(start)?;
let (status, title, content) = resolve_ticket(&args.ticket, &worklane_dir)?;
@@ -1130,64 +1222,50 @@ pub fn cmd_check(args: &CheckArgs, checked: bool, start: &Path) -> Result<()> {
return Err(anyhow!("Ticket '{}' has no acceptance criteria", title));
}
let chosen = match &args.criterion {
None => ask_which_criterion(&criteria, &title)?,
Some(search) => {
let found = find_criteria(&criteria, search);
match found.len() {
1 => found[0],
0 if is_index(search) => {
return Err(anyhow!(
"'{}' is not one of the {} criteria of '{}':\n{}",
search.trim(),
criteria.len(),
title,
criteria_list(&criteria)
));
}
0 => {
return Err(anyhow!(
"No criterion of '{}' matches '{}'. Its criteria are:\n{}",
title,
search,
criteria_list(&criteria)
));
}
_ => {
return Err(anyhow!(
"'{}' matches {} criteria of '{}':\n{}\n\nUse the number instead.",
search,
found.len(),
title,
numbered_criteria(&criteria, &found)
));
}
}
}
let chosen = match args.criteria.as_slice() {
[] => vec![ask_which_criterion(&criteria, &title)?],
terms => resolve_criteria(&criteria, terms, &title)?,
};
let criterion = &criteria[chosen];
let verb = if checked { "checked" } else { "unchecked" };
// Only the criteria that are not already in the target state, so a batch where
// every box is already ticked writes nothing, the way a single one always has.
let changing: Vec<usize> = chosen
.iter()
.copied()
.filter(|offset| criteria[*offset].checked != checked)
.collect();
if criterion.checked == checked {
println!(
"Already {}: {}",
verb,
color_text(&criterion.text, Color::Green)
);
return Ok(());
if !changing.is_empty() {
let lines: Vec<usize> = changing
.iter()
.map(|offset| criteria[*offset].line)
.collect();
let updated = set_criteria(&content, &lines, checked);
let uuid = parse_ticket_field(&content, "ID");
save_ticket(&worklane_dir, &status, &uuid, &title, None, &updated)?;
}
let updated = set_criterion(&content, criterion.line, checked);
let uuid = parse_ticket_field(&content, "ID");
save_ticket(&worklane_dir, &status, &uuid, &title, None, &updated)?;
// Reported after the write, one line per criterion the call named, so nothing
// claims a mark the file does not carry.
let verb = if checked { "checked" } else { "unchecked" };
let past = if checked { "Checked" } else { "Unchecked" };
for offset in chosen {
let criterion = &criteria[offset];
let state = if criterion.checked == checked {
format!("Already {}", verb)
} else {
past.to_string()
};
println!(
"{} {}: {}",
state,
offset + 1,
color_text(&criterion.text, Color::Green)
);
}
println!(
"{} {}: {}",
if checked { "Checked" } else { "Unchecked" },
chosen + 1,
color_text(&criterion.text, Color::Green)
);
Ok(())
}
+36 -8
View File
@@ -2,6 +2,7 @@ use anyhow::Result;
use clap::Parser;
mod campaign;
mod clipboard;
mod command;
mod handlers;
mod install;
@@ -48,10 +49,11 @@ fn main() -> Result<()> {
Some(Command::Ls {
status,
priority,
tag,
campaign,
}) => {
let worklane_dir = find_worklane_dir(&start)?;
cmd_ls(&status, priority, &campaign, &worklane_dir)
cmd_ls(&status, priority, &tag, &campaign, &worklane_dir)
}
Some(Command::Show { id }) => {
let worklane_dir = find_worklane_dir(&start)?;
@@ -163,17 +165,34 @@ fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()>
continue;
}
// Every keypress takes away what the last one said, so a notice never
// outlives the moment it belongs to. Ahead of the prompt as well as the
// arms: a key typed into a query is still a key. The rule is
// `Board::clear_notice`, where a test can reach it, and the arm below that
// sets one runs after this.
board.clear_notice();
// Ahead of the arms, because a prompt has to swallow every key it is
// given: typing `d` into a query must not toggle the done column and `q`
// must not quit. It reports what it took, so the arms below stay a plain
// match on the keys it did not, and it takes nothing when no prompt is open.
// The rule is `Board::search_key`, where a test can reach it.
if board.search_key(key, screen) {
continue;
}
match key.code {
KeyCode::Char('q') => board.should_quit = true,
// One arm, because the two keys mean one thing: close what is open, and
// quit when there is nothing left to close. Two arms carrying one rule
// is how a later edit changes it for one key and not the other, which is
// what `q` quitting out from under an open ticket already was. The rule
// itself is `Board::dismiss`, where a test can reach it.
KeyCode::Esc | KeyCode::Char('q') => board.dismiss(),
// The only key that leaves the board from an open ticket, which is why
// the footer names it there.
KeyCode::Char('c') if key.modifiers.contains(KeyModifiers::CONTROL) => {
board.should_quit = true
}
// Esc closes the detail view, and only quits when there is nothing
// left to dismiss.
KeyCode::Esc => match board.detail {
Some(_) => board.toggle_detail(),
None => board.should_quit = true,
},
KeyCode::Enter | KeyCode::Char(' ') => board.toggle_detail(),
KeyCode::Left | KeyCode::Char('h') => board.select_column(-1, screen),
KeyCode::Right | KeyCode::Char('l') => board.select_column(1, screen),
@@ -191,6 +210,15 @@ fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()>
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),
// 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, so this arm
// is only ever the way in.
KeyCode::Char('/') => board.open_search(),
// `y` as in yank, for the readers this board is for, and the only letter
// left that a vim hand would reach for. The clipboard is handed in rather
// than reached for inside `Board`, so the suite can drive both answers.
KeyCode::Char('y') => board.copy_selected_id(clipboard::copy),
_ => {}
}
}
+1920 -68
View File
File diff suppressed because it is too large Load Diff
+616 -69
View File
@@ -539,8 +539,12 @@ pub fn format_comments_with(
/// an edit at every call site.
#[derive(Default)]
pub struct Resolved {
/// The block [`render_relations`] built, or empty for a ticket with no relations.
pub relations: String,
/// The relations of the ticket, both directions, from [`relations_for`]. Empty for a
/// ticket with none at either end.
///
/// Rows rather than the rendered block: the CLI paints them into escapes and the
/// board styles the same rows itself, since a paragraph is no place for an escape.
pub relations: Vec<RelationRow>,
/// The Campaign value as it reads, from [`reference_cell`]. Empty leaves the stored
/// value to render as it sits, which is what a ticket in no campaign wants.
pub campaign: String,
@@ -555,7 +559,7 @@ pub fn content_trim_colored(content: &str, resolved: &Resolved) -> String {
/// The rule is measured on the name as displayed, in characters. It used to span the
/// raw line, so it ran three past the heading for the `## `, and byte length over-drew
/// anything non-ASCII.
fn push_heading(out: &mut String, heading: &str, colored: bool) {
fn push_heading(out: &mut Body, heading: &str, colored: bool) {
let name = heading.strip_prefix("## ").unwrap_or(heading);
out.push_str(&paint(name, Color::Orange, colored));
@@ -572,10 +576,70 @@ fn push_heading(out: &mut String, heading: &str, colored: bool) {
///
/// [`Resolved`] carries the parts that come from elsewhere on the board, since the
/// body alone cannot render them.
/// One piece of the rendered body: text as it prints, or relations still as rows.
///
/// The body is one string to the CLI and a run of styled lines to the board, and the
/// only part that differs is the relations block. Splitting the body here rather than
/// building it twice is what keeps the two views from drifting: everything outside the
/// block is rendered once, by [`content_parts`], and the rows are handed on unpainted.
pub enum BodyPart {
Text(String),
Relations(Vec<RelationRow>),
}
/// The body under construction. Text accumulates into the trailing run, and a relations
/// block closes it, so a caller pushes text and rows without tracking which it pushed
/// last.
#[derive(Default)]
struct Body {
parts: Vec<BodyPart>,
}
impl Body {
fn push_str(&mut self, text: &str) {
match self.parts.last_mut() {
Some(BodyPart::Text(run)) => run.push_str(text),
_ => self.parts.push(BodyPart::Text(text.to_string())),
}
}
fn push(&mut self, c: char) {
match self.parts.last_mut() {
Some(BodyPart::Text(run)) => run.push(c),
_ => self.parts.push(BodyPart::Text(c.to_string())),
}
}
fn push_relations(&mut self, rows: &[RelationRow]) {
self.parts.push(BodyPart::Relations(rows.to_vec()));
}
/// Whether the text written so far ends with `suffix`. A relations block never does,
/// since it is not text yet.
fn ends_with(&self, suffix: &str) -> bool {
match self.parts.last() {
Some(BodyPart::Text(run)) => run.ends_with(suffix),
_ => false,
}
}
}
pub fn content_trim(content: &str, colored: bool, resolved: &Resolved) -> String {
let relations = resolved.relations.as_str();
content_parts(content, colored, resolved)
.iter()
.map(|part| match part {
BodyPart::Text(text) => text.clone(),
BodyPart::Relations(rows) => render_relations(rows, colored),
})
.collect()
}
/// The body rendered into its parts, with the colour decision already applied to the
/// text and deliberately not to the relations.
pub fn content_parts(content: &str, colored: bool, resolved: &Resolved) -> Vec<BodyPart> {
let relations = resolved.relations.as_slice();
let lines: Vec<&str> = content.trim().lines().collect();
let mut result = String::new();
let mut result = Body::default();
let mut current_section = "";
let mut criterion = 0;
let mut i = 0;
@@ -598,7 +662,7 @@ pub fn content_trim(content: &str, colored: bool, resolved: &Resolved) -> String
// after everything.
if is_metadata_heading(line) && !stores_relations && !relations.is_empty() {
push_heading(&mut result, RELATIONS.heading, colored);
result.push_str(relations);
result.push_relations(relations);
result.push('\n');
shown_relations = true;
}
@@ -622,7 +686,7 @@ pub fn content_trim(content: &str, colored: bool, resolved: &Resolved) -> String
// holds the same edges resolved to a title, and the inverses with them.
if line.trim_end() == RELATIONS.heading && !relations.is_empty() {
let end = section_end(&lines, i);
result.push_str(relations);
result.push_relations(relations);
// The blank line the skipped body ended with, before the next heading.
if end < lines.len() {
result.push('\n');
@@ -705,10 +769,10 @@ pub fn content_trim(content: &str, colored: bool, resolved: &Resolved) -> String
result.push('\n');
}
push_heading(&mut result, RELATIONS.heading, colored);
result.push_str(relations);
result.push_relations(relations);
}
result
result.parts
}
/// Colour the `1.` at the head of a numbered line, leaving the rest alone.
@@ -1640,86 +1704,279 @@ impl RelationIndex {
/// relations block and the Campaign field, so a dangling reference is spelled one way
/// wherever it is shown.
pub fn reference_cell(uuid: &str, name: Option<&str>, colored: bool) -> String {
let id = paint(short_id(uuid), Color::Red, colored);
paint_cells(&reference_cells(uuid, name), colored)
}
/// The same cross reference in cells, for a renderer that is not writing escapes.
///
/// The one spelling of a reference, so the relations block and the Campaign field cannot
/// come to say a dangling one differently, and the board draws the id in the colour the
/// guideline gives it rather than dropping every colour to stay safe.
pub fn reference_cells(uuid: &str, name: Option<&str>) -> Vec<Cell> {
let mut cells = vec![
Cell::plain("("),
Cell::colored(short_id(uuid), Color::Red),
Cell::plain(") "),
];
match name {
Some(name) => format!("({}) {}", id, name),
None => format!("({}) {}", id, paint("_missing_", Color::Grey, colored)),
Some(name) => cells.push(Cell::plain(name)),
None => cells.push(Cell::colored("_missing_", Color::Grey)),
}
cells
}
/// Cells as the CLI prints them: each one painted, or carried through as it stands.
pub fn paint_cells(cells: &[Cell], colored: bool) -> String {
cells
.iter()
.map(|cell| match cell.color {
Some(color) => paint(&cell.text, color, colored),
None => cell.text.clone(),
})
.collect()
}
/// The mark a blocking relation carries, and a card waiting on one.
///
/// Not a fourth circle. The Geometric Shapes glyphs belong to the priority meter, and
/// another one two cells away from it would read as part of that ramp rather than as a
/// different fact. A multiplication sign is Latin-1, like the middle dot the unset
/// priority draws, so it renders wherever the meter already does. That is the same
/// safe-glyph rule that took the quadrant circles out of the ramp.
///
/// One glyph for both places, since both say the same word: on a card that this ticket
/// is held up, in the relations block that this edge is what holds one. The direction is
/// the label's to say.
pub const BLOCKED_MARK: &str = "\u{d7}";
/// The mark a `relates to` row carries: a plain pointer to somewhere else worth reading.
pub const RELATES_MARK: &str = "\u{2192}";
/// The mark a regression row carries, pointing back at the fix it undid.
pub const REGRESSION_MARK: &str = "\u{2190}";
/// The mark for the status of a relation's target, and the colour it is drawn in.
///
/// One circle where the priority meter is always two, which is what keeps the two apart:
/// the meter reads `\u{25cf}\u{25d0}` and a status reads `\u{25d0}`, and they never sit in the same column.
/// `the_status_mark_is_one_cell_where_the_meter_is_two` pins that, since it is the whole
/// reason a circle is safe here when it is not safe on a card.
///
/// `\u{25cb}` not started, `\u{25d0}` under way, `\u{25cf}` finished, so the shape carries how far the
/// target has got and the colour says which of the two middle stages it is in. A ramp
/// inside one column, the way the priority meter reuses the palette: grey for the pile
/// 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] = [
("backlog", "\u{25cb}", Color::Grey),
("committed", "\u{25d0}", Color::Orange),
("reviewing", "\u{25d0}", Color::Cyan),
("done", "\u{25cf}", Color::Green),
];
/// The mark for a status, or `?` for a target the board no longer holds.
///
/// A placeholder rather than a blank, so the id column does not move when one row's
/// target has gone, and grey rather than a stage of the flow: the `_missing_` beside it
/// is grey for the same reason. An unrecognised value reads the same way, since the
/// status comes from the directory the ticket was found in and guessing at a fifth stage
/// would mark a status nothing can act on. `every_status_has_a_mark` pins the pairing
/// against `status_dirs`.
pub fn status_mark(status: Option<&str>) -> (&'static str, Color) {
let found = status.and_then(|status| {
STATUS_MARKS
.iter()
.find(|(name, _, _)| *name == status)
.map(|(_, mark, colour)| (*mark, *colour))
});
found.unwrap_or(("?", Color::Grey))
}
/// The glyph and colour for a kind of relation.
///
/// The label already names the kind in words, and this is what makes the block scannable
/// without reading them: the rows that hold you up are the red crosses, whichever
/// direction they point. Arrows and a cross rather than shapes from the priority
/// vocabulary, and all three are in the ramp the footer's own `\u{2190}\u{2192}\u{2191}\u{2193}` already draws.
///
/// The colours reuse the palette the way the priority meter does, as a small ramp inside
/// one column rather than as new meanings: brightred is the cross a card already draws,
/// cyan the pointer, orange the way back. Nothing here is a colour standing in for a
/// uuid or a title, which are what sit beside it on the row.
pub fn relation_mark(kind: RelationKind) -> (&'static str, Color) {
match kind {
RelationKind::BlockedBy => (BLOCKED_MARK, Color::BrightRed),
RelationKind::RelatesTo => (RELATES_MARK, Color::Cyan),
RelationKind::RegressionOf => (REGRESSION_MARK, Color::Orange),
}
}
/// A relation's target as it reads.
fn target_cell(target: Option<&RelatedTicket>, uuid: &str, colored: bool) -> String {
reference_cell(uuid, target.map(|ticket| ticket.title.as_str()), colored)
/// One row of the Relations block: which relation, and what it points at.
///
/// The target is `None` for a uuid the board no longer holds, which is the one case with
/// neither a name nor a status to show.
#[derive(Clone, Debug)]
pub struct RelationRow {
/// Which edge this is, which decides the mark. Kept beside the label rather than
/// derived from it: the label is the same word for both directions of `relates to`,
/// and reading a kind back out of prose is how a mark comes to disagree with a row.
pub kind: RelationKind,
/// The kind as it reads from this end, which is what the row is padded against.
pub label: &'static str,
pub uuid: String,
/// The ticket it names, once the board has been read for it.
pub target: Option<RelationTarget>,
}
/// The Relations section as it is shown, or empty when there is nothing to show.
/// What a relation points at: what to call it, and how far it has got.
///
/// Both directions, stored first: the relations the ticket holds, then the ones held
/// against it, named from this end. Rendered from the index rather than from the body
/// alone, because a bare uuid says nothing and half the relations are not in the file.
pub fn render_relations(
stored: &[Relation],
index: &RelationIndex,
uuid: &str,
colored: bool,
) -> String {
let mut rows: Vec<(&'static str, String)> = stored
/// One `Option` around both rather than two, because they come from the same lookup and
/// so are absent together. The status is here again after 5ae9c7f took it out: the mark
/// keyed on the kind alone for one commit, and a blocking row's state is the thing a
/// reader most wants without leaving the ticket.
#[derive(Clone, Debug)]
pub struct RelationTarget {
pub title: String,
pub status: String,
}
/// A run of text and the colour it is drawn in, or `None` for the default foreground.
///
/// The unit both renderers take: [`paint`] turns one into an escape sequence for the
/// CLI, and the board turns the same one into a ratatui `Span`. A block laid out once
/// and painted twice cannot draw two different blocks.
#[derive(Clone, Debug)]
pub struct Cell {
pub text: String,
pub color: Option<Color>,
}
impl Cell {
fn plain(text: impl Into<String>) -> Self {
Cell {
text: text.into(),
color: None,
}
}
fn colored(text: impl Into<String>, color: Color) -> Self {
Cell {
text: text.into(),
color: Some(color),
}
}
}
/// The relations of one ticket, both directions, in the order they are shown.
///
/// Stored first: the relations the ticket holds, then the ones held against it, named
/// from this end. Read from the index rather than from the body alone, because a bare
/// uuid says nothing and half the relations are not in the file.
///
/// The single builder. Everything that shows a relation goes through these rows, so the
/// CLI and the board cannot disagree about which edges there are, what they are called
/// or which direction comes first.
pub fn relation_rows(stored: &[Relation], index: &RelationIndex, uuid: &str) -> Vec<RelationRow> {
let target_of = |ticket: Option<&RelatedTicket>| {
ticket.map(|ticket| RelationTarget {
title: ticket.title.clone(),
status: ticket.status.clone(),
})
};
let mut rows: Vec<RelationRow> = stored
.iter()
.map(|relation| {
(
relation.kind.label(),
target_cell(index.get(&relation.target), &relation.target, colored),
)
.map(|relation| RelationRow {
kind: relation.kind,
label: relation.kind.label(),
uuid: relation.target.clone(),
target: target_of(index.get(&relation.target)),
})
.collect();
rows.extend(index.inbound(uuid).into_iter().map(|(kind, holder)| {
(
kind.inverse_label(),
target_cell(Some(holder), &holder.uuid, colored),
)
RelationRow {
kind,
label: kind.inverse_label(),
uuid: holder.uuid.clone(),
target: target_of(Some(holder)),
}
}));
if rows.is_empty() {
return String::new();
}
rows
}
// Measured on the labels, which carry no colour, and padded before the target cell
// is joined on, for the reason the metadata table is: an escape sequence counted
// towards a width tilts the column the moment colour is on.
/// The Relations block laid out: one row of cells per relation, or nothing to show.
///
/// The layout lives here rather than in each renderer, so the mark, the padding and the
/// gutter are decided once. The labels are measured with no colour on them and padded
/// before the target is joined, for the reason the metadata table is: an escape sequence
/// counted towards a width tilts the column the moment colour is on.
pub fn relation_cells(rows: &[RelationRow]) -> Vec<Vec<Cell>> {
let width = rows
.iter()
.map(|(label, _)| label.chars().count())
.map(|row| row.label.chars().count())
.max()
.unwrap_or(0);
rows.iter()
.map(|row| {
let (kind, kind_colour) = relation_mark(row.kind);
let (status, status_colour) =
status_mark(row.target.as_ref().map(|target| target.status.as_str()));
let padding = " ".repeat(width - row.label.chars().count());
// Kind, then state, then who: what sort of edge this is, how far the ticket
// at the other end has got, and which ticket that is. Both marks go ahead of
// the id, where they describe the target rather than the row, and every row
// carries both, so nothing is pushed out of line the way the card's blocked
// mark would have been.
let mut cells = vec![
Cell::plain(format!("{}{}{}", row.label, padding, COLUMN_GUTTER)),
Cell::colored(kind, kind_colour),
Cell::plain(" "),
Cell::colored(status, status_colour),
Cell::plain(" "),
];
cells.extend(reference_cells(
&row.uuid,
row.target.as_ref().map(|target| target.title.as_str()),
));
cells
})
.collect()
}
/// The Relations section as the CLI prints it, or empty when there is nothing to show.
pub fn render_relations(rows: &[RelationRow], colored: bool) -> String {
let mut out = String::new();
for (label, cell) in &rows {
out.push_str(label);
out.push_str(&" ".repeat(width - label.chars().count()));
out.push_str(COLUMN_GUTTER);
out.push_str(cell);
for row in relation_cells(rows) {
out.push_str(&paint_cells(&row, colored));
out.push('\n');
}
out
}
/// The rendered Relations block for one ticket, reading the board for the rest of it.
/// The relations of the ticket in `content`, read against the board around it.
///
/// The colour decision is passed in rather than asked for, like everything else the
/// body renders: the board draws the same text with colour off.
pub fn relations_block(content: &str, worklane_dir: &Path, colored: bool) -> Result<String> {
/// Rows rather than a rendered block: the board styles them itself, since an escape
/// sequence in a ratatui paragraph is drawn as literal bytes.
pub fn relations_for(content: &str, worklane_dir: &Path) -> Result<Vec<RelationRow>> {
let title = heading_title(content);
let stored = parse_relations(content, &title)?;
let index = RelationIndex::load(worklane_dir)?;
Ok(render_relations(
Ok(relation_rows(
&stored,
&index,
&parse_ticket_field(content, "ID"),
colored,
))
}
@@ -1814,6 +2071,19 @@ pub fn is_index(search: &str) -> bool {
search.trim().parse::<usize>().is_ok()
}
/// Whether `search` is the keyword standing for every criterion.
///
/// Checked before `find_criteria`, the way the index is checked before the substring,
/// so a criterion whose text contains "all" is reachable only by its number or by a
/// different substring. The keyword wins because ticking every box is the reason the
/// word is typed, and a board where `all` sometimes means one criterion and sometimes
/// means the lot would be worse than one that can be addressed another way.
///
/// Case-insensitive, like the substring match it stands beside.
pub fn is_all_criteria(search: &str) -> bool {
search.trim().eq_ignore_ascii_case("all")
}
/// Which criterion `search` names: a one-based index as `show` prints, or a
/// case-insensitive substring of the text.
///
@@ -1839,16 +2109,20 @@ pub fn find_criteria(criteria: &[Criterion], search: &str) -> Vec<usize> {
.collect()
}
/// Tick or untick the criterion on `line`, leaving every other byte alone.
/// Tick or untick the criteria on `lines`, leaving every other byte alone.
///
/// Only the character between the brackets is spliced. Rebuilding the line would
/// normalise its indentation and whatever spacing it carried after the checkbox.
pub fn set_criterion(content: &str, line: usize, checked: bool) -> String {
///
/// Every line in one pass, so a batch is one rewrite and one save rather than one of
/// each per criterion. `lines` is searched rather than indexed because a ticket holds
/// a handful of criteria, and a set would only move the cost somewhere else.
pub fn set_criteria(content: &str, lines: &[usize], checked: bool) -> String {
let mark = if checked { 'x' } else { ' ' };
let mut out = String::with_capacity(content.len());
for (index, current) in content.lines().enumerate() {
match (index == line, current.find("- [")) {
match (lines.contains(&index), current.find("- [")) {
(true, Some(at)) => {
let opens = at + "- [".len();
out.push_str(&current[..opens]);
@@ -1986,6 +2260,27 @@ pub struct TicketItem {
/// asking per card would re-read every ticket body on every draw rather than on the
/// tick that changed something.
pub tags: Vec<String>,
/// The full uuid from the ticket's own ID field, as a relation stores it.
///
/// `id` is the seven characters a listing prints; a relation names the whole uuid,
/// so pairing a stored blocker with the ticket it points at needs the whole thing.
/// Absent or unset reads as `_Not set_`, the way every other field does, and the
/// board guards for it rather than matching on it.
pub uuid: String,
/// The uuids of the tickets this one records a `blocked by` against, empty when it
/// records none.
///
/// Read here for the reason `criteria` is: the board marks every held-up card on
/// every tick, and asking per card would re-read every ticket body on every draw.
/// The uuids only, never the answer: whether a blocker is still open is a fact
/// about another ticket, so it belongs to whoever holds the whole board.
///
/// A Relations section that cannot be parsed reads as no blockers rather than as a
/// ticket that cannot be listed. `show` and `mv` still refuse it, which is where a
/// hand-edited file has to be reported; a board or a listing that stops on one
/// malformed ticket is the worse failure, and is the same exception `detail_of`
/// already makes.
pub blockers: Vec<String>,
/// The file this came from. The listing ignores it; the TUI opens it for the
/// detail view rather than resolving the ticket a second time.
pub path: std::path::PathBuf,
@@ -2121,6 +2416,13 @@ pub fn collect_ticket_items(status_path: impl AsRef<Path>) -> Result<Vec<TicketI
let filename = e.path().file_stem()?.to_string_lossy().to_string();
let created_at = parse_ticket_field(&content, "Created At");
let blockers = parse_relations(&content, &title)
.unwrap_or_default()
.into_iter()
.filter(|relation| relation.kind == RelationKind::BlockedBy)
.map(|relation| relation.target)
.collect();
// Through `criteria()`, so the card and the numbers `show` prints cannot
// disagree: a checkbox written into a description is not a criterion there
// and is not counted here.
@@ -2143,6 +2445,8 @@ pub fn collect_ticket_items(status_path: impl AsRef<Path>) -> Result<Vec<TicketI
criteria: progress,
campaign: parse_campaign(&content),
tags: parse_tags(&content),
uuid: parse_ticket_field(&content, "ID"),
blockers,
path: e.path(),
})
})
@@ -2555,6 +2859,45 @@ mod tests {
fs::remove_dir_all(&dir).unwrap();
}
/// The blockers come off the read that builds the item, so the board pays no second
/// pass for them, and only the `blocked by` kind is one: the other two record no
/// dependency and gate nothing.
///
/// A section that cannot be parsed reads as no blockers rather than as a ticket that
/// cannot be listed. `show` and `mv` are where a hand-edited file is reported; a
/// listing that stops on one malformed ticket is the worse failure.
#[test]
fn collect_ticket_items_reads_the_uuid_and_the_blockers_it_records() {
let dir = std::env::temp_dir().join(format!("worklane-blocked-{}", uuid::Uuid::new_v4()));
fs::create_dir_all(&dir).unwrap();
let uuid = |tail: &str| format!("11111111-0000-4000-8000-00000000000{tail}");
let write = |name: &str, relations: &str| {
fs::write(
dir.join(format!("{}.md", uuid(name))),
format!(
"# T{name}\n\n## Relations\n{relations}\n## Metadata\n\n- **ID**: {}\n",
uuid(name)
),
)
.unwrap();
};
write("1", &format!("\n- blocked by {}\n- relates to {}\n", uuid("2"), uuid("3")));
write("2", "\n- regression of 99999999-0000-4000-8000-000000000000\n");
write("3", "\n- waits for the other one\n");
let items = collect_ticket_items(&dir).unwrap();
let of = |title: &str| items.iter().find(|item| item.title == title).unwrap();
assert_eq!(of("T1").uuid, uuid("1"));
assert_eq!(of("T1").blockers, vec![uuid("2")]);
assert!(of("T2").blockers.is_empty(), "a regression was read as a blocker");
assert!(of("T3").blockers.is_empty(), "an unreadable section was not survived");
fs::remove_dir_all(&dir).unwrap();
}
/// Whole values, so a filter or a card cannot confuse two tags that share a prefix.
#[test]
fn parse_tags_splits_on_commas_and_keeps_whole_values() {
@@ -3133,6 +3476,32 @@ mod tests {
}
// --------------------------------------------------------------- relations --
/// One row as the block shows it, for a test about where the block goes rather than
/// about how it was derived.
fn row(
kind: RelationKind,
label: &'static str,
uuid: &str,
title: &str,
status: &str,
) -> RelationRow {
RelationRow {
kind,
label,
uuid: uuid.to_string(),
target: Some(RelationTarget {
title: title.to_string(),
status: status.to_string(),
}),
}
}
/// The status mark as the block draws it, so a row assertion reads like the row.
/// The glyphs themselves are pinned literally by `the_status_marks_are_pinned`.
fn smark(status: &str) -> &'static str {
status_mark(Some(status)).0
}
const TARGET: &str = "b1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d";
const SELF: &str = "641e3d5c-1b0e-4d2f-9a7e-3c8b5f0a2d61";
@@ -3258,30 +3627,208 @@ mod tests {
]);
let stored = vec![relation(RelationKind::RegressionOf, TARGET)];
// Each row marked for its own kind: the way back for the regression, the cross
// for the block, the pointer for the neighbour.
assert_eq!(
render_relations(&stored, &index, SELF, false),
"regression of (b1b2c3d) The blocker\n\
blocks (ccccccc) The other one\n\
relates to (ccccccc) The other one\n"
render_relations(&relation_rows(&stored, &index, SELF), false),
format!(
"regression of {REGRESSION_MARK} {backlog} (b1b2c3d) The blocker\n\
blocks {BLOCKED_MARK} {reviewing} (ccccccc) The other one\n\
relates to {RELATES_MARK} {reviewing} (ccccccc) The other one\n",
backlog = smark("backlog"),
reviewing = smark("reviewing"),
)
);
}
/// The mapping itself, literally, so a change to a glyph or a colour is a decision
/// rather than a surprise. Every other assertion about a row interpolates these.
#[test]
fn the_status_marks_are_pinned() {
assert_eq!(status_mark(Some("backlog")), ("\u{25cb}", Color::Grey));
assert_eq!(status_mark(Some("committed")), ("\u{25d0}", Color::Orange));
assert_eq!(status_mark(Some("reviewing")), ("\u{25d0}", Color::Cyan));
assert_eq!(status_mark(Some("done")), ("\u{25cf}", Color::Green));
assert_eq!(status_mark(None), ("?", Color::Grey));
}
/// Every status the board holds is told apart from the other three. The shape does
/// not do it alone, since committed and reviewing are both half circles, so it is the
/// pair that has to be unique. Pinned against `status_dirs` rather than the four
/// names written out here, so a status added later fails this instead of silently
/// reading as `?`.
#[test]
fn every_status_has_a_mark() {
let mut seen = std::collections::HashSet::new();
for status in status_dirs() {
let (mark, colour) = status_mark(Some(status));
assert_ne!(mark, "?", "{status} has no mark of its own");
assert!(
seen.insert((mark, colour)),
"{status} is drawn exactly like another status"
);
}
assert_eq!(seen.len(), 4, "{seen:?}");
}
/// An unrecognised value reads as missing rather than as a fifth stage of the flow.
#[test]
fn a_status_the_board_does_not_use_reads_as_missing() {
assert_eq!(status_mark(Some("elsewhere")), ("?", Color::Grey));
assert_eq!(status_mark(Some("")), ("?", Color::Grey));
}
/// The circles are the priority meter's glyphs, and this is what keeps a status from
/// being read as a level: the meter is always two cells and a status mark is one.
/// A card carries the meter and never a status mark; the block carries the status
/// mark and never a meter.
#[test]
fn the_status_mark_is_one_cell_where_the_meter_is_two() {
for status in status_dirs() {
assert_eq!(
status_mark(Some(status)).0.chars().count(),
1,
"{status} is drawn wide enough to read as a priority meter"
);
}
for priority in [
Priority::Level(1),
Priority::Level(3),
Priority::Level(5),
Priority::Unset,
] {
assert_eq!(
priority_mark(priority).0.chars().count(),
2,
"{priority:?} is drawn narrow enough to read as a status mark"
);
}
}
/// The mark on each row is the status of the ticket that row names, not of the ticket
/// being read, so four relations in four statuses read four ways.
#[test]
fn the_block_marks_each_target_with_its_own_status() {
let rows: Vec<RelationRow> = status_dirs()
.into_iter()
.map(|status| row(RelationKind::RelatesTo, "relates to", TARGET, status, status))
.collect();
let rendered = render_relations(&rows, false);
for status in status_dirs() {
assert!(
rendered.contains(&format!("{} (b1b2c3d) {status}", smark(status))),
"no {status} row marked {:?}:\n{rendered}",
smark(status)
);
}
}
/// Every kind has a mark of its own, and no two share one: the mark is what makes the
/// block scannable without reading the labels, so two kinds drawn alike would defeat
/// it.
#[test]
fn every_relation_kind_has_a_mark_of_its_own() {
let kinds = [
RelationKind::BlockedBy,
RelationKind::RelatesTo,
RelationKind::RegressionOf,
];
let mut seen = std::collections::HashSet::new();
for kind in kinds {
let (mark, colour) = relation_mark(kind);
assert!(!mark.is_empty(), "{kind:?} has no mark");
assert!(seen.insert(mark), "{kind:?} shares its mark with another kind");
assert_ne!(
colour,
Color::Green,
"{kind:?} is drawn in the colour that means a title"
);
}
assert_eq!(seen.len(), 3, "{seen:?}");
}
/// Both directions of one kind carry the same mark, since the kind is what the mark
/// says and the label is what says which way it points.
#[test]
fn both_directions_of_a_kind_carry_one_mark() {
let index = RelationIndex::new(vec![
related(TARGET, "The blocker", "backlog", Vec::new()),
related(
"cccccccc-1111-4222-8333-444444444444",
"The held one",
"backlog",
vec![relation(RelationKind::BlockedBy, SELF)],
),
]);
let stored = vec![relation(RelationKind::BlockedBy, TARGET)];
let rendered = render_relations(&relation_rows(&stored, &index, SELF), false);
let backlog = smark("backlog");
assert!(
rendered.contains(&format!("blocked by {BLOCKED_MARK} {backlog} (b1b2c3d)")),
"{rendered}"
);
assert!(
rendered.contains(&format!("blocks {BLOCKED_MARK} {backlog} (ccccccc)")),
"{rendered}"
);
}
/// The cards spend the circles on priority, two cells away from nothing at all, so a
/// relation drawn as one would be read as a level.
#[test]
fn no_relation_mark_is_a_priority_glyph() {
let levels = [1, 2, 3, 4, 5].map(|level| priority_mark(Priority::Level(level)).0);
let priority: String = levels
.iter()
.copied()
.chain([priority_mark(Priority::Unset).0])
.collect();
for kind in [
RelationKind::BlockedBy,
RelationKind::RelatesTo,
RelationKind::RegressionOf,
] {
let (mark, _) = relation_mark(kind);
assert!(
!priority.contains(mark),
"{kind:?} is drawn with {mark:?}, which the priority meter uses"
);
}
}
/// The id is kept, since it is the only thing left to go looking for, and the title
/// is `_missing_` rather than a bare uuid pretending to be one.
#[test]
fn a_target_the_board_does_not_have_renders_as_missing() {
let stored = vec![relation(RelationKind::BlockedBy, TARGET)];
// The kind mark survives, since it is read from this ticket's own file, and the
// status mark cannot: `?` holds the column so the id does not move, and
// `_missing_` is what says the target is gone.
assert_eq!(
render_relations(&stored, &RelationIndex::new(Vec::new()), SELF, false),
"blocked by (b1b2c3d) _missing_\n"
render_relations(
&relation_rows(&stored, &RelationIndex::new(Vec::new()), SELF),
false
),
format!("blocked by {BLOCKED_MARK} ? (b1b2c3d) _missing_\n")
);
}
#[test]
fn a_ticket_with_no_relations_at_either_end_renders_no_block() {
let index = RelationIndex::new(vec![related(TARGET, "Elsewhere", "backlog", Vec::new())]);
assert_eq!(render_relations(&[], &index, SELF, false), "");
assert_eq!(
render_relations(&relation_rows(&[], &index, SELF), false),
""
);
}
/// Without the guard every ticket with no ID field relates to every other one that
@@ -3307,10 +3854,10 @@ mod tests {
"# T\n\n## Relations\n- blocked by {}\n\n## Metadata\n\n- **ID**: {}\n",
TARGET, SELF
);
let rendered = content_trim(&content, false, &Resolved { relations: "blocked by (b1b2c3d) The blocker\n".to_string(), ..Default::default() });
let rendered = content_trim(&content, false, &Resolved { relations: vec![row(RelationKind::BlockedBy, "blocked by", TARGET, "The blocker", "backlog")], ..Default::default() });
assert!(
rendered.contains("Relations\n─────────\n\nblocked by (b1b2c3d) The blocker\n\nMetadata"),
rendered.contains(&format!("Relations\n─────────\n\nblocked by {BLOCKED_MARK} {} (b1b2c3d) The blocker\n\nMetadata", smark("backlog"))),
"{rendered:?}"
);
assert!(!rendered.contains(TARGET), "the bare uuid was printed: {rendered:?}");
@@ -3322,10 +3869,10 @@ mod tests {
#[test]
fn the_body_injects_the_block_when_the_file_has_no_section() {
let content = format!("# T\n\n## Description\nBody.\n\n## Metadata\n\n- **ID**: {}\n", SELF);
let rendered = content_trim(&content, false, &Resolved { relations: "blocks (641e3d5) The gated one\n".to_string(), ..Default::default() });
let rendered = content_trim(&content, false, &Resolved { relations: vec![row(RelationKind::BlockedBy, "blocks", SELF, "The gated one", "committed")], ..Default::default() });
assert!(
rendered.contains("Body.\n\nRelations\n─────────\n\nblocks (641e3d5) The gated one\n\nMetadata"),
rendered.contains(&format!("Body.\n\nRelations\n─────────\n\nblocks {BLOCKED_MARK} {} (641e3d5) The gated one\n\nMetadata", smark("committed"))),
"{rendered:?}"
);
}
@@ -3334,9 +3881,9 @@ mod tests {
/// worth more at the end than dropped.
#[test]
fn the_body_appends_the_block_when_there_is_no_metadata() {
let rendered = content_trim("# T\n\n## Description\nBody.\n", false, &Resolved { relations: "blocks (641e3d5) X\n".to_string(), ..Default::default() });
let rendered = content_trim("# T\n\n## Description\nBody.\n", false, &Resolved { relations: vec![row(RelationKind::BlockedBy, "blocks", SELF, "X", "done")], ..Default::default() });
assert!(rendered.ends_with("Relations\n─────────\n\nblocks (641e3d5) X\n"), "{rendered:?}");
assert!(rendered.ends_with(&format!("Relations\n─────────\n\nblocks {BLOCKED_MARK} {} (641e3d5) X\n", smark("done"))), "{rendered:?}");
}
/// No block and a section holding only its placeholder: the section renders as it
+273
View File
@@ -53,6 +53,43 @@ fn create_ticket(worklane: &Path) {
.unwrap();
}
/// A second ticket whose criteria carry the word `all`, so the keyword's precedence
/// can be pinned without renumbering the shared fixture.
const ALL_UUID: &str = "6b1f9c22-0d4e-4a1b-9f37-2c85ab4d1e70";
fn create_all_in_text_ticket(worklane: &Path) {
let lines = [
"# All in the text",
"",
"## Acceptance Criteria",
"- [ ] all the boxes are listed",
"- [ ] the footer is drawn",
"",
"## Metadata",
"",
&format!("- **ID**: {}", ALL_UUID),
"- **Status**: backlog",
"",
];
fs::write(
worklane
.join("backlog")
.join(format!("{}_all-in-the-text.md", ALL_UUID)),
lines.join("\n"),
)
.unwrap();
}
fn all_in_text_ticket(worklane: &Path) -> String {
fs::read_to_string(
worklane
.join("backlog")
.join(format!("{}_all-in-the-text.md", ALL_UUID)),
)
.unwrap()
}
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(args);
@@ -285,3 +322,239 @@ fn check_leaves_nothing_behind() {
.collect();
assert_eq!(strays, Vec::<String>::new());
}
/// The common case the batch exists for: the work is done, every box is true.
#[test]
fn all_ticks_every_criterion() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let out = run(&temp, &["check", UUID, "all"]);
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
let content = ticket(&worklane);
assert!(content.contains("- [x] alpha shared\n"), "{content}");
assert!(content.contains("- [x] beta alone\n"), "{content}");
assert!(content.contains("- [x] gamma shared\n"), "{content}");
// beta was already ticked, so it is reported unchanged rather than as a new mark
let stdout = String::from_utf8_lossy(&out.stdout);
assert!(stdout.contains("Checked 1: alpha shared"), "{stdout:?}");
assert!(stdout.contains("Already checked 2: beta alone"), "{stdout:?}");
assert!(stdout.contains("Checked 3: gamma shared"), "{stdout:?}");
// And nothing outside the section was touched
assert!(
content.contains("- [ ] A checkbox in the description, which is not a criterion.\n"),
"the description checkbox was ticked: {content}"
);
assert!(
content.contains(" A handwritten line inside the section.\n"),
"the handwritten line was lost: {content}"
);
}
/// An index and a substring in one call, each addressed by the existing rules.
#[test]
fn one_call_takes_several_mixed_terms() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let out = run(&temp, &["check", UUID, "3", "ALPHA"]);
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
let content = ticket(&worklane);
assert!(content.contains("- [x] alpha shared\n"), "{content}");
assert!(content.contains("- [x] gamma shared\n"), "{content}");
// Reported in show's order whatever order the terms arrived in
let stdout = String::from_utf8_lossy(&out.stdout);
let alpha = stdout.find("Checked 1: alpha");
let gamma = stdout.find("Checked 3: gamma");
assert!(
matches!((alpha, gamma), (Some(alpha), Some(gamma)) if alpha < gamma),
"reported out of order, or one of them is missing: {stdout:?}"
);
}
/// The same criterion named twice, once by number and once by text, is one mark and
/// one line of output.
#[test]
fn a_criterion_named_twice_is_reported_once() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let out = run(&temp, &["check", UUID, "1", "alpha", "all"]);
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
let stdout = String::from_utf8_lossy(&out.stdout);
assert_eq!(
stdout.matches("alpha shared").count(),
1,
"alpha was reported more than once: {stdout:?}"
);
assert_eq!(
stdout.lines().count(),
3,
"one line per criterion, not per term: {stdout:?}"
);
}
/// Nothing to change, so nothing is written, the way a single already-ticked
/// criterion already behaves.
#[test]
fn a_batch_that_would_change_nothing_writes_nothing() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
run(&temp, &["check", UUID, "all"]);
let before = ticket(&worklane);
let out = run(&temp, &["check", UUID, "all"]);
assert!(out.status.success());
let stdout = String::from_utf8_lossy(&out.stdout);
assert_eq!(
stdout.matches("Already checked").count(),
3,
"{stdout:?}"
);
assert_eq!(ticket(&worklane), before, "the file was rewritten anyway");
}
/// One term that matches nothing refuses the whole call, so the ticket is never left
/// half-marked.
#[test]
fn a_term_matching_nothing_leaves_the_batch_unwritten() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let before = ticket(&worklane);
let out = run(&temp, &["check", UUID, "1", "nowhere", "3"]);
let stderr = String::from_utf8_lossy(&out.stderr);
assert_eq!(out.status.code(), Some(1));
assert!(stderr.contains("nowhere"), "the term was not named: {stderr:?}");
assert_eq!(ticket(&worklane), before, "alpha was ticked anyway");
}
/// An ambiguous term in a batch is refused the same way a lone one is, and names
/// itself rather than whichever term happened to come first.
#[test]
fn an_ambiguous_term_in_a_batch_names_itself_and_writes_nothing() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let before = ticket(&worklane);
let out = run(&temp, &["check", UUID, "1", "shared"]);
let stderr = String::from_utf8_lossy(&out.stderr);
assert_eq!(out.status.code(), Some(1));
assert!(stderr.contains("'shared' matches 2 criteria"), "{stderr:?}");
assert!(stderr.contains("1. [ ] alpha shared"), "{stderr:?}");
assert!(stderr.contains("3. [ ] gamma shared"), "{stderr:?}");
assert_eq!(ticket(&worklane), before);
}
/// An index out of range in a batch is still a bad index, not a failed text search.
#[test]
fn an_index_out_of_range_in_a_batch_leaves_the_file_untouched() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let before = ticket(&worklane);
let out = run(&temp, &["check", UUID, "1", "9"]);
let stderr = String::from_utf8_lossy(&out.stderr);
assert_eq!(out.status.code(), Some(1));
assert!(stderr.contains("is not one of the 3 criteria"), "{stderr:?}");
assert_eq!(ticket(&worklane), before);
}
/// The decision this pins: `all` is the keyword, checked before the substring the way
/// the index is, so it ticks every criterion and not the one whose text says "all".
#[test]
fn all_is_the_keyword_and_not_a_substring_of_the_text() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_all_in_text_ticket(&worklane);
run(&temp, &["check", ALL_UUID, "all"]);
let content = all_in_text_ticket(&worklane);
assert!(content.contains("- [x] all the boxes are listed\n"), "{content}");
assert!(
content.contains("- [x] the footer is drawn\n"),
"all matched its own text instead of every criterion: {content}"
);
}
/// And the criterion whose text carries the word is still reachable, by its number or
/// by a longer substring.
#[test]
fn a_criterion_whose_text_contains_all_is_still_reachable() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_all_in_text_ticket(&worklane);
run(&temp, &["check", ALL_UUID, "all the boxes"]);
let content = all_in_text_ticket(&worklane);
assert!(content.contains("- [x] all the boxes are listed\n"), "{content}");
assert!(content.contains("- [ ] the footer is drawn\n"), "{content}");
}
#[test]
fn uncheck_takes_all() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let out = run(&temp, &["uncheck", UUID, "all"]);
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
let content = ticket(&worklane);
assert!(content.contains("- [ ] alpha shared\n"), "{content}");
assert!(content.contains("- [ ] beta alone\n"), "{content}");
assert!(content.contains("- [ ] gamma shared\n"), "{content}");
let stdout = String::from_utf8_lossy(&out.stdout);
assert!(stdout.contains("Unchecked 2: beta alone"), "{stdout:?}");
assert!(stdout.contains("Already unchecked 1: alpha shared"), "{stdout:?}");
}
#[test]
fn uncheck_takes_several_mixed_terms() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
run(&temp, &["check", UUID, "all"]);
let out = run(&temp, &["uncheck", UUID, "2", "gamma"]);
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
let content = ticket(&worklane);
assert!(content.contains("- [x] alpha shared\n"), "{content}");
assert!(content.contains("- [ ] beta alone\n"), "{content}");
assert!(content.contains("- [ ] gamma shared\n"), "{content}");
}
#[test]
fn a_failing_term_refuses_an_uncheck_batch_too() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let before = ticket(&worklane);
let out = run(&temp, &["uncheck", UUID, "2", "nowhere"]);
assert_eq!(out.status.code(), Some(1));
assert_eq!(ticket(&worklane), before, "beta was unticked anyway");
}
+174
View File
@@ -296,3 +296,177 @@ fn ls_shows_a_mark_for_the_level() {
// The raw number is not what the listing shows
assert!(!stdout.contains(" 1 "), "the digit leaked into the row");
}
/// A ticket whose Tags field is whatever the test needs it to be, written verbatim so a
/// missing field, an unset one and a real list are all reachable.
fn create_ticket_with_tags(
worklane_dir: &std::path::Path,
status: &str,
title: &str,
tags: &str,
priority: &str,
) {
let slug: String = title.to_lowercase().replace(' ', "-");
let body = format!(
"# {title}\n\n## Metadata\n\n - **ID**: 00000000-0000-0000-0000-000000000001\n - **Priority**: {priority}\n{tags} - **Due**: _Not set_\n- **Owner**: alice\n- **Status**: {status}\n"
);
fs::write(
worklane_dir
.join(status)
.join(format!("00000000-0000-0000-0000-000000000001_{slug}.md")),
body,
)
.unwrap();
}
/// The Tags line as a ticket carries it, for the common case of a real list.
fn tags(list: &str) -> String {
format!("- **Tags**: {list}\n")
}
#[test]
fn ls_filters_by_tag_and_composes_with_status_and_priority() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket_with_tags(&worklane, "backlog", "Tagged bug", &tags("bug,cli"), "1");
create_ticket_with_tags(&worklane, "backlog", "Tagged feature", &tags("feature"), "1");
create_ticket_with_tags(&worklane, "backlog", "Lower bug", &tags("bug"), "3");
create_ticket_with_tags(&worklane, "committed", "Started bug", &tags("bug"), "1");
// Alone, through the grouped listing: every status, only the tagged tickets.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(["ls", "--tag", "bug"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Tagged bug"), "{stdout}");
assert!(stdout.contains("Lower bug"), "{stdout}");
assert!(stdout.contains("Started bug"), "a tagged ticket in another status was dropped");
assert!(!stdout.contains("Tagged feature"), "an untagged ticket came through");
// The counts are filtered too, since they are the same collect.
assert!(stdout.contains("[BACKLOG] 2 tickets"), "{stdout}");
assert!(stdout.contains("[COMMITTED] 1 ticket"), "{stdout}");
// With the status positional.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", "bug"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Tagged bug"));
assert!(stdout.contains("Lower bug"));
assert!(!stdout.contains("Started bug"), "the status was ignored");
// With --priority, and with both: none asked for is everything kept, so the three
// compose without a rule per pair.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "--tag", "bug", "--priority", "1"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Tagged bug"));
assert!(stdout.contains("Started bug"));
assert!(!stdout.contains("Lower bug"), "the priority was ignored");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", "bug", "--priority", "1"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Tagged bug"));
assert!(!stdout.contains("Lower bug"), "the priority was ignored");
assert!(!stdout.contains("Started bug"), "the status was ignored");
assert!(!stdout.contains("Tagged feature"), "the tag was ignored");
}
/// The field is a list of whole values, not a string to search: a ticket tagged `bugfix`
/// is not a ticket tagged `bug`, and neither is one tagged `Bug`. Case sensitive is the
/// opinion the field already takes, since `tag_color` draws those two differently.
#[test]
fn ls_matches_a_whole_tag_value_and_not_a_substring_or_another_case() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket_with_tags(&worklane, "backlog", "Real bug", &tags("bug"), "2");
create_ticket_with_tags(&worklane, "backlog", "Only bugfix", &tags("bugfix"), "2");
create_ticket_with_tags(&worklane, "backlog", "Capital Bug", &tags("Bug"), "2");
// A value that only appears with its neighbours around it, so a match on the raw
// field would find it and a match on the split values cannot.
create_ticket_with_tags(&worklane, "backlog", "Spaced list", &tags("cli, filter"), "2");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", "bug"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Real bug"), "{stdout}");
assert!(!stdout.contains("Only bugfix"), "bug matched bugfix");
assert!(!stdout.contains("Capital Bug"), "bug matched Bug");
// Trimmed on the way in, so the space after the comma is not part of the tag.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", "filter"]);
assert!(get_stdout(&mut cmd).contains("Spaced list"));
// And the field as written is not itself a tag.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", "cli, filter"]);
let stdout = get_stdout(&mut cmd);
assert!(!stdout.contains("Spaced list"), "the whole field matched as one tag");
}
/// No tags is no match, however the ticket spells it: the field absent, unset, or empty.
#[test]
fn ls_never_matches_a_ticket_carrying_no_tags() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket_with_tags(&worklane, "backlog", "Has one", &tags("bug"), "2");
create_ticket_with_tags(&worklane, "backlog", "Field unset", &tags("_None_"), "2");
create_ticket_with_tags(&worklane, "backlog", "Field empty", "- **Tags**:\n", "2");
create_ticket_with_tags(&worklane, "backlog", "Field missing", "", "2");
create_ticket_with_tags(&worklane, "backlog", "Only commas", &tags(", ,"), "2");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", "bug"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Has one"), "{stdout}");
for absent in ["Field unset", "Field empty", "Field missing", "Only commas"] {
assert!(!stdout.contains(absent), "{absent} matched a tag it does not carry");
}
// Nor does an empty tag reach the filter: the value parser refuses it, so nothing is
// listed rather than everything.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", ""]);
cmd.assert().failure().code(2);
}
/// A tag nothing carries lists nothing and still succeeds. The message is the one `ls`
/// already gives for a filter that empties a status, rather than a second one invented
/// here for tags alone.
#[test]
fn ls_with_a_tag_nothing_carries_lists_nothing() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket_with_tags(&worklane, "backlog", "Tagged bug", &tags("bug"), "2");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", "frontend"]);
cmd.assert().success();
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", "frontend"]);
let stdout = get_stdout(&mut cmd);
assert!(!stdout.contains("Tagged bug"), "{stdout}");
assert!(stdout.contains("No tickets in 'backlog' status."), "{stdout}");
// Through the grouped listing the counts go to zero and no section is drawn.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(["ls", "--tag", "frontend"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("[BACKLOG] 0 tickets"), "{stdout}");
assert!(!stdout.contains("Tagged bug"), "{stdout}");
}
+44 -4
View File
@@ -289,6 +289,21 @@ fn relate_leaves_everything_it_was_not_asked_about_alone() {
assert!(content.contains("- **Owner**: alice"), "{content}");
}
/// The mark each kind prints before the id. Written out rather than imported: these
/// tests drive the binary, so they see only its output.
///
/// The cross is the one a held-up card already carries, since both say the same word.
const BLOCKED_MARK: &str = "\u{d7}";
const RELATES_MARK: &str = "\u{2192}";
/// And the mark for the status of the ticket the row names, which follows the kind: a
/// circle filling up as the target moves through the flow.
const BACKLOG_MARK: &str = "\u{25cb}";
const DONE_MARK: &str = "\u{25cf}";
/// A target the board no longer holds has no status, and `?` holds the column so the id
/// does not move.
const NO_STATUS_MARK: &str = "?";
/// The kind, the short id and the title, so the section reads without a second lookup.
#[test]
fn show_renders_the_kind_the_short_id_and_the_title() {
@@ -299,7 +314,10 @@ fn show_renders_the_kind_the_short_id_and_the_title() {
let shown = stdout(&run(&temp, &["show", GATED]));
assert!(shown.contains("Relations"), "{shown}");
assert!(shown.contains("blocked by (b1b2c3d) The blocker"), "{shown}");
assert!(
shown.contains(&format!("blocked by {BLOCKED_MARK} {BACKLOG_MARK} (b1b2c3d) The blocker")),
"{shown}"
);
// Never the stored line: a bare uuid says nothing about what it points at.
assert!(!shown.contains(BLOCKER), "{shown}");
}
@@ -314,12 +332,31 @@ fn show_lists_the_relation_the_other_ticket_holds() {
run(&temp, &["relate", GATED, "--relates-to", FIXED]);
let shown = stdout(&run(&temp, &["show", BLOCKER]));
assert!(shown.contains("blocks (641e3d5) The gated one"), "{shown}");
assert!(
shown.contains(&format!("blocks {BLOCKED_MARK} {BACKLOG_MARK} (641e3d5) The gated one")),
"{shown}"
);
assert!(!ticket(&worklane, BLOCKER).contains("Relations"));
// Two kinds on one ticket, each with its own mark, and the second mark is the state
// of the ticket at the far end: the old fix is in done and the blocker is not. That
// is the pair the block is for, which kind of edge and whether it is finished.
let shown = stdout(&run(&temp, &["show", GATED]));
assert!(
shown.contains(&format!("blocked by {BLOCKED_MARK} {BACKLOG_MARK} (b1b2c3d) The blocker")),
"{shown}"
);
assert!(
shown.contains(&format!("relates to {RELATES_MARK} {DONE_MARK} (f1f2f3f) The old fix")),
"{shown}"
);
// `relates to` is symmetric, so it reads the same way from either end.
let shown = stdout(&run(&temp, &["show", FIXED]));
assert!(shown.contains("relates to (641e3d5) The gated one"), "{shown}");
assert!(
shown.contains(&format!("relates to {RELATES_MARK} {BACKLOG_MARK} (641e3d5) The gated one")),
"{shown}"
);
}
#[test]
@@ -331,7 +368,10 @@ fn a_target_that_no_longer_exists_renders_as_missing() {
fs::remove_file(find(&worklane, BLOCKER)).unwrap();
let shown = stdout(&run(&temp, &["show", GATED]));
assert!(shown.contains("blocked by (b1b2c3d) _missing_"), "{shown}");
assert!(
shown.contains(&format!("blocked by {BLOCKED_MARK} {NO_STATUS_MARK} (b1b2c3d) _missing_")),
"{shown}"
);
}
/// The section is the one part of a ticket read back by machine, so a line nobody can