fix(coding-agent): do not highlight read errors (#6731)

This commit is contained in:
Danila Poyarkov
2026-07-17 10:02:50 +03:00
committed by GitHub
parent 056c8cbb80
commit a2c5ee33eb
2 changed files with 20 additions and 2 deletions
@@ -8,7 +8,7 @@ import { type BashOperations, createBashToolDefinition } from "../src/core/tools
import { createReadTool, createReadToolDefinition } from "../src/core/tools/read.ts";
import { createWriteToolDefinition } from "../src/core/tools/write.ts";
import { ToolExecutionComponent } from "../src/modes/interactive/components/tool-execution.ts";
import { initTheme } from "../src/modes/interactive/theme/theme.ts";
import { initTheme, theme } from "../src/modes/interactive/theme/theme.ts";
import { stripAnsi } from "../src/utils/ansi.ts";
function createBaseToolDefinition(name = "custom_tool"): ToolDefinition {
@@ -401,6 +401,24 @@ describe("ToolExecutionComponent parity", () => {
expect(rendered).not.toContain("two\n\n");
});
test("does not syntax-highlight read errors based on the requested file path", () => {
const component = new ToolExecutionComponent(
"read",
"tool-read-error-highlighting",
{ path: "config.exs", offset: 120, limit: 130 },
{},
createReadToolDefinition(process.cwd()),
createFakeTui(),
process.cwd(),
);
const error = "Offset 120 is beyond end of file (96 lines total)";
component.updateResult({ content: [{ type: "text", text: error }], details: undefined, isError: true }, false);
const rendered = component.render(120).join("\n");
expect(stripAnsi(rendered)).toContain(error);
expect(rendered).toContain(theme.fg("toolOutput", error));
});
test("collapses ordinary read results until expanded", () => {
const component = new ToolExecutionComponent(
"read",