mirror of https://github.com/kortix-ai/suna.git
Add support for rendering 'complete' tool content and attachments
Co-authored-by: tnfssc <tnfssc@gmail.com>
This commit is contained in:
parent
1551ce9b4a
commit
66bb34a5ba
|
@ -150,6 +150,22 @@ export function renderMarkdownContent(
|
|||
{renderAttachments(attachmentArray, fileViewerHandler, sandboxId, project)}
|
||||
</div>
|
||||
);
|
||||
} else if (toolName === 'complete') {
|
||||
// Handle complete tool specially - extract text and attachments
|
||||
const completeText = toolCall.parameters.text || '';
|
||||
const attachments = toolCall.parameters.attachments || '';
|
||||
|
||||
// Convert single attachment to array for consistent handling
|
||||
const attachmentArray = Array.isArray(attachments) ? attachments :
|
||||
(typeof attachments === 'string' ? attachments.split(',').map(a => a.trim()) : []);
|
||||
|
||||
// Render complete tool content with attachment UI
|
||||
contentParts.push(
|
||||
<div key={`complete-${match.index}-${index}`} className="space-y-3">
|
||||
<Markdown className="text-sm prose prose-sm dark:prose-invert chat-markdown max-w-none break-words [&>:first-child]:mt-0 prose-headings:mt-3">{completeText}</Markdown>
|
||||
{renderAttachments(attachmentArray, fileViewerHandler, sandboxId, project)}
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
const IconComponent = getToolIcon(toolName);
|
||||
|
||||
|
@ -242,6 +258,24 @@ export function renderMarkdownContent(
|
|||
{renderAttachments(attachments, fileViewerHandler, sandboxId, project)}
|
||||
</div>
|
||||
);
|
||||
} else if (toolName === 'complete') {
|
||||
// Extract attachments from the XML attributes
|
||||
const attachmentsMatch = rawXml.match(/attachments=["']([^"']*)["']/i);
|
||||
const attachments = attachmentsMatch
|
||||
? attachmentsMatch[1].split(',').map(a => a.trim())
|
||||
: [];
|
||||
|
||||
// Extract content from the complete tag
|
||||
const contentMatch = rawXml.match(/<complete[^>]*>([\s\S]*?)<\/complete>/i);
|
||||
const completeContent = contentMatch ? contentMatch[1] : '';
|
||||
|
||||
// Render <complete> tag content with attachment UI (using the helper)
|
||||
contentParts.push(
|
||||
<div key={`complete-${match.index}`} className="space-y-3">
|
||||
<Markdown className="text-sm prose prose-sm dark:prose-invert chat-markdown max-w-none break-words [&>:first-child]:mt-0 prose-headings:mt-3">{completeContent}</Markdown>
|
||||
{renderAttachments(attachments, fileViewerHandler, sandboxId, project)}
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
const IconComponent = getToolIcon(toolName);
|
||||
const paramDisplay = extractPrimaryParam(toolName, rawXml);
|
||||
|
|
|
@ -216,11 +216,11 @@ export function CompleteToolView({
|
|||
)}
|
||||
|
||||
{/* Text/Summary Section */}
|
||||
{(text || completeData.summary) && (
|
||||
{(text || completeData.summary || completeData.result) && (
|
||||
<div className="space-y-2">
|
||||
<div className="bg-muted/50 rounded-2xl p-4 border border-border">
|
||||
<Markdown className="text-sm prose prose-sm dark:prose-invert chat-markdown max-w-none [&>:first-child]:mt-0 prose-headings:mt-3">
|
||||
{text || completeData.summary}
|
||||
{text || completeData.summary || completeData.result}
|
||||
</Markdown>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue