anthropics / anthropics/claude-code

[BUG] Text copied from the Claude Code TUI and pasted into the prompt is shown on separate lines in the sent message

Open
#95,512 1 comment 1 reaction 0 assignees View on GitHub
area:tui bug has repro platform:macos
Dominant language
TypeScript
Stars
146k
Forks
23.8k
PR merge metrics
PR metrics pending

Description

## What's wrong

When a message contains text copied from the Claude Code TUI itself (for example, a phrase from an assistant reply), the sent message renders the pasted text on its own lines, with blank lines added before and after it. The prompt box shows the text inline before sending.

The session JSONL shows the cause. Each paste is stored wrapped as:

```
\n\n\n\n\n\n
```

The transcript view hides the tags but keeps the newlines around them.

This only happens with text copied out of the Claude Code TUI. Text copied from another app and pasted the same way renders inline as expected.

Also, every paste in the session gets the same id (`3940`).

## Steps to reproduce

1. Switch to fullscreen rendering with `/tui fullscreen`, if it is not already the current mode.
2. Type some text in the prompt.
3. Select and copy a phrase from an earlier assistant message in the Claude Code TUI, then paste it into the prompt.
4. Type some more text and press Enter.

**Expected:** the sent message looks the way it did in the prompt box.
**Actual:** the pasted phrase appears on separate lines, broken away from the text around it.

Example as stored in the JSONL:

```
"content":"regarding \"\n\n\nDo you want the design doc, or one of the other two routes\n\n\n\" - what \"other two routes\" are you talking about?"
```

Pasting text copied from any other app in step 3 does not reproduce the bug.

## Environment

- Claude Code 2.1.277 and 2.1.278
- TUI mode: fullscreen (`/tui fullscreen`)
- macOS 27.0
- Terminal: [Nice](https://github.com/Nick-Anderssohn/nice), a native macOS terminal. It reports `TERM_PROGRAM=ghostty`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue in fullscreen mode with /tui fullscreen, then inspect the session JSONL and the transcript view handling of pasted-content tags. Verify how TUI clipboard data differs from text copied elsewhere. Done means pasted text stays inline in the sent message and successive pastes do not reuse the same id.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.