Files
worklane/docs/tui-prompts.md
T

22 KiB

The Board Prompts

The three input modes on the board and the key that copies an id off it.

The Search Prompt

  • search: Option<Search> is the whole mode, the shape detail uses: "the prompt is open" and "what is in it" cannot disagree, and closing it leaves nothing to reset. Search also carries missed, set when enter found nothing and cleared by the next edit, since the message is about the query that missed
  • The prompt swallows every key it is given. Board::search_key runs ahead of the action arms in main.rs and reports what it took, rather than every arm below asking whether a search is open. Typing d into a query must not toggle done and q must not quit; with no prompt open it takes nothing, so the dispatch is unchanged for every other state. The rule is on Board for the reason dismiss is: the arm is not reachable from a test
  • ctrl-c is the one key it declines, because a terminal application always honours it and a prompt that ate it would leave no way off the board. Every other control combination is swallowed and does nothing: it must not type its letter, and it must not fall through either, since the action arms match on the code alone and ctrl-d would reach the one bound to d
  • Esc is consumed by the search before it can mean anything else, which is the collision e7612de left behind: esc and q close the overlay, and both have to lose to an open prompt. It falls out of the pre-branch rather than being ordered by hand
  • first_match searches the visible columns, every card in them, not the rows on screen. A query that answered differently on a tall terminal and a short one is not a search, and the jump scrolls the match into view anyway. Hidden columns stay out: with done hidden, a match there would put the highlight on a ticket that is not on the board. Reading order is column by column, then top to bottom
  • Id and title only, per 3b16540, both lowercased. The title has to be case insensitive to be worth typing, and giving the id the same treatment lets a pasted id match whatever case it was copied in. An empty or all-space query matches nothing rather than everything
  • The jump goes through select_at, the tail select_card already used. follow_selection scrolls the column the card is in, and the offsets are per column and on the Tab, so a jump across columns moves the right one; refresh_detail keeps an open overlay on the ticket the selection names. A second version of either is how a jump comes to scroll differently from the arrow keys
  • A hit closes the prompt and a miss keeps it open, marked, with the selection untouched. The query can then be corrected in place instead of retyped from /. Doing nothing visible is what makes a reader retype a query that was already right
  • The prompt takes the whole footer row, because the key list it replaces describes nothing that currently works while every key is going into the buffer. Its two keys are drawn as every other key is, cyan on the key and the default foreground on the word. That the query then sits in the same foreground as the descriptions is what the house style costs on this row, and the cursor is what says which half is an input — which it does in a terminal with no colour at all. no match stays brightred beside the query it is about, being the one thing on the row that is neither a key nor what was typed
  • The real terminal cursor goes after the query, not a glyph standing in for one. ratatui shows the cursor only for a frame that asked for it, so set_cursor_position is also what says "you are typing" while the query is still empty. Clamped to the row, so a query longer than the terminal leaves it on the last cell
  • Both closed footers name /, since the jump works with a ticket open as well: it moves the selection and the overlay follows
  • Out of scope on purpose, each its own ticket once the input mode exists: n and N for the next and previous match, searching the description, tags or owner, regex, and filtering the board down to matches rather than selecting one

