(76d10d7) Strike through a relation to a discarded ticket, and bump to 0.31.5

The relations block marked a target `○ ◐ ●` or `?`, and none of those can say
the target was discarded: the status mark is one cell in a column of five
states, and `●` in grey against `●` in green is a colour a pipe does not get.
A row pointing at abandoned work therefore read as a live dependency, which is
exactly what it is not.

The row is struck through instead, the whole of it, gutter and padding
included, so the line runs unbroken from the label to the end of the title.
The relation stays recorded, for completeness and for the case the target is
moved back out of discarded, and reads at a glance as no longer standing for
anything. The mark column is untouched: 451fb83 already gave a discarded
target the full circle of done in the grey of the untouched pile, and the
strike is additive on top of that.

`Cell` learns a modifier, the first style on it that is not a colour. Same
trick as the palette, one step further: `Modifier::ansi()` is SGR 9 and
`From<Modifier> for ratatui::style::Modifier` is `CROSSED_OUT`, so a style
that exists for one renderer and not the other is a compile error. Bold stays
out of it, because bold rides inside `Color::Magenta.ansi()` and `span_from`
adds it back from the colour alone; a second modifier goes beside this one.

`paint_cell` opens the modifier ahead of the colour and closes both with one
reset, which is why the reset is now a constant the two writers share rather
than a literal in `paint`. `span_from` takes the modifier too and has no early
return for the uncoloured case any more: a struck plain run is a styled span
with no foreground. `Cell::struck` is a builder, because the strike is decided
a whole row at a time by the layout that already chose the colours.

`Body::push_cell` merges on the whole style rather than the colour alone.
Nothing outside the relations block carries a modifier today, and a merge
keyed on the colour would silently strike a plain run through the moment one
did.

The strike is under the same flag every other escape is, so a piped `show`
carries none of it. That is the bargain committed and reviewing already take
for being told apart by colour alone, and `assets/SKILL.md` says so outright
rather than leaving an agent to infer that a plain-looking row may point at
abandoned work.

