Skip to content

fix(terminal): make Ctrl+V / Cmd+V paste work in the HTTP web client - #9900

Merged
nwparker merged 2 commits into
stablyai:mainfrom
kespineira:fix/web-client-terminal-paste
Jul 24, 2026
Merged

nwparker merged 2 commits into
stablyai:mainfrom
kespineira:fix/web-client-terminal-paste

Conversation

@kespineira

@kespineira kespineira commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

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.clipboard only 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 native paste event, but its early return (if (isClipboardEventPasteRequired()) return) ran before preventDefault()/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 new firesNativePasteEvent(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.

  • Test file terminal-clipboard-event-paste.test.ts — 8/8 tests pass on branch. New firesNativePasteEvent cases 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.
  • Lint clean: oxlint on the 3 changed source files exits 0, no max-lines disable.
npx vitest run --config config/vitest.config.ts \
  src/renderer/src/components/terminal-pane/terminal-clipboard-event-paste.test.ts
=> Test Files  1 passed (1) | Tests  8 passed (8)

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 firesNativePasteEvent plus tests to stop remapped paste chords from injecting control characters (Ctrl+Y/Ctrl+D) into the PTY.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds clipboard-event fallback support for terminal paste in web clients without navigator.clipboard.readText. Clipboard text is extracted from ClipboardEvent, validated, and passed through the existing terminal paste flow. Keyboard paste handling defers to the paste event when required. The change also adds configurable clipboard text reading and unit tests for environment detection and clipboard text extraction.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description covers the change well, but it omits several required template sections, including Screenshots, Testing checklist, AI Review Report, Security Audit, and Notes. Add the missing template sections with test commands, a review/security summary, and Notes; include screenshots or explicitly state 'No visual change'.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main user-facing fix: restoring paste in the HTTP web client.

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.

@coderabbitai coderabbitai 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.

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.tsx
  • src/renderer/src/components/terminal-pane/terminal-clipboard-event-paste.test.ts
  • src/renderer/src/components/terminal-pane/terminal-clipboard-event-paste.ts

claude and others added 2 commits July 23, 2026 04:18
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
@nwparker
nwparker force-pushed the fix/web-client-terminal-paste branch from baad801 to 419fa81 Compare July 23, 2026 11:51
@kespineira

Copy link
Copy Markdown
Contributor Author

Thanks @nwparker! Good catch on the remapped-chord case, the firesNativePasteEvent gate is really clean solution

@nwparker
nwparker merged commit a4f42ad into stablyai:main Jul 24, 2026
@nwparker

Copy link
Copy Markdown
Contributor

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 main, reviewed, and merged. Really appreciate it! 🙏

OrcaWin pushed a commit to badaverse/orca that referenced this pull request Jul 28, 2026
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]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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]>
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.

4 participants