Skip to content

[Code Quality] Expand Huh forms usage for interactive CLI operations #14338

@github-actions

Description

@github-actions

Description

The Huh forms library is currently underutilized - only confirmation dialogs are implemented. Expanding Huh usage to other interactive CLI operations (secret input, workflow selection, configuration forms) will improve user experience and reduce input errors.

Current Problem

From the Terminal Stylist Report (Jan 31, 2026):

  • Current Huh usage: Only pkg/console/confirm.go (confirmation dialogs)
  • Missing opportunities: Input fields, multi-select menus, form validation
  • Current approach: Manual fmt.Scanf and text-based prompts
  • Impact: Less polished UX, prone to input validation errors

Current State

// Only confirmation dialogs use Huh
func ConfirmAction(title, affirmative, negative string) (bool, error) {
    var confirmed bool
    confirmForm := huh.NewForm(
        huh.NewGroup(
            huh.NewConfirm().
                Title(title).
                Affirmative(affirmative).
                Negative(negative).
                Value(&confirmed),
        ),
    ).WithAccessible(IsAccessibleMode())
    // ...
}

Suggested Changes

Priority 1: Secret Input (High Impact)

Replace fmt.Scanf in pkg/cli/secret_set_command.go:

// BEFORE
fmt.Print("Enter secret value: ")
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
secretValue := scanner.Text()

// AFTER
var secretValue string
huh.NewForm(
    huh.NewGroup(
        huh.NewInput().
            Title("Enter secret value").
            Password(true).  // Masks input
            Validate(func(s string) error {
                if len(s) == 0 {
                    return fmt.Errorf("secret value required")
                }
                return nil
            }).
            Value(&secretValue),
    ),
).WithAccessible(IsAccessibleMode()).Run()

Benefits:

  • Password masking (security)
  • Built-in validation
  • Better error messages
  • Accessible mode support

Priority 2: Workflow Multi-Select (Medium Impact)

Add workflow selection for compilation:

var selectedWorkflows []string
options := make([]huh.Option[string], len(workflows))
for i, wf := range workflows {
    options[i] = huh.NewOption(wf.Title, wf.Path)
}

huh.NewForm(
    huh.NewGroup(
        huh.NewMultiSelect[string]().
            Title("Select workflows to compile").
            Description("Use space to select, enter to confirm").
            Options(options...).
            Limit(10).  // Show 10 at a time
            Value(&selectedWorkflows),
    ),
).WithAccessible(IsAccessibleMode()).Run()

Use cases:

  • gh aw compile --interactive (select multiple workflows)
  • gh aw validate --interactive (select workflows to validate)
  • gh aw run --interactive (select workflow to run)

Priority 3: Configuration Forms (Lower Impact)

Interactive workflow scaffolding:

type WorkflowConfig struct {
    Name    string
    Engine  string
    Verbose bool
}

var config WorkflowConfig

huh.NewForm(
    huh.NewGroup(
        huh.NewInput().
            Title("Workflow name").
            Validate(validateWorkflowName).
            Value(&config.Name),
        
        huh.NewSelect[string]().
            Title("Select AI engine").
            Options(
                huh.NewOption("Copilot", "copilot"),
                huh.NewOption("Claude", "claude"),
                huh.NewOption("Codex", "codex"),
            ).
            Value(&config.Engine),
        
        huh.NewConfirm().
            Title("Enable verbose mode?").
            Value(&config.Verbose),
    ),
).WithAccessible(IsAccessibleMode()).Run()

Use cases:

  • gh aw init (create new workflow interactively)
  • gh aw config (configure global settings)

Files Affected

New functionality:

  • pkg/console/input.go (input helpers)
  • pkg/console/select.go (select/multi-select helpers)
  • pkg/console/form.go (form composition helpers)

Refactor existing:

  • pkg/cli/secret_set_command.go (secret input)
  • pkg/cli/compile_command.go (workflow selection)
  • pkg/cli/init_command.go (interactive scaffolding)

Success Criteria

  • Secret input uses Huh with password masking
  • Workflow multi-select available in compile/validate commands
  • Interactive forms available for at least 3 CLI commands
  • All forms respect accessibility mode (ACCESSIBLE, NO_COLOR)
  • TTY fallback works correctly (text-based prompts)
  • No regressions in non-interactive usage
  • User feedback indicates improved UX

Estimated Effort

Medium (1-2 days)

  • Secret input: 2-3 hours
  • Multi-select: 3-4 hours
  • Configuration forms: 4-6 hours
  • Testing and polish: 2-3 hours

Source

Extracted from Terminal Stylist Report: Console Output Analysis (Discussion #12889)

Priority

Medium - Improves user experience and reduces errors. Not blocking functionality, but high value for interactive CLI usage.

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 8, 2026, 1:18 PM UTC

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions