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

オープン
#94,293 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
area:tui bug has repro platform:macos
主要言語
Python
スター
145k
フォーク
23.1k
PR マージ指標
PR 指標を取得中

説明

### 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)

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。