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 | |
| 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')
| -rw-r--r-- | Omni/Jr/Web/Handlers.hs | 2 | ||||
| -rw-r--r-- | Omni/Jr/Web/Partials.hs | 33 | ||||
| -rw-r--r-- | Omni/Jr/Web/Types.hs | 2 |
3 files changed, 28 insertions, 9 deletions
diff --git a/Omni/Jr/Web/Handlers.hs b/Omni/Jr/Web/Handlers.hs index 463c9f7..da8a2e6 100644 --- a/Omni/Jr/Web/Handlers.hs +++ b/Omni/Jr/Web/Handlers.hs @@ -435,7 +435,7 @@ server = let isInProgress = case TaskCore.findTask tid tasks of Nothing -> False Just task -> TaskCore.taskStatus task == TaskCore.InProgress - pure (AgentEventsPartial events isInProgress now) + pure (AgentEventsPartial tid events isInProgress now) taskEventsStreamHandler :: Text -> Servant.Handler (SourceIO ByteString) taskEventsStreamHandler tid = do 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 diff --git a/Omni/Jr/Web/Types.hs b/Omni/Jr/Web/Types.hs index c463bfa..025f3a6 100644 --- a/Omni/Jr/Web/Types.hs +++ b/Omni/Jr/Web/Types.hs @@ -287,7 +287,7 @@ newtype TaskListPartial = TaskListPartial [TaskCore.Task] data TaskMetricsPartial = TaskMetricsPartial Text [TaskCore.TaskActivity] (Maybe TaskCore.RetryContext) UTCTime -data AgentEventsPartial = AgentEventsPartial [TaskCore.StoredEvent] Bool UTCTime +data AgentEventsPartial = AgentEventsPartial Text [TaskCore.StoredEvent] Bool UTCTime data DescriptionViewPartial = DescriptionViewPartial Text Text Bool |
