(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>
This commit is contained in:
Ansho Rei
2026-08-22 15:23:55 +02:00
co-authored by Claude Opus 5
parent ece201e3ab
commit ce32b42ae4
4 changed files with 95 additions and 2 deletions
+1
View File
@@ -213,6 +213,7 @@ and this file is for what someone changing worklane's own code needs.
- **`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
Generated
+1 -1
View File
@@ -1494,7 +1494,7 @@ dependencies = [
[[package]]
name = "worklane"
version = "0.14.0"
version = "0.15.0"
dependencies = [
"anyhow",
"assert_cmd",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "worklane"
version = "0.14.0"
version = "0.15.0"
edition = "2024"
[dependencies]
+92
View File
@@ -4258,6 +4258,98 @@ mod tests {
);
}
/// The line of the body carrying `needle`, so a test can ask what colour a run of it
/// is drawn in rather than reading the flattened text.
fn body_line(detail: &Detail, needle: &str) -> Line<'static> {
detail
.body
.lines
.iter()
.find(|line| {
line.spans
.iter()
.map(|span| span.content.as_ref())
.collect::<String>()
.contains(needle)
})
.cloned()
.unwrap_or_else(|| panic!("no line holding {needle:?} in:\n{}", detail.plain()))
}
/// The colour of the span whose whole content is `text`, on that line.
fn span_color(line: &Line<'static>, text: &str) -> Option<ratatui::style::Color> {
line.spans
.iter()
.find(|span| span.content.as_ref() == text)
.map(|span| span.style.fg)
.unwrap_or_else(|| panic!("no span {text:?} in {line:?}"))
}
/// A short id is red everywhere the CLI prints one, and the overlay was the one place
/// it was not: the body arrived as flat text because a paragraph is no place for an
/// escape. It is styled now, so the guideline holds in both views.
///
/// Paired the way the guideline demands. The absence, no escape byte in the body,
/// cannot pass on its own: a version that dropped every colour to stay safe would
/// satisfy it, so the presence is asserted beside it. And the one character version
/// of this, passing `true` to the body renderers, fails the absence.
#[test]
fn the_relation_id_is_red_in_the_overlay_and_no_escape_reached_the_body() {
let dir = related_board();
let mut board = one_board(&dir);
board.toggle_detail();
let detail = board.detail.as_ref().expect("no detail");
let row = body_line(detail, "blocked by");
assert_eq!(
span_color(&row, "2222222"),
Some(Color::Red.into()),
"the target's id is not red: {row:?}"
);
// The pair: colour arrived, and it arrived as a style rather than as bytes.
assert!(
row.spans.iter().any(|span| span.style.fg.is_some()),
"nothing on the row is coloured at all, so the guard below is vacuous"
);
assert!(
!detail.plain().contains('\x1b'),
"escapes reached the body: {:?}",
detail.plain()
);
}
/// A target the board no longer holds keeps the id, which is the only thing left to
/// go looking for, and says `_missing_` in the grey that means an unset value. The
/// colour must not turn a gap into something that reads like a real target.
#[test]
fn a_missing_target_still_reads_as_missing_in_the_overlay() {
let dir = board_dir();
let holder = "11111111-0000-4000-8000-000000000000";
std::fs::write(
dir.join("backlog").join(format!("{holder}_a-holder.md")),
format!(
"# A holder\n\n## Relations\n- blocked by 99999999-0000-4000-8000-000000000000\n\
\n## Metadata\n\n- **ID**: {holder}\n- **Status**: backlog\n"
),
)
.unwrap();
let mut board = one_board(&dir);
board.toggle_detail();
let detail = board.detail.as_ref().expect("no detail");
let row = body_line(detail, "blocked by");
assert_eq!(span_color(&row, "_missing_"), Some(Color::Grey.into()));
assert_eq!(
span_color(&row, "9999999"),
Some(Color::Red.into()),
"the id went with the title it could not find"
);
// `?` rather than a stage of the flow, in grey rather than the status orange.
assert_eq!(span_color(&row, "?"), Some(Color::Grey.into()));
}
/// The detail view is the second renderer of a ticket body, so it resolves a
/// relation the way `show` does rather than printing the uuid the file stores.
///