From d15970e12c000f4bd3e428bd59774981de3314a5 Mon Sep 17 00:00:00 2001 From: Tommaso Sciortino Date: Thu, 20 Nov 2025 11:46:53 -0800 Subject: [PATCH] remove duplicated mouse code (#13525) --- .../cli/src/ui/utils/kittyProtocolDetector.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/packages/cli/src/ui/utils/kittyProtocolDetector.ts b/packages/cli/src/ui/utils/kittyProtocolDetector.ts index e5682566c0..c15e5a052d 100644 --- a/packages/cli/src/ui/utils/kittyProtocolDetector.ts +++ b/packages/cli/src/ui/utils/kittyProtocolDetector.ts @@ -9,10 +9,8 @@ import * as fs from 'node:fs'; let detectionComplete = false; let kittySupported = false; -let sgrMouseSupported = false; let kittyEnabled = false; -let sgrMouseEnabled = false; /** * Detects Kitty keyboard protocol support. @@ -50,7 +48,7 @@ export async function detectAndEnableKittyProtocol(): Promise { process.stdin.setRawMode(false); } - if (kittySupported || sgrMouseSupported) { + if (kittySupported) { enableSupportedProtocol(); process.on('exit', disableAllProtocols); process.on('SIGTERM', disableAllProtocols); @@ -83,10 +81,6 @@ export async function detectAndEnableKittyProtocol(): Promise { kittySupported = true; } - // Broaden mouse support by enabling SGR mode if we get any device - // attribute response, which is a strong signal of a modern terminal. - sgrMouseSupported = true; - finish(); } }; @@ -110,13 +104,10 @@ export function isKittyProtocolEnabled(): boolean { function disableAllProtocols() { try { if (kittyEnabled) { + // use writeSync to avoid race conditions fs.writeSync(process.stdout.fd, '\x1b[1u'); kittyEnabled = true; } - if (sgrMouseSupported) { - fs.writeSync(process.stdout.fd, '\x1b[?1006h'); - sgrMouseEnabled = true; - } } catch { // Ignore }