2026-01-20 18:33:29 +02:00
|
|
|
"use client";
|
|
|
|
|
|
2026-01-22 16:43:08 -08:00
|
|
|
import type { FC } from "react";
|
2026-01-25 15:23:45 +05:30
|
|
|
import { Spinner } from "@/components/ui/spinner";
|
2026-01-26 23:32:30 -08:00
|
|
|
import { cn } from "@/lib/utils";
|
2026-01-20 18:33:29 +02:00
|
|
|
|
|
|
|
|
interface ChatSessionStatusProps {
|
|
|
|
|
isAiResponding: boolean;
|
|
|
|
|
respondingToUserId: string | null;
|
|
|
|
|
currentUserId: string | null;
|
|
|
|
|
members: Array<{
|
|
|
|
|
user_id: string;
|
2026-01-20 18:39:50 +02:00
|
|
|
user_display_name?: string | null;
|
|
|
|
|
user_email?: string | null;
|
2026-01-20 18:33:29 +02:00
|
|
|
}>;
|
|
|
|
|
className?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const ChatSessionStatus: FC<ChatSessionStatusProps> = ({
|
|
|
|
|
isAiResponding,
|
|
|
|
|
respondingToUserId,
|
|
|
|
|
currentUserId,
|
|
|
|
|
members,
|
|
|
|
|
className,
|
|
|
|
|
}) => {
|
|
|
|
|
if (!isAiResponding || !respondingToUserId) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (respondingToUserId === currentUserId) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const respondingUser = members.find((m) => m.user_id === respondingToUserId);
|
2026-01-22 16:43:08 -08:00
|
|
|
const displayName =
|
|
|
|
|
respondingUser?.user_display_name || respondingUser?.user_email || "another user";
|
2026-01-20 18:33:29 +02:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
className={cn(
|
|
|
|
|
"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground bg-muted/50 rounded-lg",
|
|
|
|
|
"animate-in fade-in slide-in-from-bottom-2 duration-300 ease-out",
|
|
|
|
|
className
|
|
|
|
|
)}
|
|
|
|
|
>
|
2026-01-25 15:23:45 +05:30
|
|
|
<Spinner size="xs" />
|
2026-01-20 18:33:29 +02:00
|
|
|
<span>Currently responding to {displayName}</span>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|