Skip to content

fix(terminal): stop leaking Shift+Enter CSI-u without Kitty handshake - #8386

Closed
bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/grok-shift-enter-csi-u-leak
Closed

bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/grok-shift-enter-csi-u-leak

Conversation

@bbingz

@bbingz bbingz commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Stop sending Shift+Enter as Kitty CSI-u (\x1b[13;2u) on macOS/Linux when the pane has not enabled Kitty keyboard — that path leaked as literal [13;2u (user-visible garble, especially in Grok).
  • Same gate for Ctrl+Enter CSI-u (\x1b[13;5u).
  • Mark trusted Grok on Windows as CSI-u Shift+Enter (same as Droid) so newline works when KKP is active.

Closes #8385.

Screenshots

No visual design change. Before: Shift+Enter without KKP could paint [13;2u into the Grok composer. After: Esc+CR until KKP is active, then CSI-u.

Testing

  • pnpm lint
  • pnpm typecheck
  • Focused Vitest: terminal-shortcut-policy.test.ts + terminal-windows-shift-enter.test.ts (42/42)
  • pnpm build
  • Added regression coverage for inactive-KKP Shift+Enter → Esc+CR, Ctrl+Enter gate, and trusted Grok CSI-u encoding
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/terminal-shortcut-policy.test.ts src/renderer/src/components/terminal-pane/terminal-windows-shift-enter.test.ts

AI Review Report

Reviewed against Grok-only, local macOS/Windows, terminal-TUI (not Native Chat). Confirmed the leaked text matches CSI-u Shift+Enter. Windows agent-declared CSI-u for Droid remains unconditional (#7620). Grok gets the same Windows declaration so trusted Grok newlines match its KKP path from #7944. Remote/SSH Windows clients still use Esc+CR when ConPTY classification is not local.

Security Audit

No new IPC, filesystem, network, auth, secrets, or dependency surface. Only changes which already-trusted key chord bytes are written to an open PTY.

Unconditional CSI-u on macOS/Linux injected literal `[13;2u` when the
app had not enabled Kitty keyboard. Gate CSI-u on active KKP flags,
keep Windows agent-declared CSI-u for Droid/Grok, and avoid Ctrl+Enter
CSI-u without the handshake.
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9897b212-33eb-46dc-ab61-1f3d74325ede

📥 Commits

Reviewing files that changed from the base of the PR and between 26934b1 and 7169052.

📒 Files selected for processing (4)
  • src/renderer/src/components/terminal-pane/terminal-shortcut-policy.test.ts
  • src/renderer/src/components/terminal-pane/terminal-shortcut-policy.ts
  • src/renderer/src/components/terminal-pane/terminal-windows-shift-enter.test.ts
  • src/shared/tui-agent-config.ts

📝 Walkthrough

Walkthrough

Windows Shift+Enter encoding now supports CSI-u for trusted Grok process evidence. Shortcut resolution gates non-local Windows CSI-u behavior on kitty keyboard activity, falling back to alt-enter when inactive. Ctrl+Enter now returns no action when kitty is inactive and emits CSI-u when active. Tests were updated and expanded to cover these conditions across Windows encodings and shortcut forwarding paths.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: preventing Shift+Enter CSI-u leakage without Kitty handshake.
Description check ✅ Passed The description covers summary, screenshots, testing, AI review, and security audit, and is mostly complete per the template.
Linked Issues check ✅ Passed The changes implement the requested KKP gating for Shift+Enter and Ctrl+Enter and add trusted Grok Windows CSI-u support.
Out of Scope Changes check ✅ Passed The PR stays focused on terminal shortcut handling, associated config, and regression tests with no clear unrelated changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker

Copy link
Copy Markdown
Contributor

Superseded by #8427, now merged. That fix keeps the live Kitty-state gate for off-Windows Shift+Enter, adds Electron inactive/active/reset coverage, and preserves existing Ctrl+Enter plus Droid-only Windows routing after real Grok 0.2.93 verification showed the broader changes here could regress those paths. Thanks for identifying the core CSI-u leak.

@nwparker nwparker closed this Jul 12, 2026
@bbingz
bbingz deleted the fix/grok-shift-enter-csi-u-leak branch August 1, 2026 00:47
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.

[Bug]: Grok terminal shows literal [13;2u (Shift+Enter CSI-u leak) and long-output garble

3 participants