Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6fe51e31e | ||
|
|
c606b5ba43 | ||
|
|
90b313952b | ||
|
|
7240fc263b | ||
|
|
580e3cf7f0 |
@@ -94,14 +94,36 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- The draw aligns the focused column again on its own geometry, so a resize between keypress and frame cannot hide the selection, and caps every column against blank space past its last card. The stored value may go stale after a tick shrinks the column; that is fine, because what is drawn is corrected immediately and the next navigation writes the correction back
|
||||
- Entering another column follows the selection rather than resetting to its top. The card index carries across columns, so a reset would open the column with the highlight below the fold whenever it was — the opposite of the detail view's reset-on-selection-move, where each ticket genuinely starts at its own top. The index is shared and clamps permanently when a shorter column pulls it down, so a column you return to follows the selection to where it now sits rather than holding your old place
|
||||
- **The footer names only keys that work.** It read `↑↓ scroll` when nothing scrolled at all, which sends the reader looking for their own mistake. A UI that misdescribes itself is worse than one that is merely incomplete
|
||||
- **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_comments_with` take the colour decision for that reason
|
||||
- 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, criteria count bottom right. The two numbers are in corners because that is where the eye goes for one, and both 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
|
||||
- **A card's height therefore depends on the column's width**, so `card_lines` and `card_height` both take it. `column_areas` is shared between the draw and `follow_selection` for the same reason: `Ratio` hands the remainder column to whichever slot it likes, and reproducing that arithmetic by hand is how the measurement and the draw come to disagree about where a card starts
|
||||
- **A corner that will not fit is dropped whole**, never truncated or wrapped: half a date reads as a different date, and a card that reflows in a narrow column changes height, which the scroll would then have to chase. The left corner is the ticket's identity and always stays
|
||||
- The criteria count is a field on `TicketItem`, filled in `collect_ticket_items` where the file is already being read, and counted through `criteria()` so a checkbox in a description is not counted here or numbered by `show`. Do not count per card: that re-reads every ticket body on every draw instead of on the tick that changed something. `None` rather than `[0/0]` for a ticket with no criteria
|
||||
- `due_date` cuts a due value back to its date only when it has one. The field is not validated (daa0e79), so it can hold a time or free text, and taking the first word regardless would turn "next friday" into "next"
|
||||
- **Done is hidden until `d` asks for it.** Not a new opinion: `ls` already counts done in its summary and leaves it out of the listing. Done only grows, so a quarter of the width was going to the column least often read. The footer carries its count while it is hidden, which is the board's version of that summary line
|
||||
- **Hiding is a change to what is drawn, never to what is read.** `reload` still scans the done directory and `digest` still watches it, so the footer count is right and revealing the column needs no rescan. Do not "optimise" that into a conditional scan
|
||||
- `visible()` returns a prefix of `columns`, not a filter, which is what keeps `column` and `offsets` valid as indices into either. It is derived from where `DONE` actually sits rather than assuming the last slot, and `the_done_column_is_last` pins the assumption. A status inserted after done would otherwise hide two columns in silence
|
||||
- Hiding the column under the selection moves the selection to the last drawn column and **closes an open detail view**. The alternative, refreshing the modal onto whichever ticket the selection landed on, swaps what someone is reading without saying so, which is how a person acts on the wrong ticket. Showing done again is a no-op for the selection, since a column is appended rather than inserted
|
||||
- The choice is not remembered between runs. worklane has no config file and one flag is not a reason to start one; if it should persist, that is its own ticket
|
||||
- **Assert a column heading against the top border row, not the whole screen.** The footer names done too, so `screen.contains("done (0)")` passes on the footer whether the column is drawn or not. Three tests went vacuous that way the moment done was hidden; `headings()` and `footer()` exist so the next one does not
|
||||
- **Assert a column heading against the top border row, not the whole screen.** The footer names done too, so `screen.contains("done (0)")` passes on the footer whether the column is drawn or not. Three tests went vacuous that way the moment done was hidden; `headings()` and `footer()` exist so the next one does not. `headings()` locates the row through `board_area()` rather than taking row zero, since the tab row sits above it when more than one board is monitored
|
||||
|
||||
### Monitoring Several Boards
|
||||
- `worklane tui <path>...` takes any number of paths, each resolved through `find_worklane_dir` the way the working directory is: the first `.worklane` at or above it. No path is the working directory, so a bare `worklane` and `worklane tui` are unchanged
|
||||
- The failure **names the path** that had no board, since with several arguments "No .worklane directory found" does not say which one was wrong. Only when a path was given: a bare `worklane` has no path to name and keeps the message every other command gives, which is what its integration test asserts
|
||||
- Two paths inside one project resolve to the same `.worklane` and are monitored once. `projects()` dedupes on the resolved directory, not on the argument
|
||||
- **`Tab` owns the selection**, `column`, `card` and `offsets`, not `Board`. Sharing them across projects would point the selection at whatever unrelated ticket sat at the same place in the tab you switched to. `Board::current()` is the tab in view, and `show_done` stays on the board because it is a preference about the flow rather than about a project
|
||||
- The tabs are fixed for the run: a project cannot be added or dropped without restarting, so `Board::new` builds the tab list once and `reload` only refills each tab's columns. `reload` clamps **every** tab, and `select_tab` clamps again on arrival, because done may have been hidden while another tab was in view
|
||||
- The merge tab goes **first** and is where the view opens: it is the reason to monitor several boards at once. It is materialised in `reload`, from the cards already read, rather than computed per draw — the same reason the criteria count is filled in `collect_ticket_items`
|
||||
- The merge is **sorted**, through `by_priority_then_title` in `util.rs`, not concatenated. An overview whose order depended on the order of the arguments would bury one project's p1 under another's p5. That comparator is exported for this and is the one `collect_ticket_items` uses, so the two orders cannot drift
|
||||
- `Card` wraps a `TicketItem` with the project it came from, `Some` only on the merge tab. Decided at reload rather than passed down to `card_lines` as a "which tab is this" flag. `TicketItem` is therefore `Clone`: the merge holds a second copy rather than re-reading every tree
|
||||
- **The project follows the id, on the card and on the overlay border.** Across boards the id is not an address: two projects can hold the same title, and seven characters do not say where they live. `project_label` takes what the row has left after the mark and the id and ends in an ellipsis, and it is measured before the due date, so on the merge the project wins the narrow column and the date is what `corner_line` drops
|
||||
- `tab` and `shift+tab` cycle rather than clamp, unlike the cards and columns: a row of tabs is a ring, and there is no end of a list to run off. Both were free of every other binding — the columns took `hjkl` and the arrows
|
||||
- **The tab row is drawn only when there is more than one board**, so a single board is the view it has always been. `frame_rows()` gives it `Length(0)` otherwise, which keeps the row indices the same for both cases and is shared with `card_width` and `column_text_height` for the reason `column_areas` is: geometry reproduced by hand drifts from the draw
|
||||
- `digest_of` hashes each board's `digest` into one value, so a change in any of them redraws. Do not watch only the first
|
||||
|
||||
### Shipping the Agent Assets
|
||||
- The skill is embedded with `include_str!` from `assets/SKILL.md`, not copied by an install script. `cargo install` places binaries and nothing else, so an installed document that is not in the binary is a document that drifts from it
|
||||
@@ -115,6 +137,9 @@ and this file is for what someone changing worklane's own code needs.
|
||||
|
||||
### Color and Output
|
||||
- Use `color_text()` for coloured output — it respects `should_use_colors()` (terminal detection), and `paint()` is the same with the decision passed in
|
||||
- **`color_text()` is for the CLI's own printing only. Anything reachable from `content_trim` takes the decision as an argument and calls `paint()`**, because the board renders with colour off and an escape sequence in a ratatui paragraph is drawn as literal bytes. `nothing_the_body_renders_asks_the_terminal_for_the_colour_decision` scans this file and fails on a new caller; the allowlist is `ambiguous`, which builds a failed-search message for stderr
|
||||
- A function that takes an `enabled` flag must use it all the way down. `colorize_bold` honoured its flag on the early return and then asked `should_use_colors()` for the bold run, which made the flag a lie in half the function
|
||||
- **A test that asserts an absence has to be paired with one that asserts the presence.** The guard for this, an assert that the detail view holds no escape byte, could not fail: a test binary has no tty, so `should_use_colors()` was false and the leaking branch was never taken. The pair is now `content_trim(.., false)` has no escape and `content_trim(.., true)` still colours, which pins the flag as the only thing that decides
|
||||
- **The palette is the `Color` enum, not a string.** `Color::ansi()` gives the CLI its SGR sequence and `From<Color> for ratatui::style::Color` gives the TUI its equivalent, so a colour that exists for one renderer and not the other is a compile error. The stringly-typed version needed a test for exactly that, and a missing entry silently produced an empty prefix, which is how `magenta` came to be undefined
|
||||
- Reset color with `\x1b[0m` after colored text
|
||||
- Bold uses `\x1b[1;35m` (magenta bold)
|
||||
@@ -131,7 +156,7 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- Grey is indexed colour 8 in the 256-colour form, not SGR 90 or 37. Both of those failed on a real palette: 90 leans on the bright-black slot and 37 can sit on top of the default foreground. `\x1b[38;5;8m` is byte for byte what crossterm emits for ratatui's `Color::DarkGray`, the grey frig and pantop use for dimmed rows
|
||||
|
||||
### Code Organization
|
||||
- Colorization functions (`colorize_line`, `colorize_ordered`, `content_trim_colored`) handle markdown formatting
|
||||
- Colorization functions (`colorize_ordered`, `colorize_bold`, `content_trim_colored`) handle markdown formatting. `colorize_line` is gone: it was a `pub` alias for `colorize_bold` with one caller, and the only thing it added was asking the terminal
|
||||
- `show` renders the Metadata section as a two column table via `render_metadata_table`, not line by line. Column width is measured on the raw field names in characters and padding is applied before anything is styled: measuring a coloured string counts its escapes towards its width. `paint()` is `color_text()` with the colour decision passed in, which is what lets a test render both ways in one process
|
||||
- The title is printed once, by `cmd_show`. `content_trim_colored` skips the `# ` heading in the file content
|
||||
- Rules under headings are measured on the displayed name in characters, never on the raw line or in bytes
|
||||
|
||||
Generated
+1
-1
@@ -1494,7 +1494,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "worklane"
|
||||
version = "0.8.2"
|
||||
version = "0.9.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assert_cmd",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "worklane"
|
||||
version = "0.8.2"
|
||||
version = "0.9.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -5,7 +5,7 @@ Worklane is a local Kanban flow for agentic software development.
|
||||
## Commands
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `worklane` or `worklane tui` | Opens the board: four status columns, redrawn when the tree changes. Read only. Opens on backlog, committed and reviewing; `d` shows or hides done, whose count stays in the footer either way. Arrows or `hjkl` to move, `enter` for detail, `pgup`/`pgdn` to scroll an open ticket, `q` to quit |
|
||||
| `worklane` or `worklane tui [path...]` | Opens the board: four status columns, redrawn when the tree changes. Read only. Opens on backlog, committed and reviewing; `d` shows or hides done, whose count stays in the footer either way. Arrows or `hjkl` to move, `enter` for detail, `pgup`/`pgdn` to scroll an open ticket, `q` to quit. Each path opens the first `.worklane` at or above it, the working directory by default. Several paths are monitored together, as a tab per project plus an `all` tab that merges them, with `tab` and `shift+tab` between them |
|
||||
| `worklane init` | Creates `.worklane/` with backlog, committed, reviewing, done directories |
|
||||
| `worklane add` | Creates a ticket in backlog with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--owner`, `--priority` flags |
|
||||
| `worklane ls [status]` | Lists tickets, sorted by priority then title. Optional positional status, and `--priority <1-5>` |
|
||||
|
||||
+5
-1
@@ -110,7 +110,11 @@ pub enum Command {
|
||||
Append(AppendArgs),
|
||||
|
||||
/// Open the board view
|
||||
Tui,
|
||||
Tui {
|
||||
/// Projects to monitor, each resolved to the first `.worklane` at or above it.
|
||||
/// Several are shown as tabs. Defaults to the working directory
|
||||
paths: Vec<std::path::PathBuf>,
|
||||
},
|
||||
|
||||
/// Tick an acceptance criterion
|
||||
Check(CheckArgs),
|
||||
|
||||
+13
-6
@@ -38,8 +38,10 @@ fn main() -> Result<()> {
|
||||
let start = std::env::current_dir()?;
|
||||
|
||||
match cli.command {
|
||||
// No subcommand opens the board, the way a bare `frig` does.
|
||||
None | Some(Command::Tui) => run_tui(&start),
|
||||
// No subcommand opens the board, the way a bare `frig` does, and with no path
|
||||
// it opens the board above the working directory.
|
||||
None => run_tui(&[], &start),
|
||||
Some(Command::Tui { paths }) => run_tui(&paths, &start),
|
||||
Some(Command::Init) => cmd_init(&start),
|
||||
Some(Command::Add(args)) => cmd_add(&args, &start),
|
||||
Some(Command::Ls { status, priority }) => {
|
||||
@@ -92,14 +94,14 @@ fn restore_terminal() -> std::io::Result<()> {
|
||||
)
|
||||
}
|
||||
|
||||
fn run_tui(start: &std::path::Path) -> Result<()> {
|
||||
fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()> {
|
||||
use crossterm::event::{self, Event, KeyCode, KeyEventKind, KeyModifiers};
|
||||
use std::io::IsTerminal;
|
||||
|
||||
// The board is looked for before the terminal is, so running this outside a
|
||||
// The boards are looked for before the terminal is, so running this outside a
|
||||
// worklane directory gives the same message every other command gives rather than
|
||||
// a complaint about the terminal.
|
||||
let worklane_dir = find_worklane_dir(start)?;
|
||||
let projects = tui::projects(paths, start)?;
|
||||
|
||||
// Without this, entering raw mode on a pipe fails with a bare "No such device or
|
||||
// address (os error 6)", which says nothing about the actual mistake. A bare
|
||||
@@ -113,7 +115,7 @@ fn run_tui(start: &std::path::Path) -> Result<()> {
|
||||
));
|
||||
}
|
||||
|
||||
let mut board = tui::Board::new(&worklane_dir)?;
|
||||
let mut board = tui::Board::new(projects)?;
|
||||
|
||||
install_panic_hook();
|
||||
crossterm::terminal::enable_raw_mode()?;
|
||||
@@ -161,6 +163,11 @@ fn run_tui(start: &std::path::Path) -> Result<()> {
|
||||
KeyCode::Down | KeyCode::Char('j') => board.select_card(1, screen),
|
||||
KeyCode::PageUp => board.scroll_detail(-1, screen),
|
||||
KeyCode::PageDown => board.scroll_detail(1, screen),
|
||||
// Tabs cycle rather than clamp, the way tabs everywhere do, and are
|
||||
// a no-op with a single board. Free of every other binding: the
|
||||
// columns took hjkl and the arrows.
|
||||
KeyCode::Tab => board.select_tab(1, screen),
|
||||
KeyCode::BackTab => board.select_tab(-1, screen),
|
||||
// Free of the other bindings, and the footer names it in both states.
|
||||
KeyCode::Char('d') => board.toggle_done(screen),
|
||||
_ => {}
|
||||
|
||||
+1405
-239
File diff suppressed because it is too large
Load Diff
+212
-16
@@ -403,7 +403,7 @@ pub fn content_trim(content: &str, colored: bool) -> String {
|
||||
|
||||
// Implementation Plan - color numbers in cyan
|
||||
if current_section == "## Implementation Plan" {
|
||||
result.push_str(&colorize_ordered(line));
|
||||
result.push_str(&colorize_ordered(line, colored));
|
||||
result.push('\n');
|
||||
continue;
|
||||
}
|
||||
@@ -454,7 +454,13 @@ pub fn content_trim(content: &str, colored: bool) -> String {
|
||||
result
|
||||
}
|
||||
|
||||
pub fn colorize_ordered(line: &str) -> String {
|
||||
/// Colour the `1.` at the head of a numbered line, leaving the rest alone.
|
||||
///
|
||||
/// Takes the decision rather than asking for it. Asking is what put `\x1b[36m` and
|
||||
/// `\x1b[0m` around every Implementation Plan number in the board's detail view,
|
||||
/// which renders with colour off precisely because a paragraph is not a place an
|
||||
/// escape sequence can go.
|
||||
fn colorize_ordered(line: &str, colored: bool) -> String {
|
||||
if line.chars().next().is_none_or(|c| !c.is_ascii_digit()) {
|
||||
return line.to_string();
|
||||
}
|
||||
@@ -468,7 +474,7 @@ pub fn colorize_ordered(line: &str) -> String {
|
||||
// still scanning digits
|
||||
} else if *c == '.' && i + 1 < chars.len() && chars[i + 1] == ' ' {
|
||||
let number = &line[..i + 1];
|
||||
result.push_str(&color_text(number, Color::Cyan));
|
||||
result.push_str(&paint(number, Color::Cyan, colored));
|
||||
result.push_str(&line[i + 1..]);
|
||||
return result;
|
||||
} else {
|
||||
@@ -558,7 +564,10 @@ fn render_metadata_table(lines: &[&str], colored: bool) -> String {
|
||||
result.push_str(METADATA_GUTTER);
|
||||
result.push_str(&metadata_value_cell(name, value, colored));
|
||||
}
|
||||
MetadataRow::Other(text) => result.push_str(&colorize_line(text)),
|
||||
// The decision this row is rendered under, not the one the terminal
|
||||
// would give: `colorize_line` asked `should_use_colors()` here, which is
|
||||
// how escapes reached the board's detail view.
|
||||
MetadataRow::Other(text) => result.push_str(&colorize_bold(text, colored)),
|
||||
}
|
||||
result.push('\n');
|
||||
}
|
||||
@@ -571,10 +580,6 @@ pub fn is_unknown_value(value: &str) -> bool {
|
||||
trimmed == "_None_" || trimmed == "_Not set_" || trimmed == "-None-" || trimmed == "-Not set-"
|
||||
}
|
||||
|
||||
pub fn colorize_line(line: &str) -> String {
|
||||
colorize_bold(line, should_use_colors())
|
||||
}
|
||||
|
||||
/// Replace `**bold**` with colour, or leave the line exactly as it is.
|
||||
///
|
||||
/// Taking `enabled` rather than asking makes both paths testable, and the
|
||||
@@ -600,7 +605,9 @@ fn colorize_bold(line: &str, enabled: bool) -> String {
|
||||
match (i + 2..chars.len()).find(|&at| is_delimiter(&chars, at)) {
|
||||
Some(close) => {
|
||||
let bold: String = chars[i + 2..close].iter().collect();
|
||||
result.push_str(&color_text(&bold, Color::Magenta));
|
||||
// `enabled`, not `should_use_colors()`. Asking again here made the
|
||||
// flag a lie: the early return above respected it and this did not.
|
||||
result.push_str(&paint(&bold, Color::Magenta, enabled));
|
||||
i = close + 2;
|
||||
}
|
||||
// Unterminated: the rest is literal. The old scan walked off the end
|
||||
@@ -1152,6 +1159,20 @@ pub fn parse_priority(content: &str) -> Priority {
|
||||
priority_from_value(&parse_ticket_field(content, "Priority"))
|
||||
}
|
||||
|
||||
/// How far along a ticket is: criteria ticked against criteria written.
|
||||
///
|
||||
/// `total` is never zero. A ticket with no criteria has no progress to show, and a card
|
||||
/// reading `[0/0]` says less than a card saying nothing, so the absence is `None`.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Progress {
|
||||
pub met: usize,
|
||||
pub total: usize,
|
||||
}
|
||||
|
||||
/// `Clone` because the board's All tab holds the same ticket twice: once under its
|
||||
/// own project's tab and once in the merge across projects. Re-reading the file for
|
||||
/// the second copy would scan every tree twice on every tick that changed anything.
|
||||
#[derive(Clone)]
|
||||
pub struct TicketItem {
|
||||
pub title: String,
|
||||
pub owner: String,
|
||||
@@ -1159,11 +1180,42 @@ pub struct TicketItem {
|
||||
pub id: String,
|
||||
pub created: String,
|
||||
pub priority: Priority,
|
||||
/// Ticked against total, or `None` for a ticket with no criteria.
|
||||
///
|
||||
/// Counted where the file is already being read, so the board pays nothing for it
|
||||
/// beyond the count itself: the alternative, counting per card, would re-read every
|
||||
/// ticket body on every draw rather than on the tick that changed something. The
|
||||
/// listing ignores it, as it ignores `path`.
|
||||
pub criteria: Option<Progress>,
|
||||
/// The file this came from. The listing ignores it; the TUI opens it for the
|
||||
/// detail view rather than resolving the ticket a second time.
|
||||
pub path: std::path::PathBuf,
|
||||
}
|
||||
|
||||
/// The date part of a due value, for a view with only a corner to spend on it.
|
||||
///
|
||||
/// The field is not validated, see daa0e79, so it holds whatever a caller typed: a bare
|
||||
/// date, a date and a time, or free text. Only a real `YYYY-MM-DD` prefix is cut back
|
||||
/// to. Taking the first word regardless would turn a free-text due into its first word,
|
||||
/// which is worse than showing what is stored and letting the column decide.
|
||||
pub fn due_date(due: &str) -> &str {
|
||||
let candidate = due.split([' ', 'T']).next().unwrap_or(due);
|
||||
match is_ymd(candidate) {
|
||||
true => candidate,
|
||||
false => due,
|
||||
}
|
||||
}
|
||||
|
||||
fn is_ymd(value: &str) -> bool {
|
||||
let bytes = value.as_bytes();
|
||||
bytes.len() == 10
|
||||
&& bytes[4] == b'-'
|
||||
&& bytes[7] == b'-'
|
||||
&& [0, 1, 2, 3, 5, 6, 8, 9]
|
||||
.iter()
|
||||
.all(|at| bytes[*at].is_ascii_digit())
|
||||
}
|
||||
|
||||
/// Grey for a value that is not set, per the colour guideline.
|
||||
///
|
||||
/// `show` already did this in its metadata rendering, so the listing was the one
|
||||
@@ -1265,6 +1317,18 @@ pub fn collect_ticket_items(status_path: impl AsRef<Path>) -> Result<Vec<TicketI
|
||||
let filename = e.path().file_stem()?.to_string_lossy().to_string();
|
||||
let created_at = parse_ticket_field(&content, "Created At");
|
||||
|
||||
// Through `criteria()`, so the card and the numbers `show` prints cannot
|
||||
// disagree: a checkbox written into a description is not a criterion there
|
||||
// and is not counted here.
|
||||
let counted = criteria(&content);
|
||||
let progress = match counted.len() {
|
||||
0 => None,
|
||||
total => Some(Progress {
|
||||
met: counted.iter().filter(|criterion| criterion.checked).count(),
|
||||
total,
|
||||
}),
|
||||
};
|
||||
|
||||
Some(TicketItem {
|
||||
title,
|
||||
owner,
|
||||
@@ -1272,21 +1336,28 @@ pub fn collect_ticket_items(status_path: impl AsRef<Path>) -> Result<Vec<TicketI
|
||||
id: short_id(&filename).to_string(),
|
||||
created: format_created_at(&created_at),
|
||||
priority: parse_priority(&content),
|
||||
criteria: progress,
|
||||
path: e.path(),
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Priority first, title as the tiebreak, which is what the sort used to be.
|
||||
items.sort_by(|a, b| {
|
||||
a.priority
|
||||
.rank()
|
||||
.cmp(&b.priority.rank())
|
||||
.then_with(|| a.title.to_lowercase().cmp(&b.title.to_lowercase()))
|
||||
});
|
||||
items.sort_by(by_priority_then_title);
|
||||
Ok(items)
|
||||
}
|
||||
|
||||
/// The order a status column is read in: priority first, title as the tiebreak.
|
||||
///
|
||||
/// Named and exported because the board's All tab merges several boards' columns into
|
||||
/// one and has to land in the order the listing uses. A merge sorted a second way
|
||||
/// would put a p1 below a p5 depending on which project it came from.
|
||||
pub fn by_priority_then_title(a: &TicketItem, b: &TicketItem) -> std::cmp::Ordering {
|
||||
a.priority
|
||||
.rank()
|
||||
.cmp(&b.priority.rank())
|
||||
.then_with(|| a.title.to_lowercase().cmp(&b.title.to_lowercase()))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -1552,6 +1623,131 @@ mod tests {
|
||||
assert_eq!(rendered, format!("Priority {glyph} _Not set_\n"));
|
||||
}
|
||||
|
||||
/// A ticket with the two things that used to leak: a numbered plan, and a
|
||||
/// hand-written line inside the Metadata section.
|
||||
const BOTH_LEAKS: &str = "# T\n\n## Implementation Plan\n1. First step\n2. Second step\n\
|
||||
\n## Metadata\n\n- **ID**: abc\nA **handwritten** note\n";
|
||||
|
||||
/// The bug: the board asks for `content_trim(content, false)` because a paragraph
|
||||
/// is no place for an escape sequence, and two paths asked the terminal instead.
|
||||
#[test]
|
||||
fn the_body_carries_no_escape_when_the_colour_is_off() {
|
||||
let rendered = content_trim(BOTH_LEAKS, false);
|
||||
|
||||
assert!(
|
||||
!rendered.contains('\x1b'),
|
||||
"an escape survived colour being off: {rendered:?}"
|
||||
);
|
||||
// And the content is all still there, in plain form.
|
||||
assert!(rendered.contains("1. First step"), "{rendered:?}");
|
||||
assert!(rendered.contains("**handwritten**"), "{rendered:?}");
|
||||
}
|
||||
|
||||
/// The other half of the pair, and the one that makes the first mean something:
|
||||
/// with the flag on, both paths still colour. Without this, the passing test above
|
||||
/// could be a colouring path that was simply deleted.
|
||||
#[test]
|
||||
fn the_body_colours_the_plan_number_and_a_metadata_note_when_the_colour_is_on() {
|
||||
let rendered = content_trim(BOTH_LEAKS, true);
|
||||
|
||||
assert!(
|
||||
rendered.contains(&format!("{}1.", Color::Cyan.ansi())),
|
||||
"the plan number lost its colour: {rendered:?}"
|
||||
);
|
||||
assert!(
|
||||
rendered.contains(&format!("{}handwritten", Color::Magenta.ansi())),
|
||||
"the bold run lost its colour: {rendered:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The flag has to be the only thing that decides, or the disabled path is just
|
||||
/// the terminal's answer in disguise — which is why the leak survived a test
|
||||
/// asserting the detail view holds no escapes. In a test binary there is no tty,
|
||||
/// so `should_use_colors()` is false and the leaking branch was never taken.
|
||||
#[test]
|
||||
fn nothing_the_body_renders_asks_the_terminal_for_the_colour_decision() {
|
||||
let callers = callers_of_color_text(include_str!("util.rs"));
|
||||
|
||||
// `ambiguous` is the one that may: it builds the candidate list for a failed
|
||||
// search, reaches the user on stderr, and is not reachable from `content_trim`.
|
||||
assert_eq!(
|
||||
callers,
|
||||
vec!["ambiguous".to_string()],
|
||||
"`color_text` asks `should_use_colors()`. Everything reachable from \
|
||||
`content_trim` has to take the decision as an argument and pass it to \
|
||||
`paint` instead, because the board renders with colour off and an escape \
|
||||
in a ratatui paragraph is drawn as literal bytes. If the new caller really \
|
||||
is CLI-only, add it here and say why."
|
||||
);
|
||||
}
|
||||
|
||||
/// Which functions in this file call `color_text`, by name, definitions and the
|
||||
/// test module excluded.
|
||||
fn callers_of_color_text(source: &str) -> Vec<String> {
|
||||
let body = match source.find("\n#[cfg(test)]") {
|
||||
Some(end) => &source[..end],
|
||||
None => source,
|
||||
};
|
||||
|
||||
let mut current = String::new();
|
||||
let mut callers = Vec::new();
|
||||
for line in body.lines() {
|
||||
if let Some(rest) = line.strip_prefix("fn ").or_else(|| line.strip_prefix("pub fn ")) {
|
||||
current = rest.split('(').next().unwrap_or_default().to_string();
|
||||
continue;
|
||||
}
|
||||
if line.contains("color_text(") && !callers.contains(¤t) {
|
||||
callers.push(current.clone());
|
||||
}
|
||||
}
|
||||
|
||||
callers
|
||||
}
|
||||
|
||||
/// The field is not validated, see daa0e79, so the card cannot trust it to be a
|
||||
/// bare date. Only a real date prefix is cut back to: free text is left alone,
|
||||
/// since turning "next friday" into "next" would be a worse answer than the width.
|
||||
#[test]
|
||||
fn a_due_value_is_cut_back_to_its_date_only_when_it_has_one() {
|
||||
assert_eq!(due_date("2026-12-31"), "2026-12-31");
|
||||
assert_eq!(due_date("2026-12-31 09:30:00"), "2026-12-31");
|
||||
assert_eq!(due_date("2026-12-31T09:30:00Z"), "2026-12-31");
|
||||
assert_eq!(due_date("_Not set_"), "_Not set_");
|
||||
assert_eq!(due_date("next friday"), "next friday");
|
||||
assert_eq!(due_date("2026-1-1 09:30"), "2026-1-1 09:30");
|
||||
}
|
||||
|
||||
/// The count on a card comes from `criteria()`, the same function that numbers them
|
||||
/// in `show`, so the two cannot disagree about what a criterion is.
|
||||
#[test]
|
||||
fn collect_ticket_items_counts_the_criteria_show_would_number() {
|
||||
let dir = std::env::temp_dir().join(format!("worklane-count-{}", uuid::Uuid::new_v4()));
|
||||
fs::create_dir_all(&dir).unwrap();
|
||||
|
||||
let write = |name: &str, body: &str| {
|
||||
fs::write(
|
||||
dir.join(format!("11111111-0000-4000-8000-00000000000{name}.md")),
|
||||
format!("# T{name}\n\n{body}\n\n## Metadata\n\n- **Owner**: alice\n"),
|
||||
)
|
||||
.unwrap();
|
||||
};
|
||||
|
||||
// A checkbox in the description is not a criterion, in either view.
|
||||
write(
|
||||
"1",
|
||||
"## Description\n- [x] not a criterion\n\n## Acceptance Criteria\n- [x] One\n- [ ] Two",
|
||||
);
|
||||
write("2", "## Acceptance Criteria\n_No acceptance criteria provided._");
|
||||
|
||||
let items = collect_ticket_items(&dir).unwrap();
|
||||
let counted: Vec<Option<Progress>> = items.iter().map(|item| item.criteria).collect();
|
||||
|
||||
assert!(counted.contains(&Some(Progress { met: 1, total: 2 })), "{counted:?}");
|
||||
assert!(counted.contains(&None), "a ticket with no criteria got a count: {counted:?}");
|
||||
|
||||
fs::remove_dir_all(&dir).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_section_rule_matches_the_width_of_its_name() {
|
||||
let rendered = content_trim_colored("# T\n\n## Description\nbody\n");
|
||||
|
||||
@@ -13,6 +13,20 @@ fn setup_worklane(temp: &TempDir) {
|
||||
}
|
||||
}
|
||||
|
||||
/// A project inside the temp directory, for the path arguments. The temp directory
|
||||
/// itself is left without a board, so a path that resolves has to resolve to this one.
|
||||
fn setup_project(temp: &TempDir, name: &str) -> std::path::PathBuf {
|
||||
let project = temp.child(name);
|
||||
let worklane = project.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
|
||||
for dir in ["backlog", "committed", "reviewing", "done"] {
|
||||
worklane.child(dir).create_dir_all().unwrap();
|
||||
}
|
||||
|
||||
project.path().to_path_buf()
|
||||
}
|
||||
|
||||
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(args);
|
||||
@@ -69,6 +83,60 @@ fn an_unknown_subcommand_is_still_a_usage_error() {
|
||||
assert_eq!(run(&temp, &["--bogus"]).status.code(), Some(2));
|
||||
}
|
||||
|
||||
/// A path argument is resolved before the terminal is, the same way the working
|
||||
/// directory is: reaching the tty complaint is what says the board was found.
|
||||
#[test]
|
||||
fn a_path_argument_names_the_board_to_open() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let project = setup_project(&temp, "project");
|
||||
|
||||
// Run from a directory with no board of its own, so only the argument can find one.
|
||||
let out = run(&temp, &["tui", project.to_str().unwrap()]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{stderr:?}");
|
||||
assert!(stderr.contains("needs a terminal"), "{stderr:?}");
|
||||
}
|
||||
|
||||
/// And several of them, which is the point of taking paths at all.
|
||||
#[test]
|
||||
fn several_path_arguments_are_accepted() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let first = setup_project(&temp, "first");
|
||||
let second = setup_project(&temp, "second");
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&["tui", first.to_str().unwrap(), second.to_str().unwrap()],
|
||||
);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{stderr:?}");
|
||||
assert!(stderr.contains("needs a terminal"), "{stderr:?}");
|
||||
}
|
||||
|
||||
/// With several paths, "No .worklane directory found" does not say which one was wrong.
|
||||
#[test]
|
||||
fn a_path_with_no_board_is_named_in_the_failure() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let project = setup_project(&temp, "project");
|
||||
|
||||
let elsewhere = temp.child("elsewhere");
|
||||
elsewhere.create_dir_all().unwrap();
|
||||
let path = elsewhere.path().to_str().unwrap().to_string();
|
||||
|
||||
// The first path resolves, the second does not.
|
||||
let out = run(&temp, &["tui", project.to_str().unwrap(), &path]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{stderr:?}");
|
||||
assert!(stderr.contains(&path), "the failing path is not named: {stderr:?}");
|
||||
assert!(
|
||||
stderr.contains("No .worklane directory found"),
|
||||
"the usual message is gone: {stderr:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// `tui` has to appear in the help, or nothing points at it.
|
||||
#[test]
|
||||
fn the_help_lists_the_tui_command() {
|
||||
|
||||
Reference in New Issue
Block a user