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:
@@ -265,13 +265,13 @@ export const editToolRenderer = {
|
||||
|
||||
if (result.isError) {
|
||||
if (errorText) {
|
||||
text += `\n\n${uiTheme.fg("error", errorText)}`;
|
||||
text += `\n\n${uiTheme.fg("error", replaceTabs(errorText))}`;
|
||||
}
|
||||
} else if (result.details?.diff) {
|
||||
text += renderDiffSection(result.details.diff, rawPath, expanded, uiTheme, ui, renderDiffFn);
|
||||
} else if (editDiffPreview) {
|
||||
if ("error" in editDiffPreview) {
|
||||
text += `\n\n${uiTheme.fg("error", editDiffPreview.error)}`;
|
||||
text += `\n\n${uiTheme.fg("error", replaceTabs(editDiffPreview.error))}`;
|
||||
} else if (editDiffPreview.diff) {
|
||||
text += renderDiffSection(editDiffPreview.diff, rawPath, expanded, uiTheme, ui, renderDiffFn);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user