Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(swift-ios): keep composer controls above keyboard #5829

Closedsaphid(GitHub profile, opens in a new tab)wants to merge 181 commits intot3code/rebuild-mobile-app-swift fromrefs/pull/5829/headopened View on GitHub

What Changed

  • Detect a local docked software keyboard without treating a hidden, floating, remote, or hardware-keyboard assistant frame as full-screen keyboard occupancy.
  • Initialize from the composer’s own UIWindow and scope keyboard-frame conversion to that active window scene.
  • Clear prior keyboard occupancy when the composer window/frame is unavailable or its scene is inactive, preventing accessibility keyboard metrics from sticking after hide or inactivation.
  • Cap the expanded composer to three lines while that keyboard is visible, or one line at accessibility text sizes, while preserving the existing seven-line behavior otherwise.
  • Give the attachment/model/send footer vertical priority so the text field scrolls instead of clipping the controls.
  • At accessibility text sizes only, move the composer one footer row above keyboard clipping and paint the vacated strip with the app background.
  • Reserve that clearance in layout so the new-task workspace controls remain visible instead of being covered by a visual offset.
  • Add focused coverage for line limits, keyboard-frame classification, and the new-task accessibility layout policy.

This is intentionally stacked on t3code/rebuild-mobile-app-swift at 0d0c77431c851ff31181fb5f1708f351e0c5e80c. It contains no signing, bundle-identity, build-number, or unrelated feature changes.

Why

At accessibility text sizes, the new-task composer can consume the remaining keyboard-safe height. The attachment and model controls then render below the docked software keyboard, leaving only the text field visible.

The fix responds only to a local keyboard frame that is docked at the bottom and at least 100 points tall. Normal text sizes retain their workspace controls, and hidden/floating/remote/assistant-bar frames do not activate the compact accessibility layout.

Verification on iPhone Air / iOS 26.5, Debug, with accessibility-extra-extra-extra-large and the docked software keyboard:

  • Exact owner head before: footer fully clipped.
  • This PR head after: attachment, model, and send controls remain visible.
  • The software keyboard is visibly docked while the text row and footer remain reachable without overlap.

Auto-growth is intentionally independent: #5801 at 8662cf32964c9299453e60fe157b57955866b175 exclusively owns the text-field .fixedSize(horizontal: false, vertical: true) change. This PR does not duplicate or absorb that line.

UI Changes

Before (0d0c77431)After (0659dbde6)
Composer footer clipped below the docked keyboardComposer footer visible above the docked keyboard

Verification

  • FeatureComposerPowerTests: 12 passed, 0 failed, 0 skipped, including missing-window/frame and inactive-scene reset coverage.
  • apps/swift-ios/Scripts/ci-test.sh: 222 tests in 27 suites passed, exit 0.
  • Integrated clearance pass on iPhone Air / iOS 26.5 against the disposable backend at accessibility XXXL: workspace controls, composer footer, and the visibly docked software keyboard remain clear of one another.
  • git diff --check: clean.
  • Cursor Bugbot’s stale-occupancy finding at a00273ab0 was fixed by making every scene-local keyboard update assign a fresh result. Its later workspace-control overlap finding at 8471e9cdc was fixed by replacing the visual offset with layout-participating bottom clearance. Cursor’s exact-head review of 0659dbde6 completed with no issues.
  • Exact-head CI passed: Check, Test, Mobile Native Static Analysis, Release Smoke, and Contract fixtures and native tests.
  • MacroScope reviewed 0659dbde6: Correctness found no issues across 12 code objects with zero annotations, and Approvability approved the PR.
  • CodeRabbit completed its incremental review through 0659dbde6 with no new actionable comments; no review threads remain unresolved.
  • Pre-commit vp fmt has no applicable Swift target and exits with “Expected at least one target file”; the commit was made after the Swift-specific gates above passed.
  • A previous direct Claude Opus 5 high review attempt against a00273ab0 returned HTTP 429 before inference because the weekly limit was exhausted. No Claude review is claimed.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes

Note

Medium Risk Touches UIKit keyboard notifications and window-scoped layout in a core chat composer path; behavior is localized and covered by new tests, but incorrect keyboard detection could still affect accessibility layouts.

Overview Fixes the chat composer being clipped under a docked software keyboard, especially at accessibility text sizes on the new-thread sheet.

Keyboard awareness is added via the composer’s own UIWindow (FeatureComposerWindowReader) and UIResponder keyboard notifications, with frames converted into that window. Only a local, bottom-docked keyboard (≥100pt tall, scene active) counts as occupying the screen; hidden, floating, remote, and short assistant-bar frames do not. Occupancy clears on hide and when window/scene context is missing or inactive.

When that keyboard is visible, the message field’s lineLimit drops from 1…7 to 1…1, and the attachment/model/send footer gets vertical layout priority so controls stay visible while the field scrolls. At accessibility dynamic type with the keyboard up, padding tightens and 52pt bottom clearance is applied in layout (not just visual offset) so footer and workspace controls sit above the keyboard.

New unit tests cover FeatureComposerKeyboardLayout line limits, frame classification, and accessibility clearance.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit f2ed77976e8895a778f21e150833284e20f0eff2. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Fix composer controls to stay above keyboard in iOS chat view

  • Adds FeatureComposerKeyboardLayout to centralize keyboard-aware layout logic: collapsing the TextField to a single visible line when a docked software keyboard is present, and reserving bottom clearance for accessibility-sized keyboards.
  • Introduces FeatureComposerWindowReader (a UIViewRepresentable) to expose the composer's UIWindow so keyboard frames can be converted and layout guides read.
  • Subscribes to keyboard show/hide/frame-change notifications to track whether a local, docked, sufficiently tall keyboard occupies the screen.
  • Adds four unit tests in FeatureComposerPowerTests.swift covering docked, floating, hidden, and remote keyboard scenarios, plus accessibility clearance.
