Repository navigation
feat(prompts): add back navigation to group (#39) - #617
StringerBell69 wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 8fb6fce The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
30c9666 to
8fb6fce
Compare
Pressing Shift+Tab during a grouped prompt returns to the previous step, discarding its answer and re-running the previous prompt. - @clack/core: add a `back` action (unbound by default, so standalone prompts are unchanged), a `BACK_SYMBOL`/`isBack()` pair mirroring `CANCEL_SYMBOL`/`isCancel()`, and a `'back'` prompt state. - @clack/prompts: rework `group()` into a navigable loop. Back is on by default (disable with `navigate: false`) and exposes `onBack`. Closes bombshell-dev#39
8fb6fce to
8c4775b
Compare
|
hey @StringerBell69, thanks for picking this up! before i review, could you update the description to follow our pr template? looks like your agent wrote its own structure instead, so the type of change, checklist and ai disclosure sections are missing. i'd also love a short description in your own words of how you tackled this, it helps a lot to know where to focus on a change this size. and since the description says it's a draft for design feedback, could you mark the pr as draft too? |
|
I was building a CLI with clack (with Claude's help) and got really annoyed when I made a wrong move and couldn't go back a step. I thought it was a misconfiguration on my end. I figured that someone else had probably hit the same thing, so I asked how to add a back option in the least intrusive way, without denaturing the app. That's why the whole thing is modeled on the existing I built this with Claude, but I reviewed the design and the full diff and ran the tests locally. Happy to adjust the approach. I'll be on my way back from school, so I won't be as responsive. (wrote this in french and asked claude to translate) |
What does this PR do?
Adds back navigation to the
group()utility: pressing Shift+Tab returns to the previous step. Answers are kept, and each step receives its previous answer asprevious, so passing it toinitialValuerestores what was entered. Back is disabled on the first step. It's on by default (navigate: falseto opt out) and exposes anonBack({ from, to, results })callback.How I approached it (in my own words): I was building a CLI with clack (with Claude's help) and got really annoyed when I made a wrong keystroke and couldn't go back a step. I figured clack probably had this requested already if it was open source — found #39 — and wanted the least intrusive way to add a back option without changing how clack works for everyone else. So the design mirrors the existing
cancelpath as closely as possible:backaction that is unbound by default (standalone prompts behave exactly as before), aBACK_SYMBOL/isBack()pair mirroringCANCEL_SYMBOL/isCancel(), and a'back'state. Going back erases the step's own frame so navigation stays clean.group()reworked into a navigable loop. It only bindsShift+Tab→back while a step that can go back is showing, and restores the previous alias state afterwards.I'm open to changing the approach (default on vs opt-in, the key, the temporary alias binding) per the discussion in #39.
Closes #39
Type of change
Checklist
pnpm testpasses (targeted tests for my change pass; the only failing tests are 4 pre-existingnote.test.tssnapshot cases that also fail onmainin my environment — unrelated to this PR)pnpm formathas been runAI-generated code disclosure
Built with Claude (Anthropic). I described the problem and the "least intrusive" constraint, reviewed the design and the full diff, and ran the tests locally. Flagging it so reviewers can pay extra attention to the core keypress/render edges and the
group()alias handling.