fix: apply --no-color flag to huh interactive prompts#454
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #454 +/- ##
==========================================
+ Coverage 71.08% 71.13% +0.04%
==========================================
Files 220 220
Lines 18512 18547 +35
==========================================
+ Hits 13160 13194 +34
+ Misses 4177 4176 -1
- Partials 1175 1177 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
zimeg
left a comment
There was a problem hiding this comment.
@srtaalej Super nice approach to bringing a more... "boring?" theme to forms 🎨 ✨
I'm leaving an issue we might find quick to address around confirm defaults before merging. I'm also curious if the hints below the prompts can have formatting removed or if that's internal upstream?
←/→ toggle • enter submit • y Yes • n No
internal/style/theme.go
Outdated
| t.Focused.FocusedButton = lipgloss.NewStyle().Padding(0, 2).MarginRight(1) | ||
| t.Focused.BlurredButton = lipgloss.NewStyle().Padding(0, 2).MarginRight(1) |
|
👾 ramble: I'm now uncertain if the comment about "hint" formatting is too nuanced but I do find that the Charm team offers a "default" theme that might be useful to use here for confidence in edge cases?
🔗 https://github.com/charmbracelet/huh?tab=readme-ov-file#themes |
zimeg
left a comment
There was a problem hiding this comment.
@srtaalej LGTM! And thanks for exploring what's possible with these packages 📺 ✨
I'm approving this after a bit more testing and some changes noted below. If this all looks alright I think we can merge it! One note we might want to follow up with support for the variables:
$ NO_COLOR=1 slack run
Which right now removes format from huh but not the select options! No blocker for this PR 🚢
I hope the note on ANSI limitations makes sense too 📚 We might find that unicode and other box drawing characters are alright but not escaped sequences for this flag 🤓
internal/style/theme.go
Outdated
| t.Focused.SelectedPrefix = lipgloss.NewStyle().SetString("[x] ") | ||
| t.Focused.UnselectedOption = lipgloss.NewStyle() | ||
| t.Focused.UnselectedPrefix = lipgloss.NewStyle().SetString("[ ] ") | ||
| t.Focused.FocusedButton = lipgloss.NewStyle().Padding(0, 2).MarginRight(1).Bold(true).Underline(true) |
There was a problem hiding this comment.
🌟 praise: This is a clever approach @srtaalej!
👾 note: I made changes in 2c51483 that adjust this to remove the bold and underline formatting when using this --no-color flag. We'll want to avoid ANSI altogether:
🎨 https://en.wikipedia.org/wiki/ANSI_escape_code#Select_Graphic_Rendition_parameters
📸 note: Here's a move recent preview, with also changes of 784f9f2 added:


Changelog
Summary
The --no-color flag stripped styles from CLI output but not from huh interactive prompts (select, confirm, input, etc.), because huh uses its own theme/rendering pipeline. This PR added ThemePlain() — a colorless huh theme with no ANSI styling so that when --no-color is set, forms now use ThemePlain + huh's accessible mode, rendering as plain numbered lists instead of a styled TUI
Test plan
Run
slack create --no-colorand verify prompts render as plain numbered lists with no colorRun
slack login --no-colorand verify confirmation prompt has no colorRun
slack create(without --no-color) and verify themed prompts still workgo test ./internal/style/ ./internal/iostreams/Requirements