The Command Prompt

  • prompt: Option<Prompt> is the whole mode, the shape search and detail use: open and content cannot disagree, and closing it leaves nothing to reset. Prompt carries the line, the cursor as a byte offset into it, and refused, which is Search::missed with something to say
  • Board::prompt_key is third in the pre-dispatch, beside search_key and picker_key and on the same contract: while a command is being typed q is a letter, d leaves the columns alone and tab stays out of the project tabs, and ctrl-c is the one key declined. It takes a Size for enter's sake: running a command reloads the board and then has to bring the ticket it moved back into view, which is the measurement follow_selection takes. Only one of the two prompts can be open at once: : is reachable from the action arms alone, and while either has the keyboard the other's key is a character in a line
  • esc and enter are the mode's own keys and are answered in prompt_key; everything else belongs to the line and goes to Prompt::key. That is also what keeps the borrow straight, since closing the prompt takes the whole board and editing takes only the prompt. Left, right, home, end, backspace and ctrl-w behave as they do in a shell, and ctrl-w eats the separators behind the cursor before the word behind those, so one press at the end of mv 1b78a24 takes the id. There is deliberately no tab: suggesting the selected ticket is 00a14e7, and until then it is a key that must not reach the tabs
  • The grammar is clap's, with nothing restated. The line is tokenised by split_line, the binary's own name goes in front, and the arguments go to the same Cli definition the shell reaches, so a flag added to a command is typeable here the day it is added. Through Cli::command().try_get_matches_from_mut rather than try_parse_from, for what the matches give back: command_name walks the subcommands to name what resolved (campaign show, not campaign) instead of a match over every variant, which would be a second list of every verb the CLI has and one that goes stale silently
  • refused is cleared by an edit and not by a movement. The message is about the line, and moving the cursor does not change the line. Prompt::key clears it in the three arms that write to the line
  • A line that ends inside a quote never reaches clap. That is what Unclosed is for: a grammar complaint about a sentence nobody finished describes the wrong thing. Enter on an empty line, or one of nothing but separators, closes the prompt with nothing said, the way esc does — the bare form of the CLI opens a board and there is one on the screen
  • Enter runs it, through main.rs's dispatch and never through a handler this file names. That match is the one mapping from a parsed command to the function that performs it: main calls it with its own stdout and the working directory, Board::run calls it with a buffer and the selected tab's root. A second copy inside tui.rs would drift the first time a command was added, and it would drift silently, since both halves go on compiling. The match is exhaustive so a new verb cannot fall into an _ arm and do nothing, and main_and_the_prompt_run_one_dispatch_table reads both files as text to pin it. Only tui is matched outside the table, in main, because the board is that table's caller rather than an entry in it; reached from the prompt it is refused in those words
  • from_arg_matches on the same matches gives run the typed values. One parse, two readings: command_name walks the subcommands to name what resolved and from_arg_matches reconstructs the Cli. A match over every Command variant to get one or the other would be a second list of every verb the CLI has
  • The handler's own words are what the board reports, word for word. Those messages are written for a person already, and a second set kept here would go stale the first time one of them changed. The sink is a buffer, so the words come back as text and the board styles them; it is plain for the same reason Detail holds spans, since a ratatui paragraph prints an escape rather than obeying it. An error never goes through a sink at all — color_text asks the process about its stdout, which under the board answers yes about a terminal the message is not going to — so error_lines runs without_escapes over it and puts each cause on a line of its own
  • A handler that errors leaves the prompt open with the line intact. The usual cause is an ambiguous id, and the fix is two more characters rather than the whole line retyped from :. Ambiguity is an Err carrying the candidates, not a print and an exit, which is what makes it safe to reach from here at all
  • The reload after a command is unconditional, and runs whether it failed or not. tick reloads on the digest, which is right for a change made in another pane and needless latency for one the board just made: the reader would watch their own mv take up to a poll interval to appear. Either way, because a handler that failed part way through has still written
  • The selection is restored by uuid across that reload, never by index. mv puts the card in another column, set --title renames its file, and a filter can drop it out of view entirely, so the slot is not the ticket. Board::reselect has three answers: the card is in a drawn column and the selection goes to it; it is on the board but in a column the rotation is hiding, which is where --status done lands by default, so the notice says where it went and which key shows it; or the filter no longer holds it, which is said too, since a card vanishing from under the highlight reads as a bug in the board
  • The merge tab is refused, for now. It is the one tab that is not a board — its cards came from several .worklane directories and it is none of them — so Board::current_project answers None there and the command is refused rather than landing on whichever project came first. Routing by the card a command names is ebc5755. The project is resolved by index and not by the tab's name, which is a label two projects can share: e1d79c3 is exactly that, and a write routed by name would be that bug with a file changing at the end of it
  • Notice holds as many lines as the command used, and Board::notice_on_row decides where they go. One line with nothing else holding the row draws on the footer, where a copy's notice has always drawn. Anything else — several lines, or any answer at all while the prompt is still open on an error — draws as a box at the foot of the columns, cut to what the columns leave with the dropped count on its last row. A box rather than more rows of footer, and that is the whole reason it is an overlay: a footer that grew and shrank as notices came and went would reflow the columns on every keypress, moving every card the reader is looking at. draw and draw_footer both ask notice_on_row, so the two cannot come to disagree and draw the message twice or not at all
  • What a refused line shows is clap's own message with the usage block cut off, which is also what drops the --help line after it. --help is the exception: it parses as an error of the kind that means print this and what it would print is a page, so it is caught and answered in a row's worth of words, or clap's help lands on the alternate screen the way an unsunk println! would. --version goes through the ordinary path, because what it prints is one line by construction. ColorChoice::Never on the command, so nothing that reaches the row carries an escape
  • The keys' width comes off the row before the line is windowed, so a long command does not push them off the end; a message takes the row from the keys instead, since the reader has just been told something and esc and enter still do what they did. prompt_window anchors the window on the cursor's right edge, which costs the text after the cursor on a long line: keeping both ends needs a scroll offset in state, and the draw is where the width is known and the state is not writable
  • : command is named in every footer state, because the key works in every one of them, and the prompt's own key is drawn as ↵ run

