Skip to content

fix(mobile): paste links copied from the iOS share sheet into the chat composer - #45009

Merged
AmoabaKelvin merged 1 commit into
mainfrom
fix-44721-ios-paste-url
Nov 20, 2026
Merged

AmoabaKelvin merged 1 commit into
mainfrom
fix-44721-ios-paste-url

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

On iPhone, copying a link with the share sheet's Copy button and then pasting it into the chat box did nothing. Now the link gets pasted.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​23 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​23
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​7 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6

What Changed

Before: a link copied without plain text (Safari's share sheet Copy, and per the report WhatsApp and other apps) pasted nothing into the mobile chat composer. Pasting the link into Notes and copying it again was the only workaround.

After: the link is inserted into the field like any other text. Image paste still works the same.

Mechanism: iOS puts only public.url on the pasteboard for these copies, so WebKit's paste event has text/uri-list and no text/plain. mobileNativeChatComposerPasteHandler read only text/plain. With no text, it treated the paste as an image whose bytes WebKit left out of the event (the #38591 fallback). It cancelled the native paste, read the shell clipboard, found no image, and nothing was inserted. Now the handler counts text/uri-list as the paste's text when the event lists no image/* item, so the native paste goes ahead and inserts the URL.

Why

The wrong call is the handler's "no text/plain means image" rule, so the fix goes there. Every chat composer on the phone uses this handler: the main composer, the queued-message editor and the overlay.

The check looks at whether the event lists an image item, not at whether WebKit handed over the image file. A Safari image copy also carries the image's URL as text/uri-list (seen on the simulator), and an image with missing bytes can carry it too. Those pastes still attach the image instead of pasting its URL.

Desktop isn't changed. It shares clipboardEventPromptText, but it leaves text-less pastes to the native paste, and on Linux copied files arrive as text/uri-list. So the URL fallback stays in the mobile handler.

Linked Issue

Fixes #44721

Visual Proof

The real handler, bundled into a page in Safari on an iOS 27.2 simulator (WebKit, the same engine as the app's page). It shows a link copied with the share sheet and pasted with long-press Paste into the field that uses mobileNativeChatComposerPasteHandler.

Before (main) After
before-share-sheet-link-paste.png after-share-sheet-link-paste.png
defaultPrevented=true, onPasteImages file=null, the field stays empty defaultPrevented=false, the URL is in the field

Testing

These are the paste events iOS WebKit fired on the simulator:

  • Share sheet Copy: types=["text/uri-list"], getData('text/plain')="". On main the handler inserted nothing. With the fix the URL is inserted.
  • "Copy Link" from a link's long-press menu: text/uri-list plus text/plain. That worked before and still works.
  • Copy of a Safari image: Files plus text/uri-list. The image is still attached and the native paste is still cancelled, before and after.

Also ran:

  • mobile-native-chat-composer-paste.test.ts, which fails on main and passes with the fix
  • pnpm check:changed
  • the mobile test typecheck ratchet

I didn't build the native app (no dev client on hand). The page code is what runs in the app's WebView.

Perf: the change adds one getData call and one pass over the clipboard items per paste event. It adds no work per keystroke or per render.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

Risk

The riskiest case is an iOS paste whose event lists only text/uri-list (no image item) while the shell clipboard holds an image. That paste would now insert the URL instead of attaching the image. I found no source that produces it. Photos copies carry no URL, and Safari image copies list their image item. Backing it out is a plain revert.

Level: Low

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Mobile page code only. Nothing on the host or the wire changes, and desktop, SSH and older hosts are unaffected. The terminal paste button reads the native clipboard instead of a WebKit paste event, so it doesn't use this handler.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…oser

iOS share-sheet copies put only public.url on the pasteboard, so WebKit's
paste event carries text/uri-list and no text/plain. The composer read that
as an image paste with missing bytes, cancelled the native paste and found
no image, so nothing was inserted.
@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When prompt text is empty, the paste handler now uses text/uri-list as text if the clipboard does not contain an image. The test checks that a URL-list paste does not prevent the event’s default behavior or call the image-paste callback.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 90dd4

Pasting a link copied from the iOS share sheet should now insert its URL into the composer, and image pastes keep their existing handling. The remaining uncertainty is an unconfirmed event shape in which a URI arrives with no image item while the shell clipboard holds an image; no evidence shows this occurs.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: iOS share-sheet links pasted into the mobile chat composer. The raw summary confirms the handler now uses text/uri-list as text when no image item is present, which ma…
Description check Passed The description follows the template closely. It has ELI5, What Changed (before and after plus mechanism), Why (including the desktop alternative and why the fix sits in the mobile handler), Linked Is…
Linked Issues check Passed Issue #44721 requires that pasting a copied link into the iOS Chat view insert its URL when the clipboard has no plain-text item. The whole-PR diff (merge base 6a206af to head 90dd489) changes mobileN…
Out of Scope Changes check Passed The whole-PR diff touches one source file in the mobile composer paste path, plus the test file described in the summary. The source change adds the text/uri-list fallback and an image/* item check. B…
Full details: Title check

Explanation

The title names the main change: iOS share-sheet links pasted into the mobile chat composer. The raw summary confirms the handler now uses text/uri-list as text when no image item is present, which matches the title's fix. The title is short, specific, and uses the conventional fix(scope) prefix.

Full details: Description check

Explanation

The description follows the template closely. It has ELI5, What Changed (before and after plus mechanism), Why (including the desktop alternative and why the fix sits in the mobile handler), Linked Issue (Fixes #44721), Visual Proof (before/after table with images), Testing with specific paste cases, Risk with level and revert plan, and the Agent skill boundary and checklist. Gaps: the Testing checklist item for lint, typecheck, test, and build is unchecked, and the AI Disclosure section is empty. The template says to skip AI Disclosure for internal team members, so that gap is minor. The Linked Issue line has a concrete issue number. The Visual Proof section uses a simulator screenshot pair, which the template accepts.

Full details: Linked Issues check

Explanation

Issue #44721 requires that pasting a copied link into the iOS Chat view insert its URL when the clipboard has no plain-text item. The whole-PR diff (merge base 6a206af to head 90dd489) changes mobileNativeChatComposerPasteHandler in mobile-native-chat-composer-paste.ts. When clipboardEventPromptText returns nothing and the event lists no image/* item, the handler now uses the text/uri-list value as the paste text. For a text-less URL paste, the handler no longer cancels the native paste, so the URL is inserted. Image pastes that list an image/* item keep the existing image path. The handler is shared by the main composer, queued-message editor, and overlay, so the fix covers the Chat view paths named in the issue. The added test covers the text/uri-list-only case, per the PR summary. I did not inspect the test file directly. The native app was not built, so the device behavior rests on the author's simulator evidence and the code path. No coding requirement remains unmet.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff touches one source file in the mobile composer paste path, plus the test file described in the summary. The source change adds the text/uri-list fallback and an image/* item check. Both serve issue #44721. The PR description states that desktop uses the shared clipboardEventPromptText but is not changed, and the diff confirms no desktop file is modified. No unrelated refactoring or feature change is visible in the summary or in the source diff.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9aa12041-52d3-4c2b-b7ac-577494aff994
Commits

Reviewing files that changed from the base of the PR and between 12d8c3e and 90dd489.

Files selected for processing: 2

  • mobile/src/session/native-chat/composer/attachments/mobile-native-chat-composer-paste.test.ts
  • mobile/src/session/native-chat/composer/attachments/mobile-native-chat-composer-paste.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@AmoabaKelvin
AmoabaKelvin merged commit 57b2d09 into main Nov 20, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Mobile (iOS): pasting a copied link via the long-press "Paste" menu inserts nothing in Chat view

1 participant