-
Notifications
You must be signed in to change notification settings - Fork 773
Description
Describe the bug
Wave Terminal's OSC 52 (clipboard) implementation requires both window and block focus, which breaks application-initiated clipboard copying when the terminal doesn't have focus. This causes issues with tools like OpenCode/Claude Code that use OSC 52 for programmatic clipboard operations.
To Reproduce
- Open Wave Terminal
- Run a terminal application that uses OSC 52 to copy text (e.g., OpenCode, tmux with OSC 52 enabled, Neovim with clipboard integration)
- Trigger a copy operation from the application
- The copy fails silently if Wave Terminal window or the specific block doesn't have focus
Example test:
printf '\033]52;c;%s\a' "$(echo -n 'test copy' | base64)"This works in iTerm2, Alacritty, kitty, and other terminals regardless of focus state, but fails in Wave Terminal when the window/block isn't focused.
Expected behavior
OSC 52 clipboard writes should succeed regardless of terminal focus state. The security model for OSC 52 is already well-established:
- Most terminals allow writes without focus (standard behavior)
- Reads (query with
?) are blocked for security (which Wave correctly does) - Size limits prevent abuse (Wave has appropriate 75KB limit)
This is particularly important for:
- AI coding assistants (OpenCode, Cursor, etc.) that copy code snippets
- Terminal multiplexers (tmux, screen) with clipboard integration
- Remote editing workflows (Vim/Neovim over SSH)
Code Reference
The focus check is in frontend/app/view/term/termwrap.ts:
function handleOsc52Command(data: string, blockId: string, loaded: boolean, termWrap: TermWrap): boolean {
if (!loaded) {
return true;
}
const isBlockFocused = termWrap.nodeModel ? globalStore.get(termWrap.nodeModel.isFocused) : false;
if (!document.hasFocus() || !isBlockFocused) {
console.log("OSC 52: rejected, window or block not focused");
return true; // ← This rejects valid clipboard operations
}
// ... rest of implementation is correct
}Suggested Fix
Remove the focus check for OSC 52 writes. The existing size limits and query blocking provide adequate security:
function handleOsc52Command(data: string, blockId: string, loaded: boolean, termWrap: TermWrap): boolean {
if (!loaded) {
return true;
}
// Remove: if (!document.hasFocus() || !isBlockFocused) check
// Keep all existing validation (size limits, query blocking, etc.)
// ...
}Desktop
- OS: macOS 15.2
- Wave Terminal: v0.13.1 (but affects all versions with OSC 52 support)
- Also affects: Linux, Windows
Related
- Clipboard shortcuts do not work on Linux #206 (clipboard shortcuts on Linux) - may share root cause
- Standard terminal behavior reference: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands