(61879a4) Surface campaigns on the board, and bump to 0.20.0

A card label and a frame, not a campaign tab. A tab had to say what its
columns are, and a campaign groups across the flow rather than within one
status, so the answer is the four columns filtered: a filter on the board
it already has, not a fifth tab.

So a card names its campaign on the label row, before the tags, marked ~
and bold, and the row drops the tags whole before it drops the campaign.
`c` opens a picker; taking a campaign filters every column to its members
and draws a frame above them carrying the id, the codename, the name, the
opening line of the description and the standing. The standing comes from
the columns, since while a campaign is selected the columns are its
members. `q` takes off one layer at a time: the overlay, the filter, the
board.

The label needs something to say, which the stored uuid is not, so
campaigns gained `Codename`: one word, `v1` or `beaver`, written by
`campaign add --codename` and validated at parse time. `campaign ls`
prints it and `resolve_in` gained an exact-codename tier above the uuid
prefix, or it would be a field you can read and cannot type. Only
campaigns carry the field, so the tier is empty for a ticket and ticket
resolution is unchanged.

The campaigns index is read once per project in `columns_of`, on the pass
that already builds the cards, and `digest` now watches the campaigns
directory: without it a campaign filed elsewhere never reached the picker.
`frame_rows` grew a row, so the two bools deciding the geometry became one
`Chrome` and the row indices are named.