The Prompt's Recall

  • up and down walk the lines already typed, and the lines are on disk. .wlhistory in the board's own folder, appended as each line is entered. It is the one file under .worklane the board writes rather than a command, and the only one that is not markdown, which is the cost of a recall worth having: a board is opened and closed all day, and one that emptied on quit would only help inside a single sitting
  • Recall is per tab, parallel to Board::tabs, so the tab in view decides which list up walks. A project's lines are the ones naming its ticket ids, and handing another board's mv back on this one would offer an id that resolves to nothing there. The tabs are fixed for the run, so the two vectors cannot drift, and the same index that picks the tab picks the recall
  • The merge tab has no file. It is the one tab that is not a board, current_project answers None there and a command typed there is refused for that reason, so there is nothing to attribute a line to. Those lines are still recalled for the run: every one of them was refused, and a refused line is the one most worth getting back. When ebc5755 routes a merge line to the board its card names, that board's file is the one to append to
  • The position is on Prompt and the lines are on Recall, so closing the prompt forgets the position and not the lines: the next : opens at the end of the list again, which is where a shell opens. pending holds the half typed line up walked away from, and walking down past the newest entry puts it back, so leaving a command to look for an older one never costs it
  • The ends are stops, not wraps. up on the oldest line leaves it up rather than cycling round to the newest, which is what a shell does with it; down with no walk under way does nothing, since there is nothing in front of a line still being typed and emptying the row would be a keypress that destroys work. An empty recall does nothing at all, and that includes leaving the line alone, or up on a board nobody has typed at would be a way to lose what is half written
  • The line is kept before anything can refuse it. A refused line never reached a handler and the fix is usually two characters, which is what the walk exists to save. Consecutive duplicates are kept once, against what is already held, so the rule spans runs as well as one sitting; a blank line is no command and is not kept. Nothing is trimmed
  • A failed write is silent, and an unreadable file is an empty recall. The line is in memory either way, so the walk works for the run on a board whose folder cannot be written, and a board with no history yet is the ordinary case rather than something to say. A notice about a history file would be about the one thing the reader did not ask for
  • .wlhistory is not in digest. Appending to it must not read as the tree moving, or every command typed would provoke a reload of every board on top of the one run already does

Splitting a Typed Line

  • split_line is the whole module, and it knows nothing about Board. The command prompt reads one string and clap reads an argv, so comment 1b78a24 the offset was never passed has to be tokenised before anything can parse it: split on whitespace it is five arguments and comment takes two. A pure function over the line and the cursor is what makes every rule reachable from a unit test, and it is in a file of its own rather than in tui.rs, which is eleven thousand lines already
  • The rules are the shell's, because that is what the prompt promises: the line is spelled there exactly as it is spelled in the shell. Runs of whitespace separate arguments, single and double quotes group one, a backslash escapes the next character except inside single quotes where it is a backslash, and an explicitly empty '' is an argument that exists and is empty — which is what --title "" being a usage error rather than a silent clear depends on. A leading hyphen is not special here: whether --foo is a flag or the text of a criterion is clap's question, and PROSE already answers it
  • Written rather than pulled in, for the two answers a shell's own splitter does not owe anybody. A line being typed is half finished, so an unterminated quote is a state to report and not an error to raise: Unclosed says which quote is open, or that the line ends on a backslash with nothing yet to escape, and the arguments up to that point are handed back anyway, because that is what a hint or a completion has to work from. And completion needs the cursor: which argument it is in counting from the verb, and whether nothing of that argument lies before it, which is the difference between completing an argument and starting one. Both fall out of the one scan and neither is reachable afterwards from the arguments alone
  • Some("") is an argument that has been opened and is still empty, which is the only thing that tells '' from nothing typed at all. The cursor's answer is taken before the last argument is pushed, so a cursor at the end of the line is in the argument being typed rather than one past it
  • The cursor is a byte offset, because that is what the prompt's own cursor is: a String inserts and removes at byte indices. Past the end reads as the end and inside a multi-byte character reads as after it, so nothing panics and no caller has to clamp first
  • Unclosed::Escape wins over an open quote, being the inner of the two, and either answer refuses the line
  • The binary's own name is not among the arguments: prepending it before Cli::try_parse_from is the caller's, since only the caller knows what it is calling

