Repository navigation
fix(terminal): the key bar's keyboard control acts on its tap's word - #2333
Conversation
## Problem On a phone, the key bar's Show/Hide keyboard control re-decided the tap's action at tap time from data-keyboard, a visual-viewport measurement that flips mid-slide (Chromium's keyboard geometry overshoots, and nothing says when it settled). Hide then ran as Show, the open control sat armed over a keyboard visibly up, rapid taps made the keyboard open and close in bursts, and after Android's back gesture (field left focused, keyboard down) Show focused an already focused field, which raises nothing. The Input line switch rode the same keyboard: switching input mode alone raised and put it away. ## Change - New src/lib/keyboardControl.ts: the tap's word is kept as intent until the measurement confirms it (held still 120 ms, past the overshoot) or the 700 ms settle window runs out; last tap wins, a composition or pending commit refuses before any state changes, and a tap this pane has no target for records nothing. One derivation, keyboardControlView, is what the label, glyph, aria-pressed and the next tap's action all read. - viewport.ts feeds each sync's measurement to the store; data-keyboard's meaning for every other reader is untouched. - toggleKeyboard now only performs the focus and blur, inside the tap's gesture: an already focused field is blurred and refocused (the back gesture's dead tap), and a blur that leaves no field focused anywhere is the keyboard going, which a blind measurement (a zoomed page, a floating keyboard) cannot see. - The mode switch is no keyboard gesture: direct to line hands the grid's keyboard to the input line, focus and all, in a layout effect before paint, gated on touch (useTerminalSends, TerminalInput's focus() handle). Unit tests drive the store on a hand clock; the demo regression is updated to the new contract, and the back-gesture branch, the mode handoff and an already focused Show with DECSET 1004 on are pinned.
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
| Layer / File(s) | Summary |
|---|---|
Keyboard intent state and viewport measurement src/lib/keyboardControl.ts, src/lib/keyboard.ts, src/lib/viewport.ts, src/lib/keyboardControl.test.ts, src/lib/keyboard.test.ts |
A new store tracks keyboard-control intent, measured visibility, and settle timing. Viewport measurements feed the store, and shared typing-field detection replaces the prior local predicate. Tests cover state transitions, timers, and subscriptions; tests for the removed helpers are deleted. |
Key-bar actions, focus handoff, and regression coverage src/components/KeyBar.tsx, src/components/PaneTerminal.tsx, src/components/TerminalInput.tsx, src/lib/useTerminalSends.ts, scripts/terminal-keyboard-demo-regression.ts, DESIGN.md, changelog.d/keyboard-control-intent.md |
The key bar displays the next action from the store. Pane actions focus or blur input fields, and the terminal input handle exposes focus(): boolean. Input-mode handoffs update focus. Regression checks and documentation cover immediate control state, focus handoffs, and cases where keyboard visibility is not measured. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Suggested reviewers: devswha
Merge Risk: 
Minimal · previous review 1ba7f
-
The change appears mergeable after normal checks; the supplied evidence does not establish an issue requiring a fix before merge.
Pre-merge checks: 
5
-
Full details: Description check
-
Explanation
The description clearly explains the problem, cause, implementation, and resulting behavior. It is on-topic and mostly complete, although it does not include the template's exact headings or validation results.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 8 functions across 10 files. (2 skipped: 2 unsupported.)
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- 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.
Comment @coderabbitai help to get the list of available commands.
… pane Review fixes on devswha#2333: - A tap's word is confirmed only by measurements taken after that tap: a reversal Show during the last Hide's animation is no longer cleared by the old, still-occluding value (agreedAt replaces changedAt). - The word is the tapping pane's own: another pane's control reads the measurement, so its Show acts while a tap is in flight elsewhere (KeyBar keyboardOwner, PaneTerminal useId + paneStorageId). - The Input line switch leaves the keyboard as the control says it is: up, the new mode's field takes it; down (including Android's back gesture with a field still focused), the switch focuses nothing. - The keyboard demo regression: read the tap's word after React commits it, keep the grid under a keyboard across a switch (devswha#1045), and hold the clock through a pane switch while a sibling's tap is in flight.
…neutral mode switch
- A tap whose measured value already agreed before it (a reversal during the last animation) is confirmed only after the measurement moves: an unchanged boolean is no proof the keyboard stopped moving. - A hold ends at its quiet window by a timer, without a further viewport event, so a Back dismissal after one up reads down (and the mode switch no longer raises it). - A pane that stops being the selected, shown one gives up its tap in flight (keyboardControl.release), so coming back it reads the measurement instead of an unusable Hide. - Demo regression: the keyboard-up switch flushes deferred work before comparing the grid and checks no resize; the sibling check asserts the tapped pane's word is in flight under the paused clock. - DESIGN and the changelog name what the switch does where the measurement is blind (floating keyboard, zoomed page).
…swha#2333 review round 3) A Show tapped after Hide's blur but before the viewport's deferred focusout sync saw the blur's local "down" and was not marked stale, so the old animation's unchanged "up" confirmed it. The store now keeps the last value the viewport measured (observed) apart from the local hidden confirmation, and a tap is stale against that. Also rewords the demo's sibling assertion to what it checks now that a pane left mid-tap gives its word up.
|
Thank you @IdrisGit — splitting the tap's word from the keyboard's measured value is the right shape, and the store made the fixes below small. Per our usual flow for external PRs, we fixed the review findings on your branch ourselves (maintainer edits, merged What we changed
Evidence
Reviews (CodeRabbit had already reviewed the first head)
Not changed (LOW, noted): a quick Show→Hide can read "Hide keyboard" briefly when a late "up" arrives after two quiet "down" readings; not reproduced on a device and not a regression. |
… not fire() fire() also ran the 700 ms settle fallback, which cancels the quiet timer, so the two quiet-window confirmations passed without it. due() runs only the timers whose deadline has come; both tests now fail when the quiet-window timer is removed.
…evswha#2333 Direct to line with the keyboard up now hands the focus to the input line instead of blurring the grid. The check's next step (a smaller viewport with no field focused is not a keyboard) assumed that blur: assert the handoff, then blur before it.
|
Merging 33f66b6, thank you @IdrisGit! On a phone, the key bar's Show/Hide keyboard control now acts on the user's tap instead of re-reading mid-slide viewport geometry: the label, glyph and aria-pressed follow the last tap, rapid taps settle on the last one without open/close bursts, a tap works again after Android's back gesture, and switching between the input line and direct typing no longer raises or drops the keyboard. Strict external review by the merge pass; per the maintainer's rule lane fix-2333 fixed the findings on the branch with maintainer edits: a stale animation could confirm a reversal tap (HIGH), the pending intent was page-wide instead of per pane, the mode switch still moved the keyboard in two cases, and two tests fired the fallback timer instead of proving the quiet window. The mobile viewport regression now asserts the input-line handoff (the intended behaviour) and blurs before its no-keyboard step. 36 tests, typecheck and the phone keyboard demo pass; Android emulator and iOS Simulator before/after are in the PR. The paused lane feat-1531 (phone keyboard-mode button) overlaps in KeyBar and PaneTerminal imports and will rebase on this. |
## Release 0.4.21 The release PR, prepared by step 1 of [docs/development.md#releasing](https://github.com/devswha/ovis/blob/main/docs/development.md#releasing), now re-folded on main `1ef6ea329108a0985b823e8235b03daddcd0a5f4` after the owner held 0.4.21 for more work. The merge pass reported the 0.4.21 queue empty. **Do not merge yet:** the owner judges the final build before release. No tag and no Release run from this PR's author. - **Version:** `version` is 0.4.21 in `package.json` and `herdr-plugin.toml`. - **Changelog:** `bun scripts/changelog-fold.ts 0.4.21 2026-10-30` folded 63 fragments into the 2026-10-30 section of `CHANGELOG.md` (71 entries), linked their PRs and deleted the fragments; `changelog.d` holds only `README.md`. - `by @login` on every outside contributor's PR link: #2361 @eddieparc, #2333 @IdrisGit, #2355 @imurfutur3, #2341 @sulthonzh, #2359 @YuuuXie, #2377 @IdrisGit, #2269 @CharleoYang, #2405 @jpcarranza94, #2414 @homebodify, #2417 @cheol-95, #2418 @eddieparc, #2435 @cheol-95. - Two outside PRs had no fragment and got an entry by hand: #2341 (OpenCode background commands, Added) and #2359 (installer test timing, Maintenance). - Issue reporters are credited in their entries: @blaker3115-Agri (#1488), @Hyd3-14 (#2026), @osamahbeig (#2343), @Shunamxiao (#2329), @matiemer (#2362), @kilhyeonjun (#2344), @eddieparc (#2360), @Ploppy3 (#2236), @sulthonzh (#2340), @WOULDU-pres (#2056), @odfalik (#2038), @aNNdii (#511), @Noobear (#2281, fixed by #2424); #2435 fixes @cheol-95's own #2434. - Two fragments ran past the changelog's width (#2418, #2269); their entries are re-wrapped, words unchanged. #2382's entry reads "OpenCode's installer puts its folder first" (reviewed earlier on this PR). - Maintainer PRs without a fragment and without a user-facing change have no entry: #2353 (check tool), #2371 (guide docs), #2396 and #2397 (tests), #2403 and #2433 (server and client transport seams, no behaviour change), #2437 (test-only fix for #2435's check). #2438's own entry (the sidebar selection marked by its fill again) is dropped: the stroke #2352 added never shipped, so users see no change; #2352's entry keeps only the Windows high-contrast Highlight bar. - **Release summaries:** en, ko, ja and zh each have 5 new, 5 improved and 5 fixed lines. Since the first review: New lists the in-browser Claude Code / Codex sign-in (#2428) in place of the tab/workspace shortcut line; Improved lists Settings → Agents (#2427) in place of the sidebar fold line; Fixed lists the Codex wrong-session fix (#2426, #2430) in place of the phone screenshot paste line. The Artifacts and Claude status-line lines keep their reviewed wording (turned on in Settings). Not in 0.4.21: #2420 (Codex chat behind Kiro), #2065 (Portal sign-in) and #2436 (relay foundations) stay open for a later release. - **Remote bundle:** `REMOTE_BUNDLE_VERSION` rises from 39 to 40 because the bundle inputs (`server/`, `shared/`, `patches/`) changed since remote-v39. After merge: push `remote-v40` on the merged commit and wait for the Remote PC bundles workflow before running Release. - **iOS:** `CURRENT_PROJECT_VERSION` stays 3 (#2370 changed `Info.plist`; build 3 is not known to be uploaded yet). ## Validation - `bun scripts/release-guards.ts --base v0.4.20`: "Release 0.4.21: remote bundle, telemetry Worker and release metadata are in order." - `dori heavy … bun run check fast` on this branch: workflow syntax, generated types and themes, typecheck, build, unit tests all ok. Unit: 9166 pass, 0 fail, 36 skip in 591 files. - Every PR in `v0.4.20..main` was pre-run for the owner's hands-on guide on isolated copies (own herdr session, fresh state, never the owner's live session). Items that need a real device (iPhone tap dictation #2370, dictation keyboards #2386, the installed desktop app's title-bar overlay #2381) are left for the owner's final check. This is a release-metadata PR: it changes no code path. Per the release steps, merge it after CI and the owner's go, then push `remote-v40`, wait for its bundles, and run Release with `0.4.21`.
Closes the phone keyboard-control bug that #1973's control hid underneath: the control is there, but a tap's meaning could not be trusted.
Problem
On a phone, the key bar over the keyboard has an Input line switch, Paste and a Show keyboard / Hide keyboard control (#1046, #1973). Two things went wrong with it:
Switching Input line / direct typing rides the same keyboard: the switch alone raises it and puts it away, so changing where you type looks like a broken keyboard button.
Cause
The control had no state of its own. Its label, glyph,
aria-pressedand the action the tap took were each re-read, at tap time, fromdata-keyboard— a visual-viewport measurement that flips in the middle of the keyboard's own slide (Chromium's geometry overshoots the resting height and no API says when it settled). A tap therefore meant whichever side of the animation the last measurement happened to land on, and a measurement blind to a zoomed page or a floating keyboard kept the control lying for good.Change
src/lib/keyboardControl.ts: a small store that keeps the tap's word (last tap wins) until the keyboard measurement confirms it and holds still (120 ms, past the overshoot) or a 700 ms settle window runs out. A composition or a pending commit refuses the tap before any state changes, and a tap this pane has no target for records nothing. One derivation (view) is what the label, the glyph,aria-pressedand the next tap's action all read, so the control can never say one thing and do another.lib/viewport.tsfeeds each measurement to the store;data-keyboard's meaning for every other reader (shell height, grid hold, CSS) is untouched.toggleKeyboardnow only performs the focus and blur, inside the tap's own gesture: Show blur-and-refocuses an already focused field, which is what re-raises the keyboard a back gesture put away, and Hide's blur leaving no field focused anywhere reads as the keyboard going where the measurement is blind.What it improves