diff --git a/static/css/chat.css b/static/css/chat.css index 2c2a153..1355f98 100644 --- a/static/css/chat.css +++ b/static/css/chat.css @@ -378,6 +378,7 @@ body:not(.loading) #loading { border: 2px solid #ed8796; } +.tool .result pre, .reasoning-text pre { background: #1b1d2a; } diff --git a/static/js/chat.js b/static/js/chat.js index b02f9c6..528a280 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -513,7 +513,7 @@ _cost.textContent = cost ? `${formatMoney(cost)}` : ""; _result.classList.toggle("error", result?.startsWith("error: ")); - _result.innerHTML = render(result || "*processing*"); + _result.innerHTML = render(result ? wrapJSON(result) : "*processing*"); this.#_tool.classList.toggle("invalid", !!invalid); diff --git a/static/js/lib.js b/static/js/lib.js index 2816127..4eddc21 100644 --- a/static/js/lib.js +++ b/static/js/lib.js @@ -114,6 +114,20 @@ function clamp(num, min, max) { return Math.min(Math.max(num, min), max); } +function wrapJSON(txt) { + if (!txt || !txt.startsWith("{")) { + return txt; + } + + try { + const data = JSON.parse(txt); + + return `\`\`\`json\n${JSON.stringify(data, null, 2)}\n\`\`\``; + } catch {} + + return txt; +} + function download(name, type, data) { let blob;