From 16c5ed6dd9faac3094b9ccb5b7b6a6d2d057a55e Mon Sep 17 00:00:00 2001 From: Augustin Date: Fri, 24 Apr 2026 16:22:54 +0200 Subject: [PATCH] fix(studio): add tool results serialization and improve message handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add tool_results array to AI message content with tool_call_id, result, and is_error - Convert cleanContent to let for potential reuse - Reset accumulated and streaming state on tool_call events 💘 Generated with Crush Assisted-by: MiniMax-M2.7 via Crush --- web/src/components/Shell.jsx | 2 +- web/src/components/Studio.jsx | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/web/src/components/Shell.jsx b/web/src/components/Shell.jsx index 5667fba..70b2df8 100644 --- a/web/src/components/Shell.jsx +++ b/web/src/components/Shell.jsx @@ -204,7 +204,7 @@ export default function Shell({ api }) { const tabsRef = useRef({}) const nextIdRef = useRef(1) const settingsRef = useRef({ fontSize: 12, fontFamily: "'JetBrains Mono', 'Fira Code', monospace", theme: 'default' }) - const activeTabRef = useRef(activeTab) + const activeTabRef = useRef(null) const pendingCommandsRef = useRef({}) useEffect(() => { activeTabRef.current = activeTab }, [activeTab]) diff --git a/web/src/components/Studio.jsx b/web/src/components/Studio.jsx index c35e2a1..f49a53b 100644 --- a/web/src/components/Studio.jsx +++ b/web/src/components/Studio.jsx @@ -197,7 +197,7 @@ function FeedItem({ msg }) { ) } - const cleanContent = displayContent.replace(/]*>[\s\S]*?<\/think>/gi, '') + let cleanContent = displayContent.replace(/]*>[\s\S]*?<\/think>/gi, '') return (
@@ -532,6 +532,8 @@ export default function Studio({ api }) { if (event && event.tool_call) { toolCalls = [...toolCalls, { call: event.tool_call, result: null }] setStreamToolCalls([...toolCalls]) + accumulated = '' + setStreaming('') return } if (event && event.tool_result) { @@ -558,6 +560,11 @@ export default function Studio({ api }) { aiMsg.content = JSON.stringify({ content: finalContent, tool_calls: toolCalls.map(tc => tc.call), + tool_results: toolCalls.map(tc => ({ + tool_call_id: tc.call?.tool_call_id, + result: tc.result?.content || '', + is_error: tc.result?.is_error || false, + })), }) } setMessages(prev => [...prev, aiMsg])