Skip to content

refactor(experiment): separate iostreams prompts from survey implementations#404

Open
zimeg wants to merge 2 commits intomainfrom
zimeg-refactor-iostreams-prompts
Open

refactor(experiment): separate iostreams prompts from survey implementations#404
zimeg wants to merge 2 commits intomainfrom
zimeg-refactor-iostreams-prompts

Conversation

@zimeg
Copy link
Member

@zimeg zimeg commented Mar 16, 2026

Changelog

N/A - "Nothing 'appening" 👻

Summary

This PR separates iostreams prompts from survey implementations for improvements to test cases and planned changes toward standard flag handling.

Reviewers

No change to logic with this change I hope!

Requirements

@zimeg zimeg added this to the Next Release milestone Mar 16, 2026
@zimeg zimeg self-assigned this Mar 16, 2026
@zimeg zimeg requested a review from a team as a code owner March 16, 2026 07:28
@zimeg zimeg added code health M-T: Test improvements and anything that improves code health experiment Experimental feature accessed behind the --experiment flag or toggle semver:patch Use on pull requests to describe the release version increment labels Mar 16, 2026
@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 69.42149% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.19%. Comparing base (35e1743) to head (2f729ee).

Files with missing lines Patch % Lines
internal/iostreams/prompts.go 79.20% 19 Missing and 2 partials ⚠️
internal/iostreams/survey.go 20.00% 14 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #404      +/-   ##
==========================================
+ Coverage   67.90%   68.19%   +0.29%     
==========================================
  Files         218      219       +1     
  Lines       18050    18055       +5     
==========================================
+ Hits        12256    12312      +56     
+ Misses       4640     4587      -53     
- Partials     1154     1156       +2     

☔ 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.

Copy link
Member Author

@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.

🔏 A few more notes on changes more!

🍀 I realize the reason to separate prompt interfaces from implementations wasn't noted in the description, but these changes hope to keep interfaces stable as the charm experiment reaches conclusion.

}, nil)
cm.IO.On("InputPrompt", mock.Anything, "Enter an expression", iostreams.InputPromptConfig{
Required: false,
}).Return("")
Copy link
Member Author

Choose a reason for hiding this comment

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

🧪 note: Lots of changes add the expected error value to mock prompts!

Comment on lines -86 to -88
if cfg.PageSize > 0 {
field.Height(cfg.PageSize + 2)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

🪓 note: Alongside changes of #400 and #401 we're hoping to use default form heights while the experiment for charm prompts remains active.

Comment on lines +192 to +217
// ConfirmPrompt prompts the user for a "yes" or "no" (true or false) value for
// the message
func (io *IOStreams) ConfirmPrompt(ctx context.Context, message string, defaultValue bool) (bool, error) {
if io.config.WithExperimentOn(experiment.Charm) {
return charmConfirmPrompt(io, ctx, message, defaultValue)
}
return surveyConfirmPrompt(io, ctx, message, defaultValue)
}

// InputPrompt prompts the user for a string value for the message, which can
// optionally be made required
func (io *IOStreams) InputPrompt(ctx context.Context, message string, cfg InputPromptConfig) (string, error) {
if io.config.WithExperimentOn(experiment.Charm) {
return charmInputPrompt(io, ctx, message, cfg)
}
return surveyInputPrompt(io, ctx, message, cfg)
}

// MultiSelectPrompt prompts the user to select multiple values in a list and
// returns the selected values
func (io *IOStreams) MultiSelectPrompt(ctx context.Context, message string, options []string) ([]string, error) {
if io.config.WithExperimentOn(experiment.Charm) {
return charmMultiSelectPrompt(io, ctx, message, options)
}
return surveyMultiSelectPrompt(io, ctx, message, options)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

👾 note: IIRC callsites often guard against flag inputs, but we might follow up with changes here to accept these in configurations so these prompts guard against scripting fallthrough!

🐌 ramble: I'm curious about the default behavior for confirm prompts too when interactive prompts aren't available since we might use the default choice instead of requiring flag alternatives to perhaps revisit the changes of #87?

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

Labels

code health M-T: Test improvements and anything that improves code health experiment Experimental feature accessed behind the --experiment flag or toggle semver:patch Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant