Skip to content

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

Closed

Description

@lingfish

Description

writeOsc52 in packages/opencode/src/cli/cmd/tui/util/clipboard.ts treats GNU screen and tmux the same way, wrapping both in \x1bPtmux;\x1b...\x1b\\. This was originally reported by @valdemardi in #26491 / #26492 (closed before merging).

The tmux; prefix is specific to tmux. Under screen, it is output verbatim alongside the escape sequences. The embedded OSC52 usually still reaches the clipboard (\x1b]52;c;...\x07 is valid enough), but the tmux; garbage and leaked escape sequences corrupt the terminal output and scramble the TUI display.

Screen also has a 768-byte DCS buffer limit (MAXSTR), so clipboard writes larger than ~750 bytes are silently truncated. Screen requires chunking with \x1b\\\x1bP between segments.

Plugins

N/A

OpenCode version

1.15.6

Steps to reproduce

  1. Run inside a GNU screen session (STY is set)
  2. Try any clipboard copy
  3. Text may reach the clipboard but the TUI display gets corrupted with garbage characters and escape artifacts

Screenshot and/or share link

N/A

Operating System

Linux

Terminal

Alacritty and GNU screen v5

Activity

  1. lingfish commented on Jun 4, 2026

    @lingfish
    Author

    Any chance the associated PR can get looked at?

    Polite ping to @kommander

  2. simonklee commented on Jun 18, 2026

    @simonklee
    Member

    Thanks reporting. I'll remove the osc52 specific things from openecode shortly and use OpenTUI directly for this. That should solve the issue since we already;

    • Distinguishes tmux and GNU Screen.
    • Use Screen DCS passthrough without the corrupting tmux; prefix.
  3. lingfish commented on Jun 18, 2026

    @lingfish
    Author

    Awesome, thankyou! Let me know if I should just nuke my PR etc or not.

  4. lingfish commented on Jun 23, 2026

    @lingfish
    Author

    Thanks reporting. I'll remove the osc52 specific things from openecode shortly and use OpenTUI directly for this. That should solve the issue since we already;

    • Distinguishes tmux and GNU Screen.
    • Use Screen DCS passthrough without the corrupting tmux; prefix.

    Hi @simonklee - politely asking for when this will happen, so that I can set my own expectations, thanks.

  5. lingfish commented on Jul 6, 2026

    @lingfish
    Author

    Just another polite ping.

  6. ferdinandyb commented on Jul 6, 2026

    @ferdinandyb
    Contributor

    @simonklee While you're at it, I also want to note, that if you run opencode in tmux, inside neovim, opencode also assume the terminal understands tmux passthrough, but will similarly leave garbage in the neovim terminal.

  7. 99742 commented on Jul 7, 2026

    @99742

    hi there,

    i am using screen to and it is the hell with your tui

    first i had to
    export TERM=screen.xterm-256color
    because with only TERM=screen the colors are out of wack and i got black text on black ground which is pity much unreadable

    Also i have to always select while pressing the shift key, i tried setting

    export OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1

    which dosnt help at all cause the selecting is still your impelmentation and right clicks are blocked still entirely but now enable your copy routine

    i had to export OPENCODE_DISABLE_MOUSE=1 for it to work somehow, which seams to also fix the home/end key, so either make this default when you detect screen or fix your clipboard handling in screen sessions...

  8. 99742 commented on Jul 7, 2026

    @99742

    correction home/end key are still broken

  9. lingfish commented on Jul 19, 2026

    @lingfish
    Author

    Hi again @simonklee just another polite ping.

  10. lingfish commented on Aug 5, 2026

    @lingfish
    Author

    Sure would be nice to get this resolved.

  11. lingfish commented on Sep 3, 2026

    @lingfish
    Author

    This is excellent that this has been addressed in opentui, but it seems the minimum version is v0.5.4, and opencode is still building with v0.4.x ☹️

  12. simonklee commented on Sep 3, 2026

    @simonklee
    Member

    This is excellent that this has been addressed in opentui, but it seems the minimum version is v0.5.4, and opencode is still building with v0.4.x ☹️

    https://opencode.ai/v2/docs - we're releasing this soon but if you cannot wait you can get it already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions