anthropics / anthropics/claude-code

Fullscreen: Cmd+C copy never reaches Claude Code on iTerm2 because CSI >4;2m after the kitty push resets iTerm2's key-reporting flags

Open
#94,293 0 comments 0 reactions 0 assignees View on GitHub
area:tui bug has repro platform:macos
Dominant language
Python
Stars
145k
Forks
23.1k
PR merge metrics
PR metrics pending

Description

### Preflight Checklist
- [x] I have searched existing issues and this is not a duplicate
- [x] I am on the latest version of Claude Code (2.1.270)
- [x] This is a bug report, not a question

### What's Wrong?

In fullscreen mode on iTerm2, `Cmd+C` on an in-app text selection does nothing. `Ctrl+C` and `Ctrl+Shift+C` copy fine. The docs say `Cmd+c` works on iTerm2 (fullscreen.md, "Use the mouse").

Root cause: Claude Code enables the kitty keyboard protocol with `CSI >5u` and immediately follows it with `CSI >4;2m` (xterm modifyOtherKeys). iTerm2 deliberately treats any `CSI > 4 ; n m` as a reset of the kitty key-reporting stack: `VT100CSI_SET_MODIFIERS` in `sources/VT100/VT100Terminal.m` sets `_keyReportingFlags = 0` and calls `removeAllObjects` on the current stack (comment in source: "CSI m will nuke the stack and CSI u will respect it"). Same code on iTerm2 master. So Claude Code's own next byte wipes the kitty mode it just enabled, iTerm2 stays on its legacy key mapper, and the legacy mapper hands every Cmd combo to the menu bar instead of the app (`iTermStandardKeyMapper.keyMapperWantsKeyEquivalent` returns `!cmdPressed`).

Captured Claude Code startup output on iTerm2 (pty capture, fullscreen):

```
ESC[?1049h ESC[5u ESC[>4;2m ESC[?1000h ... ESC[5u ESC[>4;2m ... ESC[?u
```

iTerm2's reply to that `ESC[?u` query is `ESC[?0u` (flags = 0).

### What Should Happen?

`Cmd+C` should copy the selection (the `cmd+c` → `selection:copy` default binding in the Scroll context), as documented for kitty-protocol terminals including iTerm2.

Suggested fix: send `CSI >4;2m` *before* the kitty push, or skip it when the terminal is on the kitty allowlist / the `kittyKeyboard` reading has settled true. modifyOtherKeys adds nothing once kitty flags are active.

### Error Messages/Logs

None. Key never reaches Claude Code.

### Steps to Reproduce

Environment: macOS, iTerm2 3.7.1, profile with Keys → General → Left/Right Command set to "Super" (required for iTerm2 to report Cmd at all), "Apps can change how keys are reported" on (default).

1. Prove iTerm2 forwards Cmd as Super when only kitty is enabled. In a shell:
```
printf '\e[>5u'; cat -v; printf '\e[5u\e[>4;2m\e[?u'; sleep 1; echo; printf '\e[4;2m` it prints `^[[?5u`.
3. Run `claude` with `"tui": "fullscreen"`, drag-select text, press `Cmd+C`. Nothing happens; iTerm2's Edit menu does not flash either (Copy is disabled with no native selection). `Ctrl+C` copies.

### Is this a regression?

Unknown, not tested on older versions.

### Claude Code Version

2.1.270 (macOS arm64, native binary)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the fullscreen terminal initialization that emits the kitty keyboard and modifyOtherKeys escape sequences, then compare their ordering with the iTerm2 behavior described here. Use the provided shell reproduction commands and verify against fullscreen.md; done means Cmd+C copies an in-app selection on iTerm2 without breaking Ctrl+C or Ctrl+Shift+C.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.