Compare commits

..
1 Commits
Author SHA1 Message Date
Ansho ReiandClaude Opus 5 dd2b457bff (9b7fa7d) Expand the campaign frame with enter
Three rows of prose was the right default and the wrong ceiling. enter
while the frame holds the selection gives it half the board, enter again
gives the rows back, and pgup and pgdn go on doing what they do against
whichever height it is at.

Half of what the frame and the columns divide, which is the screen less
the tab row and the footer. Half rather than most of it for the same
reason the frame is not an overlay: the columns below are the campaign's
members, and a reader inspecting the campaign has to go on seeing what
it is made of. So `Chrome::campaign` is an `Option<FrameSize>` rather
than a bool and `campaign_rows` takes a height, resolved in `frame_rows`
because that is the one place that already has an area to take a share
of, which keeps `Chrome` itself pure.

Bounded at both ends, and the upper bound is the one that matters:
`Constraint::Min(COLUMN_MIN_ROWS)` would take rows back from a frame
that asked for too many, silently, and the frame's own measurement would
then disagree with what is drawn. Floored at the collapsed height, since
expanding must never shrink the frame, so a board too short to divide
gives the collapsed height back rather than one nothing measured. Swept
over every height from 4 to 60, tabbed and not.

q does not gain a layer and the arrow keys do not take the height back.
The expanded frame is the frame at its other height, not a thing laid
over the board, so q goes on taking the campaign filter off from either
and enter is the only key that undoes what enter did. The height
outlives the selection for the same reason: it is a view of the campaign
the reader chose, so the columns stay short with the selection on a
card. `dismiss` and `select_card` are untouched, and two tests pin that.

`enter` routes through `Board::toggle_focused` rather than in the
`main.rs` arm, the rule `dismiss` and `scroll_page` follow. It was inert
on the frame for free before, because `Tab::selected` hands back nothing
there and `toggle_detail` had nothing to open; that answer is now the
thing in the way, and AGENTS.md and `Tab::selected`'s doc are amended
rather than left describing the key by what it used to do.

The toggle re-clamps the frame offset through `scroll_frame(0, screen)`.
A taller viewport has a smaller last offset, so where the reader was can
end up past the end of the frame they just asked for, and the next pgup
would count down from a number the frame never showed.

