Compare commits

...
2 Commits
Author SHA1 Message Date
Ansho ReiandClaude Fable 5 c03f47c52d (f774a33) Record a campaign move in the history log, and bump to 0.30.0
assign was the only field writer without an entry: a ticket could leave one
campaign for another with nothing recording it. Kind gains Campaign, assign
gains the --actor flag the other four writers carry, and the entry is written
after the save and behind the no-change return, the rule every writer follows.

The entry records Campaign::name, the codename or failing that the title,
settled when the entry is written so a rename cannot change what an old entry
means. The uuid the field holds says nothing in a log line, and a before-uuid
the board no longer has reads _missing_, the way the Campaign field itself
renders a dangling one.

campaign is the longest mechanical label, so LABEL_WIDTH widens from 6 to 8
and every mechanical row moves two columns right, a deliberate output change
that makes this a minor alongside the new flag.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-24 15:49:50 +02:00
Ansho ReiandClaude Fable 5 9d17f55860 (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>
2026-08-24 14:49:24 +02:00
12 changed files with 347 additions and 73 deletions
+5 -4
View File
@@ -31,7 +31,7 @@
- Format: `**Field Name**: value`
- Ticket structure: `# Title` → `## Description` → `## Acceptance Criteria` → `## Implementation Plan` → `## Metadata`
- A **campaign** file carries `ID`, `Codename`, `Owner` and `Created At`, in that order, and no `Status`. `Codename` sits directly under the ID because that is what it is, a second way to say which campaign this is; it is written by `campaign add --codename` alone and is `_Not set_` when the flag was not given. It is not in `METADATA_ORDER`, which is the anchor list for the *upsert* on a ticket, and nothing upserts a campaign
- History entries stored in `.worklane/history/<ticket_uuid>/<stamp>_<kind>.md`, with the kind's marker (`**Comment**`, `**Status**`, `**Owner**`, `**Tags**`), then the body, then `**Author**` and `**Time**`. See The History Log
- History entries stored in `.worklane/history/<ticket_uuid>/<stamp>_<kind>.md`, with the kind's marker (`**Comment**`, `**Status**`, `**Owner**`, `**Tags**`, `**Campaign**`), then the body, then `**Author**` and `**Time**`. See The History Log
## Status Workflow
`backlog` → `committed` → `reviewing` → `done`
@@ -231,7 +231,7 @@ and this file is for what someone changing worklane's own code needs.
- **The footer's last slot always answers how to get out**, and with a ticket open the honest answer is `ctrl-c`, the only key left that quits in one press. Going on saying `q quit` there would be 1b78a24 in the other direction: a footer describing a key by what it used to do
- **The overlay names its ticket on the border, not at the head of the paragraph.** `Board::detail` is a `Detail` carrying the title, the id and the text, because the name has to travel beside the body rather than inside it: `content_trim` drops the `# ` heading on purpose, since `cmd_show` prints it, and anything in the paragraph scrolls away
- `detail_title` cuts the string itself instead of leaving it to ratatui, which truncates an overlong block title at whatever cell it reaches and would take the id with it. Cut against the inner width, so the id survives whole and the name ends in an ellipsis. The id goes first because that is how every other view addresses a ticket
- The detail view renders with colour off. ratatui draws styled spans, so an escape sequence in a paragraph would be printed as literal bytes. `content_trim` and `format_history_with` take the colour decision for that reason
- The detail view renders from cells, never from painted strings: ratatui draws styled spans, so an escape sequence in a paragraph would be printed as literal bytes. `content_trim` and `format_history_with` take the colour decision for the CLI's side of the same layouts
- Read only. Moving a card by keypress is a follow-up, deliberately kept out until the watch and render loop were solid
- **A card is four corners with the title between them:** mark and short id top left, due top right, owner bottom left, comment count then criteria count bottom right. The numbers are in corners because that is where the eye goes for one, and they were invisible at the end of a line of prose
- The title takes one row or two, wrapped on spaces, with an ellipsis when even two are not enough. One row when one is enough: a second, blank row on every short ticket spends the column's height on nothing
@@ -350,7 +350,7 @@ and this file is for what someone changing worklane's own code needs.
- **`colored` still reaches `content_parts`, and it no longer means paint.** It says whether *this* renderer can carry a colour at all, and one thing turns on it: `**bold**` gives its markers up to the colour that replaces them, so a renderer with none has to keep them or the emphasis is lost rather than moved. The board passes `true`, `content_trim` passes the CLI's decision, and a piped `show` still reads its markers. Nothing else in the body consults it
- **Magenta means bold, and `span_from` is where the board learns that.** `Color::Magenta.ansi()` is `\x1b[1;35m`, so the CLI draws every bold run bold as well as magenta, and `From<Color>` can carry only the colour. Without the modifier added on the board's side the same cell would be painted two ways, which is the one thing the shared layout exists to prevent
- **The conversion is pinned from both ends.** `show_prints_the_same_body_it_printed_before_the_cells_conversion` holds a body with one of every painted run and asserts the CLI's output byte for byte, written from what it printed before the change, so the risk in sharing a layout, the CLI's output drifting to suit the board, fails the suite. `the_whole_body_is_styled_in_the_overlay_and_no_escape_reached_it` is the other end and is paired the way the guideline demands: a renderer that dropped every colour passes the absence, and one that went back to painting strings passes the presence
- **The history block is still flat, and it is the last piece that is.** `format_history_with` is a string the board appends after the body rather than part of what `content_parts` lays out, so it was outside e4d0bb7. Its own ticket, f3e099e
- **The history block arrives as cells too, so nothing in the overlay is flat.** `history_cells` lays the block out once; `format_history` is those cells through `paint_cells` and the board pushes the same ones as a `Cells` part after the body, since the log lives outside the ticket file and `content_parts` never sees it. Pinned from both ends the way the body is: `show_prints_the_same_history_it_printed_before_the_cells_conversion` holds the CLI's output byte for byte, and `the_history_block_is_styled_in_the_overlay_and_no_escape_reached_it` pairs the presence with the absence (f3e099e, closing the gap e4d0bb7 left)
### Finding the Board
- **`find_worklane_dir` classifies the entry before it follows it.** `exists()` follows a link, so a `.worklane` that was a dangling symlink answered the same as no `.worklane` at all: the walk carried on up the tree and the first board above the project became the one every write landed in, silently. `classify` reads `symlink_metadata` first and answers one of four, `Absent`, `Board`, `Dangling` or `NotADirectory`, and **`Absent` is the only one the walk carries on from**. A `.worklane` that is there but unusable is this project's board and is reported, not handed upward
@@ -394,7 +394,8 @@ and this file is for what someone changing worklane's own code needs.
- **An entry is written after the edit it describes, never before.** A refused move, a refused chown and a failed save log nothing, which is what `a_refused_move_writes_nothing` and `a_failed_edit_writes_nothing` pin. The cost of that order is that a failed entry write leaves the edit in place and reports the failure, which is the right way round: the ticket is the record and the log is the story of it
- **A no-op edit writes nothing either, and `apply` is what decides that** for `set`: a field it did not record as changed was already what the call asked for. `cmd_mv` and `cmd_chown` have their own early returns and sit behind them
- **The stamp leads the filename and the kind follows it**, so the lexicographic sort in `read_history` stays chronological however many kinds there are. The collision suffix goes last, after the kind, and is a number, so it matches no slug and the counter skips it
- **A mechanical entry renders as one line and a comment as it always did.** A field change is one fact, and a paragraph for it would bury the comments it sits between. The labels are padded to `Kind::LABEL_WIDTH`, `status` being the longest of the three, so the bodies line up under each other
- **A mechanical entry renders as one line and a comment as it always did.** A field change is one fact, and a paragraph for it would bury the comments it sits between. The labels are padded to `Kind::LABEL_WIDTH`, `campaign` being the longest of the four, so the bodies line up under each other
- **A campaign entry records `Campaign::name`, the codename or failing that the title, never the uuid the field holds.** Settled when the entry is written, not left to the renderer: a log is a record, and resolving at read time would let an entry change meaning when a campaign is renamed. A `before` uuid the board no longer has reads `_missing_`, the way the Campaign field itself renders a dangling one, and a ticket never assigned starts from `_Not set_` (f774a33)
- **`--actor` is on every command that writes an entry**, spelled from one `ACTOR_HELP` in `command.rs`: a flag documented differently on each command reads as four flags. On `chown` it sits beside `user`, which is the ticket's new assignee — the two are different questions and that command answers both
- **`set --actor` reaches only the entry `--tags` writes**, since tags are the one field of that command's that is logged. Documented on the flag rather than left for a reader to notice from the absence of entries
Generated
+1 -1
View File
@@ -1503,7 +1503,7 @@ dependencies = [
[[package]]
name = "worklane"
version = "0.29.0"
version = "0.30.0"
dependencies = [
"anyhow",
"assert_cmd",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "worklane"
version = "0.29.0"
version = "0.30.0"
edition = "2024"
[dependencies]
+10 -6
View File
@@ -273,20 +273,23 @@ existing ticket will have been written from a different angle.
## What the board records about your work
`show` ends with a HISTORY block: every comment on the ticket and every change to its
status, owner or tags, oldest first, each naming who made it. You do not write these by
hand. `mv`, `chown` and `set --tags` record themselves, and a call that changes nothing
records nothing.
status, owner, tags or campaign, oldest first, each naming who made it. You do not write
these by hand. `mv`, `chown`, `set --tags` and `assign` record themselves, and a call
that changes nothing records nothing. A campaign move is recorded by codename, or by
title for a campaign that has none, not by the uuid the field holds.
```
HISTORY
────────────────────
status backlog → committed claude (2026-08-24 12:45:00)
status backlog → committed claude (2026-08-24 12:45:00)
From claude (2026-08-24 13:10:22)
The offset was never passed to the widget.
owner _Not set_ → Ansho Rei claude (2026-08-24 13:11:04)
owner _Not set_ → Ansho Rei claude (2026-08-24 13:11:04)
campaign _Not set_ → v1 claude (2026-08-24 13:12:30)
```
Nothing else is logged: ticking a criterion, and editing the title, description, plan,
@@ -312,7 +315,8 @@ Set it once where your session's environment is configured, not on each call: `e
`~/.claude/settings.json` for Claude Code, and the environment opencode is started with
for opencode, since it passes its own environment to the tools it runs. `--actor`
overrides it for one call and is spelled the same on every command that writes an entry,
`comment`, `mv`, `chown` and `set`. An empty value counts as unset and falls back to the
`comment`, `mv`, `chown`, `set` and `assign`. An empty value counts as unset and falls
back to the
git user, and with nothing at all the author is `unknown`. It is free text, checked
against nothing: name yourself something a person reading the board will recognise.
+15
View File
@@ -50,6 +50,21 @@ pub struct Campaign {
pub content: String,
}
impl Campaign {
/// The name a reader knows the campaign by: the codename, or the title for a
/// campaign filed without one.
///
/// What the history log records for a campaign move. The field holds a uuid, which
/// says nothing in a log line, and resolving at read time would let an entry change
/// meaning when a campaign is renamed, so the name is settled when the entry is
/// written. The codename over the title because it is the word the board and the
/// command line already use for the campaign, and a log row holds two of these
/// around an arrow.
pub fn name(&self) -> &str {
self.codename.as_deref().unwrap_or(&self.title)
}
}
/// The campaigns directory as [`resolve_in`] takes it.
///
/// The name is empty because a campaign has no status: it is what makes the ambiguity
+5 -2
View File
@@ -182,8 +182,8 @@ fn annotation_line(raw: &str) -> Result<String, String> {
/// What `--actor` says on every command that writes a history entry.
///
/// One string, so the four spell it the same: a flag documented differently on each
/// command reads as four flags.
/// One string, so the five spell it the same: a flag documented differently on each
/// command reads as five flags.
const ACTOR_HELP: &str = "Who the entry is attributed to, overriding WORKLANE_ACTOR and the git user. Free text, checked against nothing";
/// Arguments that carry prose, and therefore have to accept a value starting with
@@ -302,6 +302,9 @@ pub enum Command {
/// Ticket UUID or title
ticket: String,
#[arg(long, help = ACTOR_HELP)]
actor: Option<String>,
},
/// The tag vocabulary: what the board carries, and what each tag means
+26 -1
View File
@@ -1509,7 +1509,12 @@ pub fn cmd_campaign_show(search: &str, worklane_dir: &Path) -> Result<()> {
///
/// No-op detection compares the whole file, the way `set` and `chown` do, so assigning
/// a ticket to the campaign it already names writes nothing.
pub fn cmd_assign(campaign_search: &str, ticket_id: &str, start: &Path) -> Result<()> {
pub fn cmd_assign(
campaign_search: &str,
ticket_id: &str,
actor: &Option<String>,
start: &Path,
) -> Result<()> {
let worklane_dir = find_worklane_dir(start)?;
let campaign = resolve_campaign(campaign_search, &worklane_dir)?;
let (status, title, original) = resolve_ticket(ticket_id, &worklane_dir)?;
@@ -1528,6 +1533,26 @@ pub fn cmd_assign(campaign_search: &str, ticket_id: &str, start: &Path) -> Resul
save_ticket(&worklane_dir, &status, &uuid, &title, None, &content)?;
// Behind the no-change return above and after the save, the rule every writer
// follows. The entry records `Campaign::name`, not the uuid the field holds: what
// the reader should see is settled here, when the entry is written. A campaign the
// board no longer has reads `_missing_`, the way the Campaign field itself renders
// a dangling uuid.
let before = match parse_campaign(&original) {
None => NOT_SET.to_string(),
Some(old) => CampaignIndex::load(&worklane_dir)?
.get(&old)
.map(|was| was.name().to_string())
.unwrap_or_else(|| "_missing_".to_string()),
};
write_entry(
&worklane_dir,
&uuid,
Kind::Campaign,
&change(&before, campaign.name()),
&resolve_actor(actor.as_deref()),
)?;
println!(
"Assigned '{}' to campaign '{}'",
color_text(&title, Color::Green),
+87 -40
View File
@@ -3,8 +3,8 @@
//! The comments directory was already an append-only log with exactly one event kind:
//! one file per entry under a directory named by the ticket's uuid, stamped to the
//! microsecond and written with `create_new` so two writers cannot clobber each other.
//! This is that log with the kind named in it, so a status change, an owner change and a
//! tag change are recorded beside what somebody said about them.
//! This is that log with the kind named in it, so a status change, an owner change, a
//! tag change and a campaign move are recorded beside what somebody said about them.
//!
//! What is deliberately not logged: ticking or unticking a criterion, and edits to the
//! title, description, plan, priority or due. Those change often and a log of them is
@@ -23,7 +23,7 @@ use std::path::{Path, PathBuf};
use anyhow::{Result, anyhow};
use chrono::Local;
use crate::util::{Color, TIMESTAMP_FORMAT, paint, should_use_colors};
use crate::util::{Cell, Color, TIMESTAMP_FORMAT, paint_cells, should_use_colors};
/// Where a ticket's history lives, under the board.
///
@@ -59,25 +59,32 @@ pub fn history_dir(board: &Path, uuid: &str) -> PathBuf {
/// What an entry records.
///
/// An enum rather than a string, so a kind the reader does not know is a compile error
/// instead of a word that renders as itself. The variants are the four things worth
/// keeping: what somebody said, and the three fields whose history answers a question.
/// instead of a word that renders as itself. The variants are the five things worth
/// keeping: what somebody said, and the four fields whose history answers a question.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Kind {
Comment,
Status,
Owner,
Tags,
Campaign,
}
impl Kind {
/// Every kind, which is what the reader matches a marker against and what the
/// counter matches a filename against.
pub const ALL: [Kind; 4] = [Kind::Comment, Kind::Status, Kind::Owner, Kind::Tags];
pub const ALL: [Kind; 5] = [
Kind::Comment,
Kind::Status,
Kind::Owner,
Kind::Tags,
Kind::Campaign,
];
/// The width the mechanical labels are padded to, `status` being the longest of the
/// three. `comment` is longer and is not padded to: a comment renders as a header
/// and a body, not as a row.
const LABEL_WIDTH: usize = 6;
/// The width the mechanical labels are padded to, `campaign` being the longest of
/// the four. `comment` renders as a header and a body, not as a row, so it is not
/// among them.
const LABEL_WIDTH: usize = 8;
/// The word in the filename, and the label a mechanical entry renders under.
pub fn slug(self) -> &'static str {
@@ -86,6 +93,7 @@ impl Kind {
Kind::Status => "status",
Kind::Owner => "owner",
Kind::Tags => "tags",
Kind::Campaign => "campaign",
}
}
@@ -100,6 +108,7 @@ impl Kind {
Kind::Status => "**Status**",
Kind::Owner => "**Owner**",
Kind::Tags => "**Tags**",
Kind::Campaign => "**Campaign**",
}
}
}
@@ -341,59 +350,58 @@ pub fn format_history(entries: &[Entry]) -> String {
format_history_with(entries, should_use_colors())
}
/// As above, with the colour decision passed in for the TUI.
/// As above, with the colour decision passed in.
pub fn format_history_with(entries: &[Entry], colored: bool) -> String {
paint_cells(&history_cells(entries), colored)
}
/// The block laid out once, as [`Cell`]s: the CLI paints them and the board turns the
/// same ones into styled spans, so the two views cannot draw two different blocks.
pub fn history_cells(entries: &[Entry]) -> Vec<Cell> {
if entries.is_empty() {
return paint("No history yet.", Color::Grey, colored);
return vec![Cell::colored("No history yet.", Color::Grey)];
}
let mut result = String::new();
result.push('\n');
result.push_str(&paint("HISTORY", Color::Orange, colored));
result.push_str(&format!("\n{}\n", "─".repeat(20)));
let mut cells = Vec::new();
cells.push(Cell::plain("\n"));
cells.push(Cell::colored("HISTORY", Color::Orange));
cells.push(Cell::plain(format!("\n{}\n", "─".repeat(20))));
for entry in entries {
result.push('\n');
let stamp = paint(&format!("{} ({})", entry.author, entry.time), Color::Cyan, colored);
cells.push(Cell::plain("\n"));
let stamp = format!("{} ({})", entry.author, entry.time);
match entry.kind {
// As it has always read: a header naming who said it, then the text.
Kind::Comment => {
result.push_str(&paint(
&format!("From {} ({})", entry.author, entry.time),
Color::Cyan,
colored,
));
result.push('\n');
cells.push(Cell::colored(format!("From {}", stamp), Color::Cyan));
cells.push(Cell::plain("\n"));
if !entry.body.is_empty() {
result.push_str(" ");
result.push_str(&entry.body);
cells.push(Cell::plain(format!(" {}", entry.body)));
}
result.push('\n');
cells.push(Cell::plain("\n"));
}
// One line: a field change is one fact and a paragraph for it would bury the
// comments it sits between.
_ => {
let label = paint(entry.kind.slug(), Color::Orange, colored);
let padding = Kind::LABEL_WIDTH.saturating_sub(entry.kind.slug().chars().count());
result.push_str(&format!(
"{}{} {} {}\n",
label,
" ".repeat(padding),
entry.body,
stamp
));
cells.push(Cell::colored(entry.kind.slug(), Color::Orange));
cells.push(Cell::plain(format!("{} ", " ".repeat(padding))));
cells.push(Cell::plain(entry.body.clone()));
cells.push(Cell::plain(" "));
cells.push(Cell::colored(stamp, Color::Cyan));
cells.push(Cell::plain("\n"));
}
}
}
result
cells
}
#[cfg(test)]
mod tests {
use super::*;
use crate::util::Fixture;
use crate::util::{Fixture, paint};
fn board() -> Fixture {
Fixture::new("worklane-history")
@@ -561,7 +569,7 @@ mod tests {
let rendered = format_history_with(&entries, false);
assert!(rendered.contains("HISTORY"), "{rendered}");
assert!(
rendered.contains("status committed → reviewing claude (2026-08-24 12:00:00)\n"),
rendered.contains("status committed → reviewing claude (2026-08-24 12:00:00)\n"),
"{rendered}"
);
assert!(
@@ -572,7 +580,45 @@ mod tests {
assert!(!rendered.contains('\x1b'), "colour off still painted: {rendered:?}");
}
/// Padded to the longest of the three, so every body starts in the same column
/// The pin for the cells conversion: `show` prints the block exactly as it printed
/// it before, every painted run spelled out, the way
/// `show_prints_the_same_body_it_printed_before_the_cells_conversion` pins the body.
///
/// Updated once since, deliberately: `campaign` widened the label column from 6 to
/// 8, and the campaign row itself joined the pin (f774a33).
#[test]
fn show_prints_the_same_history_it_printed_before_the_cells_conversion() {
let entries = vec![
parse_entry(
"20260824_120000_000000_status",
"**Status**\ncommitted → reviewing\n\n**Author**: claude\n**Time**: 2026-08-24 12:00:00\n",
),
parse_entry(
"20260824_120001_000000_comment",
"**Comment**\nThe offset was never passed\n\n**Author**: Ansho Rei\n**Time**: 2026-08-24 12:00:01\n",
),
parse_entry(
"20260824_120002_000000_campaign",
"**Campaign**\n_Not set_ → v1\n\n**Author**: claude\n**Time**: 2026-08-24 12:00:02\n",
),
];
let expected = format!(
"\n{}\n{}\n\n{} committed → reviewing {}\n\n{}\n The offset was never passed\n\n{} _Not set_ → v1 {}\n",
paint("HISTORY", Color::Orange, true),
"─".repeat(20),
paint("status", Color::Orange, true),
paint("claude (2026-08-24 12:00:00)", Color::Cyan, true),
paint("From Ansho Rei (2026-08-24 12:00:01)", Color::Cyan, true),
paint("campaign", Color::Orange, true),
paint("claude (2026-08-24 12:00:02)", Color::Cyan, true),
);
assert_eq!(format_history_with(&entries, true), expected);
assert_eq!(format_history_with(&[], true), paint("No history yet.", Color::Grey, true));
}
/// Padded to the longest of the four, so every body starts in the same column
/// however short the label above it is.
#[test]
fn the_mechanical_labels_are_aligned() {
@@ -580,6 +626,7 @@ mod tests {
("status", "backlog → committed"),
("owner", "_Not set_ → alice"),
("tags", "bug → bug, cli"),
("campaign", "v1 → beaver"),
];
let entries: Vec<Entry> = bodies
.into_iter()
@@ -603,7 +650,7 @@ mod tests {
at - line_start
})
.collect();
assert_eq!(columns.len(), 3);
assert_eq!(columns.len(), 4);
assert!(columns.windows(2).all(|pair| pair[0] == pair[1]), "{rendered}");
}
+3 -1
View File
@@ -82,7 +82,9 @@ fn main() -> Result<()> {
cmd_campaign_show(&campaign, &worklane_dir)
}
},
Some(Command::Assign { campaign, ticket }) => cmd_assign(&campaign, &ticket, &start),
Some(Command::Assign { campaign, ticket, actor }) => {
cmd_assign(&campaign, &ticket, &actor, &start)
}
// The bare form and `ls` are one arm: `worklane tags` was the listing before the
// group existed and the fish completion still calls it that way, so the two
// spellings cannot be allowed to drift into two behaviours.
+66 -14
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(),
@@ -4961,13 +4959,67 @@ mod tests {
let plain = board.detail.as_ref().expect("no detail").plain();
assert!(plain.contains("HISTORY"), "{plain}");
assert!(plain.contains("status backlog → committed claude ("), "{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 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]
+1 -1
View File
@@ -2378,7 +2378,7 @@ impl Cell {
Cell { text: text.into(), color: None }
}
fn colored(text: impl Into<String>, color: Color) -> Self {
pub(crate) fn colored(text: impl Into<String>, color: Color) -> Self {
Cell {
text: text.into(),
color: Some(color),
+127 -2
View File
@@ -164,6 +164,119 @@ fn clearing_the_tags_writes_a_tags_entry() {
assert!(entry.starts_with("**Tags**\nalpha → _None_\n"), "{entry:?}");
}
/// The entry names the campaign the way a reader knows it, the codename, not the uuid
/// the field actually holds. A ticket never assigned starts from the sentinel an unset
/// field reads as everywhere else.
#[test]
fn assign_writes_a_campaign_entry_naming_the_codename() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog");
run(
&temp,
&[
"campaign",
"add",
"--title",
"First public release",
"--codename",
"v1",
],
);
run(&temp, &["assign", "v1", UUID]);
let entry = only_entry(&worklane, "campaign");
assert!(entry.starts_with("**Campaign**\n_Not set_ → v1\n"), "{entry:?}");
}
/// A campaign filed without a codename is recorded by its title, the name `show` and
/// `campaign ls` fall back to.
#[test]
fn a_campaign_without_a_codename_is_recorded_by_its_title() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog");
run(&temp, &["campaign", "add", "--title", "First public release"]);
run(&temp, &["assign", "First public", UUID]);
let entry = only_entry(&worklane, "campaign");
assert!(
entry.starts_with("**Campaign**\n_Not set_ → First public release\n"),
"{entry:?}"
);
}
/// A ticket leaving one campaign for another records both ends, which is the move the
/// log exists to answer for: the field is rewritten, so nothing else remembers where the
/// ticket was.
#[test]
fn moving_between_campaigns_records_both_names() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog");
run(
&temp,
&[
"campaign",
"add",
"--title",
"First release",
"--codename",
"v1",
],
);
run(
&temp,
&[
"campaign",
"add",
"--title",
"Second release",
"--codename",
"beaver",
],
);
run(&temp, &["assign", "v1", UUID]);
run(&temp, &["assign", "beaver", UUID]);
let found = entries(&worklane);
assert_eq!(found.len(), 2, "{found:?}");
assert!(found[1].1.starts_with("**Campaign**\nv1 → beaver\n"), "{:?}", found[1].1);
}
/// Assigning the campaign a ticket already names is reported as no change, and a log of
/// no change would be a log of nothing happening.
#[test]
fn a_no_op_assign_writes_nothing() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog");
run(
&temp,
&[
"campaign",
"add",
"--title",
"First release",
"--codename",
"v1",
],
);
run(&temp, &["assign", "v1", UUID]);
let out = run(&temp, &["assign", "v1", UUID]);
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
assert_eq!(
entries(&worklane).len(),
1,
"a no-op assign logged a change it did not make"
);
}
/// The fields that change often enough that a log of them is noise. `set` writing one of
/// them is not an entry, and neither is a criterion being ticked.
#[test]
@@ -277,7 +390,7 @@ fn show_prints_the_comments_and_the_changes_in_one_sequence() {
let owned = stdout.find("alice → bob").expect("the chown is missing");
assert!(said < moved && moved < owned, "out of order:\n{stdout}");
for line in ["status backlog → committed", "owner alice → bob"] {
for line in ["status backlog → committed", "owner alice → bob"] {
assert!(stdout.contains(line), "{line:?} not in:\n{stdout}");
}
assert!(stdout.contains("From claude ("), "{stdout}");
@@ -337,14 +450,26 @@ fn the_actor_flag_names_the_writer_on_every_command_that_writes_one() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog");
run(
&temp,
&[
"campaign",
"add",
"--title",
"First release",
"--codename",
"v1",
],
);
run(&temp, &["comment", UUID, "By hand.", "--actor", "opencode"]);
run(&temp, &["mv", UUID, "--status", "committed", "--actor", "opencode"]);
run(&temp, &["chown", "bob", UUID, "--actor", "opencode"]);
run(&temp, &["set", UUID, "--tags", "beta", "--actor", "opencode"]);
run(&temp, &["assign", "v1", UUID, "--actor", "opencode"]);
let found = entries(&worklane);
assert_eq!(found.len(), 4, "{found:?}");
assert_eq!(found.len(), 5, "{found:?}");
for (name, content) in found {
assert!(content.contains("**Author**: opencode"), "{name}: {content:?}");
}