GeezerVison is showing github.com — Copying text causes the WSL GUI program window to disappear. · Issue #66978 · anomalyco/opencode
Copying text causes the WSL GUI program window to disappear. #66978DescriptionDescription
When using the latest version of opencode 2.x in WSL, after selected text is automatically copied, GUI programs opened in WSL may have their windows disappear (currently using Android Studio), and you must end the process and restart it to recover. Setting it to manual copy still has the same problem, but using opencode 1.x does not have this issue.
Plugins
No response
OpenCode version
2.4.2
Steps to reproduce
No response
Screenshot
No response
Operating System
Windows 11
Terminal
PowerShell 7.7 Activityopencodejr commented on Nov 28, 2026 Thanks for the report. Reproducing this needs Windows 11 with WSL2 and WSLg running a Linux GUI app, and we can't set that up in our automated environment, so a maintainer with a WSL setup will need to look at it.
In the meantime, these details would help:
- Which clipboard tools are installed in your WSL distro, if any (
wl-copy, xclip, xsel), and the output of echo $WAYLAND_DISPLAY $DISPLAY.
- Whether it also happens on an earlier 2.x release, for example
2.3.2. That would tell us whether it started with 2.4.x.
- Whether other WSLg apps (e.g.
gedit or xeyes) lose their windows too, or only Android Studio.
You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done editing.
Related: #65913 (on v2.4.1 in WSL2, selected text shows "Copied to clipboard" but can't be pasted).
fanyzp commented on Nov 28, 2026 hey, thanks for the report. i looked into this and your report is plausible, though i couldn't reproduce the disappearing window itself, no wsl gui setup here to test against.
what i verified: in 2.x every copy writes to the native host clipboard through opentui on top of osc 52. that host write talks to the wslg compositor, whose clipboard is shared with every gui app on the desktop. wslg's weston has a documented problem with background clipboard access stealing keyboard focus (microsoft/wslg#1512), and the same host write is already known to report success without ever reaching the windows clipboard (#65913). osc 52 alone can't hide another app's window, so the host write is the only opencode action that could be doing this, which also fits 1.x being fine.
i put up a fix that skips the host clipboard write on wsl and copies through the terminal (osc 52) only, so copying no longer touches the compositor at all. the branch is pushed but i couldn't open the pr from here, so the diff is at dev...fanyzp:fix-wsl-clipboard
two things that would settle whether this is opencode or wslg: does the android studio window come back with alt+tab, or is it gone until you kill the process? and does /mnt/wslg/weston.log show anything from right after it happens? if the window is gone for good and weston logged a crash, that's a wslg bug opencode can only avoid triggering, which is what the fix does. codemao852 commented on Nov 28, 2026 I found microsoft/weston-mirror#175 merge request in the Microsoft Weston repository. After I merged it and rebuilt WSLg and tested it, the issue still persists. However, when I switched back to opencode 1.x, the problem disappeared. I also tested mimocode, which is developed based on opencode 1.x, and there was still no problem. Regarding what you mentioned about switching windows with Alt+Tab, I tested that too, and it had no effect. At this point, it can basically be confirmed that this is a problem with opencode 2.x. WSL is the latest version 3.0.5. It doesn't cause the GUI window to disappear every time, but it happens quite frequently, so I have no choice but to roll back to opencode 1.x. I hope this can be fixed as soon as possible. Thank you.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|