(d4ce964) Record status, owner and tag changes in a history log, and bump to 0.29.0

The comments directory was already an append-only log with one event
kind. It is now .worklane/history/<uuid>/, with the kind in the entry
and in the filename after the stamp, so a ticket says how it got where
it is and not only what was said about it.

mv, chown and set --tags each write an entry after their own save and
behind their own no-change return, so a refused or no-op edit records
nothing. --actor is on all four writers now. An old comments directory
is adopted on first access and a file with no marker reads as the
comment it is, so nothing is migrated or rewritten.

The log moves to src/history.rs, out of util.rs and handlers.rs, and
the card's counter counts comments only: a ticket that has moved three
times has not been talked about.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ansho Rei
2026-08-24 13:19:09 +02:00
co-authored by Claude Opus 5
parent a1bdb5df49
commit f454d212a4
18 changed files with 1249 additions and 306 deletions
+61 -30
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::handlers::read_comments;
use crate::history::{format_history_with, history_root, read_history};
use crate::tag::{NO_ANNOTATION, TAGS_FILE, TagIndex};
use crate::util::*;
@@ -1904,22 +1904,20 @@ fn detail_of(card: &Card) -> Detail {
let resolved = worklane_dir
.and_then(|dir| crate::campaign::resolved_for(&content, dir).ok())
.unwrap_or_default();
let comments = match worklane_dir {
Some(worklane_dir) => {
read_comments(&worklane_dir.join("comments").join(&uuid)).unwrap_or_default()
}
let history = match worklane_dir {
Some(worklane_dir) => read_history(worklane_dir, &uuid).unwrap_or_default(),
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 comments are still flat, being a string the board appends rather than
// part of the rendered body.
// bytes. The history block is still flat, being a string the board appends rather
// than part of the rendered body.
let mut parts = content_parts(&content, true, &resolved);
parts.push(BodyPart::Cells(vec![Cell::plain(format!(
"\n{}",
format_comments_with(&comments, false)
format_history_with(&history, false)
))]));
Detail {
@@ -2393,9 +2391,8 @@ pub fn digest(worklane_dir: &Path) -> u64 {
// the picker, and a codename edited by hand has to reach every card that names it.
visit(worklane_dir.join(CAMPAIGNS_DIR));
// Comments live one level deeper, a directory per ticket.
let comments = worklane_dir.join("comments");
if let Ok(read) = std::fs::read_dir(&comments) {
// History entries live one level deeper, a directory per ticket.
if let Ok(read) = std::fs::read_dir(history_root(worklane_dir)) {
for entry in read.filter_map(|e| e.ok()) {
visit(entry.path());
}
@@ -4152,20 +4149,20 @@ mod tests {
/// The ticket `write_card`, `write_tagged_card` and `write_member_card` all write.
///
/// A const rather than a literal in each, now that a test has to name it from outside
/// them: the comments of a ticket live in a directory named by its uuid, so a fixture
/// them: the history of a ticket lives in a directory named by its uuid, so a fixture
/// that wrote a different one would silently count nothing.
const FIXTURE_UUID: &str = "11111111-0000-4000-8000-000000000000";
/// Comments where `comment` puts them: under the board, in a directory named by the
/// ticket's uuid, one `.md` per comment. The fixture uuid, since that is what
/// ticket's uuid, one `.md` per entry. The fixture uuid, since that is what
/// `write_card` writes into the ID field the counter reads.
fn write_comments(dir: &Path, count: usize) {
let comments = comments_dir(dir, FIXTURE_UUID);
std::fs::create_dir_all(&comments).unwrap();
let history = crate::history::history_dir(dir, FIXTURE_UUID);
std::fs::create_dir_all(&history).unwrap();
for n in 0..count {
std::fs::write(
comments.join(format!("20260823_1200{n:02}_000000.md")),
history.join(format!("20260823_1200{n:02}_000000_comment.md")),
format!("**Comment**\n\n**Author**: alice\n**Time**: 2026-08-23 12:00:{n:02}\n\nSaid {n}.\n"),
)
.unwrap();
@@ -4520,7 +4517,7 @@ mod tests {
write_comments(&dir, 2);
let board = one_board(&dir);
std::fs::remove_dir_all(comments_dir(&dir, FIXTURE_UUID)).unwrap();
std::fs::remove_dir_all(crate::history::history_dir(&dir, FIXTURE_UUID)).unwrap();
let card = board.selected().expect("no card");
let rows: Vec<String> = card_lines(card, false, 40)
@@ -4669,10 +4666,10 @@ mod tests {
write_ticket(&dir, "backlog", uuid, "First one", "");
let before = digest(&dir);
let comments = comments_dir(&dir, uuid);
std::fs::create_dir_all(&comments).unwrap();
let history = crate::history::history_dir(&dir, uuid);
std::fs::create_dir_all(&history).unwrap();
std::fs::write(
comments.join("20260821_120000_000000.md"),
history.join("20260821_120000_000000_comment.md"),
"**Comment**\nA note from elsewhere.\n\n**Author**: bob\n**Time**: 2026-08-21 12:00:00\n",
)
.unwrap();
@@ -4907,10 +4904,10 @@ mod tests {
let uuid = "11111111-0000-4000-8000-000000000000";
write_ticket(&dir, "backlog", uuid, "First one", "");
let comments = dir.join("comments").join(uuid);
let comments = crate::history::history_dir(&dir, uuid);
std::fs::create_dir_all(&comments).unwrap();
std::fs::write(
comments.join("20260821_120000_000000.md"),
comments.join("20260821_120000_000000_comment.md"),
"**Comment**\nA note from elsewhere.\n\n**Author**: bob\n**Time**: 2026-08-21 12:00:00\n",
)
.unwrap();
@@ -4937,6 +4934,40 @@ mod tests {
assert!(board.detail.is_none());
}
/// The detail view shows the sequence `show` does, mechanical entries included, so a
/// reader on the board sees how a ticket got where it is and not only what was said
/// about it.
#[test]
fn the_detail_view_shows_a_field_change_beside_a_comment() {
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 plain = board.detail.as_ref().expect("no detail").plain();
assert!(plain.contains("HISTORY"), "{plain}");
assert!(plain.contains("status backlog → committed claude ("), "{plain}");
let moved = plain.find("backlog → committed").expect("the move is missing");
let said = plain.find("And why.").expect("the comment is missing");
assert!(moved < said, "the board reordered the log:\n{plain}");
assert!(!plain.contains('\x1b'), "escapes reached the detail view: {plain:?}");
}
/// The reported bug: the modal showed a description, criteria and a metadata
/// table belonging to a ticket it never named.
#[test]
@@ -5026,10 +5057,10 @@ mod tests {
board.toggle_detail();
assert!(!board.detail.as_ref().unwrap().plain().contains("A late note."));
let comments = dir.join("comments").join(uuid);
let comments = crate::history::history_dir(&dir, uuid);
std::fs::create_dir_all(&comments).unwrap();
std::fs::write(
comments.join("20260821_120000_000000.md"),
comments.join("20260821_120000_000000_comment.md"),
"**Comment**\nA late note.\n\n**Author**: bob\n**Time**: 2026-08-21 12:00:00\n",
)
.unwrap();
@@ -5059,10 +5090,10 @@ mod tests {
let uuid = "11111111-0000-4000-8000-000000000000";
write_ticket(&dir, "backlog", uuid, "First one", &long_section(60));
let comments = dir.join("comments").join(uuid);
let comments = crate::history::history_dir(&dir, uuid);
std::fs::create_dir_all(&comments).unwrap();
std::fs::write(
comments.join("20260821_120000_000000.md"),
comments.join("20260821_120000_000000_comment.md"),
"**Comment**\nThe last word.\n\n**Author**: bob\n**Time**: 2026-08-21 12:00:00\n",
)
.unwrap();
@@ -5230,10 +5261,10 @@ mod tests {
board.scroll_detail(1, SCREEN);
let offset = board.offset;
let comments = dir.join("comments").join(uuid);
let comments = crate::history::history_dir(&dir, uuid);
std::fs::create_dir_all(&comments).unwrap();
std::fs::write(
comments.join("20260821_120000_000000.md"),
comments.join("20260821_120000_000000_comment.md"),
"**Comment**\nA late note.\n\n**Author**: bob\n**Time**: 2026-08-21 12:00:00\n",
)
.unwrap();
@@ -6608,7 +6639,7 @@ mod tests {
}
assert_eq!(board.offset, last, "the clamp and the body disagree");
// The relations sit at the end of this fixture, so the last row and the comments
// The relations sit at the end of this fixture, so the last row and the history
// line are what the last screenful has to hold.
let screen = render(&board, SCREEN.width, SCREEN.height).join("\n");
assert!(
@@ -6616,7 +6647,7 @@ mod tests {
"the last relation is not on screen:\n{screen}"
);
assert!(
screen.contains("No comments yet."),
screen.contains("No history yet."),
"the body ends past the last screenful:\n{screen}"
);
}