"use client"; import { use } from "react"; import { ArrowLeft, MessageSquare, Wrench } from "lucide-react"; import Link from "next/link"; import { useSession, useMessages } from "@/lib/hooks"; import { timeAgo, formatTokens, platformBadgeClass } from "@/lib/utils"; import { MessageBubble } from "@/components/MessageBubble"; export default function SessionReplayPage({ params }: { params: Promise<{ id: string }> }) { const { id } = use(params); const { data: sessionData } = useSession(id); const { data: messagesData, isLoading } = useMessages(id); const session = sessionData?.session; const messages = messagesData?.items || []; // Group tool results with their preceding assistant tool_calls const visibleMessages = messages.filter( (m) => m.role === "user" || m.role === "assistant" ); // Collect tool results keyed by tool_call_id const toolResults = new Map(); for (const m of messages) { if (m.role === "tool" && m.tool_call_id) { toolResults.set(m.tool_call_id, { name: m.tool_name || "tool", content: m.content || "", }); } } return (
{/* Header */}

{session?.title || `Session ${id.slice(0, 8)}`}

{session && (
{session.source} {session.message_count} msgs {formatTokens(session.input_tokens + session.output_tokens)} tok {timeAgo(session.started_at)}
)}
{/* Messages */} {isLoading ? (
{[...Array(4)].map((_, i) => (
))}
) : (
{visibleMessages.map((m) => ( ))} {visibleMessages.length === 0 && (
Empty session
)}
)}
); }