feat(tui): make prompt component messages caller-overridable#27
Merged
Conversation
The min-selection guard previously showed "at least %d selections required" without telling the user how to select. Append "— press space to select" so the error is actionable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The min/max selection validation strings were hardcoded, forcing a library change for any caller that wanted different wording. Add WithMinSelectionsError / WithMaxSelectionsError options taking a func(count int) string; nil keeps the library default, so existing callers are unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The editor was the only prompt component with no override hooks: its "(ctrl+d to submit, esc to cancel)" affordance and "[N lines]" summary were hardcoded in View(). Add WithEditorHint(string) and WithEditorSummary(func(lines int) string); empty/nil keeps the current output, so existing callers are unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…x default Adversarial review found the max-error override was only exercised through the space-toggle path, not the separate toggleAll (ctrl+a) path, and there was no symmetric "default max message" test to mirror the min case. Add both. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Resolves the API asymmetry flagged in review: WithEditorHint("") meant
"use default", so a caller could never render an empty/suppressed hint
(unlike Summary, whose nil sentinel lets a func return ""). Add an
explicit WithEditorNoHint() that drops the parenthetical entirely and
takes precedence over WithEditorHint.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Previously the multiselect min/max error overrides were only reachable
via a direct Prompter.MultiSelect call; wizard steps could not set them.
Add Step.MinError and plumb it through buildPromptModel. This lets flows
replace the grammatically awkward default ("at least 1 selections
required") on Required multi-selects.
Max/editor overrides are intentionally not plumbed: the wizard never
sets a max on multi-selects and has no editor prompt type, so wiring
them would be dead code.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Makes user-facing validation/affordance strings in the TUI prompt components caller-overridable instead of hardcoded, so consumers can customize wording without a library change. All changes ship sane defaults — existing callers are unaffected.
Multiselect
WithMinSelectionsError(func(min int) string)/WithMaxSelectionsError(func(max int) string)— override the min/max validation messages. nil keeps the library default.at least %d selections required — press space to select(more actionable).Editor (previously had no override hooks at all)
WithEditorHint(string)— override the(ctrl+d to submit, esc to cancel)affordance text.WithEditorNoHint()— suppress the affordance line entirely (resolves theHint/Summarysentinel asymmetry).WithEditorSummary(func(lines int) string)— override the post-submit[N lines]summary.Wizard
Step.MinError func(min int) string— letsMultiSelectPromptsteps customize the min-selection message, plumbed throughbuildPromptModel. Useful to replace the grammatically awkward default (at least 1 selections required) onRequiredmulti-selects.Design notes
func(count int) string) chosen over format-strings to avoid the%dfootgun and stay type-safe.textinputwas already flexible (errors come from the caller'sValidate);select/livelisthave no validation strings (labels already relabel-able). Multiselect and editor were the genuine gaps.Testing
toggleAll/Ctrl+A max path and default-when-unset cases for both min and max.TestEngine_MultiSelectMinErrorPlumbeddrives a real built model end-to-end.go build ./..., fullpkg/tui/...suite,go vet, and pre-commit (gofmt/goimports/lint/tests) all green.🤖 Generated with Claude Code