Skip to content

fix(frontend): wire clipboard copy/paste in XtermTerminal#306

Open
neversettle17-101 wants to merge 1 commit into
mainfrom
fix-terminal-clipboard-305
Open

fix(frontend): wire clipboard copy/paste in XtermTerminal#306
neversettle17-101 wants to merge 1 commit into
mainfrom
fix-terminal-clipboard-305

Conversation

@neversettle17-101

Copy link
Copy Markdown
Collaborator

Summary

  • XtermTerminal loaded several xterm.js addons but had no clipboard wiring, so neither the OS Copy command nor plain mouse drag-to-select worked against the zellij-attached PTY (zellij owns SGR mouse tracking, and xterm selection is rendered to canvas, not DOM).
  • Added an attachCustomKeyEventHandler that intercepts Cmd/Ctrl+C (copies term.getSelection() via navigator.clipboard.writeText only when there's an active selection, otherwise lets the event through so Ctrl+C still sends SIGINT) and Cmd/Ctrl+V (reads navigator.clipboard.readText() and forwards via term.paste, rather than relying on xterm's native DOM paste event).
  • Shift+drag for local text selection while zellij owns mouse tracking is xterm's existing default behavior — no change needed there.
  • No new dependency: implemented with the existing @xterm/xterm APIs, no @xterm/addon-clipboard needed.

Test plan

  • pnpm -C frontend typecheck passes
  • pnpm -C frontend test (full renderer suite, including XtermTerminal tests) passes — 140/140
  • Manual: open a session terminal, Shift+drag to select text, Cmd/Ctrl+C to copy, paste into another app
  • Manual: Cmd/Ctrl+V into the terminal pastes clipboard text into the PTY
  • Manual: Ctrl+C with no selection still sends SIGINT to the running process
  • Manual smoke test on Linux/Windows (no native Electron menu there, so this relies entirely on the explicit key handling added here)

Fixes #305

🤖 Generated with Claude Code

zellij owns SGR mouse tracking and xterm's selection model is canvas-only,
so neither the OS Copy command nor plain drag-to-select worked. Intercept
Cmd/Ctrl+C to copy the active selection (falling through when nothing is
selected so Ctrl+C still sends SIGINT) and Cmd/Ctrl+V to paste explicitly
via the clipboard API rather than relying on xterm's native paste event.

Fixes #305

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

bug(terminal): cannot copy/paste from the zellij session terminal — no clipboard wiring in XtermTerminal

1 participant