Problem
CostDashboard component exists but is missing critical UI elements expected by E2E tests, causing 3 test failures.
Current State
- ✅
CostDashboard component exists (web-ui/src/components/metrics/CostDashboard.tsx)
- ✅ Metrics panel rendered in Dashboard (
web-ui/src/components/Dashboard.tsx:519-524)
- ❌ Missing: Date range filter
- ❌ Missing: Task cost breakdown table
- ❌ Missing: Cost trend chart
Failed Tests (3 total)
All in tests/e2e/test_metrics_ui.spec.ts:
-
should filter metrics by date range (line 166)
- Error:
date-range-filter element not found
- Expected: Date range picker with start/end date inputs
-
should display cost per task (line 201)
- Error:
task-column-header element not found
- Expected: Table with columns: Task, Cost, Tokens
-
should display cost trend chart (line 281)
- Error:
trend-chart-data element not found
- Expected: Line/area chart showing cost over time
Missing UI Components
1. Date Range Filter (Priority: High)
Required data-testid elements:
date-range-filter - Container div
start-date-input - Start date picker
end-date-input - End date picker
apply-filter-button - Apply button
Example Implementation:
<div data-testid="date-range-filter" className="mb-4">
<label>Start Date</label>
<input
type="date"
data-testid="start-date-input"
value={startDate}
onChange={handleStartDateChange}
/>
<label>End Date</label>
<input
type="date"
data-testid="end-date-input"
value={endDate}
onChange={handleEndDateChange}
/>
<button data-testid="apply-filter-button" onClick={applyFilter}>
Apply
</button>
</div>
2. Task Cost Breakdown Table (Priority: High)
Required data-testid elements:
task-cost-table - Table container
task-column-header - "Task" header
cost-column-header - "Cost (USD)" header
tokens-column-header - "Tokens" header
task-row-{task_id} - Each task row
Data Source: /api/projects/{id}/metrics/costs endpoint
Example Implementation:
<table data-testid="task-cost-table" className="w-full">
<thead>
<tr>
<th data-testid="task-column-header">Task</th>
<th data-testid="cost-column-header">Cost (USD)</th>
<th data-testid="tokens-column-header">Tokens</th>
</tr>
</thead>
<tbody>
{tasks.map(task => (
<tr key={task.id} data-testid={`task-row-${task.id}`}>
<td>{task.name}</td>
<td>${task.cost.toFixed(2)}</td>
<td>{task.tokens.toLocaleString()}</td>
</tr>
))}
</tbody>
</table>
3. Cost Trend Chart (Priority: Medium)
Required data-testid elements:
trend-chart - Chart container
trend-chart-data - Data visualization (SVG/Canvas)
chart-x-axis - X-axis (time labels)
chart-y-axis - Y-axis (cost labels)
Recommended Library: Recharts (already used in project?)
Example Implementation:
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip } from 'recharts';
<div data-testid="trend-chart">
<LineChart width={600} height={300} data={trendData}>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="date" data-testid="chart-x-axis" />
<YAxis data-testid="chart-y-axis" />
<Tooltip />
<Line
type="monotone"
dataKey="cost"
stroke="#8884d8"
data-testid="trend-chart-data"
/>
</LineChart>
</div>
API Endpoints Required
Verify these endpoints exist and return correct data:
-
GET /api/projects/{id}/metrics/costs
- Returns:
{ total_cost_usd, by_agent[], by_model[], by_task[] }
-
GET /api/projects/{id}/metrics/costs?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD
- Returns: Filtered cost data for date range
-
GET /api/projects/{id}/metrics/trend
- Returns: Time-series data
[{ date, cost, tokens }]
Implementation Estimate
- Date Range Filter: 30-45 minutes
- Task Cost Table: 45-60 minutes
- Cost Trend Chart: 60-90 minutes
- Testing & Polish: 30 minutes
- Total: 2.5-3.5 hours
Acceptance Criteria
Files to Modify
web-ui/src/components/metrics/CostDashboard.tsx - Add all three components
web-ui/src/api/metrics.ts - Add API client functions (if missing)
web-ui/package.json - Add charting library if needed
Optional Enhancements
- Export to CSV button
- Toggle between daily/weekly/monthly aggregation
- Hover tooltips on chart
- Sortable table columns
- Cost alerts/budgets
Problem
CostDashboard component exists but is missing critical UI elements expected by E2E tests, causing 3 test failures.
Current State
CostDashboardcomponent exists (web-ui/src/components/metrics/CostDashboard.tsx)web-ui/src/components/Dashboard.tsx:519-524)Failed Tests (3 total)
All in
tests/e2e/test_metrics_ui.spec.ts:should filter metrics by date range (line 166)
date-range-filterelement not foundshould display cost per task (line 201)
task-column-headerelement not foundshould display cost trend chart (line 281)
trend-chart-dataelement not foundMissing UI Components
1. Date Range Filter (Priority: High)
Required data-testid elements:
date-range-filter- Container divstart-date-input- Start date pickerend-date-input- End date pickerapply-filter-button- Apply buttonExample Implementation:
2. Task Cost Breakdown Table (Priority: High)
Required data-testid elements:
task-cost-table- Table containertask-column-header- "Task" headercost-column-header- "Cost (USD)" headertokens-column-header- "Tokens" headertask-row-{task_id}- Each task rowData Source:
/api/projects/{id}/metrics/costsendpointExample Implementation:
3. Cost Trend Chart (Priority: Medium)
Required data-testid elements:
trend-chart- Chart containertrend-chart-data- Data visualization (SVG/Canvas)chart-x-axis- X-axis (time labels)chart-y-axis- Y-axis (cost labels)Recommended Library: Recharts (already used in project?)
Example Implementation:
API Endpoints Required
Verify these endpoints exist and return correct data:
GET /api/projects/{id}/metrics/costs
{ total_cost_usd, by_agent[], by_model[], by_task[] }GET /api/projects/{id}/metrics/costs?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD
GET /api/projects/{id}/metrics/trend
[{ date, cost, tokens }]Implementation Estimate
Acceptance Criteria
Files to Modify
web-ui/src/components/metrics/CostDashboard.tsx- Add all three componentsweb-ui/src/api/metrics.ts- Add API client functions (if missing)web-ui/package.json- Add charting library if neededOptional Enhancements