diff --git a/AGENTS.md b/AGENTS.md index 86452a9..e40bf15 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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 ...` 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 diff --git a/Cargo.lock b/Cargo.lock index d09373f..6965725 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1494,7 +1494,7 @@ dependencies = [ [[package]] name = "worklane" -version = "0.14.0" +version = "0.15.0" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index 760bcde..13d0583 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "worklane" -version = "0.14.0" +version = "0.15.0" edition = "2024" [dependencies] diff --git a/src/tui.rs b/src/tui.rs index 997c551..58aaa52 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -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::() + .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 { + 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. ///