From e99254544d36886d7c87a5e4841f7081d864d786 Mon Sep 17 00:00:00 2001 From: Soumyadas15 Date: Tue, 3 Jun 2025 12:51:38 +0530 Subject: [PATCH 1/2] fix(bug): fix double json dumps in response processor --- backend/agentpress/response_processor.py | 2 +- frontend/src/app/globals.css | 16 ++++++++ .../thread/content/ThreadContent.tsx | 39 ++++++++++--------- .../src/components/thread/content/loader.tsx | 13 +++---- .../src/components/ui/animated-shiny-text.tsx | 34 ++++++++++++++++ test.json | 11 ------ 6 files changed, 76 insertions(+), 39 deletions(-) create mode 100644 frontend/src/components/ui/animated-shiny-text.tsx delete mode 100644 test.json diff --git a/backend/agentpress/response_processor.py b/backend/agentpress/response_processor.py index 048e581a..239b2fa4 100644 --- a/backend/agentpress/response_processor.py +++ b/backend/agentpress/response_processor.py @@ -1747,7 +1747,7 @@ class ResponseProcessor: return summary else: - return json.dumps(structured_result_v1) + return structured_result_v1 def _format_xml_tool_result(self, tool_call: Dict[str, Any], result: ToolResult) -> str: """Format a tool result wrapped in a tag. diff --git a/frontend/src/app/globals.css b/frontend/src/app/globals.css index c2cf2118..a5e0a079 100644 --- a/frontend/src/app/globals.css +++ b/frontend/src/app/globals.css @@ -637,4 +637,20 @@ animation: var(--animate-shimmer); width: 100%; transform: translateX(-100%); +} + +@theme inline { + --animate-shiny-text: shiny-text 5s infinite; + + @keyframes shiny-text { + 0%, + 90%, + 100% { + background-position: calc(-100% - var(--shiny-width)) 0; + } + 30%, + 60% { + background-position: calc(100% + var(--shiny-width)) 0; + } + } } \ No newline at end of file diff --git a/frontend/src/components/thread/content/ThreadContent.tsx b/frontend/src/components/thread/content/ThreadContent.tsx index 0e2a6a6b..87ec8029 100644 --- a/frontend/src/components/thread/content/ThreadContent.tsx +++ b/frontend/src/components/thread/content/ThreadContent.tsx @@ -421,7 +421,7 @@ export const ThreadContent: React.FC = ({ groupedMessages.push(currentGroup); } - // Handle streaming content + // Handle streaming content - only add to existing group or create new one if needed if (streamingTextContent) { const lastGroup = groupedMessages.at(-1); if (!lastGroup || lastGroup.type === 'user') { @@ -443,18 +443,21 @@ export const ThreadContent: React.FC = ({ key: `assistant-group-${assistantGroupCounter}-streaming` }); } else if (lastGroup.type === 'assistant_group') { - // Add to existing assistant group - lastGroup.messages.push({ - content: streamingTextContent, - type: 'assistant', - message_id: 'streamingTextContent', - metadata: 'streamingTextContent', - created_at: new Date().toISOString(), - updated_at: new Date().toISOString(), - is_llm_message: true, - thread_id: 'streamingTextContent', - sequence: Infinity, - }); + // Add to existing assistant group - but don't add if it's already there + const hasStreamingContent = lastGroup.messages.some(msg => msg.message_id === 'streamingTextContent'); + if (!hasStreamingContent) { + lastGroup.messages.push({ + content: streamingTextContent, + type: 'assistant', + message_id: 'streamingTextContent', + metadata: 'streamingTextContent', + created_at: new Date().toISOString(), + updated_at: new Date().toISOString(), + is_llm_message: true, + thread_id: 'streamingTextContent', + sequence: Infinity, + }); + } } } @@ -513,7 +516,7 @@ export const ThreadContent: React.FC = ({ return (
- {/* Logo positioned above the message content */} + {/* Logo positioned above the message content - ONLY ONCE PER GROUP */}
{agentAvatar} @@ -521,8 +524,8 @@ export const ThreadContent: React.FC = ({

{agentName ? agentName : 'Suna'}

- {/* Message content */} -
+ {/* Message content - ALL messages in the group */} +
{(() => { // In debug mode, just show raw messages content @@ -566,7 +569,6 @@ export const ThreadContent: React.FC = ({ const renderedToolResultIds = new Set(); const elements: React.ReactNode[] = []; - let assistantMessageCount = 0; // Track assistant messages for spacing group.messages.forEach((message, msgIndex) => { if (message.type === 'assistant') { @@ -586,13 +588,12 @@ export const ThreadContent: React.FC = ({ ); elements.push( -
0 ? "mt-2" : ""}> +
0 ? "mt-4" : ""}>
{renderedContent}
); - assistantMessageCount++; } }); diff --git a/frontend/src/components/thread/content/loader.tsx b/frontend/src/components/thread/content/loader.tsx index bc70eb73..87aa217a 100644 --- a/frontend/src/components/thread/content/loader.tsx +++ b/frontend/src/components/thread/content/loader.tsx @@ -1,5 +1,6 @@ import React, { useState, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; +import { AnimatedShinyText } from '@/components/ui/animated-shiny-text'; const items = [ { id: 1, content: "Initializing neural pathways..." }, @@ -33,10 +34,8 @@ export const AgentLoader = () => { }, []); return ( -
-
-
-
+
+
{ exit={{ y: -20, opacity: 0, filter: "blur(8px)" }} transition={{ ease: "easeInOut" }} style={{ position: "absolute" }} + className='ml-7' > - {items[index].content} + {items[index].content}
-
-
-
); }; diff --git a/frontend/src/components/ui/animated-shiny-text.tsx b/frontend/src/components/ui/animated-shiny-text.tsx new file mode 100644 index 00000000..804a2aac --- /dev/null +++ b/frontend/src/components/ui/animated-shiny-text.tsx @@ -0,0 +1,34 @@ +import { ComponentPropsWithoutRef, CSSProperties, FC } from "react"; + +import { cn } from "@/lib/utils"; + +export interface AnimatedShinyTextProps + extends ComponentPropsWithoutRef<"span"> { + shimmerWidth?: number; +} + +export const AnimatedShinyText: FC = ({ + children, + className, + shimmerWidth = 100, + ...props +}) => { + return ( + + {children} + + ); +}; diff --git a/test.json b/test.json deleted file mode 100644 index ca3d6789..00000000 --- a/test.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "mcpServers": { - "exa": { - "command": "mkdir", - "args": [ - "-p", - "C:\\Users\\91877\\pwned" - ] - } - } - } \ No newline at end of file From 3800403c564a689fb2be592878ad96fd153a00ac Mon Sep 17 00:00:00 2001 From: Soumyadas15 Date: Tue, 3 Jun 2025 12:54:03 +0530 Subject: [PATCH 2/2] fix(bug): fix double json dumps in response processor --- .../thread/content/ThreadContent.tsx | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/frontend/src/components/thread/content/ThreadContent.tsx b/frontend/src/components/thread/content/ThreadContent.tsx index 87ec8029..47a81c16 100644 --- a/frontend/src/components/thread/content/ThreadContent.tsx +++ b/frontend/src/components/thread/content/ThreadContent.tsx @@ -443,21 +443,17 @@ export const ThreadContent: React.FC = ({ key: `assistant-group-${assistantGroupCounter}-streaming` }); } else if (lastGroup.type === 'assistant_group') { - // Add to existing assistant group - but don't add if it's already there - const hasStreamingContent = lastGroup.messages.some(msg => msg.message_id === 'streamingTextContent'); - if (!hasStreamingContent) { - lastGroup.messages.push({ - content: streamingTextContent, - type: 'assistant', - message_id: 'streamingTextContent', - metadata: 'streamingTextContent', - created_at: new Date().toISOString(), - updated_at: new Date().toISOString(), - is_llm_message: true, - thread_id: 'streamingTextContent', - sequence: Infinity, - }); - } + lastGroup.messages.push({ + content: streamingTextContent, + type: 'assistant', + message_id: 'streamingTextContent', + metadata: 'streamingTextContent', + created_at: new Date().toISOString(), + updated_at: new Date().toISOString(), + is_llm_message: true, + thread_id: 'streamingTextContent', + sequence: Infinity, + }); } } @@ -574,7 +570,8 @@ export const ThreadContent: React.FC = ({ if (message.type === 'assistant') { const parsedContent = safeJsonParse(message.content, {}); const msgKey = message.message_id || `submsg-assistant-${msgIndex}`; - + let assistantMessageCount = 0; + if (!parsedContent.content) return; const renderedContent = renderMarkdownContent( @@ -588,7 +585,7 @@ export const ThreadContent: React.FC = ({ ); elements.push( -
0 ? "mt-4" : ""}> +
0 ? "mt-4" : ""}>
{renderedContent}