Repository navigation
feat(terminal): cursor style, held key-bar arrows and pinch-to-zoom - #758
Merged
Merged
Conversation
Issue #620 asks for a saved cursor preference: today the terminal always start at a blinking block, with no setting for it. The issue's own comment give the exact xterm.js hook (term.options.cursorStyle, term.options.cursorBlink, applied live like theme and font already are, no remount needed). This add the smaller first version the issue itself allow: shape (block, bar, underline) and blink (on, off), saved per device. A program in the pane that sets its own cursor style with DECSCUSR can still change it after, same as today, since whether herdr's attach stream pass that sequence through is not established yet (the issue's own "not checked yet" note) and the "allow applications to override" toggle depend on it. sanitizeSettings gets new red-then-green tests for the two fields, and the three translation files get the new strings (checked by the existing i18n test, which fail on a missing or stale entry).
## Change On a phone, holding an arrow on the touch key bar sent one key and then nothing. It now repeats like a held hardware key. - `src/lib/keyRepeat.ts` holds the timing as a pure state machine with an injectable clock: no key on press, the first repeat after `KEY_REPEAT_DELAY_MS` (400 ms), then one every `KEY_REPEAT_INTERVAL_MS` (50 ms) until release. Only `ArrowUp`/`ArrowDown`/`ArrowLeft`/`ArrowRight` key items repeat, including saved combinations such as Ctrl+←; Esc, Tab, Enter, ^C, catalog keys and the modifier and mode buttons do not. - A tap is unchanged: it still sends one key through `onKey` → `pressKey` on `click`. After a hold has repeated, the click that follows the release is swallowed, so a hold never ends with an extra key. Every repeat goes through the same `onKey` path (latest callback through a ref), so held Ctrl/Alt/Shift and saved combinations apply to each repeated key. - `Key` in `KeyBar.tsx` tracks the primary pointer with pointer capture. The repeat stops on `pointerup`, `pointercancel`, `lostpointercapture`, the button becoming disabled, the document becoming hidden, the window losing focus, and unmount. KeyBar is not remounted when the pane changes, so `PaneTerminal` passes a `holdScope` (`paneStorageId:view`) and a change of pane or lens cancels the hold. - A sideways swipe that starts on an arrow keeps scrolling the row and sends nothing: moving more than 10 px before the repeat starts cancels the pending hold, as does the `pointercancel` the browser sends when it takes over the pan. - Keys prevent `contextmenu`, and `.key` sets `-webkit-touch-callout: none`, so a long press opens no callout or menu. - No setting, WS frame or server change: the existing `keys` frame and the server's queue merge carry the repeat. No new UI strings. - Docs: `docs/terminal-input.md` (key bar), `docs/development.md` and `scripts/ci-browser.sh` list the new browser regression. CHANGELOG: `Unreleased → Added`. On the issue's open questions this PR takes the narrow side: only the four arrows repeat, and 400 ms / 50 ms are fixed constants. Closes #718 ## Validation - `bun run generate:types --check`, `bun run typecheck`, `bun run build`: pass. - `bun run test:unit`: 2237 pass, 0 fail, run with `TMPDIR=/tmp`. New `src/lib/keyRepeat.test.ts` covers tap/hold boundaries at the delay and interval, release and cancel, the one-shot click suppression, the movement slop and which items repeat. `scripts/ci-browser.test.ts` now expects 22 browser scripts. - New `scripts/key-bar-hold-repeat-regression.ts` (demo transport, 393×852 touch context, CDP touch events): all 7 checks pass, in three runs before rebasing onto current `main` and one after: - a tap on ← sends exactly one key; - holding ← sends 10–11 keys, none before the delay, and nothing after release; - a hold shorter than the delay sends one key; - a horizontal swipe from ← scrolls the overflowing row and sends no key; - a held Esc does not repeat (Chrome sends no `click` after a long touch, so it sends no key, as before this change); - with Ctrl held, every repeated key is Ctrl+←; - a held arrow prevents the `contextmenu` default. - `scripts/sticky-modifiers-regression.ts`, `scripts/key-bar-customization-demo-regression.ts`, `scripts/terminal-arrows-clicks-regression.ts`: pass. - Tried by hand on a phone over Tailscale Serve against a server built from this branch: tap, hold, release and sideways scroll behaved as described. - Not run: the full `bun run test:integration` and `bun run test:ui`.
## Change On a phone, a two-finger pinch on the terminal now changes the per-device `terminalFontSize` setting, the same one as the Settings stepper. - **While pinching:** the size is `round(startSize × distance / startDistance)`, clamped to 10–22 px. Each time that whole-pixel size changes, this device's xterm font changes and the grid refits locally. A small badge at the top of the terminal shows the size (`17px`). No resize frame goes to the server during the gesture. - **Release:** when the first finger lifts, the handler sends one forced resize for the new grid (only when the terminal is in use, and never for observe, fixed-grid or Chat), then saves the setting. The existing font effect sees the font already applied and sends nothing more. So a gesture adds one shared-pty resize, not one per size step. - **Cancel:** `touchcancel` restores the starting size, saves nothing and sends no resize. A released, watched pane gets one `watch` update at the end instead of one per step. - **Touch handling:** the host listeners move to the capture phase, so xterm's own viewport touch scrolling does not take the first finger of a pinch. A second finger ends a one-finger scroll. The finger left after a partial release does not scroll until a new touch. `gesturestart`/`gesturechange` are prevented on the host for iOS Safari. One-finger scroll and adopted-grid pan are unchanged. - No new setting or strings. **Differs from the proposal in #707.** The issue proposed a CSS `transform: scale()` preview with the font applied only on release, and listed "change the font live and defer the pty resize" as an alternative. On a real phone the scale preview enlarged and cropped the terminal content, which was hard to read. A badge alone showed the number but not the result. This PR uses the live local font instead. The cost is local reflows during the gesture (up to 7 for 13→20). Meanwhile this device's grid can disagree with the pty until the release resize. The shared pty still sees one resize per gesture, which was the point of the proposal. Pinching on the KeyBar, input line or header still zooms the page, as on `main`. Those regions keep their current `touch-action`. Closes #707 ## Validation - `HERDR_TEST_MODE=unit bun test ./src/lib/pinchFontSize.test.ts`: 5 pass (ratios, rounding, 10/22 clamps, coincident or non-finite distances). - `bun run generate:types --check`, `bun run typecheck`, `bun run build`: pass. - `TMPDIR=/tmp bun run test:unit`: 2223 pass, 49 skip, 0 fail. - New `scripts/terminal-pinch-regression.ts`, also wired into `scripts/ui-regression.ts`, drives real two-finger CDP touches in 390×844 mobile emulation on an isolated test session. It checks the following: - 13→20 and 20→13: the font changes before release, the terminal is not transformed, 0 resize frames and 0 wheel events during the gesture, then exactly 1 resize frame on release. The frame's rows match the rendered grid (37×31 for 20 px). `visualViewport.scale` stays 1. - Clamps at 22 and 10 px, one resize each. - `touchcancel` restores 13 px and the grid, saves nothing, sends no resize. - One-finger scroll → second finger → partial release: the remaining finger sends 0 wheels, and a new one-finger drag scrolls again. - The size survives a reload. - `bun scripts/ui-regression.ts`: passes, including the new check. - `bun scripts/windows-lens-browser-qa.ts` (one-finger history scroll, adopted-grid pan on a phone): all 7 checks pass with an `en-US` browser locale, run on the first revision of this branch, before the live font change. The one-finger paths have not changed since. On a `ko-KR` Chrome it times out at the English `Terminal` selector, as clean `main` does. - Manual: tested on a physical Android phone (Chrome) and an iPhone (Safari) over Tailscale. - Not checked: a Windows mirror pane, long-press text selection during or after a pinch.
…ws and pinch badge
This was referenced Oct 11, 2026
…-0.4.6 # Conflicts: # CHANGELOG.md
…-0.4.6 # Conflicts: # CHANGELOG.md
devswha
added a commit
that referenced
this pull request
Oct 13, 2026
…aging keys repeat (#965) ## 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 #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. (#718 left "should Backspace, Delete, PageUp, PageDown repeat too?" as an open question; #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 #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 - Refs #862 (held backspace does not repeat). This fixes the key-bar ⌫ case. The issue does not say whether the reporter held the key-bar key or the system keyboard's backspace; the soft keyboard's own repeat goes through xterm's textarea, not this code, so I did not use "Closes". - `DEFAULT_KEY_BAR_ITEMS` is unchanged: ⌫ is still opt-in through key-bar customization. Neither #862 nor the docs ask for it in the default bar, and changing defaults touches settings migration and telemetry customization flags. - #935 (opt-in composer autocorrect, open) touches `Composer.tsx` / `PaneTerminal.tsx` / `compose.ts` only; no file overlap. Its body says "the terminal input line keeps its current attributes"; after this PR those attributes are off, matching the composer default. I suggest its toggle should not cover the terminal line, since shell tokens are the worst case for autocorrect. - #943 and #946 (open) touch `KeyBar.tsx` but not the repeat logic or `keyRepeat.ts`; this PR does not edit `KeyBar.tsx`. - Changelog: one fragment, `changelog.d/terminal-input-autocorrect-and-key-repeat.md` (two Fixed entries). ## 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](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Change
Three maintainer-approved contributions to the terminal, carried onto current
mainin one PR because all three editsrc/components/PaneTerminal.tsxand each conflicted withmain. Each keeps its contributor as commit author (cherry-picked in order #731, #719, #713; the contributors' commit messages carry the full design notes).sanitizeSettings, applied live throughterm.options(no remount). A program's own DECSCUSR can still change it. Strings in ko/ja/zh.PaneTerminalpasses aholdScopeso a pane or lens change cancels a hold. Newscripts/key-bar-hold-repeat-regression.tsis in the browser lane.touchcancelrestores the starting size. Newscripts/terminal-pinch-regression.tsruns inscripts/ui-regression.ts.Conflict resolution only: the cursor props go on the
PaneTerminalthatPaneCanvasnow renders,holdScopeand the pinch badge sit onmain's current KeyBar line and terminal host, andscripts/ci-browser.test.tsexpects 26 browser scripts. The review findings on the three PRs were CodeRabbit's missing changelog links; the changelog entries are added in a separate commit with both PR links and credit.Closes #620, Closes #718, Closes #707
Supersedes #731, #719, #713
Screenshots (390 px phone, demo fixtures)
Verification
Before the change (branch scripts and tests against
main'ssrc/):bun scripts/key-bar-hold-repeat-regression.ts: FAIL, "a held Left repeats before release (got 1)".bun scripts/terminal-pinch-regression.ts(isolated test session): FAIL, "pinch start shows the size badge".HERDR_TEST_MODE=unit bun test ./src/lib/settings.test.ts: FAIL on the cursor defaults test.On this branch:
bun run generate:types --check,bun run typecheck,bun run build: PASS.bun run test:unit: 2472 pass, 8 skip, 0 fail (includes settings, keyRepeat, pinchFontSize, i18n, motion and ci-browser tests).bun scripts/key-bar-hold-repeat-regression.ts: PASS (tap, hold 10–11 repeats, short hold, swipe, Esc, sticky Ctrl, contextmenu).bun scripts/terminal-pinch-regression.ts(isolated test session) andCHECK_MAX_RUNS=8 bun run check run --build bun scripts/terminal-pinch-regression.ts: PASS.bun scripts/settings-pages-demo-regression.ts(every Settings page at 390 and 320 px) andbun scripts/key-bar-customization-demo-regression.ts: PASS.xterm-cursor-barwithout blink; choosing Underline and Blinking in Settings changes the live cursor toxterm-cursor-underline xterm-cursor-blink; a pinch shows the21pxbadge and saves 21 on release.After merging
main(5792d71, #755; the only conflict was CHANGELOG, both sections kept):bun run typecheckPASS; settings, keyRepeat, pinchFontSize, i18n, motion, paneLens and ci-browser tests 94 pass, 0 fail;CHECK_MAX_RUNS=8 bun run check run --build bun scripts/terminal-pinch-regression.ts,bun scripts/key-bar-hold-repeat-regression.tsandbun scripts/settings-pages-demo-regression.tsPASS.