Skip to content

feat(terminal): keyboard only from the key bar on a touch screen (opt-in) - #2966

Merged
devswha merged 10 commits into
mainfrom
feat/keyboard-on-request
Nov 5, 2026
Merged

devswha merged 10 commits into
mainfrom
feat/keyboard-on-request

Conversation

@devswha

@devswha devswha commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Fixes #1635.

What

A new opt-in setting, Settings > Terminal > Keyboard only from the key bar (off by default, a device setting kept in its own storage key like the other recent opt-ins). With it on, on a touch screen:

  • While this pane's key-bar keyboard control reads Show keyboard, the input line and xterm's helper textarea carry inputmode="none". A tap on the grid, the line, Send or a key-bar key still focuses them as before, but the browser raises no soft keyboard.
  • Show keyboard removes the attribute from the field it focuses, inside the same tap, so the keyboard comes up.
  • Hide keyboard, or the system putting the keyboard away (Android's back gesture, read from the measured viewport), turns the control back to Show, and the attribute comes back.

With it off (the default), nothing changes: no field gets inputmode, except the existing none on xterm's field in Input line mode.

The hold is setting && coarse pointer && !requested. requested is a per-pane state that the control's Show tap sets. Hide clears it, and so do a keyboard measured going down (the back gesture, through lib/keyboardControl.ts's notifications) and the focus leaving the pane's fields. Nothing is held while the control cannot be pressed (offline, input not ready, held by another bridge, ended, view only). The line still takes a draft there, so a tap raises the keyboard as with the setting off (omo re-review). The focus-out check accepts only the line or xterm's field, not other fields in the pane such as the find bar. The hold is deliberately not the control's displayed direction: that falls back to the viewport measurement after its settle window, and the measurement is blind to an iPad floating keyboard or a zoomed page (Codex review). The line gets it as a prop. xterm's field gets it through its own layout effect in useTerminalSends, separate from the mode-switch effect, so a re-hold never re-runs that effect's blur or handoff.

Differences from the issue's proposal

  • The issue proposed a setting that is on by default and is switched off to opt in. This one is named for the opt-in instead and is off by default. The behaviour is the same.
  • The Input line / Direct typing switch does not move to a long press. Since feat(terminal): add a phone keyboard visibility control #1973 it has its own key beside the keyboard control, so no long press is needed.

Design reference: Termux's KEYBOARD extra key, the keyboard toggle of a phone terminal app. Reading is the rest state, and typing is asked for. DESIGN.md has the entry.

Tests

  • scripts/terminal-keyboard-demo-regression.ts: a new keyboard-on-request scenario on a 390-wide phone runs with the setting off and on, in line and direct mode. At rest, after a tap on the line or grid, after Show (inputmode checked as the tap's own focus runs), with the keyboard up, after the system dismissal, after Hide, after an unmeasured Show outlives the settle window, and after the focus leaves the pane's fields, it checks the field's inputmode and focus. An offline step (the line still raises a keyboard for a draft) was added in the second round. Each review step fails without its fix; the unmeasured step fails with (an unmeasured keyboard Show raised is not taken back). Failing first: with the src/ change stashed, it fails at on, line: at rest the field raises no keyboard (actual null, expected "none"). With the change, the whole script passes, including every existing scenario.
  • src/lib/settings.test.ts: the default, sanitising, device scope, and the setting's own key surviving an old tab's whole-record save.

Screenshots

Settings > Terminal at 390 and 1280, in light and dark, were checked by eye with the row off and on. The row sits right after Key bar and uses the same Toggle as its neighbours. Nothing else changes visually.

Validation

  • bun run check fast: pass (on the merged head, via the heavy runner).
  • bun scripts/terminal-keyboard-demo-regression.ts: pass.
  • bun test src/lib/settings.test.ts: pass.
  • Not run: the full browser suite (CI runs it), and a native iOS or Android keyboard check. Chromium's synthetic viewport stands in for the keyboard here; inputmode="none" is the platforms' documented way to suppress the soft keyboard (Chrome on Android, Safari on iOS).

…-in)

Settings > Terminal > Keyboard only from the key bar (off by default, a
device setting): while the key bar's keyboard control reads Show, the
input line and xterm's field carry inputmode=none, so a tap on the grid,
the line, Send or a key focuses without raising the soft keyboard. Show
removes the attribute inside its own tap; Hide, or the system putting the
keyboard away, brings it back.

Fixes #1635
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

CodeRabbit ASCII loading animation

Currently processing new changes in this PR. This may take a few minutes, please wait...

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e82c9a5 and 77c37e9.

