diff --git a/integration-tests/globalSetup.ts b/integration-tests/globalSetup.ts index 150fa7316d..5f963f7459 100644 --- a/integration-tests/globalSetup.ts +++ b/integration-tests/globalSetup.ts @@ -13,6 +13,7 @@ import { mkdir, readdir, rm } from 'node:fs/promises'; import { join, dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; import { canUseRipgrep } from '../packages/core/src/tools/ripGrep.js'; +import { disableMouseTracking } from '@google/gemini-cli-core'; const __dirname = dirname(fileURLToPath(import.meta.url)); const rootDir = join(__dirname, '..'); @@ -74,9 +75,7 @@ export async function setup() { export async function teardown() { // Disable mouse tracking if (process.stdout.isTTY) { - process.stdout.write( - '\x1b[?1000l\x1b[?1003l\x1b[?1015l\x1b[?1006l\x1b[?1002l', - ); + disableMouseTracking(); } // Cleanup the test run directory unless KEEP_OUTPUT is set diff --git a/packages/core/src/utils/terminal.ts b/packages/core/src/utils/terminal.ts index 5e2fdb8bf0..b8c8bf71df 100644 --- a/packages/core/src/utils/terminal.ts +++ b/packages/core/src/utils/terminal.ts @@ -6,6 +6,21 @@ import { writeToStdout } from './stdio.js'; +/** + * ANSI escape codes for disabling mouse tracking. + */ +export function disableMouseTracking() { + writeToStdout( + [ + '\x1b[?1000l', // Normal tracking + '\x1b[?1003l', // Any-event tracking + '\x1b[?1015l', // urxvt extended mouse mode + '\x1b[?1006l', // SGR-style mouse tracking + '\x1b[?1002l', // Button-event tracking + ].join(''), + ); +} + export function enableMouseEvents() { // Enable mouse tracking with SGR format // ?1002h = button event tracking (clicks + drags + scroll wheel)