Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4502de7ee3 |
@@ -135,6 +135,9 @@ 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
|
||||
- **`q` and `esc` are one key: close what is open, quit when there is nothing left to close.** `q` used to set `should_quit` outright, so a reader who pressed it to put a ticket away lost the board instead, which is not what `q` does anywhere else that lays a document over a list. One match arm in `main.rs`, not two: two arms carrying one rule is how a later edit changes it for one key and not the other
|
||||
- **The rule is `Board::dismiss`, not the match arm.** The dispatch in `main.rs` is not reachable from a test, so anything decided there is undecidable by the suite. The arm is the line that names the keys and nothing else. `the_dispatch_gives_q_and_esc_one_arm_and_leaves_ctrl_c_quitting` scans `main.rs` for what the arm cannot say for itself, over whitespace-collapsed source so rustfmt cannot fail it
|
||||
- **The footer's last slot always answers how to get out**, and with a ticket open the honest answer is `ctrl-c`, the only key left that quits in one press. Going on saying `q quit` there would be 1b78a24 in the other direction: a footer describing a key by what it used to do
|
||||
- **The overlay names its ticket on the border, not at the head of the paragraph.** `Board::detail` is a `Detail` carrying the title, the id and the text, because the name has to travel beside the body rather than inside it: `content_trim` drops the `# ` heading on purpose, since `cmd_show` prints it, and anything in the paragraph scrolls away
|
||||
- `detail_title` cuts the string itself instead of leaving it to ratatui, which truncates an overlong block title at whatever cell it reaches and would take the id with it. Cut against the inner width, so the id survives whole and the name ends in an ellipsis. The id goes first because that is how every other view addresses a ticket
|
||||
- The detail view renders with colour off. ratatui draws styled spans, so an escape sequence in a paragraph would be printed as literal bytes. `content_trim` and `format_comments_with` take the colour decision for that reason
|
||||
|
||||
Generated
+1
-1
@@ -1494,7 +1494,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "worklane"
|
||||
version = "0.13.4"
|
||||
version = "0.13.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assert_cmd",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "worklane"
|
||||
version = "0.13.4"
|
||||
version = "0.13.5"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
+8
-7
@@ -164,16 +164,17 @@ fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()>
|
||||
}
|
||||
|
||||
match key.code {
|
||||
KeyCode::Char('q') => board.should_quit = true,
|
||||
// One arm, because the two keys mean one thing: close what is open, and
|
||||
// quit when there is nothing left to close. Two arms carrying one rule
|
||||
// is how a later edit changes it for one key and not the other, which is
|
||||
// what `q` quitting out from under an open ticket already was. The rule
|
||||
// itself is `Board::dismiss`, where a test can reach it.
|
||||
KeyCode::Esc | KeyCode::Char('q') => board.dismiss(),
|
||||
// The only key that leaves the board from an open ticket, which is why
|
||||
// the footer names it there.
|
||||
KeyCode::Char('c') if key.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||
board.should_quit = true
|
||||
}
|
||||
// Esc closes the detail view, and only quits when there is nothing
|
||||
// left to dismiss.
|
||||
KeyCode::Esc => match board.detail {
|
||||
Some(_) => board.toggle_detail(),
|
||||
None => board.should_quit = true,
|
||||
},
|
||||
KeyCode::Enter | KeyCode::Char(' ') => board.toggle_detail(),
|
||||
KeyCode::Left | KeyCode::Char('h') => board.select_column(-1, screen),
|
||||
KeyCode::Right | KeyCode::Char('l') => board.select_column(1, screen),
|
||||
|
||||
+114
-2
@@ -471,6 +471,26 @@ impl Board {
|
||||
};
|
||||
}
|
||||
|
||||
/// Put away what is open, and quit when there is nothing left to put away.
|
||||
///
|
||||
/// What `esc` has always done, and now what `q` does too. `q` used to set
|
||||
/// `should_quit` outright, so a reader who pressed it to close a ticket lost the
|
||||
/// whole board instead, which is not what `q` means anywhere else that lays a
|
||||
/// document over a list.
|
||||
///
|
||||
/// Here rather than in the match arm in `main.rs`: that dispatch is not reachable
|
||||
/// from a test, so a rule written into it is a rule nothing can check. The arm is
|
||||
/// left as the one line that names the keys.
|
||||
///
|
||||
/// `ctrl-c` is therefore the only key that leaves the board while a ticket is open,
|
||||
/// and the footer says so rather than leaving the reader to find out.
|
||||
pub fn dismiss(&mut self) {
|
||||
match self.detail {
|
||||
Some(_) => self.toggle_detail(),
|
||||
None => self.should_quit = true,
|
||||
}
|
||||
}
|
||||
|
||||
/// Scroll the open detail view by whole screenfuls, one line kept for overlap.
|
||||
///
|
||||
/// Up and down move the selection, so the scroll is on PageUp and PageDown. That is
|
||||
@@ -1199,9 +1219,13 @@ fn draw_footer(frame: &mut Frame, board: &Board, area: Rect) {
|
||||
false => "",
|
||||
};
|
||||
|
||||
// The last slot answers the same question in both states: how to get out of here.
|
||||
// With a ticket open `q` closes it, so the honest answer there is `ctrl-c`, which is
|
||||
// the only key left that quits in one press. Naming `q quit` over an open overlay
|
||||
// would be the fault 1b78a24 was, a footer describing a key by what it used to do.
|
||||
let keys = match board.detail {
|
||||
Some(_) => {
|
||||
format!(" {tabs}←→↑↓ select pgup/pgdn scroll enter close {done} q quit ")
|
||||
format!(" {tabs}←→↑↓ select pgup/pgdn scroll enter/q close {done} ctrl-c quit ")
|
||||
}
|
||||
None => format!(" {tabs}←→ column ↑↓ card enter detail {done} q quit "),
|
||||
};
|
||||
@@ -2567,6 +2591,73 @@ mod tests {
|
||||
assert_eq!(board.offset, offset);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- close or quit --
|
||||
|
||||
/// A reader pressing `q` to put a ticket away lost the whole board instead.
|
||||
#[test]
|
||||
fn dismiss_closes_an_open_overlay_and_leaves_the_board_up() {
|
||||
let dir = board_dir();
|
||||
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
|
||||
let mut board = one_board(&dir);
|
||||
board.toggle_detail();
|
||||
assert!(board.detail.is_some(), "nothing was open to dismiss");
|
||||
|
||||
board.dismiss();
|
||||
assert!(board.detail.is_none(), "the overlay stayed open");
|
||||
assert!(!board.should_quit, "closing a ticket took the board with it");
|
||||
|
||||
// Still on the ticket it was opened from, so the next `enter` reopens it.
|
||||
assert_eq!(selected_title(&board).as_deref(), Some("First one"));
|
||||
}
|
||||
|
||||
/// With nothing over the board there is nothing to put away, so the key means what
|
||||
/// it has always meant.
|
||||
#[test]
|
||||
fn dismiss_quits_when_there_is_nothing_left_to_dismiss() {
|
||||
let dir = board_dir();
|
||||
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
|
||||
let mut board = one_board(&dir);
|
||||
board.dismiss();
|
||||
assert!(board.should_quit, "the board stayed up with nothing to close");
|
||||
}
|
||||
|
||||
/// The rule is `Board::dismiss`, which the two tests above reach. What is left to
|
||||
/// guard is the dispatch that cannot be reached: that both keys arrive there from
|
||||
/// one arm, and that `ctrl-c` still quits outright, since after this it is the only
|
||||
/// key that leaves the board while a ticket is open.
|
||||
///
|
||||
/// Scanned the way `nothing_the_body_renders_asks_the_terminal_for_the_colour_decision`
|
||||
/// scans, and over whitespace-collapsed source so rustfmt cannot fail it.
|
||||
#[test]
|
||||
fn the_dispatch_gives_q_and_esc_one_arm_and_leaves_ctrl_c_quitting() {
|
||||
let source = include_str!("main.rs")
|
||||
.split_whitespace()
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ");
|
||||
|
||||
assert!(
|
||||
source.contains("KeyCode::Esc | KeyCode::Char('q') => board.dismiss(),"),
|
||||
"`q` and `esc` mean one thing and have to reach `Board::dismiss` from one \
|
||||
arm. Two arms carrying one rule is how a later edit changes it for one key \
|
||||
and not the other, which is what this ticket already was."
|
||||
);
|
||||
|
||||
let at = source
|
||||
.find("KeyCode::Char('c') if key.modifiers.contains(KeyModifiers::CONTROL)")
|
||||
.expect("no ctrl-c arm in the dispatch");
|
||||
// What the arm does, not what is anywhere near it: the arms after this one call
|
||||
// the board and would answer a whole-file search.
|
||||
let arm = &source[at..(at + 120).min(source.len())];
|
||||
assert!(
|
||||
arm.contains("=> { board.should_quit = true }"),
|
||||
"`ctrl-c` has to keep quitting outright: with `q` closing an open ticket it \
|
||||
is the only key that leaves the board in one press, and the footer says so. \
|
||||
Found instead: {arm}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The footer is what sent the reporter looking for their own mistake, so it has to
|
||||
/// name the keys that exist and only those.
|
||||
#[test]
|
||||
@@ -2587,11 +2678,32 @@ mod tests {
|
||||
assert!(closed.contains("enter detail"), "{closed}");
|
||||
assert!(!closed.contains("scroll"), "a scroll offered with nothing open:\n{closed}");
|
||||
|
||||
assert!(closed.contains("q quit"), "nothing says how to leave:\n{closed}");
|
||||
|
||||
board.toggle_detail();
|
||||
let open = render(&board, SCREEN.width, SCREEN.height).join("\n");
|
||||
assert!(open.contains("pgup/pgdn scroll"), "{open}");
|
||||
assert!(open.contains("select"), "{open}");
|
||||
assert!(open.contains("enter close"), "{open}");
|
||||
assert!(open.contains("enter/q close"), "{open}");
|
||||
}
|
||||
|
||||
/// The other half of giving `q` a second meaning. A footer that goes on saying
|
||||
/// `q quit` over an open ticket describes the key by what it used to do, which is
|
||||
/// the fault 1b78a24 was in the other direction.
|
||||
#[test]
|
||||
fn the_footer_names_q_as_the_close_key_while_a_ticket_is_open() {
|
||||
let dir = board_dir();
|
||||
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
|
||||
let mut board = one_board(&dir);
|
||||
board.toggle_detail();
|
||||
|
||||
let row = footer(&board, 120, 20);
|
||||
assert!(row.contains("enter/q close"), "q is not named as the close key:\n{row}");
|
||||
assert!(!row.contains("q quit"), "q still offered as the quit key:\n{row}");
|
||||
// And the last slot still answers how to get out, which from here is the one
|
||||
// key that does it in a single press.
|
||||
assert!(row.contains("ctrl-c quit"), "nothing says what quits from here:\n{row}");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------- several boards at once --
|
||||
|
||||
Reference in New Issue
Block a user