From 11ee0b44397ff5f58a11a105883c07a39d49bfa3 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 1 Dec 2025 18:59:04 -0500 Subject: Fix timeline partial to include cost/token metrics and controls The HTMX-refreshed AgentEventsPartial was missing: - Cost/token summary in header - Live toggle button - Autoscroll toggle button - Comment form Now matches the full page renderUnifiedTimeline output. --- Omni/Jr/Web/Partials.hs | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'Omni/Jr/Web/Partials.hs') diff --git a/Omni/Jr/Web/Partials.hs b/Omni/Jr/Web/Partials.hs index 79c997e..9c0e870 100644 --- a/Omni/Jr/Web/Partials.hs +++ b/Omni/Jr/Web/Partials.hs @@ -15,8 +15,15 @@ import qualified Lucid import qualified Lucid.Base as Lucid import Numeric (showFFloat) import Omni.Jr.Web.Components - ( priorityBadgeWithForm, + ( aggregateCostMetrics, + commentForm, + formatCostHeader, + formatTokensHeader, + metaSep, + priorityBadgeWithForm, + renderAutoscrollToggle, renderListGroupItem, + renderLiveToggle, renderMarkdown, renderRelativeTimestamp, renderTimelineEvent, @@ -235,13 +242,25 @@ instance Lucid.ToHtml DescriptionEditPartial where instance Lucid.ToHtml AgentEventsPartial where toHtmlRaw = Lucid.toHtml - toHtml (AgentEventsPartial events isInProgress now) = do + toHtml (AgentEventsPartial tid events isInProgress now) = do + let nonCostEvents = filter (\e -> TaskCore.storedEventType e /= "Cost") events + eventCount = length nonCostEvents + (totalCents, totalTokens) = aggregateCostMetrics events Lucid.h3_ <| do - Lucid.toHtml ("Timeline (" <> tshow (length events) <> ")") - when isInProgress <| Lucid.span_ [Lucid.class_ "timeline-live"] " LIVE" - if null events + Lucid.toHtml ("Timeline (" <> tshow eventCount <> ")") + when (totalCents > 0 || totalTokens > 0) <| do + Lucid.span_ [Lucid.class_ "timeline-cost-summary"] <| do + metaSep + when (totalCents > 0) <| Lucid.toHtml (formatCostHeader totalCents) + when (totalCents > 0 && totalTokens > 0) <| metaSep + when (totalTokens > 0) <| Lucid.toHtml (formatTokensHeader totalTokens <> " tokens") + when isInProgress <| do + renderLiveToggle + renderAutoscrollToggle + if null nonCostEvents then Lucid.p_ [Lucid.class_ "empty-msg"] "No activity yet." else do Lucid.div_ [Lucid.class_ "timeline-events"] <| do - traverse_ (renderTimelineEvent now) events - timelineScrollScript + traverse_ (renderTimelineEvent now) nonCostEvents + when isInProgress <| timelineScrollScript + commentForm tid -- cgit v1.2.3