Criterion 13 is not done: 2a83bd4 has not landed, so there is no tag
frame to give a second height to. What it inherits is on the ticket, and
all of it is generic rather than campaign-specific.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 03:08:39 +02:00
6 changed files with 509 additions and 24 deletions
+9 -4
View File
@@ -235,18 +235,23 @@ and this file is for what someone changing worklane's own code needs.
- **A campaign the board does not hold labels nothing**, the answer `mark_blocked` gives a dangling blocker. `campaign_cell` 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 four 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`, `done_count` and the copy key all keep working unchanged
- **`Tab::campaign` is a uuid on the tab, not on the `Board`.** A campaign belongs to one `.worklane`, so a filter carried onto another project's tab would empty it and say nothing about why. It is looked up by uuid rather than held as an index, and a selection whose campaign has left the board is cleared by `reload` rather than left filtering the board to nothing
- **The frame above the columns is `Chrome::CAMPAIGN_ROWS` rows, and `Chrome` is what every measurement takes.** `frame_rows` grew a row, so the two bools that decide the geometry became one `Chrome`, copied from `Board::chrome`: adjacent same-typed parameters are what the Rust Style rule warns about, and the draw and `follow_selection` have to measure one answer or a keypress scrolls against a board the next frame does not draw. The row indices are named (`TAB_ROW`, `CAMPAIGN_ROW`, `BOARD_ROW`, `FOOTER_ROW`), since an index written out by hand goes on meaning what it used to
- **The frame above the columns has two heights, and `Chrome` is what every measurement takes.** `Chrome::campaign` is an `Option<FrameSize>`, not a bool: `None` for a tab showing the whole board, and `Collapsed` or `Expanded` for one filtered to a campaign, because both heights have to be measured the same way by everything that measures the board. `frame_rows` grew a row, so the two bools that decide the geometry became one `Chrome`, copied from `Board::chrome`: adjacent same-typed parameters are what the Rust Style rule warns about, and the draw and `follow_selection` have to measure one answer or a keypress scrolls against a board the next frame does not draw. The row indices are named (`TAB_ROW`, `CAMPAIGN_ROW`, `BOARD_ROW`, `FOOTER_ROW`), since an index written out by hand goes on meaning what it used to
- **The whole description is carried off the one read, and the cut is on the view.** `section_prose` replaced `section_opening`, which cut to the opening line at read time: the campaign file is only in hand while the campaigns directory is being read, so what that read has to carry is everything a view might want, and `CampaignRow::summary` takes the one line the picker draws back off it. Two fields, one cut from the other, are two strings free to come from different reads of the same file
- **`CAMPAIGN_PROSE_ROWS` is a constant, not a height fitted to the description.** Three rows of prose plus a border either side. A frame that grew and shrank with the campaign would resize every column whenever the filter changed, and a reader would look for a card where the previous campaign's description had put it. It does not have to be right for the longest description, because scrolling is what covers the rest — which is also why three was affordable where one row was not
- **`CAMPAIGN_PROSE_ROWS` is the collapsed height, and it is a constant rather than a height fitted to the description.** Three rows of prose plus a border either side. A frame that grew and shrank with the campaign would resize every column whenever the filter changed, and a reader would look for a card where the previous campaign's description had put it. It does not have to be right for the longest description, because scrolling is what covers the rest — which is also why three was affordable where one row was not
- **The expanded height is a share, not a second constant: half of what the frame and the columns divide.** That is the screen less the tab row and the footer, so the split is even between the two of them rather than even against rows neither gets all of. Half rather than most of it for the same reason the frame is not an overlay: the columns below are the campaign's members, and a reader inspecting the campaign has to go on seeing what it is made of. Floored, so the odd row goes to the cards. `Chrome::campaign_rows` takes the height because of this, and `frame_rows` is where it is called, since that is the one place that already has an area to take a share of — which is what keeps `Chrome` itself pure and copyable from `Board::chrome` with no screen to hand
- **The share is bounded at both ends, and `COLUMN_MIN_ROWS` is why.** `Constraint::Min(COLUMN_MIN_ROWS)` would take rows back from a frame that asked for too many, silently, and the frame's own measurement would then disagree with what is drawn — the fault `Chrome` exists to prevent. So the share is capped at what leaves the columns those rows, and floored at `CAMPAIGN_ROWS`, since expanding must never shrink the frame. On a board too short to divide, `enter` gives the collapsed height back rather than a height nothing measured. `the_expanded_share_is_bounded_at_both_ends` sweeps every height from 4 to 60, tabbed and not, because one screen that happens to work says nothing about the arithmetic
- **The frame says the rest of what it has to say on its borders**, the trade the detail overlay makes with its title and its page indicator: `(id) ~codename · Name` on the top one, the standing on the bottom right, and `q board` then the page indicator on the bottom left. Every row spent here is a row of cards
- **The frame's page indicator goes on the bottom border beside `q board`, not on the top beside the title.** The title is cut against the border it sits on, so an indicator up there would shorten a long campaign name the moment its description grew past three rows; and the bottom right is the standing's, which is what the frame is *about* where the indicator is only where the reader has got to in it. Dropped before `q board` when the two cannot both fit, since with a campaign selected the footer's last slot names `ctrl-c quit` and the border is the only place that says `q` gives the board back
- **`Focus` is the third place the selection can be, and `Tab` is what holds it.** The board had a column and a card and `select_card` clamped at zero; up from the top card now reaches the frame and down returns to the column it left, since the column index is never what changed. Per tab beside the filter and the offset, so switching away and back returns to where the tab was left. `Focus::Frame` while no campaign is selected is the one state that must never exist — `select_campaign` and `reload` are what keep it from arising
- **`Tab::selected` hands back nothing while the frame holds the selection.** Every key that acts on a card has to answer for the frame, and the answer for `enter` falls out of this rather than being written into the dispatch. `←→` are inert, because the frame spans the width of the board and moving the column underneath would change nothing on screen. `y` is the exception that earns its place: it copies the campaign's short id, so `y copy id` means the id of the selected thing in every state the selection can be in. No card is drawn reversed there either, since that highlight is what says which ticket a key is about
- **`Tab::selected` hands back nothing while the frame holds the selection.** Every key that acts on a card has to answer for the frame. `←→` are inert, because the frame spans the width of the board and moving the column underneath would change nothing on screen. `y` is the exception that earns its place: it copies the campaign's short id, so `y copy id` means the id of the selected thing in every state the selection can be in. No card is drawn reversed there either, since that highlight is what says which ticket a key is about
- **`enter` routes on the focus through `Board::toggle_focused`: the frame's height on the frame, the overlay on a card.** It used to be inert on the frame for free, because `Tab::selected` hands back nothing and `toggle_detail` therefore had nothing to open. That is no longer an answer, and the routing is in `Board` rather than in the `main.rs` arm for the reason `dismiss` and `scroll_page` are
- **`q` does not gain a layer for the expanded frame, and up and down do not take it back.** The expanded frame is the frame at its other height, not a thing laid over the board, so `q` goes on taking the campaign filter off from either height and `enter` is the only key that undoes what `enter` did. The height outlives the selection for the same reason: it is a view of the campaign the reader chose, so the columns stay short with the selection on a card. `Tab::expanded` sits beside the filter and resets where `select_campaign` and `reload` reset the focus and the offset — a different campaign opens collapsed and at the top of its own description
- **The toggle re-clamps the frame offset, through `scroll_frame(0, screen)`.** A taller viewport has a smaller last offset than a shorter one, so where the reader was can end up past the end of the frame they just asked for. The draw clamps on its own geometry either way, but the stored value has to be clamped too or the next `pgup` counts down from a number the frame never showed. A scroll of no pages is that clamp and nothing else, which keeps it in the one place it lives
- **The frame is out of reach from under an open ticket.** With the overlay open, up and down step through the tickets and it follows, so a selection that reached the frame would have to either close it on an arrow key or leave it showing a ticket nothing is selecting. `an_open_ticket_keeps_the_scroll_keys_from_the_frame` builds that state by hand for exactly this reason: the precedence has to hold whether or not a keypress can reach it
- **The standing comes from the columns, not from a walk of the tree.** While a campaign is selected the columns *are* its members, done included, so `Tab::standing` counts what is already in hand rather than paying what `campaign ls` pays per campaign. Counted over every column, drawn or not: hiding done is a change to what is drawn and never to what is counted
- **The way out is on the frame's own border, not in the footer.** `q board` sits on the thing it takes away, and the footer row was already at its width naming eight keys. Dropped whole when it and the standing would meet, the rule the page indicator follows
- **`c` is named in the footer only on a closed board with nothing selected**, which is where a reader has to find it. Over an open ticket and on a filtered board it is left out: the frame's border then says how to put the campaign away, and the row has no cells to spare. Incomplete rather than wrong, which is the trade this row is allowed to make — what it must never do is name a key by what it used to do
- **The footer has three states, because the selection has three places to be.** An open ticket, the frame, and the cards. On the frame it names `↓ board`, the two scroll keys and `y copy id`, and leaves out `enter` and `←→` because they do nothing there. `↑ frame` is not named on the board, on the same trade `c` is dropped on: the frame is drawn directly above the columns and up is the key that reaches it
- **The footer has three states, because the selection has three places to be.** An open ticket, the frame, and the cards. On the frame it names `↓ board`, `enter expand` or `enter collapse`, the two scroll keys and `y copy id`, and leaves out `←→` because they do nothing there. It has to say which way `enter` goes, since the key is a toggle and the frame is always at one of its two heights. `↑ frame` is not named on the board, on the same trade `c` is dropped on: the frame is drawn directly above the columns and up is the key that reaches it. Nor is the way to collapse an expanded frame named from the cards, which is the same trade again — the frame is right there and `↑` reaches it
- **`picker: Option<Picker>` is the whole mode**, the shape `search` and `detail` use, and `Board::picker_key` runs beside `search_key` ahead of the action arms for the same reason: an open list owns the keyboard, so `d` must not toggle done and `q` must not quit while a campaign is being chosen. `ctrl-c` is the one key it declines and every other control combination is swallowed, or `ctrl-d` would reach the arm bound to `d`
- **The picker's rows are `Tab::campaigns`, not a copy taken when it opened**, so a campaign filed elsewhere appears in an open picker on the next tick. It opens on the campaign already selected, so `c` on a filtered board says where you are as well as offering somewhere to go, and a board with no campaigns gets a `Notice` rather than an empty box that has to be dismissed to learn it was empty
- **A picker row draws a real codename only.** The row opens with the short id, so the card's `~<id>` fallback would print it twice and say nothing the second time
Generated
+1 -1
View File
@@ -1503,7 +1503,7 @@ dependencies = [
[[package]]
name = "worklane"
version = "0.26.2"
version = "0.26.3"
dependencies = [
"anyhow",
"assert_cmd",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "worklane"
version = "0.26.2"
version = "0.26.3"
edition = "2024"
[dependencies]
+1 -1
View File
@@ -5,7 +5,7 @@ Worklane is a local Kanban flow for agentic software development.
## Commands
| Command | Description |
|---------|-------------|
| `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 or the campaign frame, whichever the selection is on, with a page indicator on its border while there is more of it than fits, `/` to jump to the first ticket whose id or title matches, `y` to copy the selected ticket's short id to the clipboard, `c` to pick a campaign and filter the columns to its members, `q` to close whatever is open and then to quit. A card carries its campaign beside its tags, marked `~` and bold, and a comment count in its bottom right corner, the number then `❞` in cyan, before the criteria count and absent entirely when nobody has commented; while one is selected a frame above the columns names it, shows three rows of its description and says how far it has got, and `q` on its border gives the whole board back; up from the top card of a column moves the selection to that frame, where the scroll keys page through the description and down returns to the column it came from. 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` 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 or the campaign frame, whichever the selection is on, with a page indicator on its border while there is more of it than fits, `/` to jump to the first ticket whose id or title matches, `y` to copy the selected ticket's short id to the clipboard, `c` to pick a campaign and filter the columns to its members, `q` to close whatever is open and then to quit. A card carries its campaign beside its tags, marked `~` and bold, and a comment count in its bottom right corner, the number then `❞` in cyan, before the criteria count and absent entirely when nobody has commented; while one is selected a frame above the columns names it, shows three rows of its description and says how far it has got, and `q` on its border gives the whole board back; up from the top card of a column moves the selection to that frame, where the scroll keys page through the description, `enter` gives it half the board and takes the rows back again, and down returns to the column it came from, leaving the frame at whatever height it was. 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. `--due` takes `YYYY-MM-DD` and refuses anything else at parse time |
| `worklane ls [status]` | Lists tickets, sorted by priority then title. Optional positional status, and `--priority <1-5>`, `--tag <tag>` and `--campaign <campaign>`, which compose in any combination. `--tag` matches a whole value of the comma-separated Tags field, case sensitively, so `--tag bug` does not list a ticket tagged `bugfix` or one tagged `Bug`. `--ids` prints one ticket per line as its short id, a tab and its title, unstyled, done included, for a script or a completion |
+4 -1
View File
@@ -210,7 +210,10 @@ fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()>
KeyCode::Char('c') if key.modifiers.contains(KeyModifiers::CONTROL) => {
board.should_quit = true
}
KeyCode::Enter | KeyCode::Char(' ') => board.toggle_detail(),
// The frame's own height while it holds the selection, and the detail
// overlay on a card. `Board::toggle_focused` rather than a condition here,
// for the reason the scroll keys route there.
KeyCode::Enter | KeyCode::Char(' ') => board.toggle_focused(screen),
KeyCode::Left | KeyCode::Char('h') => board.select_column(-1, screen),
KeyCode::Right | KeyCode::Char('l') => board.select_column(1, screen),
// Up and down stay on the selection, open detail view or not, so a
+493 -16
View File
@@ -44,8 +44,25 @@ const ALL: &str = "all";
pub struct Chrome {
/// Whether the tab row is drawn, which is whether more than one board is monitored.
pub tabbed: bool,
/// Whether the campaign frame is drawn, which is whether a campaign is selected.
pub campaign: bool,
/// The campaign frame, at the height it is drawn, or `None` for a tab showing the whole
/// board.
///
/// A state rather than the bool it was, because the frame has two heights now and every
/// measurement of the board has to agree about which one it is at. `Option` rather than a
/// third variant, so "there is no frame" stays the shape it was and the two heights are
/// only ever compared with each other.
pub campaign: Option<FrameSize>,
}
/// How much of the board the campaign frame is taking.
///
/// Collapsed is where it opens and where it goes back to. Expanded is what `enter` asks for
/// while the frame holds the selection, and it outlives the selection: the height is a view
/// the reader chose, not a property of where the selection happens to be.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FrameSize {
Collapsed,
Expanded,
}
impl Chrome {
@@ -72,14 +89,49 @@ impl Chrome {
/// spent here is a row of cards.
const CAMPAIGN_ROWS: u16 = Self::CAMPAIGN_PROSE_ROWS + 2;
fn campaign_rows(self) -> u16 {
match self.campaign {
true => Self::CAMPAIGN_ROWS,
false => 0,
/// The rows the frame takes out of a board `height` rows tall.
///
/// The height comes in because the expanded frame is a *share* rather than a second
/// constant, and `frame_rows` is the one place that already has an area to take a share
/// of — which is what keeps `Chrome` itself cheap and pure and copied from
/// `Board::chrome` without a screen to hand.
///
/// Half of what the frame and the columns divide between them: the board less the tab
/// row and the footer, both a fixed length above and below. Half rather than most of it,
/// and against the shared rows rather than against the whole screen, for the same reason
/// the frame is not an overlay: the columns below it are the campaign's members, and a
/// reader inspecting the campaign has to be able to go on seeing what it is made of.
/// Floored, so the odd row goes to the cards.
///
/// Bounded at both ends, and the upper bound is the one that matters:
/// `Constraint::Min(COLUMN_MIN_ROWS)` would take the rows back silently, and the frame's
/// own measurement would then disagree with what is drawn, which is the fault `Chrome`
/// exists to prevent. The lower bound is [`Self::CAMPAIGN_ROWS`], since expanding must
/// never shrink the frame — so on a board too short to divide, `enter` gives the
/// collapsed frame back rather than a height nothing measured.
fn campaign_rows(self, height: u16) -> u16 {
let Some(size) = self.campaign else { return 0 };
let shared = height.saturating_sub(u16::from(self.tabbed) + FOOTER_ROWS);
match size {
FrameSize::Collapsed => Self::CAMPAIGN_ROWS,
FrameSize::Expanded => {
let room = shared.saturating_sub(COLUMN_MIN_ROWS).max(Self::CAMPAIGN_ROWS);
(shared / 2).clamp(Self::CAMPAIGN_ROWS, room)
}
}
}
}
/// The rows the columns are never asked to give up, and the footer's one row.
///
/// Named because two places read each of them: `frame_rows` lays them out and
/// `Chrome::campaign_rows` bounds its share against them. A share computed against a
/// reservation written out by hand is a share that comes to disagree with the layout.
const COLUMN_MIN_ROWS: u16 = 3;
const FOOTER_ROWS: u16 = 1;
/// Where a tab's selection is: among its cards, or on the campaign frame above them.
///
/// The board had no focus beyond a column and a card, and `select_card` clamped at zero. A
@@ -282,6 +334,13 @@ pub struct Tab {
/// the tab was left. A tab showing the whole board has no frame to hold it, which is
/// the invariant `select_campaign` and `reload` keep.
pub focus: Focus,
/// Whether the frame is drawn at its expanded height.
///
/// Per tab like the filter it belongs to. Not per focus: `enter` on the frame is what
/// sets it and `enter` on the frame is what takes it back, so the height survives the
/// selection moving down to the cards — the reader chose a view of the campaign, not a
/// thing about where the highlight is.
pub expanded: bool,
/// First visible line of the frame's prose, counted in wrapped lines the way
/// `Board::offset` counts the overlay's.
///
@@ -302,6 +361,7 @@ impl Tab {
campaigns: Vec::new(),
campaign: None,
focus: Focus::default(),
expanded: false,
frame_offset: 0,
}
}
@@ -671,9 +731,13 @@ impl Board {
/// takes three rows off the columns, and a keypress that scrolled against the old
/// height would put the selection where the next frame does not draw it.
pub fn chrome(&self) -> Chrome {
let tab = self.current();
Chrome {
tabbed: self.tabbed(),
campaign: self.current().campaign.is_some(),
campaign: tab.campaign.is_some().then_some(match tab.expanded {
true => FrameSize::Expanded,
false => FrameSize::Collapsed,
}),
}
}
@@ -751,6 +815,7 @@ impl Board {
// selection, and the next campaign selected starts at the top of its own
// description rather than partway down the last one's.
tab.focus = Focus::Cards;
tab.expanded = false;
tab.frame_offset = 0;
}
tab.columns = retain_campaign(columns, tab.campaign.as_deref());
@@ -1231,6 +1296,7 @@ impl Board {
// the cards and its prose starts at the top — the answer `refresh_detail` gives the
// overlay when the ticket under it changes.
tab.focus = Focus::Cards;
tab.expanded = false;
tab.frame_offset = 0;
// Swallowed for the reason the tick's is not: there is nobody above a keypress to
@@ -1487,6 +1553,44 @@ impl Board {
tab.frame_offset = at.clamp(0, last) as u16;
}
/// What `enter` does: the frame's height on the frame, the overlay on a card.
///
/// The routing is here rather than in the dispatch, the rule `dismiss` and `scroll_page`
/// follow: the arms in `main.rs` are not reachable from a test. It is also what stopped
/// being automatic — `enter` was inert on the frame because `Tab::selected` hands back
/// nothing there and `toggle_detail` had nothing to open, and that answer is now the
/// thing in the way.
pub fn toggle_focused(&mut self, screen: Size) {
match self.current().focus {
Focus::Frame => self.toggle_frame(screen),
Focus::Cards => self.toggle_detail(),
}
}
/// Give the frame's prose half the board, or give the rows back.
///
/// Only from the frame, since it is the frame's own height and `enter` on a card is the
/// overlay's. `q` is not involved: it takes the campaign filter off from either height,
/// because the expanded frame is the frame at its other height and not a layer laid over
/// the board — putting a press between the reader and the board is what a fourth layer
/// would cost, and `enter` already undoes what `enter` did.
///
/// Nor does the selection take it back. Up and down go on moving on and off the frame
/// and leave it where it was, so the columns stay short with the selection on a card.
/// That is the point: the height is a view of the campaign the reader chose.
pub fn toggle_frame(&mut self, screen: Size) {
if self.current().focus != Focus::Frame {
return;
}
self.current_mut().expanded = !self.current().expanded;
// The viewport changed height, so where the reader was may be past the end of it: a
// taller frame has a smaller last offset than a shorter one. A scroll of no pages is
// that clamp and nothing else, which keeps it in the one place it lives — and it
// leaves the reader where they were rather than back at the top of the description.
self.scroll_frame(0, screen);
}
fn refresh_detail(&mut self) {
// A newly selected ticket starts at its top, not partway down where the last one
// was left.
@@ -1898,7 +2002,7 @@ pub fn draw(frame: &mut Frame, board: &Board) {
if chrome.tabbed {
draw_tabs(frame, board, rows[TAB_ROW]);
}
if chrome.campaign {
if chrome.campaign.is_some() {
draw_campaign(frame, board.current(), rows[CAMPAIGN_ROW]);
}
draw_columns(frame, board, rows[BOARD_ROW]);
@@ -1937,9 +2041,9 @@ fn frame_rows(area: Rect, chrome: Chrome) -> std::rc::Rc<[Rect]> {
.direction(Direction::Vertical)
.constraints([
Constraint::Length(u16::from(chrome.tabbed)),
Constraint::Length(chrome.campaign_rows()),
Constraint::Min(3),
Constraint::Length(1),
Constraint::Length(chrome.campaign_rows(area.height)),
Constraint::Min(COLUMN_MIN_ROWS),
Constraint::Length(FOOTER_ROWS),
])
.split(area)
}
@@ -2696,13 +2800,21 @@ fn draw_footer(frame: &mut Frame, board: &Board, area: Rect) {
// do. `↑ frame` is not named on the board for the same reason `c` is dropped from a
// filtered board: the frame is drawn right above the columns and up is the key that
// reaches it, and the row has no cells to spend saying so.
// Which way `enter` will go, since the key is a toggle and the frame is already at one
// of its two heights. Naming it `enter expand` while it collapses would be the fault
// 1b78a24 was, a footer describing a key by what it used to do.
let height = match board.current().expanded {
true => "enter collapse",
false => "enter expand",
};
let keys = match (board.detail.is_some(), board.current().focus) {
(true, _) => format!(
" {tabs}←→↑↓ select pgup/pgdn scroll / search y copy id enter/q close {done} {quit} "
),
(false, Focus::Frame) => {
format!(" {tabs}↓ board pgup/pgdn scroll / search y copy id {done} {quit} ")
}
(false, Focus::Frame) => format!(
" {tabs}↓ board {height} pgup/pgdn scroll / search y copy id {done} {quit} "
),
(false, Focus::Cards) => format!(
" {tabs}←→ column ↑↓ card / search {campaign}y copy id enter detail {done} {quit} "
),
@@ -3256,7 +3368,7 @@ mod tests {
const SCREEN: Size = Size { width: 120, height: 20 };
/// One board, no campaign selected: the chrome most of these tests measure against.
const PLAIN: Chrome = Chrome { tabbed: false, campaign: false };
const PLAIN: Chrome = Chrome { tabbed: false, campaign: None };
/// The rendered buffer as lines of text, escapes and styling dropped.
fn render(board: &Board, width: u16, height: u16) -> Vec<String> {
@@ -7305,8 +7417,11 @@ mod tests {
assert!(board.selected().is_none(), "a card was handed back from the frame");
assert!(!a_card_is_highlighted(&board, 120, 20), "a card is still drawn picked out");
board.toggle_detail();
// `enter` reaches the frame's own height now rather than the overlay, but the
// overlay is still what it does not open: there is no ticket here to open.
board.toggle_focused(SCREEN);
assert!(board.detail.is_none(), "enter opened a ticket nothing was selecting");
board.toggle_focused(SCREEN);
board.select_card(1, SCREEN);
assert!(a_card_is_highlighted(&board, 120, 20), "the highlight did not come back");
@@ -7453,6 +7568,368 @@ mod tests {
std::fs::remove_dir_all(&dir).ok();
}
// ---------------------------------------------------- the frame's two heights --
/// The frame's page indicator, or nothing when it is not drawn.
///
/// Cut out of the bottom border, where it sits between `q board` and the standing, so a
/// test can say the frame repaged without knowing what the numbers should be.
fn frame_indicator(board: &Board, width: u16, height: u16) -> Option<String> {
let rows = frame_lines(board, width, height);
let bottom = rows.last().expect("no frame drawn").clone();
let at = bottom.find("pg ")?;
Some(bottom[at..].split('─').next()?.trim().to_string())
}
/// The rows the frame takes, as the layout gives them out.
fn frame_height(board: &Board, screen: Size) -> u16 {
frame_rows(Rect::new(0, 0, screen.width, screen.height), board.chrome())[CAMPAIGN_ROW]
.height
}
/// `enter` on the frame gives its prose half the board, and `enter` again gives the rows
/// back. A toggle, so the key that expands is the key that collapses.
#[test]
fn enter_expands_the_frame_and_enter_again_gives_the_rows_back() {
let dir = board_dir();
let mut board = frame_board(&dir, 60);
let collapsed = frame_height(&board, SCREEN);
assert_eq!(collapsed, Chrome::CAMPAIGN_ROWS, "the board did not open collapsed");
board.select_card(-1, SCREEN);
board.toggle_focused(SCREEN);
let expanded = frame_height(&board, SCREEN);
assert!(board.current().expanded, "the tab does not think it expanded");
assert!(expanded > collapsed, "the frame did not grow: {expanded} rows");
board.toggle_focused(SCREEN);
assert!(!board.current().expanded, "the tab did not collapse");
assert_eq!(frame_height(&board, SCREEN), collapsed, "the rows did not come back");
std::fs::remove_dir_all(&dir).ok();
}
/// And only from the frame. `enter` on a card is the overlay's, which is what the routing
/// in `toggle_focused` is for.
#[test]
fn enter_on_a_card_opens_the_ticket_rather_than_the_frame() {
let dir = board_dir();
let mut board = frame_board(&dir, 60);
board.toggle_focused(SCREEN);
assert!(board.detail.is_some(), "enter did not open the ticket");
assert!(!board.current().expanded, "enter on a card expanded the frame");
board.toggle_focused(SCREEN);
assert!(board.detail.is_none(), "enter did not close the ticket");
std::fs::remove_dir_all(&dir).ok();
}
/// Half of what the frame and the columns divide, which is the screen less the tab row
/// and the footer. Half rather than most of it: the columns below are the campaign's
/// members, and a reader inspecting the campaign has to go on seeing what it is made of.
#[test]
fn the_expanded_frame_takes_half_of_what_it_shares_with_the_columns() {
let dir = board_dir();
let mut board = frame_board(&dir, 60);
board.select_card(-1, SCREEN);
board.toggle_focused(SCREEN);
let shared = SCREEN.height - FOOTER_ROWS;
assert_eq!(frame_height(&board, SCREEN), shared / 2, "not half of the shared rows");
// The odd row goes to the cards, and the two of them plus the footer are the screen.
let columns = board_area(SCREEN, board.chrome()).height;
assert!(columns >= shared / 2, "the cards did not keep the odd row");
assert_eq!(frame_height(&board, SCREEN) + columns + FOOTER_ROWS, SCREEN.height);
std::fs::remove_dir_all(&dir).ok();
}
/// The share is bounded at both ends, and a sweep is what says so rather than one screen
/// that happens to work. Expanding must never shrink the frame, and must never take rows
/// the columns are reserved: `Constraint::Min` would take them back silently, and the
/// measurement here would then disagree with what is drawn.
#[test]
fn the_expanded_share_is_bounded_at_both_ends() {
for height in 4..=60u16 {
for tabbed in [false, true] {
let chrome = Chrome {
tabbed,
campaign: Some(FrameSize::Expanded),
};
let rows = chrome.campaign_rows(height);
let shared = height.saturating_sub(u16::from(tabbed) + FOOTER_ROWS);
assert!(
rows >= Chrome::CAMPAIGN_ROWS,
"expanding shrank the frame to {rows} rows at height {height}"
);
// Only where the board can hold both. Below that the frame is pinned to its
// collapsed height and the layout is what apportions what is left.
if shared >= Chrome::CAMPAIGN_ROWS + COLUMN_MIN_ROWS {
assert!(
shared - rows >= COLUMN_MIN_ROWS,
"the columns kept {} rows at height {height}",
shared - rows
);
}
}
}
}
/// A board too short to divide gives the collapsed frame back rather than a height
/// nothing measured.
#[test]
fn a_board_too_short_to_divide_stays_at_the_collapsed_height() {
let short = Size { width: 80, height: 10 };
let chrome = Chrome {
tabbed: false,
campaign: Some(FrameSize::Expanded),
};
assert_eq!(chrome.campaign_rows(short.height), Chrome::CAMPAIGN_ROWS);
}
/// Every measurement of the board agrees about the expanded height. That is what `Chrome`
/// is for: a keypress that scrolled against the taller board would put the selection
/// where the next frame does not draw it.
#[test]
fn every_measurement_agrees_about_the_expanded_height() {
let dir = board_dir();
let mut board = frame_board(&dir, 60);
board.select_card(-1, SCREEN);
board.toggle_focused(SCREEN);
let rows = frame_rows(Rect::new(0, 0, SCREEN.width, SCREEN.height), board.chrome());
let total: u16 = rows.iter().map(|row| row.height).sum();
assert_eq!(total, SCREEN.height, "the rows do not add up to the screen");
// The keypress measures the prose off the screen and the draw off the area it is
// given. Two answers here is how a scroll comes to clamp against a frame nobody drew.
assert_eq!(
frame_text_area(SCREEN, board.chrome()),
rows[CAMPAIGN_ROW].inner(Margin::new(1, 1)),
"the keypress and the draw measure different prose"
);
assert_eq!(board_area(SCREEN, board.chrome()), rows[BOARD_ROW]);
assert_eq!(
column_text_height(SCREEN, board.chrome()),
rows[BOARD_ROW].height - 2,
"the cards are laid out against a column of another height"
);
std::fs::remove_dir_all(&dir).ok();
}
/// The scroll keys go on doing what they do, and the indicator repages: the step and the
/// clamp are both measured off the viewport, so both move when the frame does.
#[test]
fn the_scroll_keys_page_through_the_expanded_frame_and_the_indicator_repages() {
let dir = board_dir();
let mut board = frame_board(&dir, 60);
board.select_card(-1, SCREEN);
let collapsed = frame_indicator(&board, 120, 20).expect("no indicator collapsed");
board.toggle_focused(SCREEN);
let expanded = frame_indicator(&board, 120, 20).expect("no indicator expanded");
assert_ne!(collapsed, expanded, "the indicator did not repage: {expanded}");
assert!(expanded.starts_with("pg 1/"), "not on the first page: {expanded}");
board.scroll_page(1, SCREEN);
assert!(board.current().frame_offset > 0, "the expanded frame did not scroll");
let moved = frame_indicator(&board, 120, 20).expect("the indicator went away");
assert!(moved.starts_with("pg 2/"), "the indicator did not follow: {moved}");
// And the clamp is still the wrapped prose, not blank rows past the end of it.
board.scroll_page(40, SCREEN);
let text = frame_text_area(SCREEN, board.chrome());
let last = last_offset(&frame_prose(board.campaign().expect("no campaign")), text);
assert_eq!(board.current().frame_offset, last, "the scroll ran past the description");
std::fs::remove_dir_all(&dir).ok();
}
/// A description that did not fit the collapsed frame and does fit the expanded one
/// spends no indicator and leaves the keys inert, the answer ebad2fa gave for a short
/// description in a collapsed frame.
#[test]
fn a_description_that_fits_the_expanded_frame_spends_no_indicator() {
let dir = board_dir();
let mut board = frame_board(&dir, 5);
board.select_card(-1, SCREEN);
assert!(frame_indicator(&board, 120, 20).is_some(), "five lines fit three rows");
board.toggle_focused(SCREEN);
assert_eq!(frame_indicator(&board, 120, 20), None, "an indicator over prose that fits");
board.scroll_page(1, SCREEN);
assert_eq!(board.current().frame_offset, 0, "prose that fits scrolled");
std::fs::remove_dir_all(&dir).ok();
}
/// A description that fits the collapsed frame expands anyway. A key that worked on one
/// campaign and not the next is worse than one that sometimes has little to reveal, which
/// is the trade the scroll keys already take.
#[test]
fn a_short_description_still_expands_the_frame() {
let dir = board_dir();
let mut board = campaign_board(&dir);
board.select_campaign(Some(V1.to_string()), SCREEN);
board.select_card(-1, SCREEN);
board.toggle_focused(SCREEN);
assert!(board.current().expanded, "a one line description refused to expand");
assert!(
frame_height(&board, SCREEN) > Chrome::CAMPAIGN_ROWS,
"the frame did not grow"
);
std::fs::remove_dir_all(&dir).ok();
}
/// `q` takes the campaign filter off from an expanded frame exactly as it does from a
/// collapsed one. The expanded frame is the frame at its other height, not a layer laid
/// over the board, so it is not a press the reader has to spend on the way out.
#[test]
fn q_takes_the_filter_off_from_an_expanded_frame() {
let dir = board_dir();
let mut board = frame_board(&dir, 60);
board.select_card(-1, SCREEN);
board.toggle_focused(SCREEN);
assert!(board.current().expanded, "nothing expanded");
board.dismiss(SCREEN);
assert_eq!(board.current().campaign, None, "q was spent collapsing the frame");
assert!(!board.current().expanded, "the height outlived the frame");
assert!(!board.should_quit, "the board quit out from under the frame");
let all: usize = board.current().columns.iter().map(|c| c.cards.len()).sum();
assert_eq!(all, 4, "the whole board did not come back");
std::fs::remove_dir_all(&dir).ok();
}
/// Up and down leave the height where it was. The reader chose a view of the campaign;
/// moving the selection off it is not asking for the view back.
#[test]
fn up_and_down_leave_the_frame_at_the_height_it_was() {
let dir = board_dir();
let mut board = frame_board(&dir, 60);
board.select_card(-1, SCREEN);
board.toggle_focused(SCREEN);
let expanded = frame_height(&board, SCREEN);
board.select_card(1, SCREEN);
assert_eq!(board.current().focus, Focus::Cards, "down did not leave the frame");
assert!(board.current().expanded, "down collapsed the frame");
assert_eq!(frame_height(&board, SCREEN), expanded, "the columns took the rows back");
board.select_card(-1, SCREEN);
assert!(board.current().expanded, "up changed the height");
std::fs::remove_dir_all(&dir).ok();
}
/// The footer says which of the two `enter` is about to do, since the key is a toggle and
/// the frame is already at one of its heights. ebad2fa left it out of this row because it
/// did nothing here.
#[test]
fn the_footer_says_which_way_enter_will_go_on_the_frame() {
let dir = board_dir();
let mut board = frame_board(&dir, 60);
board.select_card(-1, SCREEN);
let row = footer(&board, 120, 20);
assert!(row.contains("enter expand"), "enter is not named on the frame:\n{row}");
board.toggle_focused(SCREEN);
let row = footer(&board, 120, 20);
assert!(row.contains("enter collapse"), "enter still offered as expand:\n{row}");
assert!(!row.contains("enter expand"), "the row names it both ways:\n{row}");
std::fs::remove_dir_all(&dir).ok();
}
/// Expanding and collapsing leave the reader where they were rather than at the top. The
/// offset has to be re-clamped as the height changes, since a taller viewport has a
/// smaller last offset than a shorter one.
#[test]
fn expanding_and_collapsing_leave_the_reader_where_they_were() {
let dir = board_dir();
let mut board = frame_board(&dir, 60);
board.select_card(-1, SCREEN);
board.scroll_page(1, SCREEN);
let at = board.current().frame_offset;
assert!(at > 0, "nothing scrolled");
board.toggle_focused(SCREEN);
assert!(board.current().frame_offset > 0, "expanding went back to the top");
// And the stored offset is inside the taller viewport, not left past its end where
// the next pgup would count down from a number the frame never showed.
let text = frame_text_area(SCREEN, board.chrome());
let last = last_offset(&frame_prose(board.campaign().expect("no campaign")), text);
assert!(board.current().frame_offset <= last, "the offset sits past the end");
board.toggle_focused(SCREEN);
assert!(board.current().frame_offset > 0, "collapsing went back to the top");
std::fs::remove_dir_all(&dir).ok();
}
/// The height is the tab's own, beside the filter it belongs to, so switching away and
/// back returns to it.
#[test]
fn the_expanded_frame_is_the_tabs_own() {
let one = board_dir();
let two = board_dir();
write_campaign(&one, V1, "First public release", "v1", &long_description(60));
write_ticket(
&one,
"backlog",
"11111111-0000-4000-8000-000000000000",
"In v1",
&campaign_field(V1),
);
write_ticket(&two, "backlog", "77777777-0000-4000-8000-000000000000", "Elsewhere", "");
let mut board = boards(&[("one", &one), ("two", &two)]);
board.select_campaign(Some(V1.to_string()), SCREEN);
board.select_card(-1, SCREEN);
board.toggle_focused(SCREEN);
assert!(board.current().expanded, "nothing expanded");
board.select_tab(2, SCREEN);
assert!(!board.current().expanded, "the height came across to another tab");
board.select_tab(-2, SCREEN);
assert!(board.current().expanded, "the tab did not keep its height");
std::fs::remove_dir_all(&one).ok();
std::fs::remove_dir_all(&two).ok();
}
/// And selecting another campaign opens its frame collapsed, the answer `select_campaign`
/// already gives the offset and the focus: it is a different description, and a reader
/// who did not ask for half the board should not be given it.
#[test]
fn selecting_another_campaign_opens_its_frame_collapsed() {
let dir = board_dir();
let mut board = frame_board(&dir, 60);
board.select_card(-1, SCREEN);
board.toggle_focused(SCREEN);
board.select_campaign(Some(BEAVER.to_string()), SCREEN);
assert!(!board.current().expanded, "the new campaign opened at half the board");
assert_eq!(frame_height(&board, SCREEN), Chrome::CAMPAIGN_ROWS);
std::fs::remove_dir_all(&dir).ok();
}
/// A campaign that leaves the board takes the frame with it, focus and offset both: the
/// filter goes back to the whole board, and a frame nothing draws must not be holding
/// the selection.