Repository navigation
fix(input): read the raw key sequence without the Ink patch (#1505) - #1670
akramcodez merged 2 commits into
Conversation
…lective#1505) Backspace was told apart from forward Delete by key.raw, a field that only exists through a pnpm patch to Ink. pnpm patches apply inside this repo alone; the published package depends on plain Ink, so npm installs lost key.raw and Backspace fell through to forward Delete. The xterm Shift/Alt+Enter newline chords and the MCP wizard's Backspace used the same field and broke the same way. Add useRawInput, which reads the sequence from the stdin event emitter Ink already exposes through useStdin, and use it in TextInput, UserInput and the MCP wizard. isNewlineKey now takes the sequence as an argument. Add a guard test that fails if key.raw is read again.
nc-review: comments — 2 nits@addyCooks — a few things worth a look, none blocking. The PR correctly removes the dependency on the pnpm-patched Ink ⚪ nit · The ⚪ nit · The guard test scans source files for the substring 🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with |
The regex in the guard test carried literal backspace characters instead of \b, so it could never match and the test passed vacuously. Use real word boundaries, and confirm it fails when a source file reads key.raw.
|
Hey @akramcodez, |
Fixes #1505
Backspace was told apart from forward Delete by key.raw, a field that only exists through a pnpm patch to Ink. pnpm patches apply inside this repo alone; the published package depends on plain Ink, so npm installs lost key.raw and Backspace fell through to forward Delete. The xterm Shift/Alt+Enter newline chords and the MCP wizard's Backspace used the same field and broke the same way.
Add useRawInput, which reads the sequence from the stdin event emitter Ink already exposes through useStdin, and use it in TextInput, UserInput and the MCP wizard. isNewlineKey now takes the sequence as an argument.
Add a guard test that fails if key.raw is read again.
Description
Fixes Backspace acting as forward Delete on npm installs of v1.31.0 (nothing happens at the end of the line, and the character to the right of the cursor is deleted mid-line).
The cause is packaging, not input handling.
patches/ink@6.8.0.patchaddskey.raw, and the Backspace check from bbae037 depends on it. The patch is a pnpmpatchedDependenciesentry, so it only applies in this repo. Dev runs and the test suite use the patched Ink, which is why this never reproduced for us.Changes:
useRawInput(intext-input.tsx) reads the raw sequence fromuseStdin().internal_eventEmitter. The listener is prepended, so it runs before anyuseInputhandler.TextInput,UserInputand the MCP wizard use it instead ofkey.raw.isNewlineKey(input, key, raw)takes the sequence as a third argument.text-input-keys.spec.tsxfails ifkey.rawis read again, because the keyboard specs pass on patched Ink either way.Type of Change
Changeset
pnpm changeset) describing this change for the changelogTesting
Automated Tests
.spec.ts/tsxfilespnpm test:allcompletes successfully)Manual Testing
Checklist