[Bug] XTVERSION query (ESC[>0q) echoed as visible text on older VTE-based terminals
Bug Description
When Claude Code starts in gnome-terminal (VTE 0.52.4, CentOS 8 / RHEL 8), the XTVERSION query escape sequence is echoed as visible garbled text [>0q in the terminal. After Claude Code exits, a DA1 response fragment 62;c may also appear.
This does not happen when running inside tmux, because tmux intercepts and handles the XTVERSION query before it reaches the underlying terminal.
Root Cause
Claude Code unconditionally sends an XTVERSION query (ESC[>0q) during terminal initialization when raw mode is first enabled:
// from cli.mjs (minified)
function ZPD() {
return { request: pK(">0q"), match: (H) => H.type === "xtversion" }
}
Old VTE versions (< 0.68) do not recognize XTVERSION and echo the raw escape sequence as visible text instead of silently ignoring it. VTE 0.68+ fixed this behavior.
The query is sent unconditionally — there is no check for VTE_VERSION, TERM_PROGRAM, or any environment variable before sending.
Steps to Reproduce
- Open gnome-terminal on CentOS 8 / RHEL 8 (VTE 0.52.4)
- Run
claude - Observe
[>0qprinted at the top of the terminal - Exit Claude Code —
62;cmay appear
Expected Behavior
No visible escape sequence artifacts in the terminal.
Workaround
Run Claude Code inside tmux or screen, which intercept the XTVERSION query.
Proposed Fix
Before sending the XTVERSION query, check the VTE_VERSION environment variable (set by all VTE-based terminals). If VTE_VERSION is present and the version is below 6800 (0.68.0), skip the XTVERSION query:
const vteVersion = parseInt(process.env.VTE_VERSION, 10);
if (!process.env.VTE_VERSION || isNaN(vteVersion) || vteVersion >= 6800) {
// safe to send XTVERSION
await this.querier.send(ZPD());
}
Alternatively, provide an environment variable (e.g., CLAUDE_CODE_NO_XTVERSION=1) to let users opt out of the query on problematic terminals.
Environment Info
- OS: CentOS 8.5 (RHEL 8), Linux 4.18.0
- Terminal: gnome-terminal 3.28.3 (VTE 0.52.4)
- Claude Code: v2.1.74
- Shell: tcsh
- tmux: works correctly (no garbled output)
Affected Terminals
Any VTE-based terminal with VTE < 0.68, including:
- gnome-terminal on CentOS 7/8, RHEL 7/8, Ubuntu 18.04/20.04
- Terminator, Tilix, Guake on older distros
- xfce4-terminal on older distros
This affects a significant number of enterprise Linux users on RHEL/CentOS 7/8 where system packages are not updated to newer VTE versions.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