Skip to content

fix(core): implement multi-chunk bracketed paste state machine#1633

Merged
Karanjot786 merged 1 commit into
Karanjot786:mainfrom
ionfwsrijan:fix/1628-bracketed-paste
Jun 21, 2026
Merged

fix(core): implement multi-chunk bracketed paste state machine#1633
Karanjot786 merged 1 commit into
Karanjot786:mainfrom
ionfwsrijan:fix/1628-bracketed-paste

Conversation

@ionfwsrijan

Copy link
Copy Markdown
Contributor

Description

The bracketed paste handler required both \x1b[200~ and \x1b[201~ markers in the same data chunk. When paste content spans multiple stdin chunks (>4KB), the first chunk contains the start marker + partial content, and subsequent chunks contain more content + the end marker. The paste handler never fires, and the start marker falls through to the escape parser which silently discards it.

The _isPasting and _pasteBuffer fields were declared but never used.

Fix

Replaced the single-chunk paste check with a proper state machine:

  1. Paste-start detection — sets _isPasting = true, strips start marker, buffers content
  2. Paste-end detection — emits accumulated _pasteBuffer as a paste event, resets state
  3. Cross-chunk accumulation — content between markers is concatenated across chunks
  4. Same-chunk handling — both markers in one chunk still works
  5. Timeout recovery — 500ms inactivity timeout aborts stale paste state

Tests

  • Single-chunk paste (existing)
  • Multi-chunk paste (two chunks)
  • Three-chunk paste
  • Both markers in one chunk with surrounding text
  • Incomplete paste timeout recovery

Closes #1628

@ionfwsrijan ionfwsrijan requested a review from Karanjot786 as a code owner June 19, 2026 06:17
@github-actions github-actions Bot added the type:bug +10 pts. Bug fix. label Jun 19, 2026
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@ionfwsrijan, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 29 minutes and 44 seconds. Learn how PR review limits work.

To continue reviewing without waiting, enable usage-based billing in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7265356a-9770-4657-a99c-b34069dca6b1

📥 Commits

Reviewing files that changed from the base of the PR and between 4b874c0 and 9a9dd25.

📒 Files selected for processing (2)
  • packages/core/src/input/InputParser.test.ts
  • packages/core/src/input/InputParser.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added area:core @termuijs/core type:testing +10 pts. Tests. labels Jun 19, 2026
@ionfwsrijan

Copy link
Copy Markdown
Contributor Author

@Karanjot786 Please review this

@Karanjot786 Karanjot786 merged commit 4fc300a into Karanjot786:main Jun 21, 2026
7 checks passed
@Karanjot786 Karanjot786 added gssoc:approved Approved PR. Earns +50 base points. level:advanced +55 pts. Complex task. quality:exceptional x 1.5 multiplier. Exceptional work. labels Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core @termuijs/core gssoc:approved Approved PR. Earns +50 base points. level:advanced +55 pts. Complex task. quality:exceptional x 1.5 multiplier. Exceptional work. type:bug +10 pts. Bug fix. type:testing +10 pts. Tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Multi-chunk bracketed paste silently discards content when paste spans multiple stdin data chunks

2 participants