diff --git a/frontend/src/components/dashboard/dashboard-content.tsx b/frontend/src/components/dashboard/dashboard-content.tsx index ea335b3f..8ae9c517 100644 --- a/frontend/src/components/dashboard/dashboard-content.tsx +++ b/frontend/src/components/dashboard/dashboard-content.tsx @@ -154,7 +154,6 @@ export function DashboardContent() { console.log('Handling BillingError:', error.detail); onOpen("paymentRequiredDialog"); } - } finally { setIsSubmitting(false); } }; diff --git a/frontend/src/components/thread/tool-views/command-tool/CommandToolView.tsx b/frontend/src/components/thread/tool-views/command-tool/CommandToolView.tsx index dcbfdd8b..95e9ef50 100644 --- a/frontend/src/components/thread/tool-views/command-tool/CommandToolView.tsx +++ b/frontend/src/components/thread/tool-views/command-tool/CommandToolView.tsx @@ -59,19 +59,37 @@ export function CommandToolView({ const formattedOutput = React.useMemo(() => { if (!output) return []; let processedOutput = output; - try { - if (typeof output === 'string' && (output.trim().startsWith('{') || output.trim().startsWith('{'))) { - const parsed = JSON.parse(output); - if (parsed && typeof parsed === 'object' && parsed.output) { - processedOutput = parsed.output; - } + + // Handle case where output is already an object + if (typeof output === 'object' && output !== null) { + try { + processedOutput = JSON.stringify(output, null, 2); + } catch (e) { + processedOutput = String(output); } - } catch (e) { + } else if (typeof output === 'string') { + // Try to parse as JSON first + try { + if (output.trim().startsWith('{') || output.trim().startsWith('[')) { + const parsed = JSON.parse(output); + if (parsed && typeof parsed === 'object') { + // If it's a complex object, stringify it nicely + processedOutput = JSON.stringify(parsed, null, 2); + } else { + processedOutput = String(parsed); + } + } else { + processedOutput = output; + } + } catch (e) { + // If parsing fails, use as plain text + processedOutput = output; + } + } else { + processedOutput = String(output); } - processedOutput = String(processedOutput); processedOutput = processedOutput.replace(/\\\\/g, '\\'); - processedOutput = processedOutput .replace(/\\n/g, '\n') .replace(/\\t/g, '\t') @@ -141,43 +159,39 @@ export function CommandToolView({
- {output && ( -
- - -
-
-
- - Terminal output -
- {exitCode !== null && exitCode !== 0 && ( - - - Error - +
+
+
+
+ + Terminal +
+ {exitCode !== null && exitCode !== 0 && ( + + + Error + + )} +
+
+
+                      {/* Show command only */}
+                      {command && (
+                        
+ {displayPrefix} + {command} +
)} -
-
-
-                        {linesToShow.map((line, index) => (
-                          
- {line || ' '} -
- ))} - {!showFullOutput && hasMoreLines && ( -
- + {formattedOutput.length - 10} more lines -
- )} -
-
+ + {!showFullOutput && hasMoreLines && ( +
+ + {formattedOutput.length - 10} more lines +
+ )} +
- )} +
{!output && !isStreaming && (
diff --git a/frontend/src/components/thread/tool-views/command-tool/_utils.ts b/frontend/src/components/thread/tool-views/command-tool/_utils.ts index d120fd9f..c739bde2 100644 --- a/frontend/src/components/thread/tool-views/command-tool/_utils.ts +++ b/frontend/src/components/thread/tool-views/command-tool/_utils.ts @@ -34,18 +34,32 @@ const extractFromNewFormat = (content: any): CommandData => { const toolExecution = parsedContent.tool_execution; const args = toolExecution.arguments || {}; - let parsedOutput = toolExecution.result?.output; - if (typeof parsedOutput === 'string') { + // Handle the case where result.output is a string (like in your example) + let output = toolExecution.result?.output; + let parsedOutput: any = {}; + + if (typeof output === 'string') { + // First try to parse it as JSON try { - parsedOutput = JSON.parse(parsedOutput); + parsedOutput = JSON.parse(output); + // If parsing succeeds, extract the actual output from the nested structure + if (parsedOutput && typeof parsedOutput === 'object') { + // Look for output in common nested structures + output = parsedOutput.output || parsedOutput.message || parsedOutput.content || output; + } } catch (e) { + // If it's not JSON, treat it as plain text output + output = output; } + } else if (typeof output === 'object' && output !== null) { + parsedOutput = output; + // Extract output from object structure + output = (output as any).output || (output as any).message || (output as any).content || null; } - parsedOutput = parsedOutput || {}; const extractedData = { command: args.command || null, - output: parsedOutput?.output || null, + output: output || parsedOutput?.output || null, exitCode: parsedOutput?.exit_code || null, sessionName: args.session_name || parsedOutput?.session_name || null, cwd: parsedOutput?.cwd || null,