iOS: keep the files chip visible while the keyboard is up

Merged
AZ
3mo ago
+251-38

Problem

Since https://github.com/manaflow-ai/cmux/pull/10594 the keyboard no longer resizes the terminal: GhosttySurfaceHostView slides the full-height render wrapper up so the render bottom rides the composer bar. The files chip was anchored to the surface's own top edge (safeAreaInsets.top + 8), so the slide carried it above the clipped-visible area and the only Files control disappeared whenever the keyboard was shown.

Fix

The chip is chrome, not render. GhosttySurfaceHostView adopts the chip container into its own keyboard-invariant coordinate space (moveArtifactChip(to:), mirroring moveBottomDock(to:)), constraint-anchored 8pt below the host's safe-area top with the same tap-target floor and width ceiling the old manual frame pass enforced. The keyboard slides only the render wrapper, so the chip is keyboard-invariant by construction: no keyboard math, no per-frame following. Hostless surfaces (tests, previews) keep a surface-anchored fallback with identical resting placement.

This also fixes the artifact-files popover anchor, which was normalized against the surface's bounds and would have drifted downward by the slide while the keyboard is up; it now normalizes against the view backing the SwiftUI representable.

(The first fix iteration used a display-link follow that re-derived the chip's visible-top inset per frame; it was replaced in d1e0609 with the constraint adoption above after review feedback that a follower is the wrong shape for this.)

Commits

Regression pair: commit 1 adds the failing tests, later commits the fix. The final tests assert the chip's frame in host coordinates is identical before, during, and after a keyboard seat ride, end to end through the real host and surface.

Note: no CI lane currently compiles cmuxFeatureTests (the cmux-ios scheme's only testable is cmuxUITests), which is how https://github.com/manaflow-ai/cmux/pull/10687 silently compile-broke TerminalKeyboardFullHeightPinTests by adding a required keyboardFrameTracker: parameter; commit 1 also repairs that call site.

This branch also carries the two main-red iOS compile fixes from https://github.com/manaflow-ai/cmux/pull/10813 (required to build any iOS archive from current main).

HIG

Checked Virtual keyboards: "Using the [keyboard] layout guide also helps you keep important parts of your interface visible while the virtual keyboard is onscreen." This fix restores exactly that for the Files control; no deliberate deviation.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved terminal artifact-chip positioning while the keyboard appears, moves, or changes height.
    • Kept chips anchored to the visible host area and prevented them from extending beyond available width.
    • Improved chip placement during terminal transitions for smoother movement.
    • Corrected workspace anchoring for empty groups without an active workspace.
  • Tests

    • Added coverage for chip anchoring, visibility, containment, and restoration across keyboard transitions.
    • Updated full-height keyboard tests to use mobile keyboard tracking.