refactor(wizard): let the wizard own its keyboard nav instead of toggling the stepper's - #147
Merged
Merged
Conversation
1 task
There was a problem hiding this comment.
Code Review
This pull request simplifies the configuration wizard by removing the useStepperInput hook and its associated navigation-disabling logic from individual step components and tests. Instead, keyboard navigation is disabled globally on the parent <Stepper> component using keyboardNav={false}. The review feedback points out an important issue where a conflicting global <esc> key handler in ConfigurationWizard intercepts the escape key and triggers onComplete(), which breaks the back-navigation of individual steps. Removing this redundant handler is recommended to fix the bug.
…ling the stepper's
Every configuration-wizard step mounted with `disableNavigation()` and unmounted
with `enableNavigation()`, so the Stepper's built-in `keyboardNav` bindings were
suppressed for the entire lifetime of every step — they never actually ran. Each
step already owns its keys: its widget (Select / MultiSelect / BlinkingTextInput)
consumes <enter> and advances by calling `goNext()` from `onConfirm`, and each
step binds <esc> itself.
Declare that directly with `keyboardNav={false}` on the Stepper and drop the five
identical disable/enable effects. Net behavior on `main` is unchanged.
This also unblocks the ink-stepper 0.2.3 bump (#142). Through 0.2.1,
`disableNavigation()` only gated the Stepper's own `useInput` handler, so a
programmatic `goNext()` still worked. 0.2.3 added an `isBlocked()` guard to
`goNext`/`goBack`/`goTo`, so the same flag now also swallows the step's explicit
`goNext()` — the wizard could never advance past step 1 and the four walkthrough
tests in `ink/main.test.tsx` failed. Not depending on that flag makes the wizard
behave identically under both versions.
Verified locally on Node 24.18.0, full suite 344/344 under ink-stepper 0.2.1
(main's lockfile) and 0.2.3; lint, format, and `npm run build` clean.
ConfigurationWizard's own useInput also handled <esc> by calling onComplete(), and Ink delivers input to every mounted useInput, so on any step past the first it double-fired with that step's own <esc> handler: the step called onBack() (or left its custom sub-mode) while the wizard completed on top of it, so <esc> effectively exited the wizard instead of going back. Drop the redundant <esc> branch (keeping ctrl+x -> ExitUI) so each step owns <esc> as intended - the first step exits, the rest go back. Resolves the review finding on #147. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
dawsontoth
force-pushed
the
fix/wizard-owns-keyboard-nav
branch
from
August 17, 2026 18:33
7ff5da7 to
06fe73d
Compare
|
🎉 This PR is included in version 0.16.43 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unblocks #142 (
ink-stepper0.2.1 → 0.2.3), and removes some plumbing that was never doing anything.What was wrong
Every step in the configuration wizard mounted with
disableNavigation()and unmounted withenableNavigation():All five steps, unconditionally, for their whole lifetime — so the
Stepper'skeyboardNavbindings were suppressed 100% of the time despite being declaredkeyboardNav={true}. They never ran.That's because each step already owns its keys: its widget (
Select,MultiSelect,BlinkingTextInput) consumes<enter>and advances by callinggoNext()fromonConfirm, and each step binds<esc>itself. The Stepper's bindings would have double-handled<enter>, which is exactly what thedisableNavigation()calls were there to prevent.What this does
Says it directly —
keyboardNav={false}on theStepper— and drops the five identical effects. That part is a pure no-op: the same wizard, minus a layer that cancelled itself out.Also: the
<esc>double-fire (review follow-up)While reviewing, we found a second self-cancelling layer of exactly the same shape.
ConfigurationWizardran its ownuseInputthat handled<esc>by callingonComplete(). Ink delivers input to every mounteduseInput, so that fired on top of the active step's own<esc>handler: on any step past the first,<esc>ran the step'sonBack()(or left the Model step's custom-entry sub-mode) and completed the wizard on top of it — so<esc>effectively exited the wizard instead of going back.Dropping that redundant
<esc>branch (keepingctrl+x → ExitUI) lets each step own<esc>as intended: the first step exits, the rest go back. This is the one behavior change in the PR —<esc>back-navigation now actually works. Added aConfigurationWizardtest asserting the wizard no longer completes on<esc>.Why it unblocks #142
Through 0.2.1,
disableNavigation()only gated the Stepper's ownuseInputhandler:A programmatic
goNext()still worked, so the wizard advanced fine.0.2.3 added an
isBlocked()guard to the navigation functions themselves:So the same flag every step was setting now also swallowed that step's own explicit
goNext(). The wizard could never leave step 1 — the frame kept rendering the provider list with the progress dot stuck on the first step, and the four walkthrough tests inink/main.test.tsxfailed. Not touching the flag at all makes the wizard behave identically under both versions.Verification
Node 24.18.0, full suite (
npx vitest --run):mainink/main.test.tsx6/6 (3 consecutive runs)mainnpm run lint,npm run format, andnpm run buildall clean.Re-verified after rebasing onto current
main(which now carries the AI SDK v4 /@openai/agents0.15 bumps and a CIbuildjob) and adding the<esc>fix: build, lint, format, and the full suite all green — 345/345, including the newConfigurationWizard<esc>test. The build is now exercised by CI too, not just locally.This PR is app code only — no manifest or lockfile changes. Once it lands, #142 should go green on a rebase.
Two notes for follow-up
1.
ink-stepperis major-risk while it's 0.x. This was a patch release that changed whatdisableNavigation()means. Worth a Renovate rule treatingink-stepperas a major-grade update until 1.0, alongside the existing AI SDK / OpenAI Agents groupings. I'll open an upstream issue too — "suppress the stepper's keybindings but still allow explicit programmatic navigation" is a legitimate use case that 0.2.3 removed with no replacement.2.
ink-stepper@0.2.2+declares a dependency onws(^8.21.2) that is never imported anywhere in its shippeddist/— I checked everyimport/requirein the bundle, and it only pullsreact,ink, andreact/jsx-runtime. Harmless, but the bump adds a WebSocket library to our production tree for nothing. Also worth mentioning upstream.