iOS: rebuild terminal keyboard pinning on one geometry authority
Reimplements the iOS terminal keyboard pinning from scratch so the composer bar, shortcuts bar, and terminal bottom track the keyboard with no bad frames.
Why a rebuild
Five open PRs (#9663, #9770, #9827, #10147, #10158) patched the same symptom set: one-frame seams between the dock and the terminal on interrupted reversals, blank terminal exposed during keyboard rise, a content snap after keyboard dismissal, and bars wedged under a raised keyboard after workspace switches. Each traced back to two structural choices on main: UIKeyboardLayoutGuide as the dock authority (misses transitions while the view is detached, broken on iOS 27, second animation clock), and keyboard motion split across two mechanisms (a constraint for the dock, a CGAffineTransform for the renderer) that required presentation-layer rebasing to stay aligned.
What changed
- One geometry authority. Keyboard frame notifications drive the dock on every OS version. The
UIKeyboardLayoutGuidepath, the iOS 27 fork (KeyboardDockGeometrySource), andCMUX_UITEST_FORCE_IOS27_KEYBOARD_DOCKare deleted. - One moving constraint system. A keyboard leg changes two constraint constants (dock bottom, render-wrapper bottom) and animates a single
layoutIfNeeded()on the keyboard's curve. The clip boundary between terminal and bars is a constraint to the dock top, so bars and terminal boundary derive from the same layout pass and cannot land on different timelines..beginFromCurrentStateretargets reversals from live presentation frames;rebaseKeyboardPresentationFromLiveFramesand the dock-animation stripping hooks are deleted. - Animated endpoint = settled layout. The wrapper animates the render bottom to the exact edge the first post-transition layout pass computes (same snapshot + cursor-aware
renderPinnedBottomEdgemath), so the completion fold is a visual no-op. Previously the renderer was translated unconditionally to the dock edge and the next layout pass snapped it to the cursor-aware pin. - Detached-transition recovery. New
MobileKeyboardFrameTrackerrecords keyboard end frames process-wide (armed at launch); a host attaching to a window settles its dock and the renderer model from that record. This also clears a stalekeyboardPresentationTransitionActiveleft by a leg interrupted by detach, which could previously freeze grid negotiation until the next keyboard event. - Tests.
TerminalKeyboardDockEndpointscarries the endpoint arithmetic with 5 unit tests.testIOS27KeyboardDockWorkaroundPinsComposerToKeyboardbecomestestNotificationKeyboardDockPinsComposerToKeyboard, the universal contract test; the dock probe keeps itskeyboardDockSourcekey (alwaysnotification). Existing reversal XCUITests (testTerminalDockStaysUnifiedAcrossRapidKeyboardReversals,testTerminalDockStaysPinnedForInPlaceKeyboardControlReversals) exercise the new path unchanged.
Localization audit: no user-facing strings added or changed (all internal layout code).
🤖 Generated with Claude Code
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Rebuilds iOS terminal keyboard pinning around a single notification‑driven geometry authority and removes UIKeyboardLayoutGuide. Ships the legacy notification+transform path as the default on all OS versions; iOS ≤26 can revert to the rebuilt single‑constraint path for correctness and stability.
- Keyboard geometry and animation: notifications drive two constraint constants (dock bottom, render-wrapper bottom) in one keyboard-curve
layoutIfNeeded(); animated endpoint equals the first settled layout;.beginFromCurrentStatehandles reversals;keyboardDidChangeFrameretargets only on disagreement with a short curve; layout self-heals the dock seat from an app‑lifetimeMobileKeyboardFrameTrackeroutside active legs; detach strips keyboard-motion animations to avoid resuming stale legs. - Legacy path (default everywhere; always on iOS 27+): will‑frame only; dock by constraint plus wrapper transform; interrupted legs rebase from presentation layers; fold pins the render at the dock; both paths recover detach from the tracker; probe reports
keyboardDockSource=legacyNotification(rebuilt path reportsnotification). - Tracker and injection: adds
MobileKeyboardFrameTrackerinCmuxMobileSupport; injected via\.mobileKeyboardFrameTrackerfrom the app composition root so hosts recover transitions missed while detached; previews/harnesses use a coordinator fallback. - Path selection and controls:
TerminalKeyboardDockPathSelectionselects the path once at host mount. Remote kill switchClientConfigFlag.iosKeyboardDockRebuildRevert(cached inMobileFeatureFlags, injected via\.keyboardDockRebuildRevertEnabled) routes iOS ≤26 to the rebuild; iOS 27+ never routes to it. DEBUG overrides:CMUX_UITEST_FORCE_LEGACY_KEYBOARD_DOCK,CMUX_UITEST_FORCE_REBUILD_KEYBOARD_DOCK, and Settings > Developer “Rebuilt Keyboard Pinning” (persists-cmux.mobile.debug.forceRebuildKeyboardDock.v1; reopen the workspace to apply; release builds ignore). - Tests and metrics: extracts endpoint math to
TerminalKeyboardDockEndpointswith unit tests inCmuxMobileTerminalKit; adds unit tests for path selection; XCUITests assert the clip‑to‑dock seam stays zero and that the dock sits within the keyboard’s accessory chrome band; render‑attachment checks move to echo‑settled points; probe adds renderer/dock gap metrics. Localization adds settings strings only.
Summary by CodeRabbit
-
New Features
- Added reliable keyboard frame tracking and visibility detection.
- Improved terminal docking and rendering during keyboard transitions, including detached views and oversized keyboards.
- Added consistent keyboard geometry calculations across supported iOS versions.
-
Bug Fixes
- Improved keyboard animations, dismissal handling, and bottom-dock positioning.
- Removed reliance on OS-specific keyboard behavior and test overrides.
-
Tests
- Added coverage for keyboard movement, dismissal, partial overlap, and boundary conditions.