fix(app): deduplicate tool call expansion sections
Command output was being shown three times: as "Command", as "Read Result", and as raw JSON "Result". Now: - Skip "Read Result" when command output is already shown - Skip raw JSON "Result" when we have structured content to display 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1391,25 +1391,34 @@ export const ToolCall = memo(function ToolCall({
|
|||||||
[readEntries]
|
[readEntries]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Check if we have structured content that makes raw JSON redundant
|
||||||
|
const hasStructuredContent = Boolean(
|
||||||
|
commandDetails?.output || editEntries.length > 0 || readEntries.length > 0
|
||||||
|
);
|
||||||
|
|
||||||
const jsonSections = useMemo(() => {
|
const jsonSections = useMemo(() => {
|
||||||
const sections: ReactNode[] = [];
|
const sections: ReactNode[] = [];
|
||||||
if (args !== undefined) {
|
if (args !== undefined) {
|
||||||
sections.push(renderJsonSection("Arguments", serializedArgs));
|
sections.push(renderJsonSection("Arguments", serializedArgs));
|
||||||
}
|
}
|
||||||
if (result !== undefined) {
|
// Only show raw Result JSON if we don't have structured content showing the same data
|
||||||
|
if (result !== undefined && !hasStructuredContent) {
|
||||||
sections.push(renderJsonSection("Result", serializedResult));
|
sections.push(renderJsonSection("Result", serializedResult));
|
||||||
}
|
}
|
||||||
if (error !== undefined) {
|
if (error !== undefined) {
|
||||||
sections.push(renderJsonSection("Error", serializedError, true));
|
sections.push(renderJsonSection("Error", serializedError, true));
|
||||||
}
|
}
|
||||||
return sections;
|
return sections;
|
||||||
}, [args, serializedArgs, result, serializedResult, error, serializedError]);
|
}, [args, serializedArgs, result, serializedResult, error, serializedError, hasStructuredContent]);
|
||||||
|
|
||||||
const renderDetails = useCallback(() => {
|
const renderDetails = useCallback(() => {
|
||||||
|
// Don't show readSections if commandDetails has output (they show the same data)
|
||||||
|
const showReadSections = !commandDetails?.output && readSections.length > 0;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!commandSection &&
|
!commandSection &&
|
||||||
editSections.length === 0 &&
|
editSections.length === 0 &&
|
||||||
readSections.length === 0 &&
|
!showReadSections &&
|
||||||
jsonSections.length === 0
|
jsonSections.length === 0
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
@@ -1423,11 +1432,11 @@ export const ToolCall = memo(function ToolCall({
|
|||||||
<View style={toolCallStylesheet.detailContent}>
|
<View style={toolCallStylesheet.detailContent}>
|
||||||
{commandSection}
|
{commandSection}
|
||||||
{editSections}
|
{editSections}
|
||||||
{readSections}
|
{showReadSections ? readSections : null}
|
||||||
{jsonSections}
|
{jsonSections}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}, [commandSection, editSections, readSections, jsonSections]);
|
}, [commandSection, commandDetails?.output, editSections, readSections, jsonSections]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ExpandableBadge
|
<ExpandableBadge
|
||||||
|
|||||||
Reference in New Issue
Block a user