iOS: stop terminal zoom + push-up during keyboard transitions
Dogfood feedback on the kbpin build (https://github.com/manaflow-ai/cmux/pull/8899, since merged): the terminal font visibly zoomed when the software keyboard closed and snapped back a moment later, and rows were pushed off the top of the screen mid-transition before sliding back down. Field recording analysis plus a simulator repro against a live Mac narrowed it to three defects in the shared-grid negotiation around a keyboard container change.
-
Stale-grant font stretch. The stretch-to-fill auto-fit ran on the geometry pass right after the keyboard target changed, while
effectiveGridstill held the previous grant (zoom.autofit eff=72x34 baseGrid=72x65 font 10.0->18.98captured live at dismissal start). It stretched the rendered font toward filling the new container with the stale row count and decayed one RPC round-trip later — the "text zooms in when the keyboard closes" glitch. The fit now waits for a settled negotiation (no keyboard animation in flight, no debouncing report, newest report echo confirmed, pass capacity equal to the last reported grid); the settle paths (animation completion, echo confirmation, retry exhaustion) each schedule one final sync so exactly one fit runs on the settled grant. -
Live-viewport bottom-pin overshoot. The render rect bottom-pinned to the live viewport unconditionally. During a dismissal the surface is already sized for the taller target viewport, so the pin pushed the top rows off screen by
renderHeight - liveHeight(renderRect=440x766@-344in the captured log) and they slid back down as the keyboard left.TerminalLetterboxGeometry.renderPinnedBottomEdgenow caps the clip at the settled amount, and a provisionally pinned render (negotiation unsettled) holds its top edge instead of riding the departing keyboard down and snapping back up when the fresh grant unpins it. Settled letterbox boxes and the keyboard-rise path keep the legacy live-edge ride. -
Incoherent cell/font pairs in capacity reports. Reports normalized the measured cell size with
liveFontSizeread at apply time; a font change queued between the measurement and the apply skews the base-font normalization by the zoom ratio and under-reports the grid several-fold (the ~10-row grants visible in the field recording, which seed the oscillation). The geometry pass now captures the font it measured with, and the report/fit use that paired value.
Verification: CmuxMobileTerminalKit host tests green (110 tests, includes new renderPinnedBottomEdge cases); simulator E2E dance (keyboard raise + dismiss over a live attach) recorded and frame-analyzed on this branch — text top position and row pitch constant through both transitions; debug log shows zoom.autofit.deferred during transitions, renderRect=440x397@0 held through the dismissal, then the echoed grant growing the render in place with zero motion. A host-runnable behavior test for defects 1/3 is not practical (they live in the iOS-only CmuxMobileTerminal target, which does not resolve on macOS hosts); the Kit pin math is unit-tested and the rest is covered by the recorded E2E evidence.
No user-facing strings changed (debug log lines only), so no localization updates.
🤖 Generated with Claude Code
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Fixes iOS keyboard transition glitches: stops the terminal font from zooming on keyboard close and prevents rows from being pushed off-screen during show/hide. Grid negotiation, render pinning, and local resizing now stay stable throughout keyboard animations.
- Bug Fixes
- Deferred stretch-to-fill until the negotiation settles; added
awaitingViewportEcho,markViewportReportConfirmed(reportID:), and a final geometry sync on settle/timeout. - Stopped content push-up: on dismissal, capped the live-bottom pin with
TerminalLetterboxGeometry.renderPinnedBottomEdge(..., holdsProvisionalPin:); on keyboard rise, deferred local shrink resize (skipset_sizeand letterbox fit), kept the old render, avoided re-stamping source-layout height, and applied one resize on settle. Tracked the last applied container size and reset it on pipeline recreation; width changes and growth still resize immediately. Added unit tests inCmuxMobileTerminalKit. - Paired capacity reports with the measured font. Captured
measuredFontSizein the geometry pass and used it incapacityReportGridandautoFitFontToEffectiveRowsto prevent bogus small-grid grants.
- Deferred stretch-to-fill until the negotiation settles; added
Summary by CodeRabbit
- Bug Fixes
- Improved terminal layout stability during keyboard transitions and viewport resizing.
- Prevented temporary rendering jumps while viewport updates are still being confirmed.
- Confirm viewport reports with the correct identifier to avoid stale confirmation.
- Ensured font fitting uses the measured font size from the geometry pass.
- Refined pinned-edge rendering during unsettled viewport negotiation and improved recovery when retries can’t complete.
- Tests
- Added coverage for pinned-edge behavior in steady state, keyboard appearance, dismissal, and transitional growth.