feat(tui): keybinding framework, bottom hint bar, live-list picker#24
Closed
hi-lei wants to merge 1 commit into
Closed
feat(tui): keybinding framework, bottom hint bar, live-list picker#24hi-lei wants to merge 1 commit into
hi-lei wants to merge 1 commit into
Conversation
Two correctness fixes surfaced by an adversarial review of the keybinding/live-list work on this branch: - liveListModel.Update now early-returns on liveListUpdateMsg once a selection is chosen. bubbletea drains queued messages after tea.Quit, so a pumped update could refilter and empty matched, panicking View's chosen branch (index out of range). Added regression test. - compositeModel.Update re-reads prompt.Hints() after forwarding a key, instead of relying on the one-time snapshot taken in setPrompt. Prompt hint labels are dynamic (e.g. esc flips to "clear filter" while filtering), so the wizard bottom bar went stale. Added regression test. Also clarify the refilter allocation comment and document the testing.Prompter.LiveList drain-goroutine lifecycle contract. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1e534ed to
d051ebe
Compare
Collaborator
Author
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
Reworks the TUI prompt layer around a generic keybinding abstraction, adds a bottom hint bar to every prompt, and introduces a new live-updating list picker. Also bundles routine dependency/CI maintenance.
Keybinding framework (
pkg/tui/bubbletea/keybinding.go, new)Replaces ad-hoc
switch msg.String()handling in each prompt with a declarative, data-driven model:KeyBinding[M]— matcher + state-aware hint label + handler; empty label hides a binding from the hint bar without disabling the key.MatchKey,MatchRune(rune + modifiers),MatchText.Dispatch(firststop=truewins, fall-through supported),HintsFor,ApplyBindingOverrides(non-mutating relabel/hide).DefaultXBindings().Bottom hint bar + relabel/hide options
All prompts (confirm, textinput, select, multiselect, password) refactored onto the binding system and gained a hint bar. New per-prompt config:
WithXRelabel(id, label),WithXHide(ids...),WithShowHints,WithHints(...). Labels are dynamic (e.g. selectescflipsesc back↔esc clear filter).Live-list picker (
pkg/tui/bubbletea/live_list.go, new)New optional
tui.LiveListercapability — a select-style picker whose rows update asynchronously over a<-chan LiveListUpdatewhile the user browses. Contract: unknown keys dropped, last-write-wins per key, cursor identity preserved by Key, type-to-filter on live labels, errored rows styled distinctly, clean pump-goroutine teardown on ctx-cancel / program-exit / channel-close.Shared helpers & wizard
list_helpers.go:visibleWindow+refiltershared across select/multiselect/livelist.testing.PromptergainsAddLiveList/LiveList.Maintenance
x/netbumped;.osv-scanner.tomlignores an unfixed kratos vuln with expiry.osv-scanner-actionv2.1.0→v2.3.8; gitleaks pinned to v8.30.1.Correctness fixes (from adversarial review)
liveListModel.Updateagainst a late pumped update after selection that could emptymatchedand panicView(index out of range).compositeModel.Updatere-readsprompt.Hints()each key so the wizard bottom bar reflects dynamic labels instead of a stale snapshot.Test plan
go build ./...,go test ./...,make lintall green.TestLiveList_NoPanicOnUpdateAfterChosen,TestComposite_HintBar_RefreshesOnFilter.🤖 Generated with Claude Code