Prefer terminal clipboard writes in VS Code dev containers (#63740)

## Why

A native clipboard write inside a dev container can succeed on the
container's desktop while leaving the host clipboard unchanged.

## What changed

Detect VS Code dev containers with `REMOTE_CONTAINERS=true` and route
clipboard copies through tmux or OSC 52. On Linux with a nonempty
`WAYLAND_DISPLAY`, use the native clipboard for copies over the
100,000-byte terminal limit and retain clipboard ownership.

Host delivery remains unconfirmed on both paths. The copy status asks
users to try pasting and points them to `/export` if the text is missing.
Keep that status out of exported transcripts.

## Testing

Add coverage for dev container detection, terminal send success and
failure, and clipboard ownership at the terminal size limit and one
byte over it.

GitOrigin-RevId: 057f7956fce8a16c8a3022b697e443b524740376
This commit is contained in:
Eric Traut
2026-11-24 20:50:04 +00:00
committed by copyberry
parent 32f77f824d
commit 39f38dcfab
10 changed files with 161 additions and 31 deletions
+2 -1
View File
@@ -257,12 +257,13 @@ fn render_markdown_transcript(cells: &[Arc<dyn HistoryCell>]) -> Result<String,
[
"• Saved conversation to ",
"• Copied conversation to clipboard",
"• Copy unconfirmed; /export saves chat",
"■ Export failed: ",
"■ Copy failed: ",
]
.iter()
.any(|prefix| text.starts_with(prefix))
|| text.strip_prefix("• ")
== Some(crate::clipboard_copy::UNCONFIRMED_COPY_MESSAGE)
})
{
continue;
@@ -50,7 +50,7 @@ fn markdown_transcript_preserves_messages_and_formats_activity() {
"■ Export failed: missing parent".into(),
])),
Arc::new(PlainHistoryCell::new(vec![
"• Copy unconfirmed; /export saves chat".into(),
"• Try pasting. If the text isn’t there, use /export to save the chat.".into(),
])),
user("", vec!["image.png".into()]),
user("[Image #1] describe this", vec!["image.png".into()]),