iOS: keep the bottom bars docked to the keyboard when the layout guide misses a transition

Closed
AZ
2mo ago
+1126-228

Bug

Keyboard rises but the bottom bars (Tab/Esc accessory toolbar + Message composer) stay seated at the screen bottom behind it. Field recording repro: keyboard up in workspace A, back to the list, open workspace B, focus input — the keyboard covers the bars and the terminal grid keeps keyboard-down geometry until the keyboard is dismissed and re-raised.

Root cause

Since https://github.com/manaflow-ai/cmux/pull/9371 the dock is constrained to UIView.keyboardLayoutGuide, which only reflects keyboard transitions UIKit routed to the view's window while the view was installed. A surface (re)attached around a workspace switch can miss the transition and stay seated on the guide's bottom-safe-area fallback while the keyboard is up. Nothing re-derives keyboard geometry after attach, so both the constraint-positioned bars and the keyboardOverlapFromLayoutGuide viewport model stay at keyboard-down layout.

Fix

Keyboard notifications are posted process-wide regardless of any view's attachment, so:

  • MobileKeyboardFrameTracker (CmuxMobileSupport) records the latest keyboard end frame from keyboardWillChangeFrame, clearing on keyboardDidHide and backgrounding.
  • The dock gains a REQUIRED inequality floor composer.bottom <= view.bottom - trackedOverlap beneath the guide equality, which drops one priority notch. The guide remains the movement engine; the floor only stops the dock from sitting below the real keyboard. It animates on the notification's own curve on the notification path and catches up from the tracker on layout after a late attach.
  • The viewport model takes max(guide, floor) so the terminal grid reserves exactly the space the lifted bars occupy.

A stale notification frame can never pin the dock below wherever the guide places it (inequality, not a second equality authority), and MobileKeyboardReservation keeps floating/split iPad keyboards at zero overlap.

Tests

Commit 1 (red): dock regression tests in a test window, where the system guide never observes a keyboard — deterministically the same wedge as the missed live transition. Covers the notification path, the attach-after-transition path, and dismissal release. Plus MobileKeyboardFrameTracker unit tests (notification-center-isolated).
Commit 2 (green): the fix.

Localization audit: no user-facing strings added or changed.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Reworked the iOS bottom dock so the toolbar and composer are a system keyboard accessory that rides the keyboard’s animation and stays docked at the bottom when the keyboard is down. This removes guide/floor glitches, stabilizes transitions, and keeps the grid reservation accurate from a tracker-derived model.

  • Bug Fixes
    • Replaced custom constraints with a self-sizing KeyboardDockAccessoryView returned as the inputAccessoryView of both the terminal input proxy and the surface; the OS now positions the dock in all states.
    • The surface becomes first responder when the keyboard is down so the dock stays seated; chrome hide/show now reloads input views to withhold/restore the accessory.
    • The keyboard toggle now branches on actual first-responder ownership (input proxy or composer) instead of the tracked visibility bit, preventing desync on rapid taps.
    • MobileKeyboardFrameTracker now feeds only the terminal grid model using window-space overlap (with the accessory’s height subtracted), clears on hide/background, and reconciles visibility on remount so the toggle starts as “Show Keyboard.”
    • Pinned the surface under the home indicator in all states (.ignoresSafeArea(.container, edges: .bottom)) to keep frame conversions stable mid-animation.
    • Added dock-accessory tests (responder wiring, chrome withholding, model derivation, glyph state) and fixed/updated injected-attach startup tests.
    • iPhone install queue: during a drain pass, only the newest queued build is launched; older ones install without launch to avoid foreground fights.

Summary by CodeRabbit

  • Bug Fixes
    • Improved composer positioning when the on-screen keyboard appears, including late or incomplete layout updates.
    • Ensured the composer remains above the keyboard and returns to the bottom of the window after dismissal.
    • Cleared keyboard positioning state when the app moves to the background, preventing stale offsets.
    • Improved keyboard overlap handling for views attached after the keyboard is already visible.
    • Improved handling of keyboard transitions when layout notifications are delayed or incomplete.

[!NOTE]
Medium Risk
Large change to terminal input, first-responder, and keyboard geometry on a user-critical path; mitigated by extensive new tests and unchanged grid math semantics aside from the positioning model shift.

Overview
Fixes iOS terminal bottom chrome (toolbar + composer) lagging or sitting behind the keyboard after workspace switches by moving dock positioning to the OS keyboard system instead of keyboardLayoutGuide constraints on the surface.

The toolbar and composer band now live in a self-sizing KeyboardDockAccessoryView returned as inputAccessoryView from the surface and the hidden typing proxy, with the surface holding first responder when the keyboard is down so the dock stays at the screen bottom. Grid reservation still follows keyboard height via a new process-wide MobileKeyboardFrameTracker (notification-based, catch-up on late attach) and subtracts the accessory footprint so the dock does not double-count.

WorkspaceDetailView adds .ignoresSafeArea(.container, edges: .bottom) so the terminal surface frame does not breathe with the home indicator mid-transition (which skewed keyboard conversions and caused visible bar pops).

Tests: MobileInjectedAttachStartupTests is rewritten for the shipped startup coordinator API (restores a compile-broken target). New tracker and keyboard-dock contract tests cover accessory wiring, overlap model, and reattach visibility.

Dev tooling: iphone-install-queue.sh installs all pending builds but launches only the newest per drain to avoid foreground fights on a single device.

Reviewed by Cursor Bugbot for commit 670b0dd06ce2585c8c28ec46907098c75b657d83. Bugbot is set up for automated code reviews on this repo. Configure here.