claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[Bug] Terminal Escape Sequences Incorrectly Rendered in Prompt

Open kylesnowschwartz opened this issue 4 months ago • 8 comments

Bug Description On the current version, I'm getting some terminal escape sequences in the prompt command line.

Image

*Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 2.0.13
  • Feedback ID: 01d1eaef-d46c-4395-b2e3-1ab43c914576

Errors

[{"error":"AxiosError: Request failed with status code 500\n    at iM (file:///Users/kyle/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:24:1136)\n    at IncomingMessage.<anonymous> (file:///Users/kyle/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:29:9845)\n    at IncomingMessage.emit (node:events:519:35)\n    at IncomingMessage.emit (node:domain:489:12)\n    at endReadableNT (node:internal/streams/readable:1696:12)\n    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)\n    at t51.request (file:///Users/kyle/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:31:2129)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async Zb6 (file:///Users/kyle/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1742:26948)\n    at async Au1 (file:///Users/kyle/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1742:26678)","timestamp":"2025-10-09T21:13:39.454Z"},{"error":"AxiosError: Request failed with status code 500\n    at iM (file:///Users/kyle/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:24:1136)\n    at IncomingMessage.<anonymous> (file:///Users/kyle/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:29:9845)\n    at IncomingMessage.emit (node:events:519:35)\n    at IncomingMessage.emit (node:domain:489:12)\n    at endReadableNT (node:internal/streams/readable:1696:12)\n    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)\n    at t51.request (file:///Users/kyle/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:31:2129)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async $j1 (file:///Users/kyle/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:424:15727)\n    at async VX8 (file:///Users/kyle/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:2706:24200)","timestamp":"2025-10-09T21:13:42.493Z"}]

kylesnowschwartz avatar Oct 09 '25 21:10 kylesnowschwartz

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/5679
  2. https://github.com/anthropics/claude-code/issues/8376
  3. https://github.com/anthropics/claude-code/issues/6635

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Oct 09 '25 21:10 github-actions[bot]

Seems to be occurring as I move from pane to pane or between tabs in Iterm2 (using cmd+ as shortcuts)

kylesnowschwartz avatar Oct 09 '25 21:10 kylesnowschwartz

I closed #10202 as a duplicate of this issue. One detail there that I'd add here: I can get into this state readily by using ctrl + g to edit my prompt in VS Code.

ryangreenberg avatar Oct 24 '25 13:10 ryangreenberg

This issue is annoying the hell out of me. I spent the past hour trying to fix it, my findings:

  • The issue happens even with an empty .zshrc file
  • It happens in multiple terminals (Kitty, Terminal.app)
  • It happens with and without tmux
  • The only way I could "fix" it was to place this wonk at the bottom of my .zshrc:
{
  while sleep 0.2; do
    printf '\e[?1004l' 2>/dev/null
  done
} &!

Claude Code appears to enable focus reporting mode (\e[?1004h) and never disables it. A terrible workaround: continuous background process running printf '\e[?1004l'

timtyrrell avatar Nov 06 '25 23:11 timtyrrell

Lol - that is a gross workaround. Why does it work? I too and very annoyed by the persistence of this issue. Occasionally it feels less obvious - but then it comes back.

kylesnowschwartz avatar Nov 07 '25 03:11 kylesnowschwartz

I only encounter this when launching vim via ctrl+g.

On Terminal.app, reset fixes it: ⌥ ⌘ R or menu option ShellReset

ibejoeb avatar Nov 26 '25 01:11 ibejoeb

If anyone else runs into this problem with iTerm2, I found a setting that appears to prevent it. I assume the focus reporting is actually used for something (notifications when prompts appear maybe?), so there's probably a tradeoff there.

Image

Note: This will only take effect in a new terminal session (e.g. a tab or window, not a Claude Code session), because focus reporting will already have been turned on. You can manually turn it off for the current session with Session -> Terminal State -> Focus Reporting

rob-odwyer avatar Dec 04 '25 17:12 rob-odwyer

I get it every session. GhosTTY with VSCode as IDE (non-plugin).

gn0rt0n avatar Dec 10 '25 22:12 gn0rt0n