Disable Kitty keyboard on local Windows terminals

This commit is contained in:
Neil
2026-05-22 00:22:51 -07:00
parent 81fcfea965
commit 4a8a48fdf4
3 changed files with 58 additions and 0 deletions
@@ -0,0 +1,40 @@
import { describe, expect, it } from 'vitest'
import { shouldDisableKittyKeyboardForTerminal } from './terminal-keyboard-protocol'
describe('shouldDisableKittyKeyboardForTerminal', () => {
it('disables Kitty keyboard for local Windows terminals', () => {
expect(
shouldDisableKittyKeyboardForTerminal({
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
connectionId: null
})
).toBe(true)
})
it('keeps Kitty keyboard enabled for SSH terminals from Windows clients', () => {
expect(
shouldDisableKittyKeyboardForTerminal({
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
connectionId: 'ssh-target-1'
})
).toBe(false)
})
it('keeps Kitty keyboard enabled on non-Windows clients', () => {
expect(
shouldDisableKittyKeyboardForTerminal({
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)',
connectionId: null
})
).toBe(false)
})
it('keeps Kitty keyboard enabled until connection state is known', () => {
expect(
shouldDisableKittyKeyboardForTerminal({
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
connectionId: undefined
})
).toBe(false)
})
})
@@ -0,0 +1,9 @@
export function shouldDisableKittyKeyboardForTerminal(args: {
userAgent: string
connectionId: string | null | undefined
}): boolean {
// Why: Windows local PTYs run through ConPTY, where some native CLIs do not
// handle xterm's Kitty-enhanced key sequences. SSH terminals keep the
// enhanced protocol for remotes that understand it.
return args.userAgent.includes('Windows') && args.connectionId === null
}
@@ -51,6 +51,7 @@ import {
isPrimarySelectionEnabled,
setPrimarySelectionText
} from '@/lib/primary-selection'
import { getConnectionId } from '@/lib/connection-context'
import {
SPLIT_TERMINAL_PANE_EVENT,
CLOSE_TERMINAL_PANE_EVENT,
@@ -58,6 +59,7 @@ import {
type CloseTerminalPaneDetail
} from '@/constants/terminal'
import { acquireWebviewsDragPassthrough } from '../browser-pane/webview-registry'
import { shouldDisableKittyKeyboardForTerminal } from './terminal-keyboard-protocol'
type UseTerminalPaneLifecycleDeps = {
tabId: string
@@ -795,6 +797,10 @@ export function useTerminalPaneLifecycle({
const currentSettings = settingsRef.current
const terminalFontWeights = resolveTerminalFontWeights(currentSettings?.terminalFontWeight)
const cursorStyle = currentSettings?.terminalCursorStyle ?? 'bar'
const disableKittyKeyboard = shouldDisableKittyKeyboardForTerminal({
userAgent: navigator.userAgent,
connectionId: getConnectionId(worktreeId)
})
return {
fontSize: currentSettings?.terminalFontSize ?? 14,
fontFamily: buildFontFamily(currentSettings?.terminalFontFamily ?? ''),
@@ -811,6 +817,9 @@ export function useTerminalPaneLifecycle({
cursorInactiveStyle: resolveTerminalCursorInactiveStyle(cursorStyle),
cursorBlink: currentSettings?.terminalCursorBlink ?? true,
macOptionIsMeta: effectiveMacOptionAsAltRef.current === 'true',
vtExtensions: {
kittyKeyboard: !disableKittyKeyboard
},
lineHeight: currentSettings?.terminalLineHeight ?? 1,
wordSeparator: currentSettings?.terminalWordSeparator
}