Fix characters (#372)

* Fix cat command

* Fix text rendering crash from undefined code points in bash output

* Revert unintentional model parameter changes from fix cat command commit
This commit is contained in:
Mr. Rc 2026-01-01 06:46:29 +05:30 committed by GitHub
parent 46bb5dcde8
commit bbf23bd5f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 9 deletions

View file

@ -13,6 +13,7 @@ import {
import stripAnsi from "strip-ansi";
import type { CustomTool } from "../../../core/custom-tools/types.js";
import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize } from "../../../core/tools/truncate.js";
import { sanitizeBinaryOutput } from "../../../utils/shell.js";
import { getLanguageFromPath, highlightCode, theme } from "../theme/theme.js";
import { renderDiff } from "./diff.js";
import { truncateToVisualLines } from "./visual-truncate.js";
@ -295,10 +296,8 @@ export class ToolExecutionComponent extends Container {
let output = textBlocks
.map((c: any) => {
let text = stripAnsi(c.text || "").replace(/\r/g, "");
text = text.replace(/\x1b./g, "");
text = text.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/g, "");
return text;
// Use sanitizeBinaryOutput to handle binary data that crashes string-width
return sanitizeBinaryOutput(stripAnsi(c.text || "")).replace(/\r/g, "");
})
.join("\n");