Fuzzy filtering for the bare-mox session picker#12
Merged
Conversation
Bare mox now renders an inline, redrawing list under the prompt: typing filters live (prefix beats substring beats subsequence), arrows and Ctrl-J/K/N/P move the selection, Enter attaches, Esc/Ctrl-C cancels. Rows are plain text truncated to the terminal width so redraw math stays exact. Raw-mode terminal handling comes from golang.org/x/term; when raw mode is unavailable the numbered prompt remains, and non-TTY invocations keep printing help. The event loop reads from a plain io.Reader, so the whole interaction is unit-tested with scripted keystrokes.
The go directive moved to 1.25 with the x/term dependency.
The action's prebuilt v2.0 binary is built with Go 1.24 and exits 3 on a go 1.25 module. v2.12.2's staticcheck also flags WriteString(Sprintf(...)), so those become Fprintf. Also swap the retired Go Report Card badge for the pkg.go.dev reference badge.
The hand-rolled ANSI renderer read as homemade. The list component brings styled two-line items (session name over state/windows/activity/ hosts), built-in fuzzy filtering, pagination, and a help footer, running inline without an alt-screen takeover. Typing filters immediately (the filter opens on first keystroke), Enter attaches the highlighted session, Esc clears the filter and then cancels. Model updates are driven directly in tests with a command-executing drain loop, so filtering (which the list applies asynchronously) is covered without a terminal. Replaces the custom fuzzy matcher, raw-mode handling, and redraw math; x/term drops back to an indirect dependency.
The list pane carries status dots (green running, dim stopped, yellow unmanaged), an accent bar on the selection, and a match counter while filtering; the preview pane shows the highlighted session's live state plus everything the config knows: hosts, connect template, sync, arrange, root, window layout. Panels are hand-drawn with title and key-hint borders, colored strictly from the terminal's 16-color palette so the user's theme decides the look. Narrow terminals collapse to the list pane alone. Filtering is now synchronous (sahilm/fuzzy directly), which also simplifies the model tests back to plain Update calls; bubbles/list and its async filter plumbing are gone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bare
moxnow opens an interactive fuzzy picker instead of the static numbered list. Type to filter (prefix beats substring beats subsequence), move with arrows orCtrl-J/K/N/P,Enterattaches,Esccancels. It renders inline under the prompt and redraws in place: no alt-screen takeover.Implementation notes:
golang.org/x/term(plusx/sysindirect, both Go-team maintained). Thegodirective moved to1.25with it, so CI builds with Go1.25now.io.Reader, so the whole interaction is unit tested with scripted keystrokes: filtering, arrow/ctrl navigation, wrap-around, backspace,Ctrl-U, and every cancel path.Tests and lint are green locally. Please give the picker a spin in a real terminal before merging, since the ANSI redraw behavior is the one thing unit tests can't fully prove.