Skip to content

fix(mobile): Android terminal moves up with the keyboard instead of snapping - #35465

Open
juliusmarminge wants to merge 3 commits into
mainfrom
factory/issue-14464-a21751
Open

juliusmarminge wants to merge 3 commits into
mainfrom
factory/issue-14464-a21751

Conversation

@juliusmarminge

Copy link
Copy Markdown
Member

Both review items were checked against the code and are correct; both are fixed. (1) Accessory overlap: KeyboardStickyView translates the full 52pt accessory, so scaling its reservation by keyboard progress left 52*(1-p) points of overlap. The animated paddingBottom is now -keyboardHeight + (accessory visible ? 52 : 0), reserving the accessory's full height once it is shown, as main does. (2) Resize storm: the animated padding still changes the native view's size every frame. That is local work: T3TerminalView.applyGrid draws min(sharedGrid, measured fit), so the view shrinks and keeps the prompt visible without a server round trip. Only the report to the PTY is deferred: terminalKeyboardShowing.ts (which already listens to the keyboard events) gains runWhenKeyboardSettles(owner, run). It runs immediately when the keyboard is still, and otherwise keeps only the latest call per owner and runs it on keyboardDidShow/keyboardDidHide. On Android, handleResize sends terminalSessionDriver.reportGridSize through it (keyed by the driver); the grid-size cache and iOS are unchanged. Measured on a leased Pixel 9 (Gboard) with a bash WINCH trap logging tput lines: keyboard open delivered one SIGWINCH (29 rows), down from about 15-20 at the previous head. Close delivered two (55, then 50 once the Android 'Attach output' bar mounts after didHide). Main's close also steps twice by its code (the accessory leaves on willHide, then padding drops on didHide); I did not count on main. A frame-by-frame recording of the open shows the prompt just above the rising keyboard and no accessory overlap. No new regex or parser.

Fixes #14464

Reproduction on main

Commit f03db4f (origin/main). Ran a fresh isolated server (node apps/server/src/bin.ts --no-browser --base-dir <scratch> --host 0.0.0.0 --auto-bootstrap-project-from-cwd <scratch project>, so no seeded data) and Metro (expo start --dev-client --lan). Leased a Pixel 9 (API 36, Gboard) from the device pool, installed the cached dev client with vp run mobile:install android --session, paired it with the test-t3-mobile pair-client helper, and created one thread with t3 thread start (its turn failed on an unknown model, which cost nothing). Opened Terminal > Open new terminal and ran seq 1 200 so the output reached the bottom. Hid the keyboard with the accessory bar's 'Dismiss keyboard' button, then recorded the screen while tapping the terminal to open the keyboard, dismissing it, and opening it again. Frame by frame: at 7.93s the keyboard is fully up, but the terminal is still full height, its prompt and last rows hidden under the keyboard, and there is no accessory bar. Nothing on screen changes until 9.11s. Then, in a single frame, the terminal moves up 21 rows (top line 152 -> 173) and the prompt and accessory bar appear above the keyboard. When the keyboard closed, the accessory bar slid down with it; I saw no snap on close. The 1.2s delay may be inflated by the remote emulator. Interactive dismissal, rotation and a second client attached to the same terminal session were not checked.

Evidence

Being captured: before and after in the real app. This section is filled in before the pull request can merge.

Tests

vp test run src/features/terminal/terminalKeyboardShowing.test.ts: 2 passed; the new case fails without the source change (runWhenKeyboardSettles missing). vp run check:changed: format failed once, fixed with vp fmt, then all pass (format, lint, knip 1/2 and 2/2, typecheck of 2 packages, test of 1 file, react compiler on 2 files). Device: Pixel 9 API 36 with Gboard against an isolated server and Metro; shell WINCH trap counts (open: 1, close: 2) and a screen recording of the keyboard open, checked frame by frame.

Not in this change

  • The key toolbar (KeyboardStickyView accessory) still mounts only when JS keyboard state flips; on a slow JS thread that is after the keyboard finishes opening, leaving one 52px step. Fixing it means mounting the accessory ahead of the JS state, which is a redesign.
  • The 'Attach output' bar and the container's bottom inset on Android still toggle on JS keyboard state.
  • Closing the keyboard: the terminal content fills the freed space only after the keyboard is gone. Main does the same; not changed here.
  • Following the animation resizes the terminal row by row while the keyboard opens (about 20 resize RPCs, deduped by reportGridSize) instead of once; batching resizes was not attempted.
  • iOS terminal still uses the step padding from useKeyboardState; not reported as broken, so left alone.
  • Interactive dismissal, rotation and a second client attached to the same terminal were not checked.
  • Keyboard close still sends two PTY resizes (keyboard gone, then the Android 'Attach output' bar mounting after didHide); main also steps twice on close by its code.
  • The key toolbar still mounts when the JS keyboard state flips, so on a slow JS thread it appears after the keyboard finishes opening.
  • If a keyboard-will event ever lacks its did event, the deferred grid report waits for the next keyboard event; the library emits did events at animation end and in its repair path.
  • A deferred report can still run if the terminal screen unmounts mid-animation; it only re-reports a size.
  • iOS terminal padding and resize reporting are unchanged.

AI-assisted; verified with the tests and tools listed above.

…napping

AI-assisted; verified with the tests and tools listed above.
…nce per keyboard move

AI-assisted; verified with the tests and tools listed above.
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 12, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Nov 12, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 08b77a1

