#5653·tmux

OSC 52 set-selection from a pane is dropped when PANE_REDRAW is pending (breaks clipboard for apps using DECSET 2026)

Author: fzy521Created Sep 28, 2026Updated Sep 28, 2026

OSC 52 set-selection from a pane is dropped when PANE_REDRAW is pending (breaks clipboard for apps using DECSET 2026)

Summary

When a pane application emits an OSC 52 clipboard write immediately after ending a synchronized update (CSI ? 2026 l), tmux 3.7c silently drops the clipboard write. This breaks "copy to clipboard" in applications that wrap every frame in DECSET 2026 begin/end markers (e.g. yazi), because the clipboard sequence always lands right after a 2026l.

Environment

  • tmux 3.7c (built from source), Linux aarch64
  • Outer terminal: Ghostty (but any terminal with the clipboard feature is affected)
  • set-clipboard on, allow-passthrough on
  • Application: yazi 26.9.1 (any OSC 52 emitter wrapped in 2026 works for repro)

Minimal reproduction

Inside any tmux pane, with a client attached:

bash
# Control: plain OSC 52 -> outer terminal clipboard IS set
printf "\033]52;c;%s\033\\" "$(printf 'plain-works' | base64)"

# Bug: same OSC 52 immediately after DECRST 2026 -> clipboard NOT set
printf "\033[?2026l\033]52;c;%s\033\\\033[?2026h" "$(printf 'sync-dropped' | base64)"

# Interesting: inserting a delay between 2026l and OSC 52 works again
printf "\033[?2026l"; sleep 2
printf "\033]52;c;%s\033\\" "$(printf 'delayed-works' | base64)"

Verified by strace-attaching the tmux server (strace -f -p <pid> -e trace=writev): the plain and delayed cases produce a writev of \033]52;c;...\007 to the client; the sync-adjacent case produces nothing.

Root cause

input_csi_dispatch_rm handles 2026l like this (input.c):

c
case 2026:
    screen_write_stop_sync(ictx->wp);
    if (ictx->wp != NULL)
        ictx->wp->flags |= PANE_REDRAW;
    break;

The very next sequence in the same input batch is the OSC 52, which goes through input_osc_52 -> screen_write_setselection -> tty_write(tty_cmd_setselection, ...) -> screen_write_set_client_cb:

c
if (wp->flags & (PANE_REDRAW|PANE_DROP))
    return (-1);

Because the pane was just flagged PANE_REDRAW by the 2026l, the set-selection command is dropped for every client. Dropping it is wrong: a clipboard write has no screen side effects, so the redraw guard should not apply. The same drop also affects OSC 52 sent from any pane with a pending redraw for other reasons.

A secondary benefit of fixing this via TTY_CTX_INVISIBLE_PANES (see patch) is that clipboard writes from panes in non-current windows are delivered too, matching user expectations (copying from a background window's application should still set the clipboard).

Proposed fix

Mark the set-selection tty context with TTY_CTX_INVISIBLE_PANES, which bypasses both the redraw-pending drop and the current-window restriction in screen_write_set_client_cb:

diff
--- a/screen-write.c
+++ b/screen-write.c
@@ -2865,6 +2865,7 @@ screen_write_setselection(struct screen_write_ctx *ctx, const char *clip,
 	struct tty_ctx	ttyctx;
 
 	screen_write_initctx(ctx, &ttyctx, 0, 0);
+	ttyctx.flags |= TTY_CTX_INVISIBLE_PANES;
 	ttyctx.sel.clip = clip;
 	ttyctx.sel.data = str;
 	ttyctx.sel.size = len;

With this patch applied, the reproduction above delivers all three payloads to the outer terminal clipboard, and yazi's copy-path (c c) works correctly.

Notes

  • tmux <= 3.6 is unaffected because DECSET 2026 was only added in 3.7 (issue #4744); the sequences were previously ignored.
  • I can open a PR with this change if the approach looks reasonable.