This commit is contained in:
Timothy Jaeryang Baek
2026-02-22 17:38:22 -06:00
parent bab64c9d52
commit 3ad2ea6f28
@@ -51,13 +51,15 @@
if (typeof parsed === 'object') { if (typeof parsed === 'object') {
return JSON.stringify(parsed, null, 2); return JSON.stringify(parsed, null, 2);
} else { } else {
return `${JSON.stringify(String(parsed))}`; return String(parsed);
} }
} catch (e) { } catch (e) {
return str; return str;
} }
} }
function parseArguments(str: string): Record<string, unknown> | null { function parseArguments(str: string): Record<string, unknown> | null {
try { try {
const parsed = parseJSONString(str); const parsed = parseJSONString(str);
@@ -78,6 +80,7 @@
$: isExecuting = attributes?.done && attributes?.done !== 'true'; $: isExecuting = attributes?.done && attributes?.done !== 'true';
$: parsedArgs = parseArguments(args); $: parsedArgs = parseArguments(args);
$: parsedResult = parseJSONString(result);
</script> </script>
<div {id} class={className}> <div {id} class={className}>
@@ -209,10 +212,14 @@
{$i18n.t('Output')} {$i18n.t('Output')}
</div> </div>
<div class="w-full max-w-none!"> <div class="w-full max-w-none!">
<Markdown {#if typeof parsedResult === 'object' && parsedResult !== null}
id={`${componentId}-tool-call-result`} <Markdown
content={`\`\`\`json\n${formatJSONString(result)}\n\`\`\``} id={`${componentId}-tool-call-result`}
/> content={`\`\`\`json\n${JSON.stringify(parsedResult, null, 2)}\n\`\`\``}
/>
{:else}
<pre class="text-xs text-gray-600 dark:text-gray-300 whitespace-pre-wrap break-words font-mono">{String(parsedResult)}</pre>
{/if}
</div> </div>
</div> </div>
{/if} {/if}