Skip to content

feat(ui): inline short pastes, only collapse when >= 5 lines#60

Merged
1bcMax merged 1 commit into
mainfrom
feat/paste-collapse-threshold
May 19, 2026
Merged

feat(ui): inline short pastes, only collapse when >= 5 lines#60
1bcMax merged 1 commit into
mainfrom
feat/paste-collapse-threshold

Conversation

@KillerQueen-Z
Copy link
Copy Markdown
Collaborator

Problem

Every bracketed-paste — even a one-line prompt — was being replaced in the input box with a [Pasted ~1 line] placeholder. Concretely, pasting:

"Buy a US phone number, then call +1-555-0123 in English and ask whether they're free for a 30-minute product demo on Thursday. Use a warm female voice and don't talk for more than two minutes."

(1 line, ~230 chars) collapses to [Pasted ~1 line]. The user can't see what they pasted, and the LLM only sees the decoded content at submit time — but the in-flight UX is broken for short snippets.

Root cause: findPasteBlocks(...) > 0 triggered the collapse unconditionally — no threshold check at all.

Fix

Mirror Hermes's behavior: only collapse pastes of >= 5 lines into a [Pasted ~N lines] block. Shorter pastes get inserted as plain text so they render verbatim and behave like normal typed input.

The threshold lives in a single named constant (PASTE_COLLAPSE_LINE_THRESHOLD) right next to the other paste markers, so it's easy to promote to a config field later if needed.

Comparison with other agents

Agent Threshold
Claude Code >= 4 lines
opencode >= 3 lines OR > 150 chars (community has been complaining this is too aggressive)
Hermes >= 5 lines (adopted here)
Cursor ~10 lines / ~1 KB
Aider never collapses

Behavior table

Paste Before After
1-line, 230-char prompt [Pasted ~1 line] inline ✅
2-line shell command [Pasted ~2 lines] inline ✅
4-line stack trace [Pasted ~4 lines] inline ✅
5-line code block [Pasted ~5 lines] [Pasted ~5 lines]
50-line log dump [Pasted ~50 lines] [Pasted ~50 lines]

Test plan

  • npm run build passes
  • Manual: paste the demo prompt above — renders inline, no [Pasted] placeholder
  • Manual: paste a 5+ line snippet — collapses to [Pasted ~N lines] as before
  • Manual: navigate with arrow keys / backspace through both short and collapsed pastes — no regressions
  • Submit decodes correctly in both branches (collapsed pastes still expand to original content at submit time)

Scope

Single-file change to src/ui/app.tsx. No new dependencies. No behavior change for pastes that exceed the threshold.

… >= 5 lines

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
@1bcMax 1bcMax merged commit 6245177 into main May 19, 2026
2 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.

1 participant