Left out and filed as d637288: nothing can give a codename to a campaign
that is already on the board.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ansho Rei
2026-08-23 12:09:07 +02:00
co-authored by Claude Opus 5
parent c65e1b4ed7
commit 528566d103
13 changed files with 1945 additions and 104 deletions
+111 -8
View File
@@ -389,14 +389,22 @@ fn status_paths(worklane_dir: &Path) -> Vec<(String, std::path::PathBuf)> {
.collect()
}
/// The three-tier search, run over `dirs`, returning the first tier that matched
/// The four-tier search, run over `dirs`, returning the first tier that matched
/// anything.
///
/// Three tiers, filled in one pass and consulted in order. A uuid prefix has to win
/// Four tiers, filled in one pass and consulted in order. A uuid prefix has to win
/// outright rather than join a flat list: ticket titles reference other tickets by id,
/// so an exact prefix match was reported as ambiguous against whichever title happened
/// to mention it.
///
/// **An exact codename wins over all three.** It is the one tier that is an exact match on
/// a field written for the purpose, so it cannot be a coincidence the way a substring can,
/// and a codename of `v1` is too short to be tried as an id at all. Only campaigns carry
/// the field, so for a ticket the tier is always empty and resolution is exactly what it
/// was. It lives here rather than in a campaign-only path for the reason the rest of this
/// function is shared: that would be a second copy of the precedence rules and a second
/// ambiguity message.
///
/// Shared by tickets and campaigns rather than written twice. A campaign is addressed
/// exactly the way a ticket is, and a second resolver would be a second copy of the
/// precedence rules to keep in step. Each entry pairs the name a match is reported
@@ -405,6 +413,7 @@ pub fn resolve_in(search: &str, dirs: &[(String, std::path::PathBuf)]) -> Result
let search_lower = search.to_lowercase();
let long_enough_for_an_id = search.chars().count() >= MIN_ID_SEARCH;
let mut by_codename: Vec<Found> = Vec::new();
let mut by_id: Vec<Found> = Vec::new();
let mut by_title: Vec<Found> = Vec::new();
let mut by_filename: Vec<Found> = Vec::new();
@@ -429,12 +438,17 @@ pub fn resolve_in(search: &str, dirs: &[(String, std::path::PathBuf)]) -> Result
.unwrap_or_default();
let uuid = filename.split('_').next().unwrap_or("");
// Case insensitive like the other three: a codename typed back off a listing
// has to resolve whatever case it was read in, which is the bargain the id
// tier already takes.
let is_codename = parse_codename(&content)
.is_some_and(|codename| codename.to_lowercase() == search_lower);
let by_prefix = long_enough_for_an_id && uuid.to_lowercase().starts_with(&search_lower);
let in_title = title.to_lowercase().contains(&search_lower);
// Still reaches the middle of a uuid, which the prefix tier cannot.
let in_filename = filename.to_lowercase().contains(&search_lower);
if !(by_prefix || in_title || in_filename) {
if !(is_codename || by_prefix || in_title || in_filename) {
continue;
}
@@ -444,7 +458,9 @@ pub fn resolve_in(search: &str, dirs: &[(String, std::path::PathBuf)]) -> Result
content,
uuid: uuid.to_string(),
};
if by_prefix {
if is_codename {
by_codename.push(found);
} else if by_prefix {
by_id.push(found);
} else if in_title {
by_title.push(found);
@@ -454,10 +470,11 @@ pub fn resolve_in(search: &str, dirs: &[(String, std::path::PathBuf)]) -> Result
}
}
Ok(match (by_id.is_empty(), by_title.is_empty()) {
(false, _) => by_id,
(true, false) => by_title,
(true, true) => by_filename,
Ok(match (by_codename.is_empty(), by_id.is_empty(), by_title.is_empty()) {
(false, _, _) => by_codename,
(true, false, _) => by_id,
(true, true, false) => by_title,
(true, true, true) => by_filename,
})
}
@@ -846,6 +863,13 @@ fn metadata_value_cell(name: &str, value: &str, colored: bool, campaign: &str) -
return paint(value, Color::Grey, colored);
}
// The same word in the same colour as the label a card draws, since `tag_color` is a
// pure function of it. No mark here: the field name has already said what this is,
// and the mark is what tells a campaign from a tag on a row that holds both.
if name == CODENAME_FIELD {
return paint(value, tag_color(value), colored);
}
if name == "Tags" {
return paint_tags(value, colored);
}
@@ -1133,6 +1157,66 @@ pub fn set_metadata_field(content: &str, field: &str, value: &str, title: &str)
/// board.
pub const CAMPAIGN_FIELD: &str = "Campaign";
/// The metadata field naming a campaign in a word, beside the uuid that addresses it.
///
/// A campaign is filed for a release or a migration, and those have names people already
/// use: `v1`, `beaver`. The uuid is what everything stores and the title is a sentence, so
/// neither is what a card has room to print. This is the short form, written by
/// `campaign add --codename` and nothing else.
///
/// Optional, and a campaign without one is not a lesser campaign: every campaign filed
/// before this existed has no field at all, which reads as unset the way an absent
/// Campaign field does.
pub const CODENAME_FIELD: &str = "Codename";
/// The mark a campaign carries where it is drawn as a label.
///
/// Not `#`, which is the tag marker: the two sit on the same row of a card and the row
/// would read as one list of tags with a stranger in it. A tilde is ASCII, so it renders
/// wherever `#` does, and it is not `@`, which reads as a person on every board anyone
/// has used.
///
/// One glyph, so the campaign on a card and the campaign in the picker are the same
/// thing said the same way.
pub const CAMPAIGN_MARK: &str = "~";
/// The campaign codename a file names, or nothing when it names none.
///
/// Absent, unset and empty are one answer, the bargain [`parse_campaign`] and
/// [`parse_tags`] both take: a campaign filed before the field existed carries no line at
/// all, and one whose line reads `_Not set_` has no codename either.
pub fn parse_codename(content: &str) -> Option<String> {
let value = parse_ticket_field(content, CODENAME_FIELD);
match is_unknown_value(&value) || value.trim().is_empty() {
true => None,
false => Some(value.trim().to_string()),
}
}
/// A campaign as a label: the mark, then the codename, or the short id when it has none.
///
/// The id is the fallback rather than the title, which is a sentence and would not fit the
/// row this is drawn on. It says little, which is the whole reason the codename field
/// exists, but it is addressable: `campaign show` takes it.
///
/// **A codename takes its own colour from [`tag_color`] and the fallback takes grey.** The
/// colour is what groups a campaign across the cards that carry it, and one word is one
/// colour in every view for the same reason a tag is. Grey on the id, rather than the red
/// a uuid is drawn in everywhere else, keeps a reserved meaning off a `TAG_COLORS` slot in
/// the one case where the label is an id: grey already means what a reader skips, which is
/// what a campaign with no codename has to say for itself.
///
/// A `Cell`, not a string, so the CLI paints it and the board makes a span of it, the way
/// a relation row already works. The bold is the board's: it is there to win a row against
/// the tags, and nothing in the CLI shares a line with them.
pub fn campaign_label(uuid: &str, codename: Option<&str>) -> Cell {
match codename {
Some(codename) => Cell::colored(format!("{CAMPAIGN_MARK}{codename}"), tag_color(codename)),
None => Cell::colored(format!("{CAMPAIGN_MARK}{}", short_id(uuid)), Color::Grey),
}
}
/// The campaign uuid a ticket names, or nothing when it names none.
///
/// Absent and unset are the same answer: a ticket that has never been assigned has no
@@ -1574,6 +1658,25 @@ fn section_body(lines: &[&str], heading: &str) -> Option<std::ops::Range<usize>>
Some(after..section_end(lines, after))
}
/// The first line of a section's body, or nothing when the section is absent or holds
/// only its placeholder.
///
/// For a view with one row to spend on prose: the board's campaign frame and its picker
/// both want the opening line of a description and have no room for the rest. Through
/// [`section_body`] rather than a scan of its own, so what counts as the section is
/// decided in one place, and the placeholder reads as nothing here the way it does to
/// `append`.
pub fn section_opening(content: &str, section: &Section) -> Option<String> {
let lines: Vec<&str> = content.lines().collect();
let body = section_body(&lines, section.heading)?;
lines[body]
.iter()
.map(|line| line.trim())
.find(|line| !line.is_empty() && *line != section.placeholder)
.map(|line| line.to_string())
}
/// Where the body's content ends, ignoring the blank lines that separate it from
/// whatever follows.
fn body_content_end(lines: &[&str], body: &std::ops::Range<usize>) -> usize {