import { For, Match, Switch, createEffect, createMemo, createSignal, onCleanup } from "solid-js" import { Part } from "@opencode-ai/ui" import { useSync } from "@/context/sync" import type { AssistantMessage as AssistantMessageType } from "@opencode-ai/sdk" export function MessageProgress(props: { assistantMessages: () => AssistantMessageType[] }) { const sync = useSync() const items = createMemo(() => props.assistantMessages().flatMap((m) => sync.data.part[m.id])) const finishedItems = createMemo(() => [ "", "", "Loading...", ...items().filter( (p) => p?.type === "text" || (p?.type === "reasoning" && p.time?.end) || (p?.type === "tool" && p.state.status === "completed"), ), "", ]) const MINIMUM_DELAY = 400 const [visibleCount, setVisibleCount] = createSignal(1) createEffect(() => { const total = finishedItems().length if (total > visibleCount()) { const timer = setTimeout(() => { setVisibleCount((prev) => prev + 1) }, MINIMUM_DELAY) onCleanup(() => clearTimeout(timer)) } else if (total < visibleCount()) { setVisibleCount(total) } }) const translateY = createMemo(() => { const total = visibleCount() if (total < 2) return "0px" return `-${(total - 2) * 40 - 8}px` }) return (
{(part) => { if (typeof part === "string") return
{part}
const message = createMemo(() => sync.data.message[part.sessionID].find((m) => m.id === part.messageID)) return (
{(p) => (
)} {(p) => } {(p) => }
) }}
) }