| Sean McCullough | 021231a | 2025-06-12 09:35:24 -0700 | [diff] [blame] | 1 | import { SketchTimeline } from "./web-components/sketch-timeline"; |
| 2 | import { 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). |
| 6 | SketchTimeline; |
| 7 | |
| 8 | export 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 McCullough | d183284 | 2025-06-20 22:42:06 -0400 | [diff] [blame] | 19 | timelineEl.scrollContainer = { value: window.document.body }; |
| Sean McCullough | 021231a | 2025-06-12 09:35:24 -0700 | [diff] [blame] | 20 | container.replaceWith(timelineEl); |
| 21 | } |
| 22 | |
| 23 | window.globalThis.renderMessagesViewer = renderMessagesViewer; |