Skip to content

fix(tui): a paste split across input batches becomes one chip - #404

Merged
mrnasil merged 2 commits into
mainfrom
fix/split-paste-one-chip
Nov 4, 2026
Merged

mrnasil merged 2 commits into
mainfrom
fix/split-paste-one-chip

Conversation

@mrnasil

@mrnasil mrnasil commented Nov 4, 2026

Copy link
Copy Markdown
Member

Problem

On Windows, pasting a two-line error (~200 chars) into the prompt collapsed only the first part into [pasted #N ~ L lines]; the rest was typed out after the chip.

The console delivers an unbracketed paste as keys. read_event_batch ends a batch at a 12 ms gap or its 400 ms linger cap, and coalesce_unbracketed_paste folds each batch on its own: the first batch became a chip, the short tail was under the chip size and was typed. The reverse split (typed head, chip tail) also happened.

Fix

input::PasteRun tracks the prompt span one flood has written. Each insert that continues it (same batch, or inside the flood window, at the run's end) extends the run. Once any part of it was a folded paste and the expanded text is chip-sized, the whole run is replaced with one chip.

  • Live Windows console only (paste_enter_guard), like the existing flood guards.
  • A human pause ends the run; text typed before the paste stays outside the chip.

Tests

  • split_paste_chip_then_typed_tail_becomes_one_chip (the reported text)
  • split_paste_typed_head_then_chip_becomes_one_chip
  • split_paste_in_many_batches_keeps_text_around_it
  • typing_after_a_paste_is_not_pulled_into_its_chip, a_short_flood_with_a_folded_part_stays_plain_text, a_paste_run_whose_span_went_stale_is_dropped

The first three fail without the fix. cargo test -p whycodes-tui (1491 passed), clippy, fmt and the budget scripts are clean.

🤖 Generated with Claude Code

mrnasil and others added 2 commits November 4, 2026 14:01
The Windows console delivers an unbracketed paste as keys, and the batch
reader cuts that flood at a 12 ms gap or its 400 ms cap. Each batch was
folded on its own, so a long paste came out as a chip followed by plain
text (or plain text followed by a chip).

Track the prompt span the flood has written. Inserts that continue it
extend the run; once part of it was a folded paste and the full text is
chip-sized, the whole run is replaced with one chip. Live Windows console
only; a human pause ends the run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mrnasil
mrnasil merged commit c1bb353 into main Nov 4, 2026
7 checks passed
@mrnasil
mrnasil deleted the fix/split-paste-one-chip branch November 4, 2026 16:30
@mrnasil mrnasil mentioned this pull request Nov 4, 2026
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