The Copy Key

  • y copies the selected card's short id, over OSC 52 written by hand. The board is where a ticket is found and the CLI is where it is acted on, and the only thing joining them was seven characters retyped off the screen. y reads as yank to the readers a keyboard board is for, and was the letter left: q, esc, enter, space, hjkl, the arrows, pgup, pgdn, tab, backtab, d and / were taken
  • The mechanism was chosen against ssh, which is where a board is often read. An escape sequence is the only one of the three ways that crosses the connection, since it is the terminal at the reader's end that owns the clipboard. A crate (arboard and its kind) wants X11 and Wayland libraries at build time, and on X11 the selection belongs to the process that set it: copy an id, quit, and the paste buffer is empty, which is precisely this flow. Shelling out to wl-copy, xclip or pbcopy is platform sniffing plus a process spawn, and does nothing on a machine where none of them is installed or on the far end of a connection. crossterm 0.28 is what ratatui 0.29 pins and it ships no clipboard command, and the backend types have to match whatever ratatui pins, so a newer crossterm cannot be picked up on its own
  • The cost is paid knowingly: a terminal that ignores OSC 52 ignores it silently, and tmux needs set-clipboard on. What clipboard::copy reports is whether the sequence was written, not whether it was honoured, and the footer message says no more than that. There is no reply to read: the query form of OSC 52 is refused by most emulators as a security matter, so nothing better is available to us
  • Base64 is twenty lines here rather than a dependency, because the only thing that goes through it is a seven-character id. Pinned on the RFC 4648 vectors, which cover both padding forms, since a wrong encoder would put plausible-looking rubbish on the clipboard
  • c and not p: the clipboard proper, not the X11 primary selection, since this is pasted into a command line. Terminated with BEL, which is what tmux documents and what every emulator that implements this at all accepts
  • What is copied is ticket.id, the seven characters the card prints, not the full uuid: they are what stops the retyping and what show, mv and comment all resolve. Decided by Board::copy_text rather than inside the arm that copies, so the string is a question the suite can ask without a clipboard. None on an empty column, since an empty string would take away whatever the reader had there and give nothing back
  • The project is left off even on the merge tab, where the id alone is not an address. This goes onto a clipboard to be pasted into a command line, and a second word in it would have to be deleted every time; running the command in the wrong project fails to resolve rather than acting on the wrong ticket
  • The clipboard is handed to Board::copy_selected_id as an argument, clipboard::copy from the dispatch and a closure from a test. That is what makes both answers drivable, and it keeps the terminal write out of the board state
  • A failure is said in the footer, not returned. There is nobody above it to handle one: the board goes on being drawn, and an error swallowed there would look exactly like a copy that worked until the paste came out wrong
  • Notice is the board's one channel for saying something in words, since a copy leaves nothing on screen to look at. failed means "nothing reached the clipboard" rather than "an error occurred", so an empty column and a refused write are one answer to the reader, both in brightred for the reason no match is
  • It takes the whole footer row, on a weaker reason than the prompt's: every key still works while a notice is up. It is that a message squeezed in beside the key list would move every key in it, and the row is the only part of the board that is not a ticket. Drawn after the prompt, which is an input and cannot be covered
  • The notice is cleared by the next keypress, not by a timer. No clock on the board and no wakeup in the loop, and the moment the reader does anything else the message has been read or was never going to be. Doing nothing leaves it up, which is the one state where it is still worth reading. Board::clear_notice runs ahead of search_key as well as the arms, since a key typed into a query is still a key, and it must never move into tick: the board redraws four times a second and a notice cleared there would never be read