Skip to content

Commit 942f647

Browse files
fix(mobile): pasting a multi-item clip with a thread link keeps every item
The native paste handlers read only the first clipboard item, so a clip whose first item held a thread link lost the rest. They now take the thread-link path only for single-item clips; longer clips paste natively. The composer guide no longer says every pasted thread link becomes a chip. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 0b7eb83 commit 942f647

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

‎apps/mobile/modules/t3-composer-editor/android/src/main/java/expo/modules/t3composereditor/T3ComposerEditorView.kt‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,11 +738,18 @@ internal class SelectionAwareEditText(
738738
return when {
739739
payload["html"]?.contains("data-t3-context-fragment=") == true -> pasteContext(payload)
740740
pasteImagesOrInterceptedText() -> true
741-
T3ComposerClipboard.hasThreadLink(payload["text"].orEmpty()) -> pasteContext(payload)
741+
isSingleItemClip() && T3ComposerClipboard.hasThreadLink(payload["text"].orEmpty()) ->
742+
pasteContext(payload)
742743
else -> false
743744
}
744745
}
745746

747+
// read() sees only the first item; native paste keeps every item of a longer clip.
748+
private fun isSingleItemClip(): Boolean {
749+
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
750+
return clipboard?.primaryClip?.itemCount == 1
751+
}
752+
746753
private fun pasteContext(payload: Map<String, String>): Boolean {
747754
pasteContextListener?.invoke(payload)
748755
return true

‎apps/mobile/modules/t3-composer-editor/ios/T3ComposerEditorView.swift‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ private final class ComposerTextView: UITextView {
226226
onPasteText?(text, selectedRange)
227227
return
228228
}
229-
if !bypassTextPasteInterception, T3ComposerClipboard.hasThreadLink(context["text", default: ""]) {
229+
// read() sees only the first item; native paste keeps every item of a longer pasteboard.
230+
if !bypassTextPasteInterception, pasteboard.numberOfItems == 1,
231+
T3ComposerClipboard.hasThreadLink(context["text", default: ""]) {
230232
onPasteContext?(context)
231233
return
232234
}

‎docs/user/composer.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,7 @@ Another thread can be context too. Type `@` followed by part of its title to pic
305305
the same server, or from a machine it links to while the Linked environments beta is on; those
306306
show the machine's name. On web and desktop you can also drag a thread out of the sidebar and
307307
drop it on the composer; a multi-selection drops together. On any client, **Copy thread** copies a
308-
link to the thread that pastes into a composer as its chip, and so does any other thread link you
309-
paste. The chip shows the thread's
308+
link to the thread that pastes into a composer as its chip. The chip shows the thread's
310309
current title and opens it when selected. Your prompt only carries a reference: the agent reads the thread's
311310
history on demand, so attaching a long thread costs nothing until the agent looks. Attaching a
312311
thread does not change it, and the agent cannot send messages to it unless you ask.

0 commit comments

Comments
 (0)