"use client"; import { IconArrowsMaximize, IconX } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import type { Task } from "./kanban-card"; import { TaskChatPanel } from "./task/task-chat-panel"; import { useTaskChatSession } from "@/hooks/use-task-chat-session"; import { getWebSocketClient } from "@/lib/ws/connection"; interface TaskPreviewPanelProps { task: Task | null; sessionId?: string | null; onClose: () => void; onMaximize?: (task: Task, sessionId: string) => void; } export function TaskPreviewPanel({ task, sessionId = null, onClose, onMaximize }: TaskPreviewPanelProps) { const { taskSessionId } = useTaskChatSession(task?.id ?? null); const activeSessionId = sessionId ?? taskSessionId; const handleSendMessage = async (content: string) => { if (!task?.id) return; const client = getWebSocketClient(); if (!client) return; if (!activeSessionId) { console.error("No active task session. Start an agent before sending a message."); return; } try { await client.request( "message.add", { task_id: task.id, session_id: activeSessionId, content }, 10000 ); } catch (error) { console.error("Failed to send message:", error); } }; return (
{/* Header */}

{task?.title ?? "Task Chat"}

{onMaximize && activeSessionId && task && ( )}
{/* Content */}
{task ? ( ) : (
Select a task to start chatting
)}
); }