feat(coding-agent): implemented width-aware text truncation and render caching across tool renderers
- Implemented width-aware text truncation across all tool renderers to respect terminal width constraints and prevent output overflow. - Enhanced render caching to include width parameter for cache invalidation when terminal width changes, improving cache accuracy. - Migrated truncateToWidth function imports from render-utils to centralized tui module for better code organization. - Introduced Hasher utility for generating width-aware cache keys in calculator, find, grep, todo-write, and write tools. - Optimized box component rendering to only truncate lines that exceed content width, reducing unnecessary truncation operations.
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
||||
truncateDiffByHunk,
|
||||
} from "../tools/render-utils";
|
||||
import type { RenderCallOptions } from "../tools/renderers";
|
||||
import { Hasher, type RenderCache, renderStatusLine, truncateToWidth } from "../tui";
|
||||
import { Ellipsis, Hasher, type RenderCache, renderStatusLine, truncateToWidth } from "../tui";
|
||||
import type { DiffError, DiffResult, Operation } from "./types";
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
@@ -283,7 +283,8 @@ export const editToolRenderer = {
|
||||
);
|
||||
}
|
||||
|
||||
const lines = width > 0 ? text.split("\n").map(line => truncateToWidth(line, width)) : text.split("\n");
|
||||
const lines =
|
||||
width > 0 ? text.split("\n").map(line => truncateToWidth(line, width, Ellipsis.Omit)) : text.split("\n");
|
||||
cached = { key, lines };
|
||||
return lines;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user