Repository navigation
fix(keys): treat keypad navigation keys as their main-block equivalents - #1225
Open
liziye627-design wants to merge 1 commit into
Open
liziye627-design wants to merge 1 commit into
liziye627-design wants to merge 1 commit into
Conversation
Contributor
|
PR author is not in the allowed authors list. |
|
@liziye627-design is attempting to deploy a commit to the Modem Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
Fixes #1223
Problem
In terminals that use the Kitty keyboard protocol (the report is Ghostty), OpenTUI decodes the numpad
PgUp/PgDn keys as
kppageup/kppagedown. Hunk's chord matcher only acceptspageup/pagedown,so the numpad keys do nothing. The same applies to the other keypad navigation keys (arrows,
Home/End, Insert/Delete).
Approach
matchesNamedKeyinpackages/hunk/src/extension-api/keys.tsnow maps the ten keypadnavigation names to the main-block key before comparing. Because this happens in the shared matcher,
built-in shortcuts, user
[keybindings]and extensionmatchesKeycalls all get the fix. Modifiermatching is unchanged; for example, shift+numpad-PgDn still does not match a plain
pagedown.On reusing OpenTUI's aliases, as the issue suggests: the table mirrors the navigation
entries of OpenTUI's
defaultKeyAliases. I couldn't import that map. It isn't in@opentui/core'spublic types (0.5.6), and importing it at runtime fails with "Export named 'defaultKeyAliases' not
found".
extension-apiis also meant to be import-free perdocs/module-boundaries.md. If you'dprefer normalizing names once in the input pipeline instead, I'm happy to rework it.
Non-goals: keypad digits and operators (
kp0,kpplus, …) andkpenter. These keys aren'tpart of the reported bug, and mapping digits could change how text input behaves.
Why core
Every review surface shares chord matching, and extensions call the same published matcher.
Tests
packages/hunk/src/lib/commandKeys.test.tspass the real Kitty sequences(
ESC [ 57417…57426 u) through OpenTUI'sparseKeypressand check each one against its chord.I ran them before changing
keys.ts: 2 failed. After the change they pass.bun test packages/hunk/src/lib/commandKeys.test.ts packages/hunk/src/extension-api/keys.test.ts: 24 passbun run typecheck,bun run lint,bun run format:check,bun run deps:check: passbun run test: shard 1 has 2519 pass, 24 skip, 1 fail; shard 2 has 2640 pass, 19 skip, 0 fail. The one failure istest/cli/npm-extension-install.test.ts("installs npm extensions that import host APIs…"),which gets npm
E401from the test's local registry. On the same machine (checked with Bun 1.4.2) it also fails on unmodifiedmain(c3af44f). The command and output are in the log.Environment: Linux x86_64, Bun 1.4.4, Node v22.23.4. Not tested on macOS or Windows.
Visual evidence
I launched the real Hunk TUI (
bun run packages/hunk/src/main.tsx -- diff) in a tuistory PTYat 120x30 with the default theme. The diff is a 200-line file with 40 changed lines. I wrote the Kitty
numpad PageDown sequence
ESC [ 57422 uto the terminal and captured the screen before and after:main(c3af44f): the screen doesn't change.The before/after text captures are below. One limit: the PTY doesn't answer terminal
capability queries, so this shows OpenTUI decoding the raw Kitty sequence. It isn't a recording from
Ghostty with a physical numpad, which I don't have.
Text captures (120x30)
main-before
main-after
fix-before
fix-after
Changeset:
.changeset/keypad-navigation-aliases.md(hunkdiff, patch).Drafted with AI assistance; the tests above were run locally.