Skip to content

feat: rework path, remove suggestion prompt #335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Jun 3, 2025
Merged

Conversation

43081j
Copy link
Collaborator

@43081j 43081j commented May 28, 2025

After some thought recently, I came to the conclusion that the path and suggestion prompts shouldn't exist in their current form.

The path prompt is a file selector - but is basically giving a poorer equivalent of the autocompletion UX. Instead of providing two ways to render completions, I think we should settle on the autocompletion prompt and remove the suggestion prompt.

This means the path prompt now uses the autocompletion prompt, but with options sourced from the file system.

Notable changes

  • Autocomplete prompt can take an options function as well as an options array. This will be called each time we need to query the options set
  • Autocomplete prompt now sets its value on <RETURN> rather than finalize event. This allows us to set the value before validation occurs, so we can then validate against the completed path
  • Core prompt no longer has a beforePrompt and instead provides an initialUserInput which can be used to set the input without setting the value
  • Autocomplete prompt can now take a validate function and will render validation errors

Behavioural differences compared to the old path

In the old path, you could enter a value which doesn't exist as an option and it would be set as the result on submit.

In the new path, you must select a value. you can no longer submit arbitrary/unknown values

cc @dreyfus92

also @MacFJA you put plenty of work into these two prompts, i know. i think it is sensible to consolidate, though. we can maintain one core prompt instead of two here and reduce the maintainer burden. this will also keep the UX consistent.

let me know what you both think

Copy link

changeset-bot bot commented May 28, 2025

🦋 Changeset detected

Latest commit: e89cd5b

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

This PR includes changesets to release 2 packages
Name Type
@clack/prompts Minor
@clack/core 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

pkg-pr-new bot commented May 28, 2025

@example/basic@example/changesets

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

commit: da7311c

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.

LGTM, we might need to update docs tho for this part, we can add them in the docs repo.

@43081j
Copy link
Collaborator Author

43081j commented Jun 1, 2025

@manuel3108 would you be able to try this branch out in svelte?

It includes the placeholder changes in main that unblock your unforking

Base automatically changed from values-up-on-bricks to main June 3, 2025 16:12
@43081j 43081j merged commit df4eea1 into main Jun 3, 2025
6 checks passed
@43081j 43081j deleted the maybe-autocomplete-path branch June 3, 2025 16:40
@43081j
Copy link
Collaborator Author

43081j commented Jun 3, 2025

@dreyfus92 im going to open an issue to track updating the docs, as the original PR didn't add any either

so we are missing a few entries

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.

2 participants