diff options
| author | Ben Sima <ben@bensima.com> | 2025-12-01 18:59:04 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-12-01 18:59:04 -0500 |
| commit | 11ee0b44397ff5f58a11a105883c07a39d49bfa3 (patch) | |
| tree | 7f29283b0ab4808e8b1d9fb5a5a0500a360e392d /Omni/Jr/Web/Partials.hs | |
| parent | d78a9a5038fb95f4035812b4ef5b0c25036aae4a (diff) | |
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.
Diffstat (limited to 'Omni/Jr/Web/Partials.hs')
| -rw-r--r-- | Omni/Jr/Web/Partials.hs | 33 |
1 files changed, 26 insertions, 7 deletions
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 |
