Skip to content

Add opt-in "Paste in Chunks" option for terminal AI agents (e.g. Claude Code) - #761

Open
leochen4891 wants to merge 2 commits into
Beingpax:mainfrom
leochen4891:paste-in-chunks
Open

leochen4891 wants to merge 2 commits into
Beingpax:mainfrom
leochen4891:paste-in-chunks

Conversation

@leochen4891

@leochen4891 leochen4891 commented Jun 8, 2026 •

Copy link
Copy Markdown

Problem

When a long transcription is pasted into a terminal-based AI agent such as Claude Code, the destination collapses the single large paste into a placeholder (for example [Pasted text #N +M lines]) rather than showing it inline. The full text is still delivered, but the user cannot read or edit it before pressing Enter.

Before — a long dictation collapses into a placeholder:

Before: collapsed pasted-text placeholder

After — with "Paste in Chunks" enabled, the same dictation lands as full, editable inline text:

After: full inline text

Approach

Add an opt-in Paste in Chunks setting. When enabled, VoiceInk pastes the transcription in smaller pieces so each paste stays below the destination's collapse threshold, and the text renders as visible, editable inline text.

This mirrors the behavior Wispr Flow documents for Claude Code (auto-splitting long dictations into chunks).

It is a layer on top of the existing clipboard paste — a separate toggle plus chunk-size picker that composes with both the Default and AppleScript paste methods, rather than a new mutually-exclusive method. It is complementary to the Direct Typing work in #701: Direct Typing reaches destinations where the clipboard does not work at all (for example remote desktop), whereas chunking keeps a working clipboard paste from being collapsed.

Changes

  • CursorPaster: the paste session now iterates over chunks with a short inter-chunk delay; splitting prefers whitespace and newline boundaries and falls back to a hard split for a single oversized run.
  • Settings: new "Paste in Chunks" toggle and chunk-size picker (250 / 500 / 750 / 1000 characters).
  • Defaults registered; off by default, so there is no behavior change unless enabled. Default chunk size is 250 characters.

Long transcriptions pasted into terminal-based AI agents such as Claude
Code are collapsed by the destination into a placeholder (for example
"[Pasted text +N lines]") instead of being shown inline, so the text
cannot be read or edited before it is submitted.

Add an opt-in setting that pastes the transcription in smaller pieces so
each paste stays below the destination's collapse threshold and the text
renders inline. Splitting prefers whitespace and newline boundaries and
falls back to a hard split for a single oversized run. The behaviour
layers on top of the existing clipboard paste methods (Default /
AppleScript) and is controlled by a separate toggle and chunk-size
picker. Off by default; default chunk size 250 characters.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@leochen4891
leochen4891 marked this pull request as ready for review June 8, 2026 19:01

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread VoiceInk/Paste/CursorPaster.swift
Comment thread VoiceInk/Paste/CursorPaster.swift Outdated
Comment thread VoiceInk/Paste/CursorPaster.swift
- Report paste success only when every chunk posts, so a later chunk no
  longer masks an earlier chunk's failure.
- Always schedule the clipboard restore, including when a chunk fails
  partway through, so a partial paste does not leave the clipboard
  clobbered.
- Split chunks by index arithmetic instead of repeatedly reading
  `count`, which is O(n) on Swift strings, avoiding O(n^2) behaviour on
  large transcriptions.
- Add unit tests for the chunk splitter (reassembly fidelity, max-length
  adherence, whitespace boundaries, hard-splitting, multiline,
  non-positive lengths, and grapheme-cluster integrity).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@leochen4891

Copy link
Copy Markdown
Author

Thanks for the review — addressed all three issues identified by cubic in 92b8d87:

  1. Partial-paste success reporting — the paste loop now ANDs each chunk's result and returns success only when every chunk posts.
  2. Clipboard left clobbered on mid-loop failure — a failed chunk now breaks out and still schedules the clipboard restore (using the last successfully prepared chunk).
  3. O(n²) splitting — the splitter advances by index arithmetic instead of repeatedly reading count (which is O(n) on Swift strings).

Also added unit tests for the chunk splitter (ChunkSplittingTests) covering reassembly fidelity, max-length adherence, whitespace boundaries, hard-splitting an oversized run, multiline, non-positive lengths, and grapheme-cluster integrity.

This branch has not been deployed

No deployments
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