From e6303589edc81377030f1d72568ab04557ae9bae Mon Sep 17 00:00:00 2001 From: Fsocietyhhh <1211904451@qq.com> Date: Mon, 18 May 2026 22:22:03 -0700 Subject: [PATCH] feat(ui): only collapse pasted text into [Pasted ~N lines] block when >= 5 lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously every bracketed-paste, no matter how short, was replaced with a [Pasted ~1 line] placeholder — including single-line prompts of a couple hundred characters. This hid the actual content from both the user and the model. Mirror Hermes's behavior: inline short pastes (<5 lines) as plain text; only collapse longer multi-line pastes (logs, files, stack traces). Threshold lives in a single constant near the other paste markers so it can later be promoted to a config field if needed. Comparison with other agents: Claude Code: >= 4 lines opencode: >= 3 lines OR > 150 chars (community complaints too aggressive) Hermes: >= 5 lines (this PR) Cursor: ~10 lines / ~1 KB Aider: never collapses --- src/ui/app.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ui/app.tsx b/src/ui/app.tsx index e3fccf9..60aa98b 100644 --- a/src/ui/app.tsx +++ b/src/ui/app.tsx @@ -30,6 +30,9 @@ const DISABLE_BRACKETED_PASTE = '\x1b[?2004l'; const USER_PROMPT_COLOR = '#FFD700'; const PASTE_BLOCK_START = '\uE000PASTE:'; const PASTE_BLOCK_END = ':PASTE\uE001'; +// Mirror Hermes: only collapse pastes of >= this many lines into a [Pasted ~N lines] block. +// Short pastes (one-liners, 2-4 line snippets) inline as plain text so the model sees them verbatim. +const PASTE_COLLAPSE_LINE_THRESHOLD = 5; const DISABLE_AUTO_WRAP = '\x1b[?7l'; const ENABLE_AUTO_WRAP = '\x1b[?7h'; @@ -242,7 +245,11 @@ function PromptTextInput({ value, onChange, onSubmit, placeholder = '', focus = if (!hasPasteEnd) return; - text = encodePasteBlock(pasteBufferRef.current); + const buffered = pasteBufferRef.current; + const lineCount = buffered.length === 0 ? 0 : buffered.split('\n').length; + text = lineCount >= PASTE_COLLAPSE_LINE_THRESHOLD + ? encodePasteBlock(buffered) + : buffered; pasteBufferRef.current = ''; pasteActiveRef.current = false; }