[BUG] Text copied from Claude Code TUI doesn't cross RDP clipboard redirection; pasting into Notepad first is required
Environment
- Claude Code: 2.1.220 (issue began when the mouse-enabled TUI rolled out)
- Server: Windows Server 2025 Standard (10.0.26100), Windows Terminal, PowerShell
- Client: Windows laptop connected via Remote Desktop (mstsc) with clipboard redirection enabled
Description
Since the "mouse enabled" version of the Claude Code TUI, text copied from Claude Code running in Windows Terminal on an RDP server no longer reaches the clipboard of the RDP client machine. Pasting on the laptop yields nothing (or stale content from an earlier copy).
The copy does succeed locally on the server: pasting into Notepad on the server works. Re-copying that same text from Notepad then propagates to the laptop normally. So the round-trip workaround is: copy in Claude Code → paste into server-side Notepad → re-copy → paste on laptop.
Expected behavior
Text copied from the Claude Code TUI should behave like any other clipboard content and be picked up by RDP clipboard redirection (rdpclip), the same way a copy from Notepad or Windows Terminal's native selection is.
Suspected cause
The symptom pattern (works locally, invisible to rdpclip, fixed by laundering through Notepad; at times associated with a still-running Claude Code instance holding clipboard ownership) suggests Claude Code is placing the text on the clipboard via OLE with delayed rendering, or holding clipboard ownership in a way rdpclip cannot serialize for redirection. A plain immediate CF_UNICODETEXT set (which is what Notepad produces) redirects fine.
Steps to reproduce
- RDP from a Windows laptop into a Windows server with clipboard redirection enabled.
- On the server, run Claude Code 2.1.220 in Windows Terminal (mouse mode active).
- Select and copy text from the Claude Code TUI.
- On the laptop, try to paste → nothing / stale content.
- On the server, paste into Notepad (works), copy from Notepad, paste on the laptop → works.
What was ruled out
- Restarting
rdpclip.exeon the server and reconnecting the RDP session: no change. - Extensive general clipboard troubleshooting (assumed "bad clipboard"): no change. The failure is specific to copies originating from the Claude Code TUI.
Related issues
- #72617 (copy from TUI doesn't reach system clipboard on Windows 10 — local-only variant of this)
- #66056 (mouse reporting capturing right-click since ~2.1.167)
Showing cached comments. Read the full discussion on GitHub ↗
3 Comments
Same thing here on 2.1.220, with
"tui": "fullscreen". Windows 11 Pro 26200, Windows Terminal 1.24.11911.0. Happens with both mRemoteNG and plainmstsc.exe, so it isn't the client.Worth noting it's not just copy-on-select: I turned that off in
/configand it still fails. Any copy done by the TUI is affected, including select + Ctrl+C. The only thing that works is holding Shift while selecting, so Windows Terminal does the selection itself, then Ctrl+C. You can tell the two apart at a glance — Claude Code's selection is light blue, the terminal's own is reverse video.I dumped the native clipboard formats after each kind of copy:
UnicodeText,Locale,Text,OEMText→ pastes fine on the remoteUnicodeTextonly → never reaches the remoteThat's the same missing
CF_LOCALE/CF_OEMTEXTsignature described in #67576, so I think it's the same bug, but OpenConsole isn't sufficient to avoid it, and the fix suggested there — native clipboard writes instead of OSC 52 for local Windows sessions — looks like the right call.Ruled out before posting: restarting rdpclip in the remote session, mstsc vs mRemoteNG, server-side redirection (works fine in both directions from anything else), UIPI (nothing elevated on either side), clipboard history and cbdhsvc,
copyFormatting(already"none"), and encoding — same failure with plain ASCII and with accented text. Writing the same string from a separate process withSet-Clipboardcrosses over instantly, so the channel itself is healthy; it's specifically the TUI's clipboard write that never gets announced to the server.I got claude to write a workaround script which does the trick for me. Here is the script and additional info Claude produced:
Environment
| | |
|---|---|
| Claude Code | 2.1.222 |
| OS | Windows 11 Pro 10.0.26200 (RDP session,
mstscclient) || Terminal | Windows Terminal 1.24.11911.0 (current stable) |
| Console host |
OpenConsole.exe— Claude Code runs in a tab spawned inside WT (explorer.exe → WindowsTerminal.exe → pwsh → claude.exe) |Symptom matches this issue exactly: copy in the Claude Code TUI → paste inside the RDP session works, paste on the RDP client yields nothing. Laundering through Notepad fixes it.
Short version of the finding: the TUI's OSC 52 write ends up on the clipboard through Windows Terminal's OLE path, which adds the
DataObjectandOle Private Datacontainer formats.rdpclipthen transfers nothing at all — not even the perfectly validCF_UNICODETEXTsitting right next to them. Measurements in the last section.---
1. What would actually fix this
Use a native Win32 clipboard write on local Windows sessions instead of OSC 52. This was already suggested in #67576 and it is the real fix: OSC 52 is only needed when the clipboard is remote (SSH). A direct
OpenClipboard/EmptyClipboard/SetClipboardData(CF_UNICODETEXT, …)produces exactly the format set thatrdpcliptransfers without complaint — verified below, that is precisely what makes the Notepad workaround work.Worth noting this is not fixable on the Windows Terminal side any time soon: WT's
mainhas already been rewritten to raw Win32 clipboard calls, but microsoft/terminal#16715 is still in the Backlog milestone and the change is not in any shipped release — I updated to current stable 1.24.11911.0 specifically to test this, and the OLE formats are unchanged. So as long as Claude Code goes through OSC 52, users on RDP stay broken regardless of what they update.Secondary, but it makes things measurably worse: stop re-emitting the same clipboard write on every re-render (#41954). Each write forces
rdpclipinto a fresh negotiation, and a second write arriving mid-negotiation is what turns a recoverable situation into "nothing arrives at all" (see section 3.2).2. Workaround
Watches for the OLE formats and rewrites the clipboard as plain text. Must run under PowerShell 7 — Windows PowerShell 5.1's
Set-ClipboardusesClipboard.SetDataObjectinternally and re-creates the very OLE formats it is supposed to remove.Four constraints, each hit the hard way — worth knowing before anyone writes their own version:
Get-Clipboard. That holds the clipboard open continuously and blocksrdpclipfrom retrieving it — with polling, the client paste fails even though the resulting formats are clean.GetClipboardSequenceNumber()detects changes without opening the clipboard.Practical cost: wait ~3 s after copying before pasting on the client.
3. Measurements
3.1 Clipboard formats
Enumerated with
OpenClipboard(NULL)+EnumClipboardFormats+GetClipboardFormatNameimmediately after each copy.After a Claude Code TUI copy (does NOT reach the RDP client):
After
Set-Clipboardin PowerShell 7, same text (DOES reach the RDP client):This differs from the fingerprint in #67576 (conhost path,
CF_UNICODETEXTonly, noCF_LOCALE/CF_OEMTEXT). Here all four text formats are present and correctly rendered — no delayed rendering, no live owner. The only difference is the two OLE container formats, consistent with a WinRTDataPackagewrite going through OLE.Relevant background: the RDP clipboard service excludes OLE formats by design and only transfers
IDataObject-rendered formats of typeTYMED_HGLOBAL— MS docs. That documents the filtering; it does not explain why the plain text alongside it is dropped too.3.2 Timing matters
This took the longest to isolate, so it may save someone else the detour:
Interpretation:
rdpclipappears to process the first (OLE) clipboard change, fail on it, and coalesce or drop the second change arriving while it is still negotiating. Waiting ~1.5 s before rewriting, then rewriting once more after another ~1.5 s, works reliably. This is inferred from behaviour, not fromrdpclipinternals.3.3 Ruled out by testing
rdpclip.exe— no lasting effect."copyFormatting": "none"in Windows Terminal — affects HTML/RTF only, not the OLE containers.OpenConsolevs delegatedconhostdistinction from #67576 — already on the "good" side of it and still affected, so this is a separate failure mode.same issue here.. i workaround by holding shift before dragging by mouse to copy, but this prevented me from using other tools like herdr cause it would copy left pane with queries