Repository navigation
fix(paste): lower threshold to 100 — Claude accumulator engages well below 800 - #72
Merged
Merged
Conversation
… well below 800 PR #71 shipped the event-driven submit-after-paste fix but the bug kept firing in practice. Per-paste debug dumps from real usage tell the story: a 215-char single-line message ("i can say that something DID NOt work…") was routed as `route:claude-plain-text` and submitted as text+`\r` in ONE PTY write — the exact code path PR #71's bracketed-paste + placeholder-detector was supposed to bypass. The 800-char gate held the door shut for the most common case. Root cause: 800 confused two different Claude TUI thresholds. * COLLAPSE threshold (~800): the point at which Claude renders `[Pasted text #N]` in the composer instead of inlining the bytes. This is the one upstream's PASTE_THRESHOLD const refers to. * ACCUMULATOR threshold (~100): the point at which Claude's paste state machine starts swallowing trailing `\r` during its ~100 ms debounce window. This fires regardless of whether collapse happens. PR #71 fixed the accumulator race for text that ALSO crossed the collapse threshold (≥800 chars or multi-line). Everything in 100–800 chars without newlines — i.e. most ordinary chat messages — stayed on the broken plain-text path. Lowering the gate to 100 routes those through the bracketed-paste + event-driven submit path, which is where the actual fix lives. Also lowers CLAUDE_PASTE_EVENT_DRIVEN_TIMEOUT_MS from 2000 → 500: in the 100–800 char range the `[Pasted text #N]` placeholder never renders, so every submit hits the timeout fallback. 2000 ms there is a noticeable per-message lag. 500 ms is still well past Claude's 100 ms accumulator window so `\r` is always safe by then. Evidence: per-paste debug dumps in ~/Library/Application Support/cc-shell/paste-debug/ - 9da6e430-...paste.jsonl: 215 chars, isPasteLike=false, plain-text route → bug - b387f634-...paste.jsonl: 145 chars, same shape, same bug - 53f74065-...paste.jsonl: 156 chars, same - 5c2b319c-...paste.jsonl: 177 chars, same Follows up #71. Numbers may need empirical tuning if 100 is too aggressive (i.e., normal-typed short messages get unnecessarily routed through bracketed paste and feel the 500 ms fallback lag), but the per-paste debug journal from #71 makes that easy to spot. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CLAUDE_PASTE_THRESHOLDfrom 800 → 100 so those messages go through the bracketed-paste path that already has the placeholder-detector behind it.CLAUDE_PASTE_EVENT_DRIVEN_TIMEOUT_MSfrom 2000 → 500 because in this size range the[Pasted text #N]placeholder never renders (no collapse), so every submit was eating the full 2 s timeout fallback.Root cause
800 conflated two different Claude TUI thresholds:
[Pasted text #N]instead of inlining bytes. UpstreamPASTE_THRESHOLDrefers to this one.\rduring its ~100 ms debounce. Fires regardless of whether collapse happens.PR #71 fixed the accumulator race for text that ALSO crossed the collapse threshold. Everything between accumulator-engaged and collapse-engaged stayed on the broken plain-text path.
Evidence
From per-paste debug dumps captured by the journal added in #71 (in
~/Library/Application Support/cc-shell/paste-debug/):9da6e430-...paste.jsonlroute:claude-plain-textb387f634-...paste.jsonlroute:claude-plain-text53f74065-...paste.jsonlroute:claude-plain-text5c2b319c-...paste.jsonlroute:claude-plain-textAll four show
isPasteLike: falseand a singlemain:writewith text+\rin one PTY frame — the exact pattern PR #71's bracketed-paste path was supposed to replace.Test plan
.)..) and press Enter — should NOT be re-routed through bracketed paste; plain-text path still handles short input.route:claude-paste,write:paste-payload, and a separatewrite:submit-crevent with strategytimeout-skip-timer(since the placeholder won't render in this size range).Followups
🤖 Generated with Claude Code