Repository navigation
Attach long pastes as a text file in Chat - #8472
Conversation
Pasting a large block of text dumped every line into the composer. Pastes of 2000+ chars or 40+ lines now become a Pasted_Text_*.txt attachment; clicking the chip shows the text back in the input.
|
@codex review |
- Attach oversized pastes instead of letting them fall back inline - Match a live File by identity so a user's Pasted_Text_*.txt is untouched - Skip the text path when the clipboard advertises native images or files - Drop the inline action if the attachment left the composer while reading
|
Pushed 7ba8281 with all four of these addressed. Summary:
Tests are up to 9 for this file (1962 total, all passing), typecheck and build clean. |
- Name the file from the first line of the paste instead of a timestamp - Chip is borderless, and sits a shade under the composer in dark mode - Track the attachment id so the chip survives the send without the name
|
Pushed af2cd93 with the design and naming feedback.
Since the name no longer marks a paste, the chip on a sent message is matched by attachment id, which the send path preserves. That is in memory, so after a page reload an old pasted attachment falls back to the normal file tile. The text is unaffected either way. 1964 tests pass, typecheck and build clean. |
- Mark a sent paste with its own wrapper tag so the chip survives a reload - Cap the preview and say how much of the paste it is holding back - Read the name through a window instead of splitting the whole paste - Attach whitespace-only pastes rather than letting them through inline - Report an attachment that throws synchronously, instead of losing it
|
Pushed f545a97. Five of the six were real, one was already fixed.
13 tests in this file, 1966 total, all passing. Typecheck and build clean. |
|
@codex review |
- Carry the byte count in the wrapper header and read it in constant time - Preview sent content by slicing it, instead of unwrapping the whole body - Drop unwrapAttachmentText, which existed only to copy megabytes
|
Pushed 181da79 for the one new comment, which was right. Sizing a sent paste ran during render: mounting a chip unwrapped the whole attachment with a regex and built a
On a 60 MB sent paste the whole render-path cost is now about 0.002 ms. 14 tests here, 1967 total, all passing, typecheck and build clean. |
|
@codex review |
A paste-only message sends no inline text, so the thread stayed "New Chat" and the title model got nothing to work from. Titles and project snippets now fall back to a bounded opening of the attachment.
|
Pushed 3df8170. The one new comment was right, and it was a regression from this PR rather than a pre-existing gap. Sending a paste with an empty composer produces
16 tests here, 1969 total, all passing. Typecheck and build clean. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3df81701f5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The deep import into `@/features/hub/lib/format` trips the repo's `no-restricted-imports` eslint rule, which allows `@/features/[name]` only. `formatBytes` is already re-exported from `features/hub/index.ts`, and the built bundle is byte-identical either way.
`pasted-text.ts` carried its own copy of the clipboard inspection already in `clipboard-files.ts`. The two paths run back to back on the same event, so any drift between them means a paste is handled twice or not at all. Both now import `clipboard-payload.ts`, which owns `browserClipboardFiles`, `clipboardHasFileEntries`, `clipboardAdvertisesFiles` and `clipboardHasPlainText`, plus the private type and file-URI helpers. `pasteClipboardFiles` collapses its separate `advertisesImage` and `advertisesFile` checks into the one call, since both uses were the disjunction. The surviving `clipboardHasLocalFileUri` catches per type rather than abandoning the scan on the first `getData` that throws, so a readable `text/uri-list` is no longer hidden by an unreadable sibling type. Relative imports carry the `.ts` extension: `npm test` runs `node --experimental-strip-types`, whose ESM resolver does not add it.
|
Pushed 1cb339c, two commits from a review pass over the branch. Restricted import (
Duplicated clipboard inspection (
New Two things fell out of merging them:
One trap worth flagging The relative imports carry the Verification
Left alone deliberately: |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1cb339c653
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Chat Search builds its text from `message.content` only, so moving a long paste into an attachment made everything past its first line unfindable. Searching for a phrase from the middle of a pasted log returned nothing. `extractText` in `use-chat-search-index.ts` now prepends `attachmentsPastedText`, which unwraps `<pasted_text ...>` bodies via the new `pastedTextContentBody`. Only pastes are read: PDF, DOCX and attached text files were never indexed, and picking them up here would change search behaviour beyond the regression and add their bodies to an index that already holds 200 threads in memory. The body goes in whole rather than sampled. That is what the index held before the paste moved out of `content`, so memory is back where it was.
`canQueueCurrentPrompt` rejects any composer holding an attachment, so a paste that used to queue as inline text started failing with "Only text prompts can be queued". Pasting a log while a response streams is exactly when queueing earns its keep, and the user was left waiting for the run or pouring the paste back into the composer by hand. The queue carries strings, and a pasted attachment is a string the composer parked in a chip, so `queuePastedTextPrompt` reads those files and folds them into the queued prompt after whatever was typed. Composers holding a real attachment still take the existing refusal. `canQueueCurrentPrompt` keeps its exact conditions; the shared ones move into `composerAcceptsQueueing` so the pasted-text path cannot drift from them. The started callback clears only when the text and the attachment ids are still the ones that were queued, matching the text-only guard it sits beside. Manual check: start a response, paste 3000 characters, press enter. The chip clears and the prompt queues with the pasted text; it sends when the run ends. Repeat with an image attached and the refusal toast still appears.
Composer drafts are plain strings in localStorage, and a pasted attachment is a File held in memory, so refreshing before sending threw the whole paste away. Inline text survived that reload before this PR moved it into an attachment. Pastes get their own slot, `chat-draft-pastes:<thread>`, rather than joining the text draft. Two reasons: the text slot is rewritten 300ms after every keystroke and a paste can run to megabytes, and a paste large enough to blow the storage quota now fails on its own key instead of taking the typed draft with it. The save effect is keyed on the attachment ids, so typing beside a paste does not touch it. `createPastedTextFile` keeps the text in a `WeakMap` beside the existing identity `WeakSet`, which is what lets the save path run without awaiting `File.text()`. Restore recreates the attachment through the same constructor, so the chip and its name come back unchanged; names are not stored because a pasted file is named from its own text. Restore skips a composer that already holds a paste. The composer outlives a thread switch, so appending there would stack one thread's paste onto another's; the stored draft keeps until the composer is clear.
|
Pushed bd0b69f. Three commits for the three P2s, all of which reproduced. Chat Search stopped finding pastes (
The whole body goes in, not a sample, because that is what the index held before the paste left Long pastes could not be queued (
An unsent paste died on reload ( Drafts are plain strings in localStorage and a pasted attachment is a Pastes now persist under their own key, Restore skips a composer that already holds a paste. The composer outlives a thread switch, so appending there would stack one thread's paste onto another's; the stored draft keeps until the composer is clear. Older items Reacted and replied to the three still-open inline comments from earlier rounds. All three were already fixed on the branch and had only been answered in prose: the inlining continuation guard (7ba8281), the preview cap (f545a97) and title generation from attachments (181da79, 3df8170). Verification
Unrelated flake worth knowing about: Manual checks for the parts that are UI:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5dc502523
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| description: "Paste it again, or paste it in smaller pieces.", | ||
| }), | ||
| ); | ||
| if (attachedPastedText) return; |
There was a problem hiding this comment.
Preserve pasted text when editing a sent prompt
After this path turns a long paste into an attachment, the sent message's regular content contains only separately typed text. The user-message Edit action seeds EditComposer from that regular content, and the editor at thread.tsx:6323-6381 neither renders nor unwraps attachments, so editing a paste-only turn opens a blank input and editing a mixed turn cannot modify the pasted portion; before this interception, the same text was editable inline. Populate the edit composer with the pasted attachment body or provide attachment editing there.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one: the paste is not lost on edit.
DefaultEditComposerRuntimeCore seeds _previousAttachments from message.attachments and calls setAttachments in its constructor, and handleSend re-sends them with the edited content (@assistant-ui/core/dist/runtime/base/default-edit-composer-runtime-core.js). Editing a paste-only turn and sending keeps the attachment; if neither the text nor the attachments changed, handleSend does not append at all.
What is true is that an attachment is not editable there and EditComposer renders no attachment UI. That is how every attachment type has always behaved in that composer, including PDFs and .txt files, and it predates this PR. Seeding the edit composer with the pasted body instead would put megabytes back into an input, which is the thing this PR exists to stop.
`messageToPlainText` shares one `collect` between `msg.content` and attachment content, so b5dc502 ran `unwrapPastedTextContent` over message bodies too. A message that legitimately opens with `<pasted_text name=...>`, a code sample about this feature being the obvious case, had its first and last lines stripped out of fine-tuning exports. `collect` now takes the source, and only attachment blocks are unwrapped, which is what `messageToText` and `messageToMarkdown` already did.
|
Pushed 4011c4a. One held up, one did not. Fixed: unwrapping reached message bodies ( Correct, and the comment I wrote in b5dc502 claiming it was a no-op was simply wrong. Not taking: editing a sent prompt The paste is not lost on edit. What is true is that the attachment is not editable there and Verification
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4011c4ad96
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const attachedPastedText = pasteLongTextAsFile( | ||
| event, | ||
| (file) => aui.composer().addAttachment(file), |
There was a problem hiding this comment.
Intercept long pastes in the Compare composer
When the user is in Compare mode, this new interception is never reached because SharedComposer owns a separate textarea whose onPaste handler at shared-composer.tsx:944-963 only calls pasteClipboardFiles. A 2,000-character or 40-line paste there therefore still follows the browser's inline path and can flood or freeze the controlled Compare input; wire the long-text handling into that composer as well.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one. Compare behaves exactly as it did before this PR, so nothing regressed there.
SharedComposer's addFiles only accepts audio and images (shared-composer.tsx:909-947); a text/plain File is dropped on the floor, and its handleFilePaste already rejects anything else with "Compare supports images and audio within the attachment size limits." Wiring pasteLongTextAsFile in would need text attachments in Compare, which do not exist, and the chip, preview, draft and send paths that go with them.
Worth doing as its own change. The PR description calls the omission out rather than leaving it implied.
`create_research_run` rejects a user message whose `content` has no text, and `_research_question_context` builds the question from `content` alone. A long paste now lives in an attachment, so a paste-only prompt was refused with "Deep research requires a user message with non-empty text" and a mixed prompt quietly researched only the short typed part. `message_text_with_pastes` in `core/inference/message_content.py` reads a message's text plus any pasted attachment bodies, with `pasted_text_body` stripping the `<pasted_text ...>` wrapper the composer adds. Both research paths use it. Other attachment types stay out. A PDF or an attached `.txt` was never part of a message's text, and pulling those into the research question would change what runs for prompts that have nothing to do with pasting.
b5dc502 stripped the paste wrapper from `messageToText`, `messageToMarkdown` and `messageToPlainText` but left `messageToOpenAI`, so Raw JSONL and bulk `jsonl-raw` exports still carried `<pasted_text name=... bytes=...>` and its closing tag. It now unwraps text parts that came from attachments, leaving message content untouched for the same reason as 4011c4a: a body may quote that syntax.
The generated-image edit overlay submits `composerText`, and its branch in `handleSubmit` returns early when that is empty. A long edit instruction became an attachment instead, which left the Send control enabled through `hasSendableContent` and then did nothing when pressed. Long pastes are no longer intercepted while the overlay is open, so an edit instruction stays where the only code path that reads it can find it.
|
Pushed 359145d. Three of the four held up. Deep Research refused a pasted question ( The sharpest of the four, and a hard failure rather than a degradation: New Raw JSONL still carried the wrapper ( b5dc502 covered Image-edit Send was a dead control ( Confirmed: the overlay branch returns on empty Not taking: the Compare composer Compare behaves exactly as it did before this PR, so nothing regressed. Verification
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 359145d2ea
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const queuedPrompt = [textAtQueue, ...texts] | ||
| .filter((part) => part.trim().length > 0) | ||
| .join("\n\n"); | ||
| if (queuedPrompt.length === 0) return; | ||
| startHydratedPromptQueue([queuedPrompt], waitForCurrentRun, () => { |
There was a problem hiding this comment.
Keep queued pastes out of inline prompt text
When a response is running and the paste is large, this expands the uncapped file back into a single queued string. PromptQueueStack then renders the entire value in both the row and its aria-label, and dispatch later places it in a normal inline message via appendTextToThread; a multi-megabyte paste can therefore freeze the queue UI and conversation despite the attachment path being introduced to prevent exactly that. Preserve pasted attachments or use bounded queue display metadata rather than converting the body to inline prompt content.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one. Folding the paste into the queued string is the first of the two options the earlier queueing item offered, and it restores exactly what happened before this PR: the same text pasted inline, queued as one prompt, rendered by the same PromptQueueStack row and aria-label and dispatched through the same appendTextToThread. Nothing about that path changed here.
The queue rendering an unbounded prompt is worth bounding, but it is true of any long typed or pasted prompt and predates this change; capping item.prompt in the row and the label is a queue-UI change on its own terms. Carrying attachments through the queue is the other option, and that is a queue schema change: startPromptQueue takes string[], and the entries are persisted and rehydrated as strings.
| const end = text.indexOf("\n", start); | ||
| const stop = Math.min( | ||
| end === -1 ? text.length : end, | ||
| start + PASTED_TEXT_NAME_SCAN_CHARS, |
There was a problem hiding this comment.
Bound the newline search to the filename scan window
For an uncapped single-line paste, or one whose next newline lies beyond the 64 KiB naming window, indexOf("\n", start) still scans the entire remaining payload before stop applies either bound. A hundreds-of-megabytes paste therefore incurs an additional full synchronous pass inside the paste event before file construction. Fresh evidence after the earlier allocation fix is that the replacement avoids copying the whole line but does not bound the newline search itself; inspect only the configured scan window.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one. createPastedTextFile runs new File([text], ...) on the same string in the same handler, which encodes every byte of it. That pass is strictly larger than the indexOf scan being described, so removing the scan changes nothing measurable about the paste.
Bounding the search also costs correctness: end === -1 currently distinguishes "no newline anywhere" from "line continues past the window", and a window-limited search cannot tell those apart, so a blank opening window would have to guess between falling back and skipping to the next line. The total walk is already bounded at 64 KB by 3592e7a, which was the case that actually scaled with input.
Pasting over selected text normally replaces it. `pasteLongTextAsFile` calls `preventDefault` and only adds an attachment, so selecting an obsolete prompt and pasting its replacement left the old text in the composer and sent both. The paste handler now drops the selected range once the attachment is accepted. Paste restore also waits on every attachment rather than pasted ones alone. A composer still holding the previous thread's image passed the old check, so the destination's paste was restored into a composer that was not yet clear, and removing that image did not re-run the effect because the signature ignored it. `composerAttachmentSignature` covers all attachment ids, and the guard is now "any attachment at all".
|
Pushed a7b2180. Two of the four held up. Fixed: a swallowed paste left the selection behind The common editing move: select an obsolete prompt, paste its replacement, and both went out. Fixed: paste restore waited on the wrong thing The guard checked pasted attachments alone, so a composer still holding the previous thread's image passed it and the destination's paste was restored into a composer that was not clear. Removing that image did not re-run the effect either, since the signature ignored it. Not taking: queued pastes as inline prompt text This is the first of the two options the earlier queueing item offered, and it restores exactly what happened before this PR: the same text pasted inline, queued as one prompt, rendered by the same The queue rendering an unbounded prompt is worth bounding, but it holds for any long typed or pasted prompt and predates this change. The other option, carrying attachments through the queue, is a schema change: Not taking: bounding the newline search
Verification
The |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
unsloth/studio/frontend/src/features/chat/runtime-provider.tsx
Lines 325 to 326 in a7b2180
For a large or uncapped paste, createPastedTextFile already retains the original string in pastedTextByFile while the File holds an encoded copy, but this call decodes the entire file into another full-size string before constructing the completed attachment. A tens- or hundreds-of-megabytes paste therefore has substantially higher peak memory than the previous inline path and can fail during send despite attaching successfully; use pastedTextOf(attachment.file) for pasted files and fall back to file.text() only for ordinary text attachments.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
An attachment is serialised after all inline text, so pasting into the middle of a prompt reordered it: `before|after` with a paste at the caret sent `beforeafter` and then the pasted body, turning one sentence into two halves joined with nothing between them. Only a paste already heading to the end of the composer becomes an attachment now. Anything mid-text pastes inline, where the order survives. Recording an insertion offset and splicing it back at serialisation would put a paste-specific case into the shared attachment path for every message. Titles pick up the paste as well. `titleTextOf` returned inline text whenever there was any, so "summarise this" plus a long paste titled the thread from the instruction alone, where the same text inline used to reach the title model. Both are now joined, with the attachment side bounded to 512 characters.
|
Pushed b2470c2. Both held up. Mixed prompts came out in the wrong order An attachment is serialised after all inline text, so Only a paste already heading to the end of the composer becomes an attachment now, Not an insertion offset: splicing it back at serialisation would put a paste-specific case into the shared attachment path that every message goes through. Titles lost the pasted subject
One correction to the item: the disabled-autotitle half is not a regression. Verification
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2470c2bcc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const pasteGoesLast = input.selectionEnd === input.value.length; | ||
| const attachedPastedText = !overlay && pasteGoesLast && pasteLongTextAsFile( |
There was a problem hiding this comment.
Preserve order when text is entered after the paste
The fresh case not covered by this end-caret guard is typing after the attachment is created: pasting a long body at the end and then adding a trailing instruction leaves that instruction in message.content, while collectTextParts in chat-adapter.ts:709-721 appends every attachment after all inline text. Thus BODY followed by Only analyze errors is sent as Only analyze errors followed by BODY, whereas the same below-threshold paste preserves the entered order; retain the paste position across subsequent composer edits or interleave it during serialization.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one. Typing after any attachment puts the typed text first, because collectTextParts appends every attachment after all inline content. Attach a PDF, a DOCX or a .txt and then type, and you get the same order; nothing about that is specific to pastes.
The mid-text case fixed in b2470c2 was different in kind: it produced beforeafter, splicing one sentence's two halves together with nothing between them. That is corrupted text. "Only analyze errors" followed by the body is an ordinary instruction-then-data prompt, unambiguous and arguably the shape a model reads best.
Making pastes uniquely position-aware means threading an insertion offset through the shared serializer that every attachment type goes through, for an ordering preference rather than a correctness problem. Same reason I declined it for the mid-text case; there I could fix it by not attaching, which is not available once the user types later.
a7b2180 deleted the selected range as soon as `pasteLongTextAsFile` returned, but that returns synchronously while `addAttachment` is still running. An attachment that then failed left the user with neither their clipboard nor the text they had selected to replace. The deletion moved into the add callback, after the attachment resolves, and it checks that the composer still holds the text that was pasted into before splicing.
|
Pushed 6e34f69. One held up, one did not. Fixed: a failed paste ate the selected text Mine, from a7b2180. The deletion moved into the add callback, after the attachment resolves, and it checks the composer still holds the text that was pasted into before splicing. Not taking: typing after the paste Typing after any attachment puts the typed text first, because The mid-text case fixed in b2470c2 was different in kind: it produced Making pastes uniquely position-aware means threading an insertion offset through the shared serializer every attachment type goes through, for an ordering preference rather than a correctness problem. Same reason as last round; the difference is that there I could fix it by not attaching, which is not available once the user types later. Verification
|
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
All three assert against source text, so a refactor that keeps the behaviour can still turn them red. That is what happened here, and the result is that every PR branching off main inherits a red Repo tests (CPU) job it did not cause. The clipboard contract reads clipboard-files.ts, but #8472 moved the DataTransfer half into clipboard-payload.ts when long pastes became attachments. The strings it looks for are all still there, just in the sibling file, so it now reads both as the one contract they always were. The title contract pins the exact line that reads the first user message. #8472 replaced extractTextParts with titleTextOf, which wraps it and appends an attachment sample for a user turn. The first user message still titles the thread, so the assertion follows the rename, plus one on titleTextOf itself so the indirection cannot quietly drop the text. The font-scale contract is the one real finding: attachment.tsx used a raw text-[11px], which ignores the UI font size preference, so that label stayed fixed while the rest of the UI scaled. Swapped for the text-ui-11 token, which is the same 11px at scale 1.
Pasting a big block of text into the chat composer dumped every line into the input, which buried whatever you were actually asking and made the composer unusable until you cleared it. There was no way to hand over a wall of text as a file.
Long pastes now attach instead of paste.
Behaviour
.txtattachment. Anything shorter pastes inline exactly as before.Introducing Unsloth Studio.txtrather than a timestamp. Path separators and control characters are stripped, the cut prefers a word boundary, and an opening with nothing usable in it falls back toPasted text.txt.TextAttachmentAdapter, so no content is lost.typesalone. A real.txtyou attach yourself keeps the normal file tile, since a pasted file is matched by identity rather than by name.Changes
studio/frontend/src/features/chat/utils/pasted-text.ts(new): thresholds, naming, file creation and recognition, the paste interception, and the wrapper stripping used by the preview.studio/frontend/src/components/assistant-ui/thread.tsx: the composer paste handler tries the text path first, then falls through to the file paste path.studio/frontend/src/components/assistant-ui/attachment.tsx: the chip, the "Show in text field" action, and the preview dialog.studio/frontend/tests/pasted-text-attachment.test.ts(new): 11 tests covering the thresholds, naming, recognition, interception, and fall through for short pastes, file pastes, native payloads and a missing clipboard.The compare composer is untouched: it only supports image and audio attachments, so a long paste there still goes inline.
One known limit: the chip on an already sent message is matched by attachment id, which is in memory only. Reload the page and an old pasted attachment renders as a normal file tile with the same name. The text itself is unaffected.
Testing
npm run typecheckclean.npm test: 1964 pass, 0 fail (includes the 11 new tests).npm run buildsucceeds and serves the new bundle.The paste path, naming and thresholds are covered by the unit tests. The chip hover and click behaviour has not been clicked through in the browser yet, so a quick manual pass on that would be welcome before merge. Happy to tune the 2000 char / 40 line threshold if it feels too eager.