fix: remove ui/colony submodule, add as regular directory
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
86
ui/colony/src/components/MessageItem.tsx
Normal file
86
ui/colony/src/components/MessageItem.tsx
Normal file
@@ -0,0 +1,86 @@
|
||||
import type { Message } from "@/types/Message";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
|
||||
interface Props {
|
||||
message: Message;
|
||||
replyTarget?: Message;
|
||||
onReply: (id: string) => void;
|
||||
}
|
||||
|
||||
const TYPE_STYLES: Record<string, string> = {
|
||||
text: "",
|
||||
code: "bg-muted font-mono text-sm whitespace-pre-wrap",
|
||||
result: "border-l-4 border-green-500 pl-3",
|
||||
error: "border-l-4 border-red-500 pl-3 text-red-700 dark:text-red-400",
|
||||
plan: "border-l-4 border-blue-500 pl-3",
|
||||
};
|
||||
|
||||
export function MessageItem({ message, replyTarget, onReply }: Props) {
|
||||
const isAgent = message.user.role === "agent";
|
||||
const isDeleted = !!message.deleted_at;
|
||||
|
||||
return (
|
||||
<div className="group px-4 py-2 hover:bg-muted/50 transition-colors">
|
||||
{replyTarget && (
|
||||
<div className="text-xs text-muted-foreground ml-8 mb-1 flex items-center gap-1">
|
||||
<span className="text-muted-foreground/50">replying to</span>
|
||||
<span className="font-medium">{replyTarget.user.display_name}</span>
|
||||
<span className="truncate max-w-64">{replyTarget.content}</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex items-start gap-2">
|
||||
<div
|
||||
className={`w-7 h-7 rounded-full flex-shrink-0 flex items-center justify-center text-xs font-bold ${
|
||||
isAgent
|
||||
? "bg-primary text-primary-foreground"
|
||||
: "bg-secondary text-secondary-foreground"
|
||||
}`}
|
||||
>
|
||||
{message.user.display_name[0]}
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-semibold text-sm">{message.user.display_name}</span>
|
||||
{isAgent && (
|
||||
<Badge variant="outline" className="text-[10px] py-0 h-4">
|
||||
agent
|
||||
</Badge>
|
||||
)}
|
||||
{message.type !== "text" && (
|
||||
<Badge variant="secondary" className="text-[10px] py-0 h-4">
|
||||
{message.type}
|
||||
</Badge>
|
||||
)}
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{new Date(message.created_at).toLocaleTimeString()}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onReply(message.id)}
|
||||
className="text-xs text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity"
|
||||
>
|
||||
reply
|
||||
</button>
|
||||
</div>
|
||||
<div className={`mt-0.5 text-sm ${TYPE_STYLES[message.type] || ""}`}>
|
||||
{isDeleted ? (
|
||||
<span className="italic text-muted-foreground">[deleted]</span>
|
||||
) : (
|
||||
message.content
|
||||
)}
|
||||
</div>
|
||||
{message.metadata && isAgent && (
|
||||
<div className="mt-1 flex gap-2 text-[10px] text-muted-foreground">
|
||||
{(message.metadata as Record<string, unknown>).model && (
|
||||
<span>{String((message.metadata as Record<string, unknown>).model)}</span>
|
||||
)}
|
||||
{(message.metadata as Record<string, unknown>).hostname && (
|
||||
<span>{String((message.metadata as Record<string, unknown>).hostname)}</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user