import { Profiler, useCallback, useState } from "react"; import { ThreadViewport } from "@/components/thread/ThreadViewport"; import { SubagentTasksProvider } from "@/components/thread/SubagentTasks"; import { useClient } from "@/providers/ClientProvider"; import { useSessionHistory } from "@/hooks/useSessions"; import { usePromptHistory } from "@/hooks/usePromptHistory"; import type { UIMessage } from "@/lib/types"; const localMessages: UIMessage[] = Array.from({ length: 280 }, (_, index) => ({ id: `local-${index}`, role: index % 2 ? "assistant" : "user", content: `Cached message ${index}`, createdAt: index + 1, })); export function HistoryBoundaryFixture({ local = false, navigate = false, tasks = false }: { local?: boolean; navigate?: boolean; tasks?: boolean }) { const { client, token } = useClient(); const [key, setKey] = useState("websocket:boundary-a"); const history = useSessionHistory(local ? null : key); const messages = local ? localMessages : history.messages; const navigation = usePromptHistory(local ? null : key, history.version, messages); const [taskWindow, setTaskWindow] = useState<{ key: string; turnIds: string[] } | null>(null); const reportVisibleMessages = useCallback((visible: UIMessage[]) => { const turnIds = [...new Set(visible.flatMap(message => message.role === "user" && message.turnId ? [message.turnId] : []))]; setTaskWindow(current => current?.key === key && current.turnIds.length === turnIds.length && current.turnIds.every((turnId, index) => turnId === turnIds[index]) ? current : { key, turnIds }); }, [key]); return
{ window.dispatchEvent(new CustomEvent("history-boundary-render", { detail: { phase, actualDuration } })); }}> 0)}> History boundary fixture} />
; }