cmdio: replace promptui with bubbletea-backed Prompt and Select#5232
Open
pietern wants to merge 6 commits into
Open
cmdio: replace promptui with bubbletea-backed Prompt and Select#5232pietern wants to merge 6 commits into
pietern wants to merge 6 commits into
Conversation
Drops the manifoldco/promptui (and transitive chzyer/readline) dependency in favor of hand-rolled bubbletea models that reproduce promptui's rendering and key handling. RunPrompt and Secret share a single-line editor that pins the cursor-block visuals, mask, validate (with inline "✗" glyph and a red ">> <err>" line surfaced after a failed Enter), HideEntered post-submit clearing, Ctrl+B/F as left/right, Ctrl+H as backspace, Ctrl+J as Enter, and Delete/Ctrl+D as EOF. RunSelect, Select, and SelectOrdered share a templated list with viewport scroll and ↑/↓ gutters, a search filter with vim-style nav and "/" toggle, Ctrl+P/N as item-up/down, Ctrl+B/F (and the left/right arrows) as page-up/down, default Active / Inactive / Selected templates that match promptui's defaults, and an empty final frame when HideSelected is set. Both primitives refuse to draw on a non-interactive terminal so callers no longer have to gate on IsPromptSupported themselves; SelectOrdered drops its now-redundant guard. SelectOptions.Items is now validated at construction and normalized to []any so the render path doesn't reflect on every row. The behavior pinned above is verified against the cmdiotest pty- and vt10x-based baseline suite developed in #5231. That suite is kept on a separate branch — and not merged here — because it pulls in test-only dependencies (creack/pty, hinshun/vt10x, x/term) that we'd prefer not to land in the main module. Co-authored-by: Isaac
Contributor
Approval status: pending
|
After the PR was opened, sweep through prompt.go and select.go and remove comments that name-drop promptui without saying anything the code doesn't already convey. Keep the comments that document a non-obvious behavior (post-submit "\n", Alt-rune dropping, Delete-as- EOF, "/" toggle batching, ">>" validation line); drop the ones that just trace where a particular spec came from. Co-authored-by: Isaac
Follow-up to the comment sweep: a few of the trimmed comments were
load-bearing — they justified intentionally-surprising behavior the
baseline tests pin. Without the "why", a future reader (or refactor)
might assume the code is incidental and "fix" it.
Restored on:
- Delete / Ctrl+D exits with EOF even on a non-empty buffer.
- Alt+<rune> word-nav combos are dropped instead of inserted (both
the prompt buffer and the select filter).
Also gave libs/cmdio/capabilities.go the same trim that the previous
commit applied to prompt.go and select.go — the Git Bash gate
comment was still naming promptui and pointing at upstream issue
links that no longer reflect why we keep the carve-out.
Co-authored-by: Isaac
libs/template/config.go and libs/databrickscfg/cfgpickers/clusters.go each had a one-line comment naming promptui to explain a constraint that still applies (single-line labels in RunSelect, ctx-free template helpers). Reword them to describe the constraint in terms of the current API instead of the removed dependency. Co-authored-by: Isaac
Final stray reference outside the cmdiotest test branch — reword to describe what the stub avoids (spawning a TUI) instead of naming the removed dependency. Co-authored-by: Isaac
Follow the earlier convention: describe what the stub avoids
("prompting") rather than the mechanism being avoided.
Co-authored-by: Isaac
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
RunPromptandRunSelectas bubbletea models that reproduce promptui's rendering and key handling end-to-end.RunPromptsupports cursor editing, mask, validate (with inline glyph and>> <err>line surfaced after a failed Enter),HideEntered, Delete/Ctrl+D as EOF, and the Ctrl+B/F/H/J aliases.RunSelectsupports templated rows, viewport scroll, filter with/toggle and vim-style nav, Ctrl+P/N item nav and Ctrl+B/F page nav, and an empty post-submit frame whenHideSelectedis set.manifoldco/promptuiand the transitivechzyer/readlinedependency.SupportsPromptcapability check into the primitives themselves so callers no longer have to gate onIsPromptSupported;SelectOrdereddrops its now-redundant guard.SelectOptions.Itemsis validated at construction and normalized to[]anyso the render path doesn't reflect on every row.Test plan
creack/pty,hinshun/vt10x) we'd prefer not to land in the main module.databricks selftest tuicommands against the released CLI: same visible output, same exit codes.