Repository navigation
Description
Description
Pasting a large block of text (e.g., a 50KB code snippet or log) into a terminal pane makes the entire Orca app freeze for multiple seconds — completely unresponsive. This happens on the latest release (v1.4.68), on Windows.
Steps to Reproduce
- Open any terminal pane in Orca (PowerShell, WSL, whatever)
- Copy a large text block — 50KB+ of code or log output works reliably
- Paste via Ctrl+V
- Observe the app freeze — UI is completely blocked, nothing responds
- After a few seconds, the paste completes and the app recovers
Root Cause
The freeze is caused by xterm.js parsing the entire pasted string synchronously on the renderer thread with no yielding or chunking.
The call chain:
TerminalPane.tsxcaptures the paste keydown →pasteTerminalClipboard()→await readClipboardText()(async IPC, fine)terminal-bracketed-paste.ts→pasteTerminalText()callsterminal.paste(text)synchronously with the entire text- xterm.js's
paste()method walks every single byte through its VT escape sequence parser on the main renderer thread — 50,000+ synchronous iterations for a 50KB paste - During this, the browser's event loop is completely blocked: no frames render, no user input is processed
Key files:
| File | Role |
|---|---|
src/renderer/src/components/terminal-pane/terminal-bracketed-paste.ts |
pasteTerminalText() and forceBracketedPaste() — the synchronous terminal.paste(text) call |
src/renderer/src/components/terminal-pane/terminal-clipboard-paste.ts |
pasteTerminalClipboard() — dispatches to pasteTerminalText |
Why the output scheduler doesn't help:
pane-terminal-output-scheduler.ts has sophisticated batching/coalescing (50ms background delay, 16ms drain interval) for PTY output, but paste input bypasses all of it entirely — it goes straight to terminal.paste().
Proposed Fix
Add chunked paste with microtask yielding in terminal-bracketed-paste.ts's pasteTerminalText():
- If text exceeds a threshold (~512 chars), split into chunks
- For each chunk, call
terminal.paste(chunk) - Between chunks,
await new Promise(r => setTimeout(r, 0))to yield the renderer thread - Each chunk should complete in < 16ms to stay under frame budget
For the Windows multiline forceBracketedPaste path (which uses terminal.input() with BRACKETED_PASTE_START/END wrappers), emit the start sequence, loop chunks with yields, then emit the end sequence.
This keeps xterm's bracketed paste semantics intact (the PTY still receives the text as a single paste event) while preventing the multi-second renderer block.
Pseudocode:
const PASTE_CHUNK_SIZE = 512
async function chunkedPaste(terminal: PasteTerminal, text: string, write: (chunk: string) => void): Promise<void> {
for (let i = 0; i < text.length; i += PASTE_CHUNK_SIZE) {
write(text.slice(i, i + PASTE_CHUNK_SIZE))
await new Promise(r => setTimeout(r, 0))
}
}
Activity
brennanb2025 commentedon Jul 4, 2026
Verified this is already handled on current
main, so closing as resolved.Mechanism. Large-paste handling is owned by the paste coordinator (
planTerminalPasteWithYield→executeTerminalPastePlan). Any payload overTERMINAL_PASTE_DIRECT_MAX_BYTES(64 KB) is sent to the PTY as event-loop-yielding, backpressure-aware chunks inside a single bracketed frame — it never does a synchronousterminal.paste()of the whole payload, so it can't block the renderer main thread. Payloads ≤64 KB stay a single fastterminal.paste().Coverage. I checked every way text can enter a terminal as a paste, and they all funnel through the coordinator: keyboard (Ctrl/Cmd+V, Shift+Insert), the native
pasteevent, app-menu paste, context-menu paste, middle-click / X11 primary-selection, programmatic paste, startup-command paste, Electron Edit›Paste, web/mobile remote clients, and SSH/remote terminals (runtime kind only lengthens the write timeout). The only two writes that bypass the coordinator can't cause this freeze: drag-and-drop pastes file paths (bounded), not file contents; and the main-process startup-draft seed is a PTY write, not a rendererterminal.paste().Regression coverage. The behavior is locked by
src/renderer/src/components/terminal-pane/terminal-paste-coordinator.test.ts— it asserts a large paste ischunked, streamed as multiple bounded PTY writes with a yield between each, wrapped in exactly one bracketed frame.Thanks @riverpilot — #5648 tackled the same freeze from the renderer side; it's redundant only because
main's coordinator already owns this path end to end.Caveat: this is verified via the paste code paths + unit tests. The freeze mechanism (blocking the main thread on a large synchronous write) is platform-independent, but since this was reported on Windows/ConPTY specifically, if a multi-MB paste still freezes on a current build, please reopen with the payload size and which paste action you used and we'll dig into the ConPTY write path.