[go-fan] Go Module Review: charmbracelet/huh #24261
Closed
Replies: 2 comments 1 reply
-
|
/plan |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
This discussion was automatically closed because it expired on 2026-04-04T08:16:38.325Z.
|
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.
-
🐹 Go Fan Report: charmbracelet/huh — Terminal Form Library
Module Overview
charmbracelet/huhis the interactive form and prompt library at the heart of gh-aw's CLI UX. It powers every password input, workflow selection list, confirmation dialog, and the multi-step workflow builder wizard. Built on Bubble Tea, it providesInput,Text,Select,MultiSelect, andConfirmfield types with theming and accessibility support.Currently pinned:
github.com/charmbracelet/huh v0.8.0(Oct 2025)Latest available:
charm.land/huh/v2 v2.0.3(released 2026-03-09, pushed 2026-03-30)Current Usage in gh-aw
The module is used in 13 files across
pkg/console/andpkg/cli/.NewForm(19×),NewGroup(22×),NewOption(33×),NewSelect(8×),NewInput(8×),NewConfirm(5×),NewMultiSelect(2×),NewText(1×),EchoModePassword(4×)Consistent patterns observed:
.WithTheme(styles.HuhTheme()).WithAccessible(console.IsAccessibleMode())— nicely consistentform.RunWithContext(ctx)for cancellation supportValidate(func(s string) error {...})The standout usage is the 4-group workflow creation wizard in
pkg/cli/interactive.go— it guides users through trigger selection, capability configuration (tools + safe-outputs multi-selects), network/security settings, and free-text instructions in a clean paginated flow.Research Findings
Recent Updates
huh reached v2.0.0 on 2026-03-09 — a significant release that migrates the entire Charm ecosystem to vanity import paths and Bubble Tea v2. Here's what changed:
github.com/charmbracelet/huhcharm.land/huh/v2github.com/charmbracelet/bubbletea v1.xcharm.land/bubbletea/v2github.com/charmbracelet/lipgloss v1.xcharm.land/lipgloss/v2*huh.Theme(pointer return)huh.ThemeFunc = func(isDark bool) *Styleshuh.Modelform.WithViewHook(func(v tea.View) tea.View)Best Practices from Maintainers
ThemeFuncto detect dark/light terminal background automaticallyOptionsFuncwith a binding for dynamic options that change based on other fieldsform.GetString("key")/form.GetInt("key")via.Key()for Bubble Tea embedded formsImprovement Opportunities
🏃 Quick Wins
1. Upgrade to huh v2 — remove the lipgloss v1 orphan dependency
This is the most impactful and natural improvement.
gh-awhas already migrated to:charm.land/bubbletea/v2 v2.0.2charm.land/lipgloss/v2 v2.0.2charm.land/bubbles/v2 v2.1.0But
github.com/charmbracelet/huh v0.8.0still depends ongithub.com/charmbracelet/lipgloss v1.x— an old dependency that now exists solely because of huh. The code even has a comment acknowledging this forced redundancy:These could be cut off on navigation in v0.8.0. The fix is free with the upgrade.
✨ Feature Opportunities
3. ThemeFunc with dark mode detection
huh v2 introduces
ThemeFunc = func(isDark bool) *huh.Styles. The currentHuhTheme()inpkg/styles/huh_theme.goalready useslipgloss.AdaptiveColorfor light/dark variants, but doesn't get theisDark boolsignal from huh's terminal detection. Migrating toThemeFuncwould let the theme make better decisions:4. Dynamic OptionsFunc for deferred option loading
The
buildSafeOutputOptions()function ininteractive.goloads all safe output options eagerly before the form starts. For larger option sets,OptionsFuncwith a binding enables lazy + cacheable loading:📐 Best Practice Alignment
5. Theme return type
HuhTheme()currently returns*huh.Themeand is called as.WithTheme(styles.HuhTheme()). After the v2 upgrade it should returnhuh.ThemeFuncand be passed directly:6. Remove the lipgloss v1 workaround comment
Once upgraded, the explanation comment in
huh_theme.gobecomes obsolete and should be removed.Recommendations
github.com/charmbracelet/huh v0.8.0→charm.land/huh/v2 v2.0.3lipgloss v1dep, gets bug fixes, aligns with already-upgraded bubbletea/lipgloss v2pkg/styles/huh_theme.go: change import, update return type toThemeFuncgithub.com/charmbracelet/huh→charm.land/huh/v2sedorgofmttoolingOptionsFuncforbuildSafeOutputOptions()Next Steps
UPGRADE_GUIDE_V2.mdin the huh repo for the complete migration checklistgo get charm.land/huh/v2@latestand update all import pathsHuhTheme()signature inpkg/styles/huh_theme.goto returnhuh.ThemeFuncgithub.com/charmbracelet/huhandgithub.com/charmbracelet/lipgloss(v1) from go.modgo mod tidy— lipgloss v1 should disappear from the dependency treeGenerated by Go Fan 🐹 — §23939308349
Module summary saved to:
scratchpad/mods/charmbracelet-huh.mdReferences:
Beta Was this translation helpful? Give feedback.
All reactions