[BUG] CPR Response Leak into Subprocess Input Buffer
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?
Claude Code's TUI layer sends ANSI Cursor Position Report (CPR) queries (\x1b[6n) but fails to consume the terminal's responses. The CPR responses ([47;6R) leak into subprocess stdin during command execution, polluting the input buffer with repeated escape sequences.
<img width="958" height="442" alt="Image" src="https://github.com/user-attachments/assets/3fabcbf9-3698-4303-84dc-bad8983e833d" />
This renders terminal input unusable during and after command execution. The issue reproduces across all terminal emulators (Alacritty, Konsole, Zed integrated terminal), indicating an application-level bug rather than terminal-specific behavior.
What Should Happen?
CPR responses should be consumed by Claude Code's terminal event loop before spawning subprocesses. The responses should never leak into user input buffers or subprocess stdin.
Error Messages/Logs
No error message displayed. Instead, terminal input buffer receives repeated CPR response sequences:
[47;6R[47;6R[47;6R[47;6R[47;6R...
The "47;6" indicates cursor position at row 47, column 6 - consistent with Claude Code's status bar region.
Steps to Reproduce
Context
- Project: LevitateOS (Linux distribution builder)
- Goal: Create automated test command that rebuilds initramfs, boots VM, runs tests, returns results
Steps Performed
- Created test script crates/builder/src/builder/initramfs/scripts/levitate-test
- Pure POSIX shell script to test installed components
- Uses case pattern matching (no grep) for brush shell compatibility
- Added script to initramfs build in crates/builder/src/builder/initramfs.rs
- Added copy_test_script() function
- Script gets copied to /bin/levitate-test
- Created cargo xtask test quick command in xtask/src/test/mod.rs
- Added Quick variant to TestCommand enum
- Implemented run_quick_test() function
- First test run failed - brush shell errors on serial console:
ERROR error: input error occurred: The cursor position could not be read within a normal duration
- Brush sends [6n (cursor position query) and times out waiting for response.
- Attempted fix: Changed kernel cmdline to use systemd.unit=rescue.target
- Modified xtask/src/test/helpers.rs line ~63
- Changed from: console=ttyS0 rw quiet TERM=dumb
- Changed to: console=ttyS0 rw quiet systemd.unit=rescue.target
- Updated run_quick_test() to skip login flow (rescue.target should give root shell directly)
- Second test run - Currently hanging at "Waiting for shell..."
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.5
Claude Code Version
2.1.7 (Claude Code)
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
Other
Additional Information
OS: Ultramarine (Fedora 43 KDE Plasma)
Terminal: Alacritty, Konsole, Ghostly, Wezterm
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