Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(ios): support image paste from composer edit menu #5610

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

What changed

  • Replace the SwiftUI composer field with a small UIKit-backed UITextView so copied images appear in the native long-press Paste menu.
  • Keep ordinary text paste unchanged, preserve text from mixed image/text pasteboard items, and keep command, model, skill, and path replacement caret placement correct.
  • Send pasted image providers through the existing image processor and attachment strip, preserving successful providers when another provider fails.
  • Reserve the shared eight-image capacity across in-flight picker, camera, Files, and paste work, and reject callbacks captured for a stale composer context.

The patch is limited to the SwiftUI iOS composer and attachment ingestion, plus focused tests and user documentation. It is stacked on the experimental SwiftUI client in #5178. The branch is rebased on 0d0c77431, which includes f79886039 and its native-CI repair.

Why

The SwiftUI field accepted pasted text but did not offer Paste for a copied screenshot or photo. A UIKit text responder can advertise image and text paste types through the standard iOS edit menu, then hand image providers to the same preparation path as the existing attachment picker.

UI evidence

Before: copied image, no PasteAfter: native Paste action
Before: long-press edit menu without PasteAfter: long-press edit menu with Paste

Resulting attachment

Copied image appears in the attachment strip

Eight-image limit

A further paste remains at eight attachments and shows the limit alert

Image-conforming provider regression

A HEIC-conforming pasteboard item still exposes Paste at the eight-image limit

Interaction video: native Paste action to attachment (10.97 seconds)

The four primary images and video were re-downloaded from the immutable evidence commit and matched their local SHA-256 hashes. The video was identified as H.264 at 1206×2622 and played in T3's collaborative preview. The HEIC regression image was captured from the final signed build after the Macroscope fix.

Validation

  • AttachmentPreparationTests + FeatureComposerPowerTests: 22 passed, 0 failed on the frozen diff after the review fixes.
  • T3_SWIFT_SIMULATOR_ID=… apps/swift-ios/Scripts/ci-test.sh: 228 tests in 27 suites, 0 failures. Existing unrelated simulator warnings remained visible; no test was weakened.
  • node scripts/generate-swift-wire-fixtures.ts --check: passed on the final diff, verifying the earlier native-CI fixture failure is repaired by the current stacking base.
  • Final signed Xcode 26.6 build, install, and launch on an iPhone 17 Pro simulator running iOS 26.5: passed.
  • Integrated UI: native menu and text-only paste; image-only paste to one attachment; mixed paste to text plus one attachment; text inserted at a nonterminal caret; nine-image paste capped at eight; and a further paste at capacity remained at eight with the limit alert.
  • Focused simulator tests cover shared pending capacity, partial-provider success, stale lifecycle tokens used by picker/camera/paste callbacks, provider loading, draft restoration, and UTF-16 caret restoration.
  • git diff --check: passed. Final range is four commits and 999 changed lines (915 additions, 84 deletions), reduced from 1,299 by removing the generic task store and duplicate test seams.
  • Fresh GPT-5.6 Sol high minimum-scope review inspected the frozen range and found one actionable issue: image interception was being disabled once eight attachments were present. Macroscope then found that hasImages misses some image-conforming providers, reproduced with public.heic. The final patch keeps interception active at capacity and detects UTType.image conformance. A late exact-head Cursor finding then reproduced an empty-to-restored-text caret jump; the fix now places that caret at the UTF-16 end while preserving ordinary selections. Affected tests and the signed integrated pass were repeated.

Checklist

  • Single-purpose SwiftUI image-paste change, minimized to the reliable behavior and its proof
  • Exact behavior and rationale described
  • Before/after and resulting-state screenshots included
  • Short interaction video included and playback verified
  • Focused tests, full native script, fixture check, and integrated simulator pass completed
  • Stacked follow-up to #5178

Implementation, integration, and fresh review: GPT-5.6 Sol in T3 Code.


Note

Medium Risk Touches core composer input and async attachment ingestion with lifecycle cancellation; behavior is well-tested but regressions in paste, limits, or draft/project context switches would affect every send path on iOS.

Overview Enables Paste for copied screenshots/photos in the iOS chat composer by swapping the SwiftUI TextField for a UIKit-backed FeatureComposerUITextView that advertises image paste types and routes image providers through the same ingestion path as Photos, Camera, and Files.

Paste and attachments: Mixed pasteboards still insert plain text (via FeatureComposerPasteTextPolicy) while images load in a serialized FeatureComposerPasteQueue, respect the shared eight-image cap (FeatureImageAttachmentPolicy.reserve / attachmentsToAppend), and surface alerts on limit or partial failure. Image detection uses UTType.image conformance so HEIC-style items still show Paste at capacity.

Lifecycle: FeatureAttachmentLifecycle tokens tied to attachmentContextID (thread or project) cancel stale picker, camera, file, and paste work on context change or send; NewThreadView shares one lifecycle across project switches.

Composer UX: Trigger replacements and empty-to-restored draft updates set caret position with UTF-16-aware selection policy; the text field grows within a bounded viewport. Focused unit tests and brief user docs cover the new behavior.

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

Note

