Skip to content

fix(terminal): no autocorrect in the input line; held Backspace and paging keys repeat - #965

Merged
devswha merged 3 commits into
mainfrom
fix/terminal-input-autocorrect-and-key-repeat
Oct 13, 2026
Merged

devswha merged 3 commits into
mainfrom
fix/terminal-input-autocorrect-and-key-repeat

Conversation

@devswha

@devswha devswha commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Problem

Two small touch-input papercuts in the terminal lens:

  1. Autocorrect in the input line. On iPhone the terminal input line (input-line mode) leaves iOS Auto-Correction and spell-check on. Typing a command with a non-dictionary token (a flag, path or branch name) and pressing Space can let the keyboard swap it for a dictionary word, and Send sends the rewritten command. Every other command or text field (composer, queue editor, key-bar settings, secret input, Portal panel) already turns autocorrect off.
  2. Held key-bar Backspace fires once. Holding the key-bar ⌫ deletes one character; clearing a line takes one tap per character. The hold-to-repeat added in feat(terminal): cursor style, held key-bar arrows and pinch-to-zoom #758 covers only the four arrows. Same for Del, Home, End, PgUp and PgDn.

Cause

  1. src/components/TerminalInput.tsx: the textarea sets only autoCapitalize="off"; no autoCorrect="off", no spellCheck={false}. Its doc comment even listed autocorrect as a rewrite the line exists to absorb.
  2. src/lib/keyRepeat.ts: isRepeatableKeyBarItem returns true only for ArrowUp/Down/Left/Right. KeyBar wires press-and-hold only for repeatable items, so every other key is a plain click. (Terminal: holding a key-bar arrow repeats it, like a held key on a keyboard #718 left "should Backspace, Delete, PageUp, PageDown repeat too?" as an open question; feat(terminal): cursor style, held key-bar arrows and pinch-to-zoom #758 shipped arrows only.)

Fix

Two commits:

  1. TerminalInput textarea gets autoCorrect="off" and spellCheck={false}, matching Composer.tsx and the queue editor. The doc comment now says autocorrect stays off and why.
  2. isRepeatableKeyBarItem uses a set: the arrows plus Backspace, Delete, Home, End, PageUp, PageDown, with or without saved modifiers (like the arrows). Escape, Tab, BackTab, Enter, Insert, ^C/^D/^Z, F-keys, printable keys and modifier buttons stay single-shot: a repeated Tab or ^C would act many times on what one press meant. Delay and rate are unchanged (400 ms / 50 ms).

Tests

  • src/lib/keyRepeat.test.ts: the positive case now covers the six editing/paging keys (bare and with saved modifiers); the negative case keeps Escape, Tab, BackTab, Enter, Insert, ctrl-c, ctrl-d, F1, printable keys and modifiers. Fails without the fix (1 fail), passes with it.
  • scripts/key-bar-hold-repeat-regression.ts: new step 5b holds the key-bar ⌫ and checks it repeats (the DEL byte on the input path, 11 sends in the run) and sends nothing after release. Without the fix the step fails ("got 1"). bun run check run bun scripts/key-bar-hold-repeat-regression.ts: all steps pass.
  • scripts/terminal-input-regression.ts (run inside ui-regression.ts): asserts the input line has autocorrect="off", spellcheck="false", autocapitalize="off". bun run check run --build bun scripts/ui-regression.ts: pass (exit 0), including "PASS terminal input".
  • bun run typecheck: pass. bun run test:unit: 3069 pass, 0 fail (including the test: enforce AGENTS.md conventions with repo-wide guard tests #949 conventions guard; the new post-release wait carries a // fixed wait: note).
  • Native iOS autocorrect was not reproduced on a device; the fix relies on WebKit honouring autocorrect="off", as the composer already does.

Notes

Merge-session review

Fixed (3468ec3):

  • docs/terminal-input.md still said only the arrows repeat when held. It now lists the arrows, ⌫, Del, Home, End, PgUp and PgDn (saved combinations of these repeat too) and says Esc, Tab, Enter, ^C, F-keys and modifier buttons send once.
  • docs/development.md now describes key-bar-hold-repeat-regression.ts as covering holds of arrows and editing keys.

Docs only, so there is no new regression test; src/lib/keyRepeat.test.ts and browser step 5b already pin the behavior. bun run check fast passes. The changelog fragment was already accurate.

Deferred: none.

🤖 Generated with Claude Code

devswha and others added 2 commits October 13, 2026 21:29
The terminal input line set only autoCapitalize="off", so iOS autocorrect
could replace a non-dictionary token (a flag, path or branch name) on Space
and the rewritten command was sent. The composer and the queue editor already
turn both off; the input line now matches them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The key bar's hold-to-repeat covered only the four arrows, so holding the
key-bar Backspace deleted one character and clearing a line took one tap per
character. The editing and paging keys now repeat like the arrows; Escape,
Tab, Enter, ^C and the function keys still send once.

Refs #862

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f4f26f0f-7f0d-4cc4-bbd4-9ef597d89ffd
📥 Commits

Reviewing files that changed from the base of the PR and between 5a4bfb3 and 3468ec3.

📒 Files selected for processing (8)
  • changelog.d/terminal-input-autocorrect-and-key-repeat.md
  • docs/development.md
  • docs/terminal-input.md
  • scripts/key-bar-hold-repeat-regression.ts
  • scripts/terminal-input-regression.ts
  • src/components/TerminalInput.tsx
  • src/lib/keyRepeat.test.ts
  • src/lib/keyRepeat.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

The hold paragraph still said only arrows repeat. Backspace, Delete,
Home, End, PageUp and PageDown repeat too now; Esc, Tab, Enter, ^C,
F-keys and modifiers send once. Also widen the description of
key-bar-hold-repeat-regression.ts, which now holds Backspace as well.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@devswha
devswha merged commit 3aec2f6 into main Oct 13, 2026
14 of 17 checks passed
@devswha
devswha deleted the fix/terminal-input-autocorrect-and-key-repeat branch October 13, 2026 15:43
devswha added a commit that referenced this pull request Oct 18, 2026
…1325)

## Summary
Holding the iOS keyboard's ⌫ in a terminal pane (direct typing) deleted
one character and stopped (#862).

Root cause, isolated in the iOS 27.0 simulator with plain textareas: the
iOS keyboard repeats a held ⌫ only while the focused field **has text**,
and not at all when the field has **`white-space: nowrap`**. Cancelling
the keydown (as xterm does), opacity 0, a tiny size, z-index under the
canvas or an opaque element over the field made no difference. xterm's
helper textarea fails both conditions: typed keys are sent on keydown
and cancelled (so nothing lands in it), xterm empties it after
Backspace/Enter/^C/blur, and xterm.css gives it `nowrap`.

Fix (iPhone and iPad only, `src/lib/deleteRepeat.ts` +
`PaneTerminal.tsx`): keep one space in an otherwise empty helper
textarea, refilled from capturing `focus`/`keydown`/`input` listeners
registered after xterm's own (a bubbling listener never runs: xterm
stops propagation in the capture phase at the target), and set the
textarea to `pre-wrap`. xterm still sends each ⌫ as DEL and cancels its
edit, so the space is never deleted and never reaches the pane;
compositions start after it (`compositionstart` uses the field's
length), and a field that already holds text is never touched.

Design reference: this is a WebKit input-field workaround, not a pattern
copied from another app. Native iOS terminals (Blink, Termius, a-Shell)
implement `UIKeyInput` themselves, so the question does not arise for
them; stock xterm.js in iOS Safari has the same defect.

## Verification
- iOS 27.0 simulator (iPhone 18 Pro), Safari, on-screen keyboard driven
with AXe touch down/up, owned raw-mode PTY capture in an isolated herdr
test session:
- 3 s hold of ⌫: **1 DEL before, 24 DELs after** (English keyboard);
Korean keyboard after the fix: 18 DELs in 2 s.
- Typed text, Space, double Space and Enter reach the PTY unchanged (`h
i ␠ ␠ z \r`), no stray space.
  - Korean typing is unchanged by this PR (see below).
- The input line was already fine (a plain field: a held ⌫ empties it
locally).
- `scripts/key-bar-hold-repeat-regression.ts` gains two steps: outside
iOS the helper textarea stays empty and `nowrap`; under an iPhone user
agent it keeps one space before the caret and `pre-wrap` through
Backspace, typing and Enter, and only the typed keys (`DEL DEL DEL a b
\r`) reach the pane. Fails on main, passes here. Chromium cannot repeat
an iOS key, so the repeat itself was measured only in the simulator.
- `scripts/terminal-ipad-ime-regression.ts` (the #938 iPad
hardware-keyboard Hangul replay) passes unchanged, and also with
`maxTouchPoints` forced to 5 so the space is active (run ad hoc, not
committed).
- `src/lib/deleteRepeat.test.ts`; `bun run check fast` passes.

## Limits / please review
- Measured only in the iOS 27.0 simulator; the reporter used Chrome on
iOS 27 (same WebKit, the CriOS user agent hits the same branch). Chrome
for iOS could not be installed in the simulator.
- The iPad **hardware-keyboard** Hangul path is covered by the recorded
replay only: with `pre-wrap`, text the editor leaves in the
one-cell-wide field wraps instead of overflowing; I did not exercise
that on a real iPad.
- The issue's "(or any key)": on the iOS soft keyboard only ⌫
auto-repeats; the key bar's keys repeat since #965.
- Separate finding, not changed here: on main, the iPhone soft Korean
keyboard in direct typing sends each jamo separately (`ㅎㅏㄴㄱㅡㄹ` for 한글).
iOS sends keydown key=jamo keyCode 0, then deleteContentBackward +
insertText with no composition events; the #938 replacement path in the
xterm patch is gated to iPad/Mac Safari, so iPhone is excluded. A plain
textarea composes 한글 correctly. Worth its own issue.

Fixes #862

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant