[go-fan] Go Module Review: charmbracelet/huh #21536
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Go Fan. A newer discussion is available at Discussion #21756. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Welcome to today's Go Fan review! 🐹 I'm diving deep into
github.com/charmbracelet/huh— the terminal forms library used throughout gh-aw for interactive TUI prompts. This one is extra exciting because huh just shipped v2.0.0 nine days ago with a new import path!Module Overview
charmbracelet/huhis the Charmbracelet ecosystem's terminal form library. It provides interactive TUI components — inputs, selects, multi-selects, confirm dialogs, text areas, and spinners — built on top of Bubble Tea. It's what makes thegh aw create --interactiveandgh aw run --interactiveexperiences feel polished.Current Usage in gh-aw
v0.8.0(released 2025-10-14)pkg/console/andpkg/cli/Key APIs in use:
NewForm/NewGroupNewConfirmNewInput+EchoModePasswordNewSelect[string]NewMultiSelect[string]NewText.WithAccessible().Filtering(true).Suggestions().Validate()Research Findings
huh v2.0.0 Release Notes (2026-03-09)
huh just shipped its second major version 9 days ago! Here's what changed:
New Import Path
Bubble Tea v2 Integration
Built on
charm.land/bubbletea/v2— the same version gh-aw already migrated to in PR #21520.Simpler Theming
View Hooks (New!)
Accessible Mode Simplified
Accessible mode is now form-level only — individual fields no longer have
.WithAccessible(). The project already follows this pattern correctly! ✅v2.0.2 / v2.0.3 (2026-03-10)
Improvement Opportunities
🚨 Migrate to
charm.land/huh/v2This is the most important finding. The project already migrated to:
charm.land/bubbles/v2(PR feat: migrate charmbracelet/bubbles to v2 (charm.land/bubbles/v2) #21520, merged yesterday!)charm.land/bubbletea/v2charm.land/lipgloss/v2Since huh v2 is built on Bubble Tea v2, keeping
github.com/charmbracelet/huhat v0.8.0 (which uses the old Bubble Tea v1 API) alongside charm.land/bubbletea/v2 creates a split-brain situation in the dependency tree. The migration path is well-documented in the UPGRADE_GUIDE_V2.md.The upgrade primarily involves:
github.com/charmbracelet/huh→charm.land/huh/v2🏃 Quick Wins
confirmExecutionswallows errors silently (run_interactive.go:355): Whenform.Run()returns an error (e.g., Ctrl+C / ErrUserAborted), the function logs it but returnsfalse. This means user cancellation and actual errors look the same to callers. Consider returning the error to distinguish intent.engine_secrets.go has 3 near-identical secret input forms (lines ~296, ~344, ~397): Three separate
NewForm(NewGroup(NewInput().EchoMode(EchoModePassword)...))blocks with similar structure. After the v2 migration, these could be consolidated into a helper function.✨ Feature Opportunities
View Hooks for the large workflow creation form (
interactive.go): The 4-group form inpromptForConfiguration()is the most complex form in the codebase. UsingWithViewHookto enable AltScreen would prevent terminal scroll artifacts and provide a cleaner full-screen experience during the multi-step wizard.Automatic dark mode theming: huh v2's built-in themes auto-detect terminal background color. Currently no custom theme is set, but explicitly using
huh.ThemeCharm(isDark)after v2 migration would make the forms look better in both light and dark terminals.📐 Best Practice Alignment
Accessible mode usage is already exemplary: Every single form in the codebase applies
.WithAccessible(console.IsAccessibleMode())at the form level. This is exactly what huh v2 recommends. No changes needed here. ✅Option construction is idiomatic: Using
huh.NewOption(label, value)throughout is the correct pattern. ✅Filtering on select: Using
.Filtering(true)for workflow selection is great UX. ✅Recommendations
High priority: Migrate
github.com/charmbracelet/huh→charm.land/huh/v2— the Charmbracelet v2 migration train has already left the station for bubbles/bubbletea/lipgloss; huh is the remaining piece.Medium priority: Refactor the 3 duplicate secret input forms in
engine_secrets.gointo a shared helper function.Low priority: Explore
WithViewHookfor the complex workflow creation form ininteractive.goto enable full-screen rendering.Next Steps
github.com/charmbracelet/huh→charm.land/huh/v2(following the same pattern as feat: migrate charmbracelet/bubbles to v2 (charm.land/bubbles/v2) #21520)engine_secrets.goGenerated by Go Fan 🐹
Module summary saved to:
scratchpad/mods/charmbracelet-huh.mdWorkflow run: §23233546981
Beta Was this translation helpful? Give feedback.
All reactions