diff options
| author | Ben Sima <ben@bensima.com> | 2025-11-27 10:59:38 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-11-27 10:59:38 -0500 |
| commit | 83ff4b622be49762491dac216ab8df374b24cd74 (patch) | |
| tree | 6f8d85b640716c43a309ae41e4bb61dd233bdfef /Omni/Agent/Log.hs | |
| parent | 273208a8ffd714eb9cda51d557dbc62ff3009932 (diff) | |
Display worker metrics on task detail page
All tests pass. Let me summarize what was implemented:
- Extended `TaskActivity` type with new fields:
- `activityAmpThreadUrl` - Link to amp thread - `activityStartedAt` -
Work start timestamp - `activityCompletedAt` - Work completion
timestamp - `activityCostCents` - API cost in cents -
`activityTokensUsed` - Token usage count
- Updated `SQL.FromRow` and `SQL.ToRow` instances for the new fields -
Updated schema to include new columns in `task_activity` table - Added
`logActivityWithMetrics` function to log activities with all met -
Added `updateActivityMetrics` function to update metrics on existing
a - Added `getLatestRunningActivity` helper function
- Captures execution timing (start/end timestamps) - Retrieves amp
thread URL from `AgentLog.getStatus` - Converts credits to cents
and logs to activity record - Uses `logActivityWithMetrics` and
`updateActivityMetrics` for tracking
- Added `getStatus` function to retrieve current status (thread
URL, cre
- Added `TaskMetricsPartial` type for HTMX auto-refresh - Extended
`TaskDetailPage` to include `RetryContext` - Added Execution Details
section on task detail page showing:
- Amp Thread URL (clickable link) - Duration (formatted as "Xm Ys")
- Cost (formatted as "$X.XX") - Retry Attempt count (if applicable)
- Last Activity timestamp
- Added `/partials/task/:id/metrics` endpoint for HTMX auto-refresh
- Auto-refresh enabled while task is InProgress (every 5s) - Added
`renderExecutionDetails` helper function
- Added `executionDetailsStyles` for metric rows and execution section
- Added dark mode support for execution details section
Task-Id: t-148.4
Diffstat (limited to 'Omni/Agent/Log.hs')
| -rw-r--r-- | Omni/Agent/Log.hs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Omni/Agent/Log.hs b/Omni/Agent/Log.hs index b1020c5..55bc1e2 100644 --- a/Omni/Agent/Log.hs +++ b/Omni/Agent/Log.hs @@ -72,6 +72,10 @@ update f = do modifyIORef' currentStatus f render +-- | Get the current status +getStatus :: IO Status +getStatus = readIORef currentStatus + -- | Set the activity message updateActivity :: Text -> IO () updateActivity msg = update (\s -> s {statusActivity = msg}) |
