[BUG] /memory UI corrupted by terminal focus escape sequences on macOS
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Bug Description
When using Claude Code on macOS, the /memory interactive menu renders corrupted text when selecting item 2 ("Project memory").
Instead of:
2. Project memory ✔
It becomes:
^[[O^[[Iject memory ✔
The escape sequences ^[[O and ^[[I are printed directly into the UI.
---
Reproduction Steps
- Launch Claude Code
- Run:
/memory
- Select item 2 (
Project memory)
The corruption happens every time.
---
Expected Behavior
The menu should render:
2. Project memory ✔
without any escape sequences.
---
Actual Behavior
UI becomes corrupted:
^[[O^[[Iject memory ✔
Looks like terminal focus escape sequences are leaking into the render buffer.
---
Environment
- OS: macOS
- Claude Code: latest (updated daily)
- Reproduces on multiple terminals:
- Ghostty
- iTerm2
- macOS Terminal
Environment checks:
TERM=xterm-256color
Shell state is normal:
sttynormal (icanon,echo)bindkeynormal- not using tmux/zellij
This suggests the bug is likely inside Claude Code’s TUI handling rather than terminal configuration.
---
Additional Notes
The escape sequences appear to match terminal focus events:
CSI I→ FocusInCSI O→ FocusOut
Possibly related to focus reporting not being filtered in the /memory interactive UI.
What Should Happen?
type /memory
Error Messages/Logs
/memory
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Memory
Auto-memory: on
1. User memory Saved in ~/.claude/CLAUDE.md
^[[O^[[Iject memory ✔ Checked in at ./CLAUDE.md
3. Open auto-memory folder
Learn more: https://code.claude.com/docs/en/memory
Steps to Reproduce
/memory
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Memory
Auto-memory: on
- User memory Saved in ~/.claude/CLAUDE.md
^[[O^[[Iject memory ✔ Checked in at ./CLAUDE.md
- Open auto-memory folder
Learn more: https://code.claude.com/docs/en/memory
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.178 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_