Skip to content

fix(cli): handle OSC52 clipboard passthrough properly under GNU screen#28592

Open
lingfish wants to merge 1 commit into
anomalyco:devfrom
lingfish:fix/osc52-gnu-screen-passthrough
Open

fix(cli): handle OSC52 clipboard passthrough properly under GNU screen#28592
lingfish wants to merge 1 commit into
anomalyco:devfrom
lingfish:fix/osc52-gnu-screen-passthrough

Conversation

@lingfish
Copy link
Copy Markdown

@lingfish lingfish commented May 21, 2026

Issue for this PR

Closes #28590

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

writeOsc52 previously wrapped all mux clients in \x1bPtmux;\x1b...\x1b\\. This only works for tmux — screen's DCS passthrough outputs the raw string, so the tmux; prefix corrupts the terminal output and scrambles the TUI display.

The fix separates the tmux and GNU screen code paths:

  • Screen is detected via process.env["STY"], tmux via process.env["TMUX"]
  • For screen: uses \x1bP\x1b]52;c;...\x07\x1b\\ (no tmux; prefix)
  • Chunks base64 at 700 bytes (screen's MAXSTR = 768, leaving ~759 after overhead)
  • Chunks are joined with \x1b\\\x1bP; the terminal accumulates partial OSC writes until \x07

Credits to @valdemardi for identifying the issue in #26491 / #26492.

How did you verify your code works?

Tested under GNU screen and tmux with short and long text passages. Tmux path unchanged — no regression.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels May 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

writeOsc52 broken under GNU screen — uses tmux DCS format, no chunking

1 participant