Macroscope summarized f2ed779.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Review Change Stack

      📝 Walkthrough

      Walkthrough

      FeatureComposerView now tracks docked software keyboards and adapts composer sizing for keyboard visibility and accessibility Dynamic Type. New helpers classify keyboard frames and calculate line limits and offsets. Tests cover these layout rules.

      Changes

      Keyboard-aware composer

      Layer / File(s)Summary
      Keyboard frame and layout rules
      apps/swift-ios/Features/Chat/FeatureComposerView.swift
      Adds keyboard-frame classification, visible line-range calculation, and accessibility vertical-offset helpers.
      Composer layout integration
      apps/swift-ios/Features/Chat/FeatureComposerView.swift
      Captures the containing window, updates keyboard state, and applies keyboard- and accessibility-dependent line limits, spacing, footer sizing, and bottom padding.
      Keyboard behavior validation
      apps/swift-ios/Tests/FeatureTests/FeatureComposerPowerTests.swift
      Tests docked, hidden, floating, undersized, and remote keyboard frames, missing context, line limits, and accessibility offsets.

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Sequence Diagram(s)

      sequenceDiagram
        participant UIKit
        participant FeatureComposerView
        participant FeatureComposerKeyboardLayout
        UIKit->>FeatureComposerView: keyboard frame change notification
        FeatureComposerView->>FeatureComposerKeyboardLayout: evaluate keyboard frame
        FeatureComposerKeyboardLayout-->>FeatureComposerView: layout metrics
        FeatureComposerView->>FeatureComposerView: apply line limits and offsets
      🚥 Pre-merge checks | ✅ 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Title check✅ PassedThe title clearly and concisely describes the main fix: keeping Swift iOS composer controls above the keyboard.
      Description check✅ PassedThe description includes complete change, rationale, UI evidence, verification results, and checklist details; a video is not included for the interaction change.
      ✨ Finishing Touches 💡 1
      🛠️ Fix failing CI checks 💡
      • Create stacked PR
      • Commit on current branch
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      ✅ Action performed

      Review finished.

      Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

    4. Actionable comments posted: 1

      🤖 Prompt for all review comments with AI agents
      Verify each finding against current code. Fix only still-valid issues, skip the
      rest with a brief reason, keep changes minimal, and validate.
      
      Inline comments:
      In `@apps/swift-ios/Features/Chat/FeatureComposerView.swift`:
      - Around line 136-142: Update the composer’s keyboard-state handling around
      updateSoftwareKeyboardState and dockedSoftwareKeyboardOccupiesScreen to
      initialize from the current keyboard visibility when the view attaches,
      including cases without a new frame notification. Scope keyboard-frame and
      screen-bound comparisons to the composer’s own UIWindowScene rather than the
      first key window across all connected scenes, and preserve the resulting state
      for accessibility offset and line-limit calculations.
      🪄 Autofix

      Fix all unresolved CodeRabbit comments on this PR:

      • Push a commit to this branch (recommended)
      • Create a new PR with the fixes

      ℹ️ Review info
      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: f1e434fa-0435-4054-bf0a-5fce3f9ae2a7

      📥 Commits

      Reviewing files that changed from the base of the PR and between 0d0c77431c851ff31181fb5f1708f351e0c5e80c and 52195fdd1bc1c060f2224a4c58c5aef534bf9fd5.

      📒 Files selected for processing (2)
      • apps/swift-ios/Features/Chat/FeatureComposerView.swift
      • apps/swift-ios/Tests/FeatureTests/FeatureComposerPowerTests.swift
    5. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      ✅ Action performed

      Review finished.

      Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

    6. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved f2ed779

      Self-contained iOS UI fix for keyboard handling with comprehensive test coverage. Changes are isolated to the composer view, adjusting layout when the software keyboard appears, with no backend or API impact.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    7. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      ✅ Action performed

      Review finished.

      Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

    8. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      ✅ Action performed

      Review finished.

      Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

    9. ✅ Bugbot reviewed your changes and found no new issues!

      Comment @cursor review or bugbot run to trigger another review on this PR

      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 0659dbde6ebb1a954ebc5ac580f7a6ed09223f43. Configure [here](https://www.cursor.com/dashboard/bugbot).
    10. @t3dotgg This SwiftUI PR is ready for your review. Its exact head is mergeable; repository/native CI, MacroScope, Cursor, and review-thread audits are clean with zero unresolved threads. The only red status is the unrelated Vercel marketing authorization check.

    11. Closing as superseded after testing the desired outcome on the final editor + reasoning stack. This historical PR has both stale topology and a real feature conflict: its final forced one-line cap whenever a keyboard is docked would undo unlimited growth and the viewport-bounded rich editor. That implementation is intentionally rejected.

      No production keyboard fix remains necessary. New Task and Thread both own the same final FeatureComposerView through .safeAreaInset(edge: .bottom), with permanent internal scrolling and caret visibility. A 434-character New Task draft was proven with the software keyboard docked: full content retained, final caret visible, and attachment/model/reasoning/send controls above the keyboard.

      Tests-only acceptance commit is preserved at saphid/swiftui-keyboard-clearance-final-stack (ecc804049), stacked behind #5610/#5985. Focused tests and full native 248 tests/28 suites pass. Video: https://alexs-macbook-pro-1.tail4e5636.ts.net:8766/swiftui-keyboard-clearance-final-stack-proof-20260810.mp4

      A separate Thread video was not captured; Thread uses the identical composer and safe-area owner, and the pure sizing regression covers keyboard hide/rotation/reuse. No useful production behavior is being discarded.

Sign in to join this conversation.