import { ActivationLocation, CrochetValue, StackTrace, TEAction, TEActionChoice, TEEvent, TEFact, TEForget, TEGoalReached, TELog, TETurn, TraceEvent, TraceTag, } from "../../vm"; import { Repr, TerminalRenderer, value_to_repr } from "./representation"; import { html } from "./representation/html-renderer"; import { Transcript } from "../transcript/transcript"; import * as React from "react"; import { Log } from "./ui/log"; import { Column, IElement, Row, Style } from "./ui/basic"; import { Tabs } from "./ui/tabs"; import { EnvV, ListV, LongListV, MapV, Value, ValueS } from "./ui/value"; import { unreachable } from "../../utils/utils"; import { Heading, List } from "./ui/info"; import { Foldable } from "./ui/folds"; type ITranscriptUI = { transcript: Transcript; }; type ITranscriptState = {}; export class TranscriptUI extends React.Component< ITranscriptUI, ITranscriptState > { readonly log = React.createRef(); readonly text_renderer = new TerminalRenderer(true); constructor(props: ITranscriptUI) { super(props); props.transcript.subscribe(this.on_message); } on_message = (entry: TraceEvent) => { this.push_render_entry(entry); }; push_render_entry(entry: TraceEvent) { this.log.current?.append(this.render_entry(entry)); } render() { return ( ); } render_entry(x: TraceEvent) { return {this.render_entry_inner(x)}; } render_entry_inner(x: TraceEvent) { if (x instanceof TELog) { return ( {this.render_message(x.value)} ); } else if (x instanceof TEFact) { return ( ( ))} /> ); } else if (x instanceof TEForget) { return ( html.render_value(a))} /> ); } else if (x instanceof TEAction) { return ( {x.choice.action.name} ({x.choice.score}) ); } else if (x instanceof TEEvent) { return ( ); } else if (x instanceof TETurn) { return ( ); } else if (x instanceof TEGoalReached) { return ( ); } else if (x instanceof TEActionChoice) { return (
{ return ( {a.action.name} ({a.score}) ); })} />
); } else { throw unreachable(x, "Trace Event"); } } render_message(x: string | CrochetValue) { if (typeof x === "string") { return (
{x}
); } else { return ; } } } function Entry(props: IElement & { type: TraceTag }) { return ( {props.children} ); } function Location(props: { location: ActivationLocation }) { return (
{StackTrace.format_location(props.location)}
); } function Meta(props: IElement) { return ( {props.children} ); } function Category(props: { tag: string; category?: string }) { return (
{props.tag}
{props.category}
); } function Message(props: IElement) { return (
{props.children}
); }