Skip to content

fix(ui): don't probe for kitty graphics under tmux - #3525

Open
olifarhaan wants to merge 1 commit into
charmbracelet:mainfrom
olifarhaan:fix-tmux-kitty-probe
Open

fix(ui): don't probe for kitty graphics under tmux#3525
olifarhaan wants to merge 1 commit into
charmbracelet:mainfrom
olifarhaan:fix-tmux-kitty-probe

Conversation

@olifarhaan

@olifarhaan olifarhaan commented Aug 8, 2026

Copy link
Copy Markdown

What

Running crush inside tmux under kitty types Gi=31;OK into the editor on startup. That string is crush's own capability probe coming back at it

Why it happened

QueryCmd (capabilities.go:91) sends the kitty graphics query wrapped in tmux passthrough, so the outer terminal answers with \x1b_Gi=31;OK\x1b\. tmux's key parser has no APC branch, so unless the whole reply lands in a single read it degrades into Alt+_, the printable run Gi=31;OK, and Alt+\, and the printables reach the pane as keystrokes. shouldQueryCapabilities returns true for tmux, so the probe goes out in the first place

Fix

Skip the kitty graphics query in QueryCmd when TMUX is set. XTVERSION and the pixel-size query still go out, since tmux answers those itself

Closes #3500

Proof

Ran crush inside tmux on a pty, then played back the exact reply kitty sends. The harness only injects a reply if crush actually asked, matching what a real terminal does:

$ python3 repro_3500.py ./crush-main          # v0.88.1
crush emitted the kitty graphics probe through tmux : True
prompt before kitty's reply                         : '> Ready...'
prompt after kitty's reply                          : '> Gi=31;OK'
verdict                                             : REPRODUCED

$ python3 repro_3500.py ./crush-patched
crush emitted the kitty graphics probe through tmux : False
prompt before kitty's reply                         : '> Ready?'
prompt after kitty's reply                          : '> Ready?'
verdict                                             : clean

Script: https://gist.github.com/olifarhaan/0fafcd38a80a0c2f4786a7dab603ef36

By hand, on kitty: tmux new-session crush, and the prompt reads Gi=31;OK before this change and stays empty after

Tests

TestQueryCmdSkipsKittyGraphicsUnderTmux fails on main:

"...\x1bPtmux;\x1b\x1b_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA\x1b\x1b\\\x1b\\" should not contain "_Gi=31"

go test -race ./internal/ui/... and golangci-lint v2.11 both clean

@charmcli

charmcli commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@olifarhaan

Copy link
Copy Markdown
Author

I have read the Contributor License Agreement (CLA) and hereby sign the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kitty graphics capability probe leaks "Gi=31;OK" into the input field when running inside tmux

2 participants