blob: e61235782b76268643f5bf9eb594caac3a5d1f58 [file] [log] [blame]
Sean McCullough021231a2025-06-12 09:35:24 -07001import { SketchTimeline } from "./web-components/sketch-timeline";
2import { aggregateAgentMessages } from "./web-components/aggregateAgentMessages";
3
4// Ensure this dependency ends up in the bundle (the "as SketchTimeline" reference below
5// is insufficient for the bundler to include it).
6SketchTimeline;
7
8export function renderMessagesViewer(viewData: any, container: HTMLDivElement) {
9 const timelineEl = document.createElement(
10 "sketch-timeline",
11 ) as SketchTimeline;
12 // Filter out hidden messages at the display level (matches sketch behavior)
13 const visibleMessages = viewData.Messages.filter(
14 (msg: any) => !msg.hide_output,
15 );
16 const messages = aggregateAgentMessages(visibleMessages, []);
17 timelineEl.messages = messages;
18 timelineEl.toolCalls = viewData.ToolResults;
Sean McCulloughd1832842025-06-20 22:42:06 -040019 timelineEl.scrollContainer = { value: window.document.body };
Sean McCullough021231a2025-06-12 09:35:24 -070020 container.replaceWith(timelineEl);
21}
22
23window.globalThis.renderMessagesViewer = renderMessagesViewer;