Skip to content

feat: add accessible flag and environment variable for screen reader friendly forms#455

Open
srtaalej wants to merge 11 commits intomainfrom
ale-accessibility-flag
Open

feat: add accessible flag and environment variable for screen reader friendly forms#455
srtaalej wants to merge 11 commits intomainfrom
ale-accessibility-flag

Conversation

@srtaalej
Copy link
Copy Markdown
Contributor

@srtaalej srtaalej commented Mar 31, 2026

Changelog

Interactive forms become screen reader friendly when the ACCESSIBLE environment variable is set or when using the --accessible flag.

Summary

Related: #454
This PR adds a global --accessible flag that switches huh interactive prompts to accessible mode. In accessible mode, select prompts render as numbered lists with "Enter a number between 1 and N" input, confirm prompts accept y/n text, and input prompts use plain line-by-line I/O. This makes the CLI usable with screen readers by avoiding the TUI-based rendering

Screenshot 2026-03-31 at 4 03 49 PM

Test plan

Run slack create --accessible and verify prompts render as numbered lists
Run slack login --accessible and verify confirm prompt accepts y/n
Run slack create (without flag) and verify normal TUI prompts still work
go test ./internal/iostreams/ -run TestFormsAccessible

Requirements

@srtaalej srtaalej self-assigned this Mar 31, 2026
@srtaalej srtaalej requested a review from a team as a code owner March 31, 2026 20:12
@srtaalej srtaalej added enhancement M-T: A feature request for new functionality semver:minor Use on pull requests to describe the release version increment labels Mar 31, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.22%. Comparing base (955c925) to head (4f13099).

Files with missing lines Patch % Lines
cmd/root.go 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #455      +/-   ##
==========================================
- Coverage   71.23%   71.22%   -0.02%     
==========================================
  Files         222      222              
  Lines       18664    18678      +14     
==========================================
+ Hits        13295    13303       +8     
- Misses       4189     4192       +3     
- Partials     1180     1183       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@srtaalej srtaalej marked this pull request as draft April 1, 2026 15:13
@srtaalej srtaalej marked this pull request as ready for review April 6, 2026 18:28
@srtaalej srtaalej requested a review from zimeg April 6, 2026 18:40
Copy link
Copy Markdown
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srtaalej So amazing to find this feature arriving here! 🍀 ✨

Before approving I want to leave a few comments, but think we can follow up with some other improvements to the edges:

  • Environment Variable: The ACCESSIBLE environment variable is standard I understand and we should include support alongside these changes! This makes preferring these prompts easier with an export added to the shell profile 🔬
  • Blank Selections: The "select" prompts request a number to be entered but accept blank input for the first option! This might be an upstream issue 🐛
  • Input Default: Adjacent for the "input" prompt I find the default value of the create command name isn't showing 🧪

The first note is most important for these changes IMHO! I'd be curious if the latter two can be proven in unit tests, but please don't consider those blocking 🙏

SlackTestTraceFlag bool
TeamFlag string
TokenFlag string
Accessible bool
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌲 thought: As we're introducing this, should we include the environment variable similar?

ACCESSIBLE

We recommend setting this through an environment variable or configuration option to allow the user to control accessibility.

🔗 https://github.com/charmbracelet/huh?tab=readme-ov-file#accessibility

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 ramble: We might find this adjacent file most useful!

// LoadEnvironmentVariables sets flags based on their environment variable value
func (c *Config) LoadEnvironmentVariables() error {

@zimeg zimeg added this to the Next Release milestone Apr 11, 2026
@zimeg zimeg added the changelog Use on updates to be included in the release notes label Apr 11, 2026
@zimeg zimeg changed the title feat: add --accessible flag to huh interactive prompts feat: add accessible flag and environment variable for screen reader friendly forms Apr 11, 2026
Copy link
Copy Markdown
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srtaalej Thanks for these updates! I'm hoping we can land a few more to bring this to a polished state for release 🔬 ✨

I tested some more cases that I'll share here:

  • One selection option: The hint is solid IMHO! I share more comments on the title format later but I'm a fan of the hint.
Image
  • Multiple select options: This highlights the ":" format a bit more for following comments.
Image
  • Invalid select options: Super cool that this validates!
Image
  • Confirmation default: This appears as a kind callout.
Image
  • Input prompts without default: These might favor the trailing ":" also?
Image

The formatting issue I callout in comments below and some screenshots above is that I think form titles should end with a ":" to signal input! Some workarounds might be needed in code but this outputs well I think.

Let me know if more testing can be requested 🫡

func buildInputForm(io *IOStreams, message string, cfg InputPromptConfig, input *string) *huh.Form {
title := message
if io != nil && io.config.Accessible && cfg.Placeholder != "" {
title = fmt.Sprintf("%s (default: %s)", message, cfg.Placeholder)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
title = fmt.Sprintf("%s (default: %s)", message, cfg.Placeholder)
title = fmt.Sprintf("%s (default: %s):", strings.TrimSuffix(message, ":"), cfg.Placeholder)

🔭 suggestion: This might not be the right syntax but I think formatting input ends best with a colon:

- Name your app: (default: flamboyant-salamander-784)
+ Name your app (default: flamboyant-salamander-784):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 ramble: We don't have a comment on this in the STYLE_GUIDE at this time and we're not consistent on using a : at all or sometimes ? instead. This might be something nice to align over time.


title := msg
if io != nil && io.config.Accessible && len(options) > 0 {
title = fmt.Sprintf("%s (press Enter for 1)", msg)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
title = fmt.Sprintf("%s (press Enter for 1)", msg)
title = fmt.Sprintf("%s (press Enter for 1):", strings.TrimSuffix(msg, ":"))

🪬 suggestion: Similar to the : suggestion above - I'm more hesitant to this one because some titles might end with "?" but I don't think that formatting is incorrect...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog Use on updates to be included in the release notes enhancement M-T: A feature request for new functionality semver:minor Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants