From 8ca616ec3a3a98274a37ac2ee5eca438573ab13a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sun, 3 May 2026 15:53:41 +0800 Subject: [PATCH] Preserve ESC in logger to allow ANSI colors Adjust logger sanitization to keep the ESC (0x1B) character so ANSI color sequences produced by render() reach the terminal. The regex was refined from removing all ASCII control chars to excluding ESC, while still stripping other control characters (including BEL) to prevent unwanted system beeps and control behavior. Comment updated to reflect this rationale. --- packages/core/src/utils/logger.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/src/utils/logger.ts b/packages/core/src/utils/logger.ts index d06eddcf..534bb7b0 100644 --- a/packages/core/src/utils/logger.ts +++ b/packages/core/src/utils/logger.ts @@ -111,9 +111,10 @@ function emit(level: LogLevel, options: LogOptions, args: unknown[]): void { const stream = level === 'warn' || level === 'error' ? process.stderr : process.stdout; // Strip ASCII control characters before writing to terminal to prevent // BEL (0x07) in user-provided strings (e.g. group member names) from - // triggering Windows system beep sounds. + // triggering Windows system beep sounds. ESC (0x1B) is preserved so the + // ANSI color sequences emitted by render() actually reach the terminal. // eslint-disable-next-line no-control-regex - stream.write(line.replace(/[\x00-\x1F\x7F]/g, '') + '\n'); + stream.write(line.replace(/[\x00-\x1A\x1C-\x1F\x7F]/g, '') + '\n'); } export function getRecentLogs(limit = 300): LogEntry[] {