Files
multica/packages/views/editor/paste-as-file.ts
Naiyuan Qing 831ef926e1 fix(editor): limit paste-as-file to chat (#6043)
#6019 opted four composers into converting an over-threshold plain-text
paste into a `pasted-text.txt` attachment. Only chat should: a wall of
text there is context handed to an agent for one turn, and the body is
not what anyone reads. In an issue comment the paste IS prose a human
reader is expected to see in the thread, so hiding it behind an
attachment chip makes the thread worse, not better.

So the three comment surfaces — new comment, reply, comment edit — stop
passing `pasteAsFileThreshold`. Nothing else changes: the extension, the
threshold constant and the failed-paste recovery all stay, because the
prop was always opt-in per editor and chat still uses every part of it.

The recovery test moves from comment-composers to
use-coordinated-uploads. Comments can no longer produce a paste-as-file
upload at all, so hosting the test there would pin a path that cannot
happen; the hook is where the contract actually lives, since the upload
outlives its mount and no editor can own the failure.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 18:03:55 +08:00

24 lines
1.2 KiB
TypeScript

/**
* Character count above which a plain-text paste is uploaded as a
* `pasted-text.txt` attachment instead of being inserted as body text.
*
* Chat is the only editor that opts in; see `pasteAsFileThreshold` in
* `content-editor.tsx` for why. The constant stays separate from that call
* site so any composer that later joins converts at the same point — two
* surfaces disagreeing would let the same content be a file on the way in and
* text on the way back out.
*
* The number is a product judgement, not a technical limit: nothing in this
* stack caps message length (no client schema max, the server only rejects
* empty content, and every column is unbounded TEXT). Below ~4k a paste is
* still scrollable as text; above it the body stops being readable and the
* attachment is the better container. For reference, ChatGPT converts at
* 10,000 characters and Discord at its 2,000-character message ceiling.
*
* NOT the same thing as `LARGE_PASTE_TEXT_THRESHOLD` in
* `extensions/markdown-paste.ts` — that one (50,000) is a parser bail-out that
* keeps a huge paste from running the markdown pipeline, and applies to every
* editor including the ones that never convert to a file.
*/
export const PASTE_AS_FILE_THRESHOLD = 4000;