refactor(coding-agent): restructured tool rendering to merge call and result displays
- Changed tool result rendering to merge call and result displays with tool arguments in headers across 13 tools. - Added args parameter to render methods enabling display of contextual metadata like patterns, paths, and commands. - Changed Read tool title to display line range when offset or limit arguments provided. - Changed worker instantiation to use direct URL import instead of pre-bundled worker files. - Removed streaming preview rendering logic from write tool.
This commit is contained in:
@@ -128,8 +128,6 @@ interface WriteRenderArgs {
|
||||
content?: string;
|
||||
}
|
||||
|
||||
const WRITE_STREAMING_PREVIEW_LINES = 12;
|
||||
|
||||
function countLines(text: string): number {
|
||||
if (!text) return 0;
|
||||
return text.split("\n").length;
|
||||
@@ -150,36 +148,6 @@ export const writeToolRenderer = {
|
||||
const pathDisplay = filePath || uiTheme.format.ellipsis;
|
||||
const status = options?.spinnerFrame !== undefined ? "running" : "pending";
|
||||
|
||||
if (args.content) {
|
||||
const contentLines = args.content.split("\n");
|
||||
const displayLines = contentLines.slice(-WRITE_STREAMING_PREVIEW_LINES);
|
||||
const hidden = contentLines.length - displayLines.length;
|
||||
const outputLines: string[] = [];
|
||||
if (hidden > 0) {
|
||||
outputLines.push(uiTheme.fg("dim", `${uiTheme.format.ellipsis} (${hidden} earlier lines)`));
|
||||
}
|
||||
outputLines.push(uiTheme.fg("dim", `${uiTheme.format.ellipsis} (streaming)`));
|
||||
|
||||
return {
|
||||
render: (width: number) =>
|
||||
renderCodeCell(
|
||||
{
|
||||
code: displayLines.join("\n"),
|
||||
language: getLanguageFromPath(rawPath),
|
||||
title: filePath ? `Write ${filePath}` : "Write",
|
||||
status,
|
||||
spinnerFrame: options?.spinnerFrame,
|
||||
output: outputLines.join("\n"),
|
||||
codeMaxLines: WRITE_STREAMING_PREVIEW_LINES,
|
||||
expanded: true,
|
||||
width,
|
||||
},
|
||||
uiTheme,
|
||||
),
|
||||
invalidate: () => {},
|
||||
};
|
||||
}
|
||||
|
||||
const text = renderStatusLine({ icon: status, title: "Write", description: pathDisplay }, uiTheme);
|
||||
return new Text(text, 0, 0);
|
||||
},
|
||||
@@ -225,4 +193,5 @@ export const writeToolRenderer = {
|
||||
invalidate: () => {},
|
||||
};
|
||||
},
|
||||
mergeCallAndResult: true,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user