Compare commits

...
1 Commits
Author SHA1 Message Date
Ansho Rei 8e7a3f1425 Fix tags in tui on narrow screen, and bump to 0.33.9 2026-11-06 17:45:49 +01:00
4 changed files with 180 additions and 32 deletions
Generated
+1 -1
View File
@@ -1563,7 +1563,7 @@ dependencies = [
[[package]]
name = "worklane"
version = "0.33.8"
version = "0.33.9"
dependencies = [
"anyhow",
"assert_cmd",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "worklane"
version = "0.33.8"
version = "0.33.9"
edition = "2024"
[dependencies]
+5 -3
View File
@@ -20,7 +20,7 @@ The TUI: the columns, the cards, the frame, the pickers and the footer.
- **`wrapped_height` is the one measurement.** `last_offset` is it less the viewport and `page_indicator` takes the same two numbers, so the clamp and the indicator cannot disagree. A second `line_count` call, or a count of the raw lines, is a number free to drift, and an indicator that says there is more to read where the scroll refuses to move is worse than none
- **The furthest offset is the last page by definition, not by division.** The clamp stops at the wrapped height less the viewport, which is not a page boundary, so the final screenful is partial: `offset / step + 1` reads `pg 2/3` at the bottom of a 25 row ticket in a 10 row viewport and claims there is more below
- **The pages are counted in `scroll_step`, a screenful less the overlap line, not in whole screenfuls.** The step is what the keys take, so counting in it names only pages `pgdn` can land on. Counting by screenfuls puts a 30 row ticket in a 10 row viewport at `pg 3/3` two rows short of its end, since three presses are what it takes to get there
- The indicator is dropped whole on an overlay too narrow for it, the rule a corner and the tags row already follow, and absent entirely when nothing scrolls, the way an untagged card spends no row on tags
- The indicator is dropped whole on an overlay too narrow for it, the rule a corner follows, and absent entirely when nothing scrolls, the way an untagged card spends no row on tags
- `page_indicator` takes four numbers and returns an `Option<String>`, so every case above is pinned without a terminal. The drawn tests exist for the two things arithmetic cannot answer: which border it landed on and what colour it reached the screen in
- **Columns scroll to keep the selected card in view.** `Board::offsets` holds one offset per column, parallel to `columns` and resized in step by `reload`, so a column you leave stays where it was. The keypress aligns the focused column via `follow_selection(screen)`, taking the screen size for the same reason `scroll_detail` does: the visible height belongs to the terminal, which only the caller measures between draws
- Card heights are measured on `card_lines`, never assumed, on both the keypress and the draw side (`card_height`, and the `starts` vec as the cards are built). An alignment that trusted a fixed card height would drift from the renderer the first time the card changed shape
@@ -46,7 +46,7 @@ The TUI: the columns, the cards, the frame, the pickers and the footer.
- **The comment count is the same field discipline and the one entry on that pass that costs a directory listing.** The history lives outside the ticket file, so `count_comments` is a `read_dir` rather than a parse: `.md` only, the filter `read_history` applies, and no body is read, because a count needs none of them. **It counts comments and not entries**, off the kind in the filename, so a card still says how many things somebody said: a ticket that has moved three times has not been talked about, and counting the moves would put a number on every card on the board. `collect_ticket_items` derives the board from `status_path.parent()` instead of taking it as a second argument, so a status directory from one board cannot arrive with the history of another. `history_dir` spells the path once for the writer, the reader and the counter, the way `campaigns_dir` does. Zero draws nothing, not a `0` and not a blank: an uncommented card is the row it has always been, which `a_card_with_no_comments_spends_nothing_on_the_corner` pins to the exact spacing
- **The count is cyan and the mark is `COMMENT_MARK`, U+275E, a Dingbat.** It is the only coloured thing on a row whose owner and criteria count are grey, because two counts side by side otherwise read as one number in brackets and another that lost its brackets. Not U+1F4AC SPEECH BALLOON: emoji presentation and East Asian Width Wide, so it draws two cells where `spans_width` counts one character and every corner on the card lands a cell out. Not U+1F5E8 LEFT SPEECH BUBBLE either: text presentation and Neutral, but in a pictograph block most terminal fonts leave as tofu. Check both properties before swapping the glyph
- **`the_count_is_read_when_the_items_are_collected_and_not_per_draw` takes the history directory away after the board is built**, and is paired with `a_comment_added_after_the_board_was_built_reaches_the_card_on_reload`, because a count that never asks the filesystem again would pass the first test by never changing. The digest already moves when a comment lands, so the reload is what recounts
- **A card names its campaign on the label row, before the tags, in bold.** `labels_line` draws both, `CAMPAIGN_MARK` (`~`) for the campaign and `#` for a tag, and the campaign takes the row's width first: two cards in one campaign is what a reader looking for a campaign is looking for, and the tags are the context around it. So a row too narrow for both drops the tags whole and keeps the campaign, the order `corner_line` and `project_label` already follow, and a campaign the row will not hold at all goes whole too. A ticket in neither spends no row, so **a ticket in no campaign renders exactly as it did before campaigns reached the card**
- **A card names its campaign on the label row, before the tags, in bold.** `labels_line` draws both, `CAMPAIGN_MARK` (`~`) for the campaign and `#` for a tag, and the campaign takes the row's width first: two cards in one campaign is what a reader looking for a campaign is looking for, and the tags are the context around it. So a row too narrow for both gives up tags until the two fit and keeps the campaign, the order `corner_line` and `project_label` already follow, and a campaign the row will not hold at all goes whole too. A ticket in neither spends no row, so **a ticket in no campaign renders exactly as it did before campaigns reached the card**
- **`Card::campaign` is a resolved `Cell`, not a uuid**, settled at reload the way `project` and `blocked` are. `TicketItem::campaign` already carries the uuid off the pass that builds the card; the name is in another directory, so `columns_of` reads `CampaignIndex` once per project and hands it to every card. Never per draw, the rule `criteria` and `tags` already hold. The merge carries the resolved cell rather than looking it up again, for the reason it carries `blocked`: a campaign is addressed inside one `.worklane`, so a merged lookup could answer one project's uuid with another project's campaign
- **A campaign the board does not hold labels nothing**, the answer `mark_blocked` gives a dangling blocker. `campaign_cells` renders that case as `_missing_` because a metadata table is a place to report a dangling reference; a card is not
- **`c` opens the campaign picker, and taking a campaign filters the tab's columns to its members.** Not a fifth tab: a campaign groups across the flow, so the shape of the answer is the statuses with fewer cards in them, which is what `campaign show` already answers the question in. Every column is kept, empty ones included. The filter is applied in `reload`, where the columns are built, so nothing downstream has to ask whether a campaign is selected — the board simply holds fewer cards, and `first_match`, `column_count` and the copy key all keep working unchanged
@@ -100,7 +100,9 @@ The TUI: the columns, the cards, the frame, the pickers and the footer.
- **`Tab::standing` is gone with it.** The frame's standing is the row's, because two counts of one number are two numbers free to drift — the rule `wrapped_height` holds for the scroll. `the_standings_are_read_when_the_cards_are_and_not_per_draw` takes the status directories away after the board is built, paired with `a_member_finished_after_the_board_was_built_completes_its_campaign` for the reason the comment count's two tests are paired: a standing that never asked the filesystem again would pass the first by never changing
- **`q` takes off one layer at a time, in the order they were put on**: the overlay, then the campaign filter, then the board. `Board::dismiss` holds all three, and it takes the screen now because clearing the filter reloads and has to follow the selection. Selecting a campaign closes an open ticket, the answer hiding the done column already gives: the ticket may not be on the filtered board at all, and swapping it for a different one without saying so is how a person acts on the wrong ticket
- **`digest` watches the campaigns directory** as well as the statuses and the history. A campaign filed elsewhere has to reach the picker and a codename edited by hand has to reach every card that names it, and a directory's own mtime would miss the edit
- **The tags go under the title, dimmed, each prefixed with `#`.** The field was invisible on the board: nothing said a ticket was tagged `bug` without opening it. The marker is what stops the row reading as a third line of the title, since a tag is an ordinary word and the title sits directly above it. The row is dropped whole when the column will not hold it, the rule a corner follows, and an untagged ticket spends no row at all, the way a short title spends no second one
- **The tags go under the title, dimmed, each prefixed with `#`.** The field was invisible on the board: nothing said a ticket was tagged `bug` without opening it. The marker is what stops the row reading as a third line of the title, since a tag is an ordinary word and the title sits directly above it. An untagged ticket spends no row at all, the way a short title spends no second one
- **A row the column will not hold draws the tags that fit and ends in `(+n)`**, the count of the ones it left out. Whole tags only, the rule a corner follows: `bug` and `bugfix` cut to the same width say the same thing. What changed in 39be95b2 is the other half of that rule — the row used to go whole, so a narrow column, which is exactly where a reader is scanning cards for a tag, showed no tags at all. A short row is allowed as long as it says it is short, and the indicator is the entire difference between a cut list and one that reads as the ticket's whole list. So a row with no room for one tag beside the count is still dropped whole: `(+3)` alone tells nobody anything, and a tag drawn without the count would lie. `tags_that_fit` measures the indicator as part of the row it counts rather than reserving it up front, because `(+9)` and `(+10)` are different widths and a list of under ten should not pay for the tenth
- **The count is grey and parenthesised**, not a colour of its own and not bracketed: it is a fact about the row rather than another tag on it, and `[n/m]` two rows below is the criteria count
- `tags` is a field on `TicketItem`, filled in `collect_ticket_items` through `parse_tags`, for the reason the criteria count is. `parse_tags` splits the comma-separated field into whole trimmed values, so a caller asking for `bug` is not answered by `bugfix`, and reads absent, `_None_` and empty as the same answer
- **A held-up card carries `BLOCKED_MARK`, `×`, after its id, in brightred.** The constant lives in `util.rs` and the relations block draws the same one, since both say the same word. A ticket its blocker has not moved out of the way of looked exactly like one that is ready, and the board is where the next thing to pick up is chosen. The mark is `mv`'s own rule asked one column ahead, so it says this cannot advance rather than that a dependency was ever recorded: a card in committed whose blocker is in reviewing is unmarked, because reviewing is where it may go, and the same card is marked once it sits in reviewing and only done is left. The two terminal columns have no next stage and nothing in them is drawn blocked. Not a fourth circle from Geometric Shapes: those belong to the priority meter two cells away and would read as part of that ramp. The multiplication sign is Latin-1, like the middle dot the unset priority draws, so it renders wherever the meter does
- **The mark goes after the id, not before it.** Ahead of the id it would push every id in the column out of line whenever one card was blocked, which costs more than one card's state is worth. It is measured before the project label and the due date, so both give way to it: those are context for a ticket somebody can start, and this is the one thing on a card that says not to. Dropped whole when the row cannot hold the identity and the mark together, the rule a corner follows
+173 -27
View File
@@ -4557,11 +4557,19 @@ fn card_lines(card: &Card, selected: bool, width: u16) -> Vec<Line<'static>> {
/// use — the stronger fact takes the row and the weaker one gives way. Bold is what stops
/// it reading as another tag when a card carries five.
///
/// A row the column will not hold is dropped whole, the rule `corner_line` applies to a
/// corner: a cut list reads as a shorter one, and `bug` and `bugfix` truncated to the
/// same width say the same thing. A ticket with neither a campaign nor a tag spends no row
/// at all, the way a short title spends no second one, so a ticket in no campaign renders
/// exactly as it did before campaigns reached the card.
/// A row that will not hold every tag draws the ones it can and ends in `(+n)`, the count
/// of the ones it left out. No tag is ever cut in half, the rule `corner_line` applies to
/// a corner: `bug` and `bugfix` truncated to the same width say the same thing. What the
/// row may do is be short, as long as it says so — the indicator is the whole difference
/// between a list that was cut and one that reads as complete, which is why the row is
/// dropped whole when it cannot hold one tag and the indicator together. A cut list
/// without the count is the thing this must never draw. Parentheses rather than brackets,
/// which are the criteria count's two rows below, and grey like the owner and that count,
/// because it is a fact about the row rather than another tag on it.
///
/// A ticket with neither a campaign nor a tag spends no row at all, the way a short title
/// spends no second one, so a ticket in no campaign renders exactly as it did before
/// campaigns reached the card.
///
/// Each tag carries its own colour, from `tag_color`, so the same tag is the same
/// colour on every card in every column, and the campaign carries its own from
@@ -4578,21 +4586,13 @@ fn labels_line(campaign: Option<&Cell>, tags: &[String], width: u16) -> Option<L
// The space between the campaign and the first tag, which the row has to hold too.
let room = width.saturating_sub(used + usize::from(campaign.is_some()));
let row = tags
.iter()
.map(|tag| format!("#{tag}"))
.collect::<Vec<_>>()
.join(" ");
let tags: &[String] = match !row.is_empty() && row.chars().count() <= room {
true => tags,
false => &[],
};
let (tags, omitted) = tags_that_fit(tags, room);
if campaign.is_none() && tags.is_empty() {
return None;
}
let mut spans = Vec::with_capacity(tags.len() * 2 + 2);
let mut spans = Vec::with_capacity(tags.len() * 2 + 3);
if let Some(cell) = campaign {
spans
.push(span_of(cell.clone()).patch_style(Style::default().add_modifier(Modifier::BOLD)));
@@ -4605,9 +4605,70 @@ fn labels_line(campaign: Option<&Cell>, tags: &[String], width: u16) -> Option<L
spans.push(Span::styled(format!("#{tag}"), Style::default().fg(tag_color(tag).into())));
}
if omitted > 0 {
spans.push(Span::raw(" "));
spans.push(Span::styled(
omitted_label(omitted),
Style::default().fg(Color::Grey.into()),
));
}
Some(Line::from(spans))
}
/// How many tags `room` cells will hold, and how many that leaves over.
///
/// Whole tags only, single spaced, in the order the ticket carries them: the first tags
/// are the ones a reader is scanning for, and reordering them would mean the same ticket
/// reads differently in two columns of different widths.
///
/// The indicator is measured as part of the row it counts, not added to a row that was
/// already full, so the answer is the largest prefix whose tags **and** `(+n)` fit. It
/// shrinks as tags are dropped — `(+9)` for nine and `(+10)` for ten — so the fit is
/// recomputed against each candidate rather than reserved once up front, which would
/// spend a cell the row does not owe on every list of under ten.
///
/// A prefix of nothing and a count of everything is a row saying only how much it is not
/// showing, which is no use to anybody, so that case comes back as no tags at all and the
/// caller spends no row on it. Every other answer either shows every tag or says how many
/// it left out; a short list that reads as a complete one is the one thing this cannot
/// return.
fn tags_that_fit(tags: &[String], room: usize) -> (&[String], usize) {
// The whole list first, which is the common case and the only one that draws no
// indicator at all.
// The hash and the space before the next tag, less the space the first one does not pay.
let whole = tags
.iter()
.map(|tag| tag.chars().count() + 2)
.sum::<usize>()
.saturating_sub(1);
if !tags.is_empty() && whole <= room {
return (tags, 0);
}
let mut width = 0;
let mut kept = 0;
for (n, tag) in tags.iter().enumerate() {
// The space before this tag, which the first one does not pay.
width += tag.chars().count() + 1 + usize::from(n > 0);
// The space before the indicator is its own, the way the space before a tag is.
if width + 1 + omitted_label(tags.len() - n - 1).chars().count() > room {
break;
}
kept = n + 1;
}
match kept {
0 => (&[], 0),
kept => (&tags[..kept], tags.len() - kept),
}
}
/// The count of the tags a row left out, as it is drawn.
fn omitted_label(omitted: usize) -> String {
format!("(+{omitted})")
}
/// The project name as it fits beside whatever the row already carries.
///
/// The mark, the id and the blocked mark are the ticket's identity and its state, and
@@ -6536,23 +6597,101 @@ mod tests {
assert!(!rows.iter().any(|row| row.contains('#')), "{rows:?}");
}
/// A row too wide for the column goes whole, the rule a corner follows: a cut list
/// reads as a shorter one, and bug and bugfix cut to the same width say the same
/// thing.
/// A row that holds every tag draws every tag and says nothing about a count, which
/// is the common card and the one the indicator must not appear on.
#[test]
fn a_tag_row_too_wide_for_the_column_is_dropped_whole() {
fn a_row_that_holds_every_tag_spends_nothing_saying_so() {
let dir = board_dir();
write_tagged_card(&dir, "Short", "2026-12-31", "- [ ] One", "frontend, operations");
// One character short of "#frontend #operations", and one over it.
let narrow = only_card_at(&dir, 20);
assert_eq!(narrow.len(), 4, "the row was kept: {narrow:?}");
assert!(!narrow.iter().any(|row| row.contains('#')), "{narrow:?}");
// Exactly "#frontend #operations".
let fits = only_card_at(&dir, 21);
assert_eq!(fits[2], "#frontend #operations", "{fits:?}");
}
/// One character short of the whole list, the card draws what it can and counts the
/// rest. The row used to go whole there, so a narrow column — which is exactly where
/// a reader is scanning cards for a tag — showed no tags at all.
#[test]
fn a_row_too_narrow_for_every_tag_keeps_what_fits_and_counts_the_rest() {
let dir = board_dir();
write_tagged_card(&dir, "Short", "2026-12-31", "- [ ] One", "frontend, operations");
let narrow = only_card_at(&dir, 20);
assert_eq!(narrow.len(), 5, "the row was dropped: {narrow:?}");
assert_eq!(narrow[2], "#frontend (+1)", "{narrow:?}");
}
/// Whole tags only: half a tag is a different tag, and `bug` and `bugfix` cut to the
/// same width say the same thing. So the row gives up a tag before it gives up a
/// character of one, and what it draws stays inside the column.
#[test]
fn a_cut_row_cuts_whole_tags_and_stays_inside_the_column() {
let dir = board_dir();
write_tagged_card(&dir, "Short", "2026-12-31", "- [ ] One", "cli, tui, docs, tests");
for inner in 5..=23u16 {
let rows = only_card_at(&dir, inner);
let row = rows.iter().find(|row| row.contains('#'));
let Some(row) = row else { continue };
assert!(
row.chars().count() <= inner as usize,
"past the column at {inner}: {row:?}"
);
for word in row.split_whitespace().filter(|word| word.starts_with('#')) {
assert!(
["#cli", "#tui", "#docs", "#tests"].contains(&word),
"a tag was cut at {inner}: {row:?}"
);
}
}
}
/// The count is of the tags left out, not of the tags on the ticket, and it grows as
/// the column narrows rather than standing for whatever the first cut happened to be.
#[test]
fn the_indicator_counts_the_tags_the_row_left_out() {
let dir = board_dir();
write_tagged_card(&dir, "Short", "2026-12-31", "- [ ] One", "cli, tui, docs, tests");
assert_eq!(only_card_at(&dir, 20)[2], "#cli #tui #docs (+1)");
assert_eq!(only_card_at(&dir, 16)[2], "#cli #tui (+2)");
assert_eq!(only_card_at(&dir, 11)[2], "#cli (+3)");
}
/// A row with no room for one tag beside the count goes whole, as it always did: a
/// row saying only how many tags it is not showing is no use to anybody, and a tag
/// drawn without the count would read as the ticket's whole list.
#[test]
fn a_row_too_narrow_for_one_tag_and_the_count_is_dropped_whole() {
let dir = board_dir();
write_tagged_card(&dir, "Short", "2026-12-31", "- [ ] One", "frontend, operations");
// One short of "#frontend (+1)".
let narrow = only_card_at(&dir, 13);
assert_eq!(narrow.len(), 4, "the row was kept: {narrow:?}");
assert!(!narrow.iter().any(|row| row.contains('#')), "{narrow:?}");
}
/// The count is grey like the owner and the criteria count, not a colour of its own:
/// it is a fact about the row rather than another tag on it.
#[test]
fn the_indicator_is_drawn_in_grey_rather_than_as_a_tag() {
let dir = board_dir();
write_tagged_card(&dir, "Short", "2026-12-31", "- [ ] One", "frontend, operations");
let board = one_board(&dir);
let card = board.selected().expect("no card");
let colour = card_lines(card, false, 20)
.into_iter()
.flat_map(|line| line.spans)
.find(|span| span.content == "(+1)")
.map(|span| span.style.fg)
.expect("no indicator on the row");
assert_eq!(colour, Some(Color::Grey.into()));
}
/// And a title that fits gets one row, or the second is wasted on every short
/// ticket in the column.
#[test]
@@ -12556,7 +12695,9 @@ approach";
/// The campaign takes the row first and the tags give way, the order a corner and a
/// project label already follow: two cards in one campaign is what a reader looking
/// for a campaign is looking for, and the tags are the context around it.
/// for a campaign is looking for, and the tags are the context around it. They give
/// way a tag at a time, with the count for the ones that went, and give way whole
/// only when what the campaign left will not hold one tag and the count.
#[test]
fn the_campaign_keeps_the_row_and_the_tags_give_way() {
let dir = board_dir();
@@ -12564,11 +12705,16 @@ approach";
write_member_card(&dir, "Short", "frontend, operations", V1);
// One character short of "~v1 #frontend #operations", and one over it.
let narrow = only_card_at(&dir, 24);
assert_eq!(narrow[2], "~v1", "the tags took the row from the campaign: {narrow:?}");
let cut = only_card_at(&dir, 24);
assert_eq!(cut[2], "~v1 #frontend (+1)", "{cut:?}");
let fits = only_card_at(&dir, 25);
assert_eq!(fits[2], "~v1 #frontend #operations", "{fits:?}");
// One character short of "~v1 #frontend (+1)", where the tags have nothing left
// to give up and the campaign keeps the row alone.
let narrow = only_card_at(&dir, 17);
assert_eq!(narrow[2], "~v1", "the tags took the row from the campaign: {narrow:?}");
}
/// And a campaign the row will not hold goes whole, never cut: half a codename is a