Tests are paired both ways, and both halves are load bearing: a renderer that
struck nothing fails the presence, and one that struck every row fails the
absence. `the_status_marks_are_pinned` had never listed discarded, so it does.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ansho Rei
2026-08-25 11:53:45 +02:00
co-authored by Claude Opus 5
parent d1a0f0ee27
commit 7994d98913
6 changed files with 359 additions and 32 deletions
+89 -15
View File
@@ -2030,13 +2030,13 @@ fn detail_body(parts: &[BodyPart]) -> Text<'static> {
let mut rest = cell.text.as_str();
while let Some((line, tail)) = rest.split_once('\n') {
if !line.is_empty() {
open.push(span_from(line, cell.color));
open.push(span_from(line, cell.color, cell.modifier));
}
lines.push(Line::from(std::mem::take(&mut open)));
rest = tail;
}
if !rest.is_empty() {
open.push(span_from(rest, cell.color));
open.push(span_from(rest, cell.color, cell.modifier));
}
}
}
@@ -2058,28 +2058,45 @@ fn detail_body(parts: &[BodyPart]) -> Text<'static> {
Text::from(lines)
}
/// A cell as the board draws it: the same text in the same colour, as a span.
/// A cell as the board draws it: the same text in the same style, as a span.
///
/// The other half of `paint_cells`, which is the CLI's. `From<Color>` is what makes the
/// two agree about what the colour is.
/// The other half of `paint_cells`, which is the CLI's. `From<Color>` and
/// `From<crate::util::Modifier>` are what make the two agree about what the style is.
fn span_of(cell: Cell) -> Span<'static> {
span_from(cell.text, cell.color)
span_from(cell.text, cell.color, cell.modifier)
}
/// The same, for a renderer holding the two halves of a cell rather than the cell.
/// The same, for a renderer holding the parts of a cell rather than the cell.
///
/// The bold on magenta is not a flourish. `Color::Magenta.ansi()` is `\x1b[1;35m`, so
/// the CLI draws every bold run bold as well as magenta, and a board that dropped the
/// modifier would be painting the same cell differently from the CLI. The colour is the
/// only thing `From<Color>` can carry, so the attribute has to be added on this side.
fn span_from(text: impl Into<String>, color: Option<Color>) -> Span<'static> {
let Some(color) = color else {
return Span::raw(text.into());
};
///
/// A cell's own modifier is the other one, and it arrives on cells with no colour too, so
/// there is no early return for the uncoloured case any more: a struck plain run is a
/// styled span with no foreground rather than a raw one. `crate::util::Modifier` is spelled
/// out because `Modifier` in this file is ratatui's, which is what the style asks for.
fn span_from(
text: impl Into<String>,
color: Option<Color>,
modifier: Option<crate::util::Modifier>,
) -> Span<'static> {
let mut style = Style::default();
let mut style = Style::default().fg(color.into());
if color == Color::Magenta {
style = style.add_modifier(Modifier::BOLD);
if let Some(color) = color {
style = style.fg(color.into());
if color == Color::Magenta {
style = style.add_modifier(Modifier::BOLD);
}
}
if let Some(modifier) = modifier {
style = style.add_modifier(modifier.into());
}
if style == Style::default() {
return Span::raw(text.into());
}
Span::styled(text.into(), style)
@@ -6952,6 +6969,12 @@ mod tests {
/// `write_ticket`'s trailer: the block has to be on screen for a test to read the
/// colour off the drawn buffer.
fn related_board() -> Fixture {
related_board_targeting("reviewing")
}
/// The same, with the target in a status of the caller's choosing: how the row is
/// drawn depends on it, so a test about a discarded target needs one there.
fn related_board_targeting(status: &str) -> Fixture {
let dir = board_dir();
let holder = "11111111-0000-4000-8000-000000000000";
let target = "22222222-0000-4000-8000-000000000000";
@@ -6965,7 +6988,7 @@ mod tests {
),
)
.unwrap();
write_ticket(&dir, "reviewing", target, "The target", "");
write_ticket(&dir, status, target, "The target", "");
dir
}
@@ -7025,6 +7048,57 @@ mod tests {
);
}
/// The strike reaches the board as a ratatui modifier, not as `\x1b[9m` in the
/// paragraph, which is what a `Paragraph` would draw as literal bytes. `Cell` carries
/// the modifier for the same reason it carries the colour: one layout, two painters.
///
/// Paired the way the guideline demands, and both halves are load bearing. A renderer
/// that struck nothing would pass the absence, and one that went back to painting
/// strings would pass the presence.
#[test]
fn a_discarded_target_is_struck_in_the_overlay_and_no_escape_reached_it() {
let dir = related_board_targeting(DISCARDED);
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");
for span in &row.spans {
assert!(
span.style.add_modifier.contains(Modifier::CROSSED_OUT),
"{:?} is not struck, so the line breaks mid row: {row:?}",
span.content
);
}
// The pair: the strike arrived as a style, and no escape arrived with it.
assert!(!row.spans.is_empty(), "the row has no spans, so the loop above is vacuous");
assert!(
!detail.plain().contains('\x1b'),
"escapes reached the body: {:?}",
detail.plain()
);
}
/// The other side of it, so the assertion above cannot be satisfied by a board that
/// strikes every relation row through: a live target is drawn as it always was.
#[test]
fn a_live_target_is_not_struck_in_the_overlay() {
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");
for span in &row.spans {
assert!(
!span.style.add_modifier.contains(Modifier::CROSSED_OUT),
"{:?} is struck through: {row:?}",
span.content
);
}
}
/// The body is no longer one string, so the clamp and the draw could measure two
/// different things. They take the same `Text`, and this is what says so: a ticket
/// whose relations run past the overlay scrolls to its last row.