Repository navigation
fix(terminal): make Ctrl+V / Cmd+V paste work in the HTTP web client - #9900
Conversation
📝 WalkthroughWalkthroughAdds clipboard-event fallback support for terminal paste in web clients without 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 96006b34-c64c-4b6b-a988-d7d460e842ea
📥 Commits
Reviewing files that changed from the base of the PR and between 300ee19 and baad8012e19cd4b052de4f5baf79565a7a93eb26.
📒 Files selected for processing (3)
src/renderer/src/components/terminal-pane/TerminalPane.tsxsrc/renderer/src/components/terminal-pane/terminal-clipboard-event-paste.test.tssrc/renderer/src/components/terminal-pane/terminal-clipboard-event-paste.ts
navigator.clipboard only exists in secure contexts, so the web client served over plain HTTP (e.g. a LAN address) read an empty clipboard and Ctrl+V silently did nothing: the keydown handler preventDefault-ed the chord and suppressed the native paste event whose clipboardData is the only clipboard access available there. When the async clipboard reader is unavailable in the web client, let the chord's native paste event fire and feed its clipboardData text through the existing paste pipeline (size limits, bracketed-paste handling and error toasts included). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RTjQWLg4wy1CgmcZKmGAuN
Co-authored-by: Orca <[email protected]>
baad801 to
419fa81
Compare
|
Thanks @nwparker! Good catch on the remapped-chord case, the |
|
Thanks so much for this, @kespineira — make Ctrl+V / Cmd+V paste work in the HTTP web client. Verified (fail-on-main/pass-on-branch), rebased on latest |
navigator.clipboard only exists in secure contexts, so the web client
served over plain HTTP (e.g. a LAN address) silently dropped every copy:
writeClipboardText resolved successfully without writing anything. This
broke Ctrl/Cmd+Shift+C, context-menu Copy, right-click copy,
copy-on-select, OSC 52, and Copy Pane/Terminal ID on the client PC.
Fall back to document.execCommand('copy') on a temporary textarea — the
only clipboard write available in insecure contexts — mirroring the
paste-side ClipboardEvent fallback (stablyai#9900). Also retry via execCommand
when a secure-context clipboard write is permission-gated, and reject
instead of silently succeeding when no write path exists.
Co-Authored-By: Claude Fable 5 <[email protected]>
…tablyai#9900) * fix(terminal): make Ctrl+V paste work in the HTTP web client navigator.clipboard only exists in secure contexts, so the web client served over plain HTTP (e.g. a LAN address) read an empty clipboard and Ctrl+V silently did nothing: the keydown handler preventDefault-ed the chord and suppressed the native paste event whose clipboardData is the only clipboard access available there. When the async clipboard reader is unavailable in the web client, let the chord's native paste event fire and feed its clipboardData text through the existing paste pipeline (size limits, bracketed-paste handling and error toasts included). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RTjQWLg4wy1CgmcZKmGAuN * fix: address review finding (bug-bash takeover) Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Neil <[email protected]> Co-authored-by: Orca <[email protected]>
Summary
Restores terminal paste on insecure-context (plain-HTTP) web clients so Ctrl+V / Cmd+V pastes text instead of silently failing — without letting custom-remapped paste chords leak raw control characters into the shell.
ELI5
When you open Orca in a browser over plain
http://, pasting into the terminal did nothing. This makes paste work again, and also makes sure a custom paste shortcut doesn't accidentally type stray control keys into your shell.Root cause & fix
navigator.clipboardonly exists in secure contexts, so on insecure-origin web clients the async clipboard read returned empty while the keydown handler had already suppressed the browser's native paste — the one clipboard access that works there. The original PR fell back to the nativepasteevent, but its early return (if (isClipboardEventPasteRequired()) return) ran beforepreventDefault()/stopPropagation(); a remapped chord (e.g. Ctrl+Y, Ctrl+D) fires no native paste event, so paste silently failed and the un-suppressed keydown reached xterm, which encoded it to the PTY (Ctrl+Y yank, Ctrl+D EOF). The fix gates that early return behind a newfiresNativePasteEvent(event, isMac)predicate (mac: Cmd+V; non-mac: Ctrl+V, Ctrl+Shift+V, Shift+Insert), so only true native-paste chords skip suppression; any other matched chord keeps the existing preventDefault/stopPropagation path — a harmless no-op matching main.Evidence
Validated & rebased onto latest main during a bug-bash triage on 2026-07-23.
terminal-clipboard-event-paste.test.ts— 8/8 tests pass on branch. NewfiresNativePasteEventcases confirm default chords match and remapped Ctrl+Y / Ctrl+D (and cross-platform Cmd+V on non-mac, Ctrl+V on mac) do NOT match — the assertion that fails if the fix is reverted.oxlinton the 3 changed source files exits 0, nomax-linesdisable.Trade-offs
None — pure fix. (Pre-existing limitation unchanged: image paste and context-menu Paste still need a secure context.)
Regression risk
Zero-regression by construction: only the buggy branch — the new early return — is narrowed by an added predicate. Standard clipboard chords (Cmd+V / Ctrl+V / Ctrl+Shift+V / Shift+Insert) still take the native-paste path; every other chord reverts to main's preventDefault/stopPropagation no-op. Electron and secure-context HTTPS clients are untouched. Proven by the passing predicate tests.
Credit to @kespineira for the original fix. Validated, rebased, and hardened via automated bug-bash review; original fix design preserved. This session added
firesNativePasteEventplus tests to stop remapped paste chords from injecting control characters (Ctrl+Y/Ctrl+D) into the PTY.