(f3e099e) Colour the history block in the detail overlay, and bump to 0.29.1

The board appended the block as a pre-rendered string with colour off, the
last flat piece of a body e4d0bb7 had fully styled. history_cells lays the
block out once: format_history is those cells painted for the CLI, and
detail_of pushes the same ones as a Cells part, so the overlay styles them
and no escape can enter. The CLI's output is pinned byte for byte, and the
overlay test pairs the presence of the colours with the absence of escapes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Ansho Rei
2026-08-24 14:49:24 +02:00
co-authored by Claude Fable 5
parent f454d212a4
commit 9d17f55860
6 changed files with 126 additions and 46 deletions
+65 -13
View File
@@ -21,7 +21,7 @@ use ratatui::text::{Line, Span, Text};
use ratatui::widgets::{Block, Borders, Clear, Paragraph, Tabs, Wrap};
use crate::campaign::{CAMPAIGNS_DIR, CampaignIndex, Standing};
use crate::history::{format_history_with, history_root, read_history};
use crate::history::{history_cells, history_root, read_history};
use crate::tag::{NO_ANNOTATION, TAGS_FILE, TagIndex};
use crate::util::*;
@@ -1885,10 +1885,10 @@ impl Board {
}
/// The ticket as the detail view holds it: its name and short id, then the body as
/// `show` renders it and the comments.
/// `show` renders it and the history.
///
/// Plain rather than coloured, since ratatui draws styled spans and an escape sequence
/// in a paragraph would be printed as literal bytes.
/// Styled spans rather than painted text, since an escape sequence in a ratatui
/// paragraph would be printed as literal bytes.
fn detail_of(card: &Card) -> Detail {
let ticket = &card.ticket;
let content = std::fs::read_to_string(&ticket.path).unwrap_or_default();
@@ -1909,16 +1909,14 @@ fn detail_of(card: &Card) -> Detail {
None => Vec::new(),
};
// Colour on, and nothing here is painted: the body arrives as cells and the
// relations as rows, and `detail_body` turns both into styled spans. An escape
// sequence never enters, which is what a ratatui paragraph would draw as literal
// bytes. The history block is still flat, being a string the board appends rather
// than part of the rendered body.
// Colour on, and nothing here is painted: the body arrives as cells, the relations
// as rows and the history block as the cells the CLI paints, and `detail_body`
// turns them all into styled spans. An escape sequence never enters, which is what
// a ratatui paragraph would draw as literal bytes.
let mut parts = content_parts(&content, true, &resolved);
parts.push(BodyPart::Cells(vec![Cell::plain(format!(
"\n{}",
format_history_with(&history, false)
))]));
let mut block = vec![Cell::plain("\n")];
block.extend(history_cells(&history));
parts.push(BodyPart::Cells(block));
Detail {
title: ticket.title.clone(),
@@ -4968,6 +4966,60 @@ mod tests {
assert!(!plain.contains('\x1b'), "escapes reached the detail view: {plain:?}");
}
/// The history block was the last flat part of the overlay, f3e099e: the board
/// appended it as a pre-rendered string after the body, so it drew plain under a
/// body e4d0bb7 had fully styled. It arrives as cells now, in the colours `show`
/// paints.
///
/// Paired the way the guideline demands: a renderer that dropped every colour would
/// pass the no-escape half, so the presence is asserted beside it.
#[test]
fn the_history_block_is_styled_in_the_overlay_and_no_escape_reached_it() {
let dir = board_dir();
let uuid = "11111111-0000-4000-8000-000000000000";
write_ticket(&dir, "backlog", uuid, "First one", "");
let history = crate::history::history_dir(&dir, uuid);
std::fs::create_dir_all(&history).unwrap();
std::fs::write(
history.join("20260821_120000_000000_status.md"),
"**Status**\nbacklog → committed\n\n**Author**: claude\n**Time**: 2026-08-21 12:00:00\n",
)
.unwrap();
std::fs::write(
history.join("20260821_120001_000000_comment.md"),
"**Comment**\nAnd why.\n\n**Author**: bob\n**Time**: 2026-08-21 12:00:01\n",
)
.unwrap();
let mut board = one_board(&dir);
board.toggle_detail();
let detail = board.detail.as_ref().expect("no detail");
let heading = body_line(detail, "HISTORY");
assert_eq!(span_color(&heading, "HISTORY"), Some(Color::Orange.into()));
let from = body_line(detail, "From bob");
assert_eq!(
span_color(&from, "From bob (2026-08-21 12:00:01)"),
Some(Color::Cyan.into())
);
let change = body_line(detail, "backlog → committed");
assert_eq!(span_color(&change, "status"), Some(Color::Orange.into()));
assert_eq!(
span_color(&change, "claude (2026-08-21 12:00:00)"),
Some(Color::Cyan.into())
);
// The other half: the colour arrived as styles, not as bytes.
assert!(
!detail.plain().contains('\x1b'),
"escapes reached the detail view: {:?}",
detail.plain()
);
}
/// The reported bug: the modal showed a description, criteria and a metadata
/// table belonging to a ticket it never named.
#[test]