sp open: interactive fuzzy picker when no id is given (#10) - #24
Merged
Conversation
5 tasks
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.
Closes #10
What changed
sp openwith no id now launches an interactive picker over the live scratches instead of requiring an id up front.New
internal/pickerpackage (stdlib-only, no new deps)match.go— pure, I/O-free fuzzy matcher. Case-insensitive subsequence match over each scratch's id + name + tags, ranked with bonuses for contiguous runs and word-boundary hits (sotdo→todo, and a clean prefix outranks a scattered match). Fully unit-tested.select.go— front-ends chosen in priority order:q/Esc/Ctrl-C/EOF cancels.Wiring
sp openis nowMaximumNArgs(1):sp open <id>keeps its exact old behavior;sp open(bare) runs the picker. Added--no-fzfto force the built-in picker.openScratchas the shared tail so a picked scratch opens identically to an explicit id (one$EDITORlaunch site preserved).render.PickerLabelrenders each row (id, name, age, expires-in, tags) — presentation stays inrender; the picker owns interaction only. Plain (no ANSI) since the labels are also the fuzzy-match/fzf input.Acceptance criteria
sp openwith no id opens an interactive selector (name, age, expires-in, tags visible)$EDITORfzfdependency (built-in prompt); detects and defers tofzfif presentqcancels cleanly with no changesNotes / deviations
go.modunchanged (nogo mod tidychurn, smaller supply-chain surface) and makes the whole selection flow headlessly unit-testable. The interaction still satisfies "keyboard-driven fuzzy filter" without raw-mode TUI. Happy to swap in a bubbletea TUI in a follow-up if you'd prefer the richer full-screen feel.sp cat/rm/resurrect" idea from the issue notes is intentionally not in scope here; the picker package is structured so those can reuseSelectlater.Testing
internal/picker(matcher + all three front-ends incl. fzf via injected fakes, and every cancel path) plusinternal/cli(sp openpicker end-to-end) andinternal/render(label).go build ./... && go vet ./... && go test ./...all green;gofmtclean;go mod tidyproduces no diff.