Skip to content

Commit 966544a

Browse files
committed
refactor: Simplify chat UI to flat message bubbles without personas
1 parent aa64c12 commit 966544a

1 file changed

Lines changed: 11 additions & 62 deletions

File tree

frontend/src/components/ai/TemplateChat.tsx

Lines changed: 11 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,8 @@ import {
88
SendIcon,
99
SparklesIcon,
1010
StopCircleIcon,
11-
CopyIcon,
12-
CheckIcon,
13-
UserIcon,
14-
BotIcon,
1511
WrenchIcon,
1612
} from 'lucide-react';
17-
import {
18-
MessageAction,
19-
} from '@/components/ai-elements/message';
2013
import { Reasoning, ReasoningTrigger, ReasoningContent } from '@/components/ai-elements/reasoning';
2114
import { MessageResponse } from '@/components/ai-elements/message';
2215
import { useState, useRef, useEffect } from 'react';
@@ -61,7 +54,6 @@ export function TemplateChat({
6154
currentSampleData,
6255
originalValues,
6356
}: TemplateChatProps) {
64-
const [copiedId, setCopiedId] = useState<string | null>(null);
6557
const [inputValue, setInputValue] = useState('');
6658
const messagesEndRef = useRef<HTMLDivElement>(null);
6759

@@ -237,12 +229,6 @@ When making changes, consider the existing template structure and build upon it
237229
}
238230
};
239231

240-
const handleCopy = async (content: string, id: string) => {
241-
await navigator.clipboard.writeText(content);
242-
setCopiedId(id);
243-
setTimeout(() => setCopiedId(null), 2000);
244-
};
245-
246232
// Helper to extract text content and tool info from message parts
247233
const renderMessageContent = (message: typeof messages[0]) => {
248234
if (!('parts' in message) || !Array.isArray(message.parts)) {
@@ -371,63 +357,26 @@ When making changes, consider the existing template structure and build upon it
371357
const textContent = getMessageText(message);
372358

373359
return (
374-
<div key={message.id} className="group flex flex-col gap-3 animate-in fade-in slide-in-from-bottom-2 duration-300">
375-
<div className={cn(
376-
"flex items-center gap-3",
377-
isUser ? "flex-row-reverse text-right" : "flex-row"
378-
)}>
379-
<div className={cn(
380-
"flex-shrink-0 w-6 h-6 rounded flex items-center justify-center shadow-sm",
381-
isUser ? "bg-primary text-primary-foreground" : "bg-purple-600 text-white"
382-
)}>
383-
{isUser ? <UserIcon className="w-3 h-3" /> : <BotIcon className="w-3 h-3" />}
384-
</div>
385-
386-
<span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground/60">
387-
{isUser ? "Question" : "ShipSec AI"}
388-
</span>
389-
390-
{!isUser && textContent && (
391-
<div className="opacity-0 group-hover:opacity-100 transition-opacity ml-2">
392-
<MessageAction
393-
tooltip="Copy"
394-
onClick={() => handleCopy(textContent, message.id)}
395-
className="h-6 w-6"
396-
>
397-
{copiedId === message.id ? <CheckIcon className="w-3 h-3 text-green-500" /> : <CopyIcon className="w-3 h-3" />}
398-
</MessageAction>
399-
</div>
400-
)}
401-
</div>
402-
360+
<div key={message.id} className="group animate-in fade-in slide-in-from-bottom-2 duration-300">
403361
<div className={cn(
404362
"text-sm leading-relaxed text-foreground/90 selection:bg-primary/20",
405-
isUser ? "pr-9 text-right font-medium text-foreground" : "pl-9"
363+
isUser
364+
? "bg-muted/50 text-foreground rounded-2xl px-4 py-2.5 ml-auto max-w-[85%]"
365+
: "text-foreground/90"
406366
)}>
407367
{isUser ? textContent : renderMessageContent(message)}
408368
</div>
409369
</div>
410370
);
411371
})
412372
)}
413-
{isLoading && (() => {
414-
const lastMsg = messages[messages.length - 1];
415-
const hasContent = lastMsg?.role === 'assistant' && renderMessageContent(lastMsg);
416-
const label = hasContent ? 'Working' : 'Thinking';
417-
418-
return (
419-
<div className="flex flex-col gap-3 pl-9 animate-in fade-in duration-500">
420-
<div className="flex items-center gap-1.5 p-2 w-fit rounded-lg bg-muted/30">
421-
<span className="flex gap-1">
422-
<span className="w-1.5 h-1.5 bg-foreground/40 rounded-full animate-bounce [animation-delay:-0.3s]"></span>
423-
<span className="w-1.5 h-1.5 bg-foreground/40 rounded-full animate-bounce [animation-delay:-0.15s]"></span>
424-
<span className="w-1.5 h-1.5 bg-foreground/40 rounded-full animate-bounce"></span>
425-
</span>
426-
<span className="text-[10px] text-muted-foreground font-medium uppercase tracking-wider ml-1">{label}</span>
427-
</div>
428-
</div>
429-
);
430-
})()}
373+
{isLoading && (
374+
<div className="flex gap-1 animate-in fade-in duration-500">
375+
<span className="w-1.5 h-1.5 bg-muted-foreground/40 rounded-full animate-bounce [animation-delay:-0.3s]"></span>
376+
<span className="w-1.5 h-1.5 bg-muted-foreground/40 rounded-full animate-bounce [animation-delay:-0.15s]"></span>
377+
<span className="w-1.5 h-1.5 bg-muted-foreground/40 rounded-full animate-bounce"></span>
378+
</div>
379+
)}
431380
<div ref={messagesEndRef} />
432381
</div>
433382

0 commit comments

Comments
 (0)