Files selected for processing: 14

  • DESIGN.md
  • changelog.d/terminal-keyboard-on-request.md
  • docs/development.md
  • scripts/terminal-keyboard-demo-regression.ts
  • src/components/PaneTerminal.tsx
  • src/components/SettingsDialog.tsx
  • src/components/TerminalInput.tsx
  • src/lib/i18n/settings.ja.ts
  • src/lib/i18n/settings.ko.ts
  • src/lib/i18n/settings.zh.ts
  • src/lib/settings.legacy-fixture.ts
  • src/lib/settings.test.ts
  • src/lib/settings.ts
  • src/lib/useTerminalSends.ts

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

…ard only from the key bar

The hold followed the control's displayed direction, which falls back to
the viewport measurement after its settle window. The measurement is
blind to a floating keyboard or a zoomed page, so inputmode=none came back
on the focused field and took the keyboard away. Hold on a per-pane
request instead: Show sets it; Hide, a keyboard measured going down, or
the focus leaving the pane's fields ends it.
… raise it

Offline, held, ended or view only, the control is disabled or absent while
the input line still takes a draft: with the setting on nothing could raise
the keyboard there. The request now also ends when the focus lands outside
the line and xterm's field, such as the find bar.
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Review notes (omo + Codex Terra xhigh), for the merge pass.

Two fix rounds after the first review:

  1. MEDIUM, reproduced by omo and Codex: an unmeasured keyboard (an iPad floating keyboard, a zoomed page) lost Show after the 700 ms settle window. The hold now follows a per-pane request, not the control's displayed direction. A regression step covers it and fails without the fix.
  2. MEDIUM, reproduced by omo: while offline, held or ended, the keyboard control is disabled but the line still takes a draft, so nothing could raise the keyboard. Nothing is held while the control cannot be pressed. A regression step covers it and fails without the fix. Also fixed, LOW: the request now ends when the focus lands outside the line and xterm's field (the find bar, for example).

The final re-review at head 1cd898c was CLEAR. These findings remain, all unreproduced, so none blocks the merge and none gets a follow-up issue:

  • MEDIUM, unreproduced (it needs real keyboard animation timing): tapping Show within a Hide animation could be cleared when the old animation's measured "down" lands.
  • MEDIUM, unreproduced; the blind measurement is pre-existing on main: with an unmeasured keyboard up, the control reads "Show keyboard", and its next tap refocuses the field instead of hiding the keyboard.
  • LOW: released is not part of the hold condition. Released panes' line usability was not confirmed.
  • LOW: like the existing mode effect beside it, the new xterm-field effect re-reads the textarea only when its dependencies change.

Not checked: native iOS or Android keyboards. Chromium's scripted viewport stands in for the keyboard in the regression script.

…connection comes back

With Keyboard only from the key bar on, a tap into the line or the grid
while the control cannot be pressed raises the keyboard itself. Record it
as the request, so the reconnect does not put inputmode=none back on the
field being typed in.
# Conflicts:
#	src/components/PaneTerminal.tsx
#	src/components/TerminalInput.tsx
#	src/lib/settings.legacy-fixture.ts
#	src/lib/settings.test.ts
#	src/lib/settings.ts
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Final re-review at head 77c37e9 (omo + Codex Terra): no HIGH. As agreed with the lead, no further fix rounds. Remaining findings:

  • MEDIUM, reproduced by omo in Chromium DOM state: with the setting on, if the line is already focused (held, no keyboard) when the connection drops, a later tap does not fire focusin, so it is not recorded as a request. On reconnect, inputmode="none" returns on the focused line, which would close a native keyboard mid-draft. The draft text is kept. Suggested fix: when the control becomes unusable while the pane's line or xterm field has the focus, treat that as a request, and add a no-blur offline variant to the regression scenario.
  • LOW (rated MEDIUM by Codex), unreproduced: with an unmeasured keyboard, a system dismissal keeps the request, so a later tap raises the keyboard without the key bar. This fails toward the setting-off behaviour.
  • LOW, unreproduced: the direct-typing hold effect re-applies only when its inputs change. A replaced xterm field would miss the attribute until then.

# Conflicts:
#	src/lib/settings.legacy-fixture.ts
#	src/lib/settings.ts
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Local merge gate (owner-approved): origin/main merged (two settings key-list conflicts, both sides kept), bun run check fast passed at this head, threads resolved. Last full review at 77c37e9: no HIGH; since then only the main merge. The remaining reproduced MEDIUM (a line focused before going offline is re-held on reconnect) does not block and is in the PR comment. Opt-in, off by default. Merged without waiting for GitHub CI.

@devswha
devswha merged commit 043069f into main Nov 5, 2026
3 checks passed
@devswha
devswha deleted the feat/keyboard-on-request branch November 5, 2026 12:22
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.

Phone: an opt-in keyboard button that alone raises the soft keyboard (inputmode=none otherwise)

1 participant