From 017839eed059688d7761f24dfe3e7953bb13cd78 Mon Sep 17 00:00:00 2001 From: akhisud3195 Date: Sun, 13 Jul 2025 15:01:14 +0530 Subject: [PATCH] Remove show/hide for internal messages and show responses --- .../playground/components/messages.tsx | 127 +++++++++--------- 1 file changed, 60 insertions(+), 67 deletions(-) diff --git a/apps/rowboat/app/projects/[projectId]/playground/components/messages.tsx b/apps/rowboat/app/projects/[projectId]/playground/components/messages.tsx index 945f6764..162fc3fe 100644 --- a/apps/rowboat/app/projects/[projectId]/playground/components/messages.tsx +++ b/apps/rowboat/app/projects/[projectId]/playground/components/messages.tsx @@ -31,7 +31,6 @@ function UserMessage({ content }: { content: string }) { } function InternalAssistantMessage({ content, sender, latency, delta, showJsonMode = false }: { content: string, sender: string | null | undefined, latency: number, delta: number, showJsonMode?: boolean }) { - const [expanded, setExpanded] = useState(true); const isJsonContent = useMemo(() => { try { JSON.parse(content); @@ -40,7 +39,18 @@ function InternalAssistantMessage({ content, sender, latency, delta, showJsonMod return false; } }, [content]); - const [jsonMode, setJsonMode] = useState(isJsonContent); + + const hasResponseKey = useMemo(() => { + if (!isJsonContent) return false; + try { + const parsed = JSON.parse(content); + return parsed && typeof parsed === 'object' && 'response' in parsed; + } catch { + return false; + } + }, [content, isJsonContent]); + + const [jsonMode, setJsonMode] = useState(false); const [wrapText, setWrapText] = useState(true); // Show plus icon and duration @@ -50,9 +60,17 @@ function InternalAssistantMessage({ content, sender, latency, delta, showJsonMod ); - // Get first line preview - const firstLine = content.split('\n')[0].trim(); - const preview = firstLine.length > 50 ? firstLine.substring(0, 50) + '...' : firstLine; + // Extract response content for display + const displayContent = useMemo(() => { + if (!isJsonContent || !hasResponseKey) return content; + + try { + const parsed = JSON.parse(content); + return parsed.response || content; + } catch { + return content; + } + }, [content, isJsonContent, hasResponseKey]); // Format JSON content const formattedJson = useMemo(() => { @@ -69,72 +87,47 @@ function InternalAssistantMessage({ content, sender, latency, delta, showJsonMod
{sender ?? 'Assistant'}
-
-
- {!expanded ? ( -
-
- {preview} -
-
- -
- {deltaDisplay} -
-
-
- ) : ( - <> -
- {isJsonContent && ( -
- - {jsonMode && ( - - )} -
- )} - {isJsonContent && jsonMode ? ( -
 setWrapText(!wrapText)}
                                     >
-                                        {formattedJson}
-                                    
- ) : ( - + {wrapText ? : } + {wrapText ? 'Overflow' : 'Wrap'} + )}
-
- -
- {deltaDisplay} -
-
- - )} + )} + {isJsonContent && hasResponseKey && jsonMode ? ( +
+                                {formattedJson}
+                            
+ ) : ( + + )} +
+
+
+ {deltaDisplay} +
+