upbound / up

The @upbound CLI
Apache License 2.0
49 stars 42 forks source link

Prevent spinner from overwriting confirmation prompt during attach/detach #476

Closed branden closed 2 months ago

branden commented 2 months ago

Description of your changes

Attach and detach commands use a spinner to communicate the status of the ongoing operation. If a potential conflict is found, such as attaching a Space that's already been attached, the user is prompted to confirm whether they want to proceed. The spinner overwrites that prompt because it's still active, so we work around that by making the spinner draw its own prompt. But the first prompt is briefly visible for a flash, and the spinner's prompt may be misleading about whether the default is to proceed or abort.

This PR updates attach and detach commands to disable the spinner while prompting the user. This relieves the spinner of needing to write its own prompt, allowing attach/detach to use the existing prompt which correctly indicates the default selection.

I have:

How has this code been tested

I put together a gist with output from the attach/detach commands. There are two text files before.txt and after.txt showing output before and after this PR. Each shows:

For convenience there's also a diff.diff showing the diff between before.txt and after.txt.

Note that the spinner's prompt in before.txt isn't captured due to competition between the spinner and the overwritten confirmation prompt and ensuing terminal weirdness.