Repository navigation
fix(terminal): stop Ctrl+Enter leaking CSI-u without kitty keyboard - #12331
ShreyanshVaibhaw wants to merge 1 commit into
Conversation
Ctrl+Enter always emitted `\x1b[13;5u`. CSI-u is application input that only
reads as a chord while the kitty keyboard protocol is negotiated; on a local
Windows ConPTY pane it is not, so the TUI printed the escape and `[13;5u`
landed in the prompt.
Shift+Enter already guards its CSI-u emission and falls back. Ctrl+Enter did
not, and its comment acknowledged the gap ("no Windows fallback yet").
Gate the sequence on active kitty keyboard and otherwise send the bare CR
xterm.js would have collapsed the chord to, which restores the pre-existing
default rather than inventing an encoding.
This narrows Ctrl+Enter behavior where the chord was never being delivered
anyway, so the rewritten test replaces an assertion that assumed no TUI
treats the CSI-u Ctrl+Enter form as inert. stablyai#12329 is a counter-example.
Fixes stablyai#12329
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughCtrl+Enter now emits 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks @ShreyanshVaibhaw — independently reproduced and confirmed your diagnosis is exactly right. I built a fix before seeing this PR and we converged on the identical source change (gate on Real-host confirmation on a Windows 11 local ConPTY pane (Git Bash), writing exactly the bytes the policy emitted: So the escape really does arrive as literal application input, as you described. With the fallback byte the same prompt executes cleanly. One gap worth flagging: this PR updates the unit test but not the two e2e specs that still pin the old bytes — I've opened #12462 with the same fix plus those e2e updates, a test for the dashboard-popout preview call site (which shares the policy), a platform × kitty-state matrix, and the real-host evidence above. Full credit to you for the find and the diagnosis — it's cited in the PR body. |
|
Duplicate of #12462 (fixes #12329). Same root cause and intended fix: stop Ctrl+Enter from emitting kitty CSI-u into ConPTY when the pane has not negotiated kitty keyboard. Please continue review/landing on #12462. If this branch has a meaningfully different implementation detail worth cherry-picking, call it out on #12462. |
Summary
Fixes #12329.
Pressing Ctrl+Enter in a local Windows ConPTY pane inserted the literal text
[13;5uinto the prompt instead of delivering the chord.Ctrl+Enter emitted the kitty CSI-u sequence unconditionally:
CSI-u is application input. It only reads as a chord while the kitty keyboard protocol is negotiated for that pane, and on a local Windows ConPTY pane it is not, so the TUI printed the escape verbatim.
Shift+Enter, three lines above, already guards exactly this and falls back to
\x1b\r:Ctrl+Enter had no such guard, and its own comment acknowledged the gap: "no Windows fallback yet (#2418)".
This gates the sequence on active kitty keyboard and otherwise sends the bare CR that xterm.js would have collapsed Ctrl+Enter to. That restores the pre-existing default rather than inventing an encoding, and matches the fallback the reporter validated locally.
Behavior change worth reviewing
The rewritten test replaces an assertion that documented the opposite assumption:
#12329 is the counter-example, with Codex 0.146.0 on ConPTY. So this is a deliberate reversal, not an oversight being patched. It narrows Ctrl+Enter only where the chord was never being delivered anyway: with kitty keyboard active the CSI-u path is unchanged.
I used
isKittyKeyboardActivePanealone rather than also reusing Shift+Enter'sgetWindowsShiftEnterEncodingsignal. That setting is specifically about the Shift+Enter encoding, and borrowing it to authorize a different chord would couple two unrelated decisions.Screenshots
No visual change.
Testing
pnpm lint(one pre-existing unrelated failure, see Notes)pnpm typecheckpnpm test(full suite does not pass on this machine before or after, see Notes)pnpm build(not run locally)Added regression tests
src/renderer/src/components/terminal-pane/: 2887 passed, 218 files, 0 failedNew
sends a bare CR for Ctrl+Enter when kitty keyboard is not activecovers Windows, non-Windows, and the unset-callback case.The existing CSI-u expectation is kept for the kitty-active path on both platforms, so the chord is still pinned where it works.
Confirmed to fail against the previous implementation: reverting the source fails exactly the new case and nothing else.
Verification caveat
I do not have Codex on a Korean IME Windows setup and did not reproduce the literal
[13;5ufirst-hand. The diagnosis in #12329 is unusually precise (the reporter located the branch in the shipped renderer bundle and validated a fallback locally), and it matches the source exactly. Verified here by tests rather than by observation.AI Review Report
Reviewed with Claude. Risks checked:
getWindowsShiftEnterEncodingtrusted-Windows path.\rrather than Shift+Enter's\x1b\r: alt-enter means newline, whereas Ctrl+Enter collapsing to CR is the documented pre-interception xterm.js behavior, so CR is the conservative restore.resolveTerminalShortcutActionpositionally with 5 args and could not reach the 8th parameter. The test now uses a small helper so the kitty callback is actually exercised instead of leftundefinedin every case.Security Audit
Notes
pnpm lintfails atverify:skill-bundle-manifestwith staleresources/skills/*.json. Reproduces on a cleanmain, so it is not introduced here, and those are generated artifacts I did not want to churn.pnpm testandpnpm buildnot completed locally. A cleanmainon this Windows machine fails 167 tests across 57 files, so a green local suite is not achievable either way. The affected area is fully green.[13;5uleak.