Skip to content

Commit cc21348

Browse files
committed
fix(acp): suppress verbose raw updates dump for edit tool calls
1 parent f0899ad commit cc21348

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

‎anycode/components/agent/AcpMessage.tsx‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const ToolCallMessage: React.FC<{
5757
const diffFileNames = getToolCallFileNames(toolCallView.diffs);
5858
const toggleLabel = formatToolCallLabel(diffFileNames, displayCommand);
5959
const toggleStats = getToolCallStats(toolCallView.diffs);
60+
const isEditCall = toolCallView.kind === 'edit' || toolCallView.diffs.length > 0;
6061

6162
return (
6263
<div className="acp-message acp-message-tool_call">
@@ -90,17 +91,17 @@ const ToolCallMessage: React.FC<{
9091
</div>
9192
)}
9293

93-
{toolUpdates && toolUpdates.length > 0 && (
94+
{!isEditCall && toolUpdates && toolUpdates.length > 0 && (
9495
<div className="acp-tool-call-section">
9596
<div className="acp-tool-call-label">Updates:</div>
9697
{toolUpdates.map((toolUpdate, index) => (
9798
<pre key={`${toolUpdate.id}-${index}`} className="acp-tool-result-content">
98-
{JSON.stringify(toolUpdate.update, null, 2)}
99+
{JSON.stringify(sanitizeToolUpdate(toolUpdate.update), null, 2)}
99100
</pre>
100101
))}
101102
</div>
102103
)}
103-
{toolCallView.kind === 'edit' && toolCallView.diffs.length > 0 && (
104+
{toolCallView.diffs.length > 0 && (
104105
<div className="acp-tool-call-section">
105106
<div className="acp-tool-call-label">Diff:</div>
106107
<div className="acp-tool-call-diffs">
@@ -504,7 +505,7 @@ const ToolUpdateMessage: React.FC<{
504505
</div>
505506
{isExpanded && (
506507
<pre className="acp-tool-update-content">
507-
{JSON.stringify(message.update, null, 2)}
508+
{JSON.stringify(sanitizeToolUpdate(message.update), null, 2)}
508509
</pre>
509510
)}
510511
</div>
@@ -601,6 +602,24 @@ const isAcpDiffContent = (value: unknown): value is AcpDiffContent => {
601602
&& (oldText === undefined || oldText === null || typeof oldText === 'string');
602603
};
603604

605+
const sanitizeToolUpdate = (update: unknown): unknown => {
606+
if (typeof update !== 'object' || update === null) return update;
607+
const record = { ...(update as Record<string, unknown>) };
608+
if (Array.isArray(record.content)) {
609+
record.content = record.content.map((item) => {
610+
if (isAcpDiffContent(item)) {
611+
return {
612+
type: 'diff',
613+
path: item.path,
614+
};
615+
}
616+
return item;
617+
});
618+
}
619+
return record;
620+
};
621+
622+
604623
const getDiffEntries = (content: unknown): AcpDiffContent[] => {
605624
return Array.isArray(content) ? content.filter(isAcpDiffContent) : [];
606625
};

0 commit comments

Comments
 (0)