[go-fan] Go Module Review: bubbletea #20169
Closed
Replies: 1 comment
-
|
This discussion was automatically closed because it expired on 2026-03-10T07:26:47.368Z.
|
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.
-
🐹 Bubble Tea is the TUI framework powering
gh-aw's interactive spinner and list selector. Today's review covers the current v1.3.10 usage, the recently-released v2.0.1 (2026-03-02), and concrete improvement opportunities in the existing code.Module Overview
github.com/charmbracelet/bubbleteais the Go TUI framework based on the Elm Architecture. Models implementInit() Cmd,Update(Msg) (Model, Cmd), andView() string. It drivesgh-aw's spinner animations and interactive list selection.Current Usage in gh-aw
pkg/console/list.go,pkg/console/spinner.go)v1.3.10(latest:v2.0.1atcharm.land/bubbletea/v2)tea.NewProgram,tea.WithAltScreen(),tea.WithoutRenderer(),tea.WithOutput(),program.Run(),program.Quit(),program.Send()The spinner uses
tea.WithoutRenderer()for manual ANSI output to stderr — a valid pattern for inline spinners. The list usestea.WithAltScreen()for full-screen interactive selection with a TTY fallback.Research Findings
Recent Updates (v2.0.0 + v2.0.1, Feb–Mar 2026)
The v2 release is a substantial upgrade with a new import domain and several API changes:
charm.land/bubbletea/v2(no longergithub.com/charmbracelet/bubbletea)View(): Returnstea.Viewstruct instead ofstring. Terminal features are now set declaratively (v.AltScreen = true) rather than as constructor optionstea.KeyPressMsg/tea.KeyReleaseMsg:tea.KeyMsgnow matches both; enables shift+enter, ctrl+h, key-release eventstea.WithWindowSize(w, h): Sets window dimensions for non-TTY testing — no more mockingtea.RequestBackgroundColor/tea.BackgroundColorMsgfor adaptive light/dark themingBest Practices from Maintainers
v.AltScreen = trueinView()rather than constructor options (v2)tea.WithWindowSize()in tests to avoid real-TTY requirementstea.RequestBackgroundColor+tea.BackgroundColorMsgfor adaptive color stylingImprovement Opportunities
🏃 Quick Wins
Fix
WindowSizeMsgheight handling (list.go:48–50)Currently only width is updated on resize:
Should also set height so the list uses the full terminal on resize:
Safe type assertion (
list.go:183)Add
tea.WithOutput(os.Stderr)to list program (list.go:174)The spinner correctly targets stderr. The list program uses default stdout, but TTY detection in the same file checks stderr. These should be consistent:
✨ Feature Opportunities
Detect terminal size for initial list dimensions (
list.go:154)The list is initialized with hardcoded
80×20:Using
golang.org/x/term(already a direct dependency) to detect actual terminal dimensions would give a better initial fit. TheWindowSizeMsgwill still correct it, but the first frame would look right.tea.WithWindowSize()in tests (v2 feature)Once on v2, tests can specify a window size without needing a real TTY:
This would enable more thorough unit tests of list rendering.
Adaptive light/dark styling (v2
BackgroundColorMsg)The list delegate hardcodes dark-biased colors. With v2,
tea.RequestBackgroundColorreturns aBackgroundColorMsgthat exposesIsDark()— enabling proper adaptive styling.📐 Best Practice Alignment
v2 Migration Roadmap
The current code is v1 idiomatic and correct. The v2 migration would require:
charm.land/bubbletea/v2list.go,spinner.goView() string→View() tea.ViewlistModel,spinnerModeltea.KeyMsg→tea.KeyPressMsglist.go:37,spinner.go:75tea.WithAltScreen()→v.AltScreen = truelist.go:174The migration is mechanical and low-risk. The biggest benefit is the Cursed Renderer (better performance, no flicker) and
tea.WithWindowSize()for testing.Recommendations
WindowSizeMsgto also update height inlist.go(list won't resize vertically otherwise)tea.WithOutput(os.Stderr)to list program for output consistencyNext Steps
list.go)bubblesv2.0.0 was also just released (2026-02-24) and is part of the same ecosystem upgradeModule summary saved to:
scratchpad/mods/bubbletea.mdSelected as most recently updated unreviewed direct dependency (v2.0.1 released 2026-03-02)
References:
Beta Was this translation helpful? Give feedback.
All reactions