fix: fixed tab character display holes in UI by sanitizing output

- Fixed tab character display in error messages and bash tool output by applying replaceTabs() sanitization.
- Added TUI rendering sanitization documentation to AGENTS.md with guidelines for sanitizing text in tool renderers.
- Applied replaceTabs() function to error text in patch shared module to ensure proper tab-to-space conversion.
- Applied replaceTabs() function to bash tool output lines in both expanded and collapsed display modes.
This commit is contained in:
can1357
2026-02-06 07:38:46 +01:00
parent 5499cc8aa5
commit 4eef01bdaa
4 changed files with 32 additions and 6 deletions
+5 -3
View File
@@ -17,7 +17,7 @@ import { applyHeadTail, normalizeBashCommand } from "./bash-normalize";
import type { OutputMeta } from "./output-meta";
import { allocateOutputArtifact, createTailBuffer } from "./output-utils";
import { resolveToCwd } from "./path-utils";
import { formatBytes, wrapBrackets } from "./render-utils";
import { formatBytes, replaceTabs, wrapBrackets } from "./render-utils";
import { ToolError } from "./tool-errors";
import { toolResult } from "./tool-result";
import { DEFAULT_MAX_BYTES } from "./truncate";
@@ -271,11 +271,13 @@ export const bashToolRenderer = {
const hasOutput = displayOutput.trim().length > 0;
if (hasOutput) {
if (expanded) {
outputLines.push(...displayOutput.split("\n").map(line => uiTheme.fg("toolOutput", line)));
outputLines.push(
...displayOutput.split("\n").map(line => uiTheme.fg("toolOutput", replaceTabs(line))),
);
} else {
const styledOutput = displayOutput
.split("\n")
.map(line => uiTheme.fg("toolOutput", line))
.map(line => uiTheme.fg("toolOutput", replaceTabs(line)))
.join("\n");
const textContent = styledOutput;
const result = truncateToVisualLines(textContent, previewLines, width);