Skip to content

fix(prompts): use settings.messages.cancel when cancel() has no message - #643

Open
IG-ABHINAV wants to merge 1 commit into
bombshell-dev:mainfrom
IG-ABHINAV:fix/cancel-default-message
Open

IG-ABHINAV wants to merge 1 commit into
bombshell-dev:mainfrom
IG-ABHINAV:fix/cancel-default-message

Conversation

@IG-ABHINAV

Copy link
Copy Markdown

What & why

From #642:

Calling cancel() without an argument does not display a cancellation message, even after setting messages.cancel with updateSettings().
The internationalization docs show updateSettings({ messages: { cancel: ... } }) followed by cancel(), so I expected the configured message to be used.

cancel defaulted its message parameter to '', so settings.messages.cancel was never read. The spinner and progress bar already fall back to settings.messages.cancel.

Closes #642

How

  • packages/prompts/src/messages.ts: message is now optional and the rendered text is message ?? settings.messages.cancel. An explicit string (including '') is still printed as given. JSDoc notes the default.
  • packages/prompts/test/messages.test.ts (new): explicit message; no message → default Canceled; no message after updateSettings({ messages: { cancel: 'Operation cancelled' } }) → that message; explicit '' still renders empty.
  • Changeset: @clack/prompts patch.

Verification

$ pnpm install --frozen-lockfile && pnpm build      # exit 0
$ cd packages/prompts && npx vitest run test/messages.test.ts
 ✓ test/messages.test.ts (4 tests)
 Test Files  1 passed (1)
      Tests  4 passed (4)
$ pnpm types                                         # tsc --noEmit, exit 0
$ npx biome check packages/prompts/src/messages.ts packages/prompts/test/messages.test.ts
Checked 2 files ... No fixes applied.

Full @clack/prompts suite, main vs this branch (Node 24.22.1 locally, not the .nvmrc 20.18.1):

main:   Test Files 3 failed | 17 passed (20)   Tests 13 failed | 615 passed | 4 skipped (632)
branch: Test Files 3 failed | 18 passed (21)   Tests 13 failed | 619 passed | 4 skipped (636)

The same 13 tests fail on main without this change (autocomplete/password/path tab-completion and cursor rendering; @clack/core has 5 similar failures, e.g. expected 'foo█' to equal 'foo'), so they look environment-related; the failing set is identical before and after.

Judgment calls

  • cancel() with no argument now prints the default Canceled instead of an empty line. That is what the i18n docs describe and matches the spinner's cancel fallback; callers who want no text can pass ''.
  • Used ?? rather than || so an explicit empty string keeps its current meaning.

Type of change

  • Bug fix

Checklist

  • pnpm test passes (or targeted tests for my change) — targeted tests pass; see the note above on pre-existing local failures
  • pnpm format has been run (biome check clean on changed files)
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset

AI-generated code disclosure

  • This PR includes AI-generated code

@changeset-bot

changeset-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f32932b

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 Patch

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

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.

[Bug] updateSettings

1 participant