Refactoring of disabling of mouse tracking in e2e tests (#17902)

This commit is contained in:
Alisa
2026-01-29 14:05:19 -08:00
committed by GitHub
parent fc926cd0b0
commit 2de39311cf
2 changed files with 17 additions and 3 deletions

View File

@@ -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

View File

@@ -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)