import { Component, createMemo, For, Match, Show, Switch } from "solid-js" import { Dynamic } from "solid-js/web" import { AssistantMessage, Message as MessageType, Part as PartType, TextPart, ToolPart, UserMessage, } from "@opencode-ai/sdk" export interface MessageProps { message: MessageType parts: PartType[] } export interface MessagePartProps { part: PartType message: MessageType hideDetails?: boolean } export type PartComponent = Component const PART_MAPPING: Record = {} export function registerPartComponent(type: string, component: PartComponent) { PART_MAPPING[type] = component } export function Message(props: MessageProps) { return ( {(userMessage) => ( )} {(assistantMessage) => ( )} ) } export function AssistantMessageDisplay(props: { message: AssistantMessage; parts: PartType[] }) { const filteredParts = createMemo(() => { return props.parts?.filter((x) => { if (x.type === "reasoning") return false return x.type !== "tool" || (x as ToolPart).tool !== "todoread" }) }) return {(part) => } } export function UserMessageDisplay(props: { message: UserMessage; parts: PartType[] }) { const text = createMemo(() => props.parts ?.filter((p) => p.type === "text" && !(p as TextPart).synthetic) ?.map((p) => (p as TextPart).text) ?.join(""), ) return
{text()}
} export function Part(props: MessagePartProps) { const component = createMemo(() => PART_MAPPING[props.part.type]) return ( ) }