diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index b66d937a..3826cb37 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ## [Unreleased] +### Fixed + +- Fixed potential text decoding issues in bash executor by using streaming TextDecoder instead of Buffer.toString() ## [0.33.0] - 2026-01-04 @@ -1298,4 +1301,4 @@ Initial public release. - Git branch display in footer - Message queueing during streaming responses - OAuth integration for Gmail and Google Calendar access -- HTML export with syntax highlighting and collapsible sections +- HTML export with syntax highlighting and collapsible sections \ No newline at end of file diff --git a/packages/coding-agent/src/core/bash-executor.ts b/packages/coding-agent/src/core/bash-executor.ts index 0a83d2e5..59ae546f 100644 --- a/packages/coding-agent/src/core/bash-executor.ts +++ b/packages/coding-agent/src/core/bash-executor.ts @@ -97,11 +97,13 @@ export function executeBash(command: string, options?: BashExecutorOptions): Pro options.signal.addEventListener("abort", abortHandler, { once: true }); } + const decoder = new TextDecoder(); + const handleData = (data: Buffer) => { totalBytes += data.length; // Sanitize once at the source: strip ANSI, replace binary garbage, normalize newlines - const text = sanitizeBinaryOutput(stripAnsi(data.toString())).replace(/\r/g, ""); + const text = sanitizeBinaryOutput(stripAnsi(decoder.decode(data, { stream: true }))).replace(/\r/g, ""); // Start writing to temp file if exceeds threshold if (totalBytes > DEFAULT_MAX_BYTES && !tempFilePath) {