fix(terminal): smooth copy/paste under tmux via OSC 52 + bracketed paste #75
No reviewers
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_router!75
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "development_terminal_clipboard_tmux"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Makes browser ⇄ remote-PTY copy/paste work reliably under tmux without lag or quirks.
set -g set-clipboard on) land in the local browser clipboard.term.paste(text)so xterm.js wraps it in bracketed-paste markers — multi-line pastes are now treated as paste (not typing) by tmux, vim, and bracketed-paste-aware shells.execCommand-based fallback for the async Clipboard API when running in an insecure context or older browser.Shift+drag selection-bypass tip.No new dependencies; server-side WS framing unchanged.
Related Issue
Closes #69
Changes
crates/hero_router/static/js/terminal.jscopyToClipboard/readFromClipboardwith<textarea>+execCommandfallback.term.parser.registerOscHandler(52, ...)for tmux yanks → local clipboard. OSC 52 queries deliberately ignored (security). Decoded payloads capped at ~1 MB.term.paste(text)(honours bracketed-paste); both Ctrl+Shift+V and right-click → Paste use it.copyToClipboard.rightClickSelectsWord: trueon theTerminalconstructor.crates/hero_router/templates/terminal.htmlShift+drag row.crates/hero_router/src/server/terminal.rs#[cfg(test)]regression tests pinning thatstrip_dsr_cpr_queriesdoes not consume OSC 52 frames. No production-code change.README.mdTest Results
cargo test -p hero_router— 81 passed, 0 failed, 0 ignored. Includes both new regression tests:server::terminal::tests::strip_dsr_cpr_queries_leaves_osc52_intactserver::terminal::tests::strip_dsr_cpr_queries_strips_only_dsrManual verification
set -g set-clipboard onlands in local clipboard.Ctrl+Shift+Vand right-click → Paste both work; multi-line paste does not auto-execute under bracketed-paste shells.Ctrl+Cstill sends SIGINT when there is no selection.Shift+drag selects natively even withset -g mouse on.New tmux sessions launched from hero_router now run `tmux set-option -g set-clipboard on ; new-session`, so OSC 52 yanks reach the browser clipboard without requiring per-user ~/.tmux.conf changes. Each whitespace-separated token becomes its own argv entry under interpreter("exec"); tmux parses a lone ";" as a command separator. #69Pull request closed