Fix iOS keyboard reversal render snap

Closed
AZ
2mo ago
+221-19

Summary

  • preserve the cursor-aware provisional render edge while the keyboard dock animates
  • fold live presentation translation into the renderer before an interrupted A→B→A reversal
  • measure the visible clip edge during the transition so the dock seam remains meaningful

Verification

  • swift test --package-path Packages/iOS/CmuxMobileTerminalKit --filter TerminalLetterboxGeometryTests
  • existing testTerminalDockStaysUnifiedAcrossRapidKeyboardReversals and testTerminalDockStaysPinnedForInPlaceKeyboardControlReversals cover the recorded interaction
  • tagged cloud build 31775619139 succeeded

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

Eliminates a one-frame snap when rapidly reversing the iOS keyboard dock. Previously the terminal wrapper resumed from its live position while the clip/dock stayed at the old target, exposing a seam; now the renderer pins a cursor-aware edge and folds the live translation before animations are cleared.

  • Host pins the visible render edge by computing a provisional keyboardTargetRenderBottom via hostedKeyboardTransitionRenderBottom(...).
  • Rebase path folds the wrapper’s presentation translation into the renderer with foldHostedKeyboardPresentationTranslation(...), resets the wrapper transform, and lays out the clip before removing animations so dock/clip/render share one visible edge.
  • Gap diagnostics now use the clip layer’s presentation bottom (terminalViewportPresentationBottom), matching the user-visible terminal edge.
  • Adds experiments/keyboard-dock-repro, a minimal UIKit repro: launch normally for the fixed transactional path; pass --buggy to reproduce the snap. The fixed path animates the dock in the keyboard’s transaction using .beginFromCurrentState.
  • Verification: swift test --package-path Packages/iOS/CmuxMobileTerminalKit --filter TerminalLetterboxGeometryTests (tests include testTerminalDockStaysUnifiedAcrossRapidKeyboardReversals and testTerminalDockStaysPinnedForInPlaceKeyboardControlReversals).

Summary by CodeRabbit

  • Bug Fixes

    • Improved terminal positioning during keyboard presentation and dismissal.
    • Reduced visual gaps and jumps between terminal content, the keyboard, and surrounding viewport.
    • Kept terminal rendering aligned while the interface resizes or transitions.
    • Improved handling of letterboxed terminal views during animated layout changes.
  • Polish

    • Refined transitions so hosted terminal content moves smoothly and settles accurately after animations.
    • Improved consistency when restoring the terminal after keyboard movement.