Macroscope's review found this PR approvable — Android terminal layout and its accessory now follow keyboard motion, while PTY resize reports are deferred until the animation settles. The effects are limited to layout and resize timing, with no apparent material data or access risk.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Android terminal now animates its bottom inset and accessory position with keyboard movement. Its bottom bar remains laid out and measured. Android grid-size reports wait until keyboard movement settles; other platforms report immediately.

Changes: Terminal keyboard synchronization

Layer / File(s) Summary
Keyboard movement and settling callbacks
apps/mobile/src/features/terminal/terminalKeyboardShowing.ts, apps/mobile/src/features/terminal/terminalKeyboardShowing.test.ts
Keyboard events now track movement and run queued callbacks when movement settles. runWhenKeyboardSettles retains only the latest queued callback for each owner. A test checks callback execution across keyboard transitions.
Terminal inset and resize integration
apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx
The Android terminal uses an animated bottom inset, persistent measured bottom bar, and animated accessory. The inset reserves accessory space when terminal operation is allowed. Android grid-size reports wait until keyboard movement settles; other platforms report immediately.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant KeyboardEvents
  participant terminalKeyboardShowing
  participant ThreadTerminalRouteScreen
  KeyboardEvents->>terminalKeyboardShowing: Report keyboard show and hide events
  ThreadTerminalRouteScreen->>terminalKeyboardShowing: Queue Android grid-size report during keyboard motion
  terminalKeyboardShowing->>ThreadTerminalRouteScreen: Run queued report when keyboard settles
Loading

Possibly related PRs

Suggested labels: bugfix

Suggested reviewers: t3dotgg

Merge Risk: Minimal · up to 08b77

This change makes the Android terminal keyboard animation smoother and defers resize reports until the keyboard settles. No merge-blocking risk was identified, although interactive dismissal and rotation were not tested on a device.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Android terminal keyboard motion now follows the keyboard instead of jumping. It matches the linked issue #14464 and the fix described in the summary. The title is one…
Description check Passed The description follows the repository template and fills every required section with specific content. Problem and Change explain the bug and the fix. Scope links issue #14464 and the author states i…
Linked Issues check Passed [#14464] requires the Android terminal and keyboard accessory to follow the keyboard on open without an abrupt upward jump. The head diff of ThreadTerminalRouteScreen.tsx replaces the step padding (us…
Out of Scope Changes check Passed All changed code sits in the terminal keyboard path. The changes are the animated Android inset and accessory, the persistent Android bottom bar with onLayout height measurement, the deferred Android …
Full details: Title check

Explanation

The title names the main change: Android terminal keyboard motion now follows the keyboard instead of jumping. It matches the linked issue #14464 and the fix described in the summary. The title is one short sentence in conventional commit form.

Full details: Description check

Explanation

The description follows the repository template and fills every required section with specific content. Problem and Change explain the bug and the fix. Scope links issue #14464 and the author states it fixes that issue. Verification gives the device steps, test results, and frame-by-frame observations, and it states what was not checked. The Evidence section says screenshots and recording are still pending, and it states that this section must be filled before merge. That gap is a non-critical item that does not block the check.

Full details: Linked Issues check

Explanation

[#14464] requires the Android terminal and keyboard accessory to follow the keyboard on open without an abrupt upward jump. The head diff of ThreadTerminalRouteScreen.tsx replaces the step padding (useKeyboardState, applied on keyboardWillShow/keyboardDidHide) with a UI-thread animated style. It uses useReanimatedKeyboardAnimation to derive paddingBottom from keyboardAnimation.height and progress. It also animates the accessory with androidAccessoryStyle, so both follow the keyboard frame by frame. This addresses the root cause the issue identifies. terminalKeyboardShowing.ts and its test add runWhenKeyboardSettles, which defers the PTY grid report during keyboard motion. This covers the issue's repeated-open reproduction. Limits: the 'Evidence' section is marked as pending, so no before/after artifact is in the repository. The device result (single frame jump on main, no overlap at the head) appears only in the PR description and is not independently verified. Interactive dismissal, rotation and a second attached client were not checked, as the PR states. No automated test covers the animated padding; the only new test covers the deferred report. The issue asks for those checks, so they remain open. The opening behavior that the issue reports is implemented in code.

Full details: Out of Scope Changes check

Explanation

All changed code sits in the terminal keyboard path. The changes are the animated Android inset and accessory, the persistent Android bottom bar with onLayout height measurement, the deferred Android grid-size report, and the runWhenKeyboardSettles helper with its test. Each of these supports the opening-jump objective of #14464. One inconsistency exists. The PR description says the 'Attach output' bar still toggles on JS keyboard state and is not changed. The head diff removes the !isKeyboardVisible gate, so that bar now renders on Android at all times. The PR objectives list changing the bar's mount as an exclusion. The change is still connected to the objective, because the bar stays under the keyboard as a measured reserve for the animated padding, so it is not an unrelated change. The description should be corrected to match the code. The iOS path keeps its prior padding and reporting behavior.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 45f6c1b and 08b77a1.

Files selected for processing: 1

  • apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx

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

…ard instead of the late JS state

AI-assisted; verified with the tests and tools listed above.
@macroscopeapp
macroscopeapp Bot dismissed their stale review November 12, 2026 19:16

Dismissing prior approval to re-evaluate 08b77a1

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Nov 12, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Native Android terminal jumps upward when the keyboard opens

1 participant