Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d17f55860 |
@@ -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
|
||||
|
||||
Generated
+1
-1
@@ -1503,7 +1503,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "worklane"
|
||||
version = "0.29.0"
|
||||
version = "0.29.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assert_cmd",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "worklane"
|
||||
version = "0.29.0"
|
||||
version = "0.29.1"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
+56
-28
@@ -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.
|
||||
///
|
||||
@@ -341,59 +341,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")
|
||||
@@ -572,6 +571,35 @@ mod tests {
|
||||
assert!(!rendered.contains('\x1b'), "colour off still painted: {rendered:?}");
|
||||
}
|
||||
|
||||
/// 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.
|
||||
#[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",
|
||||
),
|
||||
];
|
||||
|
||||
let expected = format!(
|
||||
"\n{}\n{}\n\n{} committed → reviewing {}\n\n{}\n The offset was never passed\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),
|
||||
);
|
||||
|
||||
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 three, so every body starts in the same column
|
||||
/// however short the label above it is.
|
||||
#[test]
|
||||
|
||||
+65
-13
@@ -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]
|
||||
|
||||
+1
-1
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user