BubbleTea Code Review
Hard gates (sequence)
Advance only when each pass condition is objectively true (reduces false positives on tea.Cmd and unsubstantiated blocking claims):
| Gate |
Pass condition |
| G1 — Anti–false-positive |
You skimmed NOT Issues below or read references/elm-architecture.md before recording a finding about tea.Cmd returns, value receivers on Update, or nested child Update. |
| G2 — Evidence for blocking / suspicious I/O |
Each Critical/Major finding names file path + line (or a short quoted snippet) showing the blocking call, huh.Form.Run in the wrong place, or other asserted anti-pattern—not a hypothetical. |
| G3 — Verification |
Before publishing review output, you applied beagle-go:review-verification-protocol to each proposed finding. |
Quick Reference
| Issue Type |
Reference |
| Elm architecture, tea.Cmd as data |
references/elm-architecture.md |
| Model state, message handling |
references/model-update.md |
| View rendering, Lipgloss styling |
references/view-styling.md |
| Component composition, Huh forms |
references/composition.md |
| Bubbles components (list, table, etc.) |
references/bubbles-components.md |
CRITICAL: Avoid False Positives
Read elm-architecture.md first! The most common review mistake is flagging correct patterns as bugs.
NOT Issues (Do NOT Flag These)
| Pattern |
Why It's Correct |
return m, m.loadData() |
tea.Cmd is returned immediately; runtime executes async |
Value receiver on Update() |
Standard BubbleTea pattern; model returned by value |
Nested m.child, cmd = m.child.Update(msg) |
Normal component composition |
Helper functions returning tea.Cmd |
Creates command descriptor, no I/O in Update |
tea.Batch(cmd1, cmd2) |
Commands execute concurrently by runtime |
ACTUAL Issues (DO Flag These)
| Pattern |
Why It's Wrong |
os.ReadFile() in Update |
Blocks UI thread |
http.Get() in Update |
Network I/O blocks |
time.Sleep() in Update |
Freezes UI |
<-channel in Update (blocking) |
May block indefinitely |
huh.Form.Run() in Update |
Blocking call |
Review Checklist
Architecture
Model & Update
View & Styling
Components
Critical Patterns
Model Must Be Immutable
// BAD - mutates model
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.items = append(m.items, newItem) // mutation!
return m, nil
}
// GOOD - returns new model
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
newItems := make([]Item, len(m.items)+1)
copy(newItems, m.items)
newItems[len(m.items)] = newItem
m.items = newItems
return m, nil
}
Commands for Async/IO
// BAD - blocking in Update
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
data, _ := os.ReadFile("config.json") // blocks UI!
m.config = parse(data)
return m, nil
}
// GOOD - use commands
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, loadConfigCmd()
}
func loadConfigCmd() tea.Cmd {
return func() tea.Msg {
data, err := os.ReadFile("config.json")
if err != nil {
return errMsg{err}
}
return configLoadedMsg{parse(data)}
}
}
Styles Defined Once
// BAD - creates new style each render
func (m Model) View() string {
style := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("205"))
return style.Render("Hello")
}
// GOOD - define styles at package level or in model
var titleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("205"))
func (m Model) View() string {
return titleStyle.Render("Hello")
}
When to Load References
- First time reviewing BubbleTea → elm-architecture.md (prevents false positives)
- Reviewing Update function logic → model-update.md
- Reviewing View function, styling → view-styling.md
- Reviewing component hierarchy → composition.md
- Using Bubbles components → bubbles-components.md
Review Questions
- Is Update() free of blocking I/O? (NOT: "is the cmd helper blocking?")
- Is the model immutable in Update?
- Are Lipgloss styles defined once, not in View?
- Is WindowSizeMsg handled for resizing?
- Are key bindings documented with help.KeyMap?
- Are Bubbles components sized correctly?
1---2name: bubbletea-code-review-23description: Reviews BubbleTea TUI code for proper Elm architecture, model/update/view patterns, and Lipgloss styling. Use when reviewing terminal UI code using charmbracelet/bubbletea.4---56# BubbleTea Code Review78## Hard gates (sequence)910Advance only when each **pass condition** is objectively true (reduces false positives on `tea.Cmd` and unsubstantiated blocking claims):1112| Gate | Pass condition |13|------|----------------|14| **G1 — Anti–false-positive** | You skimmed **NOT Issues** below **or** read [references/elm-architecture.md](references/elm-architecture.md) **before** recording a finding about `tea.Cmd` returns, value receivers on `Update`, or nested child `Update`. |15| **G2 — Evidence for blocking / suspicious I/O** | Each Critical/Major finding names **file path + line** (or a short quoted snippet) showing the blocking call, `huh.Form.Run` in the wrong place, or other asserted anti-pattern—not a hypothetical. |16| **G3 — Verification** | Before publishing review output, you applied **beagle-go:review-verification-protocol** to each proposed finding. |1718## Quick Reference1920| Issue Type | Reference |21|------------|-----------|22| Elm architecture, tea.Cmd as data | [references/elm-architecture.md](references/elm-architecture.md) |23| Model state, message handling | [references/model-update.md](references/model-update.md) |24| View rendering, Lipgloss styling | [references/view-styling.md](references/view-styling.md) |25| Component composition, Huh forms | [references/composition.md](references/composition.md) |26| Bubbles components (list, table, etc.) | [references/bubbles-components.md](references/bubbles-components.md) |2728## CRITICAL: Avoid False Positives2930**Read [elm-architecture.md](references/elm-architecture.md) first!** The most common review mistake is flagging correct patterns as bugs.3132### NOT Issues (Do NOT Flag These)3334| Pattern | Why It's Correct |35|---------|------------------|36| `return m, m.loadData()` | `tea.Cmd` is returned immediately; runtime executes async |37| Value receiver on `Update()` | Standard BubbleTea pattern; model returned by value |38| Nested `m.child, cmd = m.child.Update(msg)` | Normal component composition |39| Helper functions returning `tea.Cmd` | Creates command descriptor, no I/O in Update |40| `tea.Batch(cmd1, cmd2)` | Commands execute concurrently by runtime |4142### ACTUAL Issues (DO Flag These)4344| Pattern | Why It's Wrong |45|---------|----------------|46| `os.ReadFile()` in Update | Blocks UI thread |47| `http.Get()` in Update | Network I/O blocks |48| `time.Sleep()` in Update | Freezes UI |49| `<-channel` in Update (blocking) | May block indefinitely |50| `huh.Form.Run()` in Update | Blocking call |5152## Review Checklist5354### Architecture55- [ ] **No blocking I/O in Update()** (file, network, sleep)56- [ ] Helper functions returning `tea.Cmd` are NOT flagged as blocking57- [ ] Commands used for all async operations5859### Model & Update60- [ ] Model is immutable (Update returns new model, not mutates)61- [ ] Init returns proper initial command (or nil)62- [ ] Update handles all expected message types63- [ ] WindowSizeMsg handled for responsive layout64- [ ] tea.Batch used for multiple commands65- [ ] tea.Quit used correctly for exit6667### View & Styling68- [ ] View is a pure function (no side effects)69- [ ] Lipgloss styles defined once, not in View70- [ ] Key bindings use key.Matches with help.KeyMap7172### Components73- [ ] Sub-component updates propagated correctly74- [ ] Bubbles components initialized with dimensions75- [ ] Huh forms embedded via Update loop (not Run())7677## Critical Patterns7879### Model Must Be Immutable8081```go82// BAD - mutates model83func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {84 m.items = append(m.items, newItem) // mutation!85 return m, nil86}8788// GOOD - returns new model89func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {90 newItems := make([]Item, len(m.items)+1)91 copy(newItems, m.items)92 newItems[len(m.items)] = newItem93 m.items = newItems94 return m, nil95}96```9798### Commands for Async/IO99100```go101// BAD - blocking in Update102func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {103 data, _ := os.ReadFile("config.json") // blocks UI!104 m.config = parse(data)105 return m, nil106}107108// GOOD - use commands109func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {110 return m, loadConfigCmd()111}112113func loadConfigCmd() tea.Cmd {114 return func() tea.Msg {115 data, err := os.ReadFile("config.json")116 if err != nil {117 return errMsg{err}118 }119 return configLoadedMsg{parse(data)}120 }121}122```123124### Styles Defined Once125126```go127// BAD - creates new style each render128func (m Model) View() string {129 style := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("205"))130 return style.Render("Hello")131}132133// GOOD - define styles at package level or in model134var titleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("205"))135136func (m Model) View() string {137 return titleStyle.Render("Hello")138}139```140141## When to Load References142143- **First time reviewing BubbleTea** → [elm-architecture.md](references/elm-architecture.md) (prevents false positives)144- Reviewing Update function logic → [model-update.md](references/model-update.md)145- Reviewing View function, styling → [view-styling.md](references/view-styling.md)146- Reviewing component hierarchy → [composition.md](references/composition.md)147- Using Bubbles components → [bubbles-components.md](references/bubbles-components.md)148149## Review Questions1501511. Is Update() free of blocking I/O? (NOT: "is the cmd helper blocking?")1522. Is the model immutable in Update?1533. Are Lipgloss styles defined once, not in View?1544. Is WindowSizeMsg handled for resizing?1555. Are key bindings documented with help.KeyMap?1566. Are Bubbles components sized correctly?