Add image paste support to the iOS chat composer

  • Subclasses UITextView as FeatureComposerUITextView to intercept paste events, exposing the system paste menu for images and inserting any coexisting plain text before queuing image attachments.
  • Introduces FeatureComposerPasteQueue to serialize and cancel pending paste operations when the attachment context changes or a message is sent.
  • Enforces an 8-image limit across concurrent picker and paste flows via FeatureImageAttachmentPolicy and FeatureAttachmentPreparationState.reserve; excess images are dropped and the user sees an alert.
  • Replaces the SwiftUI TextField with a new FeatureComposerTextInput (UIViewRepresentable) that grows to a viewport-dependent max height and preserves caret position after autocomplete insertions.
  • Attachment context is now bound to thread/project ID so in-flight async operations are invalidated on context changes.
Macroscope summarized 9fc22e1.

Delivery: direct Validated against Theo commit: f98cab553546558e28d6e22f3dbe9807ecc3325f Depends on: none Merge order: this PR only Validation status: Mergeable; native/repository checks and current review are green. The unrelated Vercel authorization failure is a maintainer-side gate.

    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 3b9d22c2-4390-4d41-9896-e3e89f4adb83

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      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:unvouched

    3. Note

      🤖 GPT-5.6 responding on behalf of Theo

      /recheck-vouch

    4. github-actions[bot](GitHub profile, opens in a new tab) removed labelsvouch:unvouched

    5. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    6. Rebased this draft onto the signed SwiftUI base rewrite at 4df1e9bc3. All nine PR commits replayed cleanly and range-diff is patch-identical. GitHub now reports the intended 7-file diff (1,118 additions, 74 deletions). Verification: 24 focused Xcode tests passed, 0 failed; git diff --check passed. New tip: 08cc37c15.

    7. saphid(GitHub profile, opens in a new tab)commented

      Ready for maintainer review at 7dd058199 on base 0d0c77431.

      • The late exact-head Cursor caret finding was reproduced, fixed, regression-tested, replied to, and resolved.
      • Focused attachment/composer suites: 22 passed. Full apps/swift-ios/Scripts/ci-test.sh: 228 tests in 27 suites passed. Signed simulator build/install/launch passed.
      • Exact-head SwiftUI native tests, CI Check/Test, Mobile Native Static Analysis, Release Smoke, Macroscope Correctness, and Cursor Bugbot passed.
      • Macroscope Approvability completed neutral with the expected verdict that this user-facing feature needs human review; it reported no new correctness issue. CodeRabbit still explicitly says its review was skipped and is not counted as a review.
      • The remaining Vercel marketing status is the same authorization failure, unrelated to this seven-file SwiftUI-only range. GitHub reports the PR non-draft, mergeable, vouch:trusted, and size:XL at 999 changed lines.
      • The PR body retains immutable publicly rendered screenshots and a verified playable interaction video. The current live audit has no unresolved review threads.

      Only human maintainer review/merge remains.

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

      Approvability

      Verdict: Needs human review

      This PR adds a substantial new feature (image paste support from iOS edit menu) with ~900 lines of new code including custom UITextView paste handling, lifecycle management, and batch image processing. New user-facing capabilities of this scope warrant human review.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    9. @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.

    10. Added the tall-draft follow-up in a6d78788e. The UIKit composer now remains internally scrollable, keeps programmatic caret moves visible, and grows only up to half the proposed viewport (with a 12-line fallback when the proposal is unavailable), so long drafts stay reachable without displacing the transcript. apps/swift-ios/Scripts/ci-test.sh passes 230 tests. A fresh Claude Opus 5 high review found no remaining defect in the paste/tall-composer interaction.

    11. Follow-up simulator evidence for the tall-composer continuation:

      Very tall draft remains reachable above the software keyboard

      Verified on iOS 26.5 with the software keyboard enabled: the restored multi-line draft scrolls/grows without making its bottom controls unreachable.

    12. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d3c6ddc4684b6e39117d82616428c585a16d5c87. Configure [here](https://www.cursor.com/dashboard/bugbot).
    13. Added two focused acceptance tests for the final editor outcome, on top of the current live PR head (including its latest UTF-16/NUL paste fix). No production code changed in this update.

      The tests prove that visible composer height grows beyond three lines before its viewport bound, while content remains unlimited after visible height caps.

      Integrated iOS 26.5 proof used a 516-character New Task draft: it grew, capped at 50% of the viewport, scrolled internally with the caret at the end, and kept attachment/model/send semantic targets reachable. Private video: https://alexs-macbook-pro-1.tail4e5636.ts.net:8766/swiftui-final-editor-growth-keyboard-proof-20260810.mp4

      Post-update verification: focused Composer+Attachment 26/26; full native 237 tests/28 suites; git diff --check clean. Direct Opus review was attempted twice but unavailable: one aborted stream and one real exit 1 / HTTP 429 session limit. No completed independent verdict is claimed; the change is test-only and parent self-audit found no actionable issue.

      This is the acceptance evidence for closing #5801 as superseded. #5829's one-line keyboard cap remains intentionally excluded because it conflicts with this final invariant.

    14. t3-code-bot[bot](GitHub profile, opens in a new tab) approved these changes

      reviewed the full composer paste and attachment lifecycle diff, including context rotation, capacity handling, text decoding, caret restoration, and focused tests. no blocking issues found.

    15. Resolve conflicts and re-run ci

    16. Closing this version while I rebuild the upstream contribution set from the latest base. Clean versions are coming soon.

Sign in to join this conversation.