Skip to content

Conversation

delucis
Copy link

@delucis delucis commented Oct 20, 2025

As discussed on Discord, this PR proposes a change to the API for stopping spinners and progress bars.

Currently these use a slightly awkward API using a positional argument to pass a numeric code to set whether the stop is successful or the result of an error or cancellation, e.g. spinner.stop(undefined, 1).

This PR proposes removing the error code form in favour of distinct spinner.cancel() and spinner.error() methods.

This is a breaking change for anyone using the code API currently.

Notes

This PR does not change any of the existing semantics around how “cancel” and “error” are represented and preserves the current behaviour where a “cancel” code shows a red square and an “error” code shows a yellow triangle.

This is different from the .error() method of the log utility, which shows a red square.

An alternative refactor could be to rename to .stopAndWarn() (current “error” behaviour) and .stopAndError() (current “cancel” behaviour), or something like that, which would align with how log.warn and log.error look.

Or, another alternative would be to switch to an object argument like .stop({ type: 'warn' }), which could also resolve the awkwardness of the current positional style and avoid multiple methods.

Docs

This will require an update to https://bomb.sh/docs/clack/packages/prompts/#spinner

Copy link

changeset-bot bot commented Oct 20, 2025

🦋 Changeset detected

Latest commit: 8762203

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clack/prompts Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@dreyfus92 dreyfus92 left a comment

Choose a reason for hiding this comment

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

this is very solid, thank you Chris, welcome to the clack gang! 🤘🏻

Copy link

pkg-pr-new bot commented Oct 21, 2025

@example/basic@example/changesets

npm i https://pkg.pr.new/bombshell-dev/clack/@clack/core@405
npm i https://pkg.pr.new/bombshell-dev/clack/@clack/prompts@405

commit: e46826f

@43081j
Copy link
Collaborator

43081j commented Oct 21, 2025

looks good to me 👍

can you add a test or two for passing a non-empty message?

@delucis
Copy link
Author

delucis commented Oct 21, 2025

can you add a test or two for passing a non-empty message?

Done!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants