mirror of
https://github.com/multica-ai/multica.git
synced 2026-08-12 00:45:55 +02:00
* feat(runtimes): weekly usage dimension + tz-aware aggregation (MUL-2382) Adds a Weekly view to the runtime Usage chart alongside Daily and Hourly, backed by `aggregateByWeek` on the existing 180-day daily cache (no new endpoint). Weeks are ISO 8601 Mon–Sun; the in-progress week is rendered at half opacity and tooltip-labelled "partial · N / 7 days". Side effects called out in the RFC: - `sliceWindow` now reads "today" in the runtime's IANA timezone, fixing a one-day drift at the window edge when the browser and runtime sit in different time zones. - ActivityHeatmap rows are reordered Mon → Sun to match the rest of the Weekly aggregation; "today" is computed in runtime tz so the grid's trailing column lines up with the daily rows the backend buckets. Dimension / period coupling: switching dimension resets the period to that dimension's default when the active value isn't in its allowed set (Hourly 7/30, Daily 7/30/90, Weekly 30/90/180). Unit tests cover weekStart / addDays / tz-aware today, the sliceWindow boundary, and aggregateByWeek's partial-week math. Co-authored-by: multica-agent <github@multica.ai> * fix(runtimes): weekly chart shows trailing calendar weeks (MUL-2382) aggregateByWeek built one bucket per week-with-data, and the caller took the last N buckets. With sparse data — old populated weeks plus empty stretches near today — the slice surfaced the old weeks instead of the trailing in-window calendar weeks the user selected. Now aggregateByWeek takes weekCount and emits exactly that many trailing calendar weeks anchored at today's week in the runtime tz. Buckets are pre-zeroed so empty in-range weeks render as empty bars; rows outside the window are dropped. Co-authored-by: multica-agent <github@multica.ai> * feat(usage): drop Hourly dim + add Daily/Weekly to workspace dashboard (MUL-2382) - Remove Hourly from the runtime usage WHEN-chart: segmented control is now Daily / Weekly. Drop the HourlyActivityChart component, aggregateCostByHour helper, byHour query subscription, and the when_tab_hourly i18n key. - Add the same Daily / Weekly dimension toggle to the workspace-level Usage page (dashboard-page.tsx). Time-range linkage matches the runtime page: Daily allows 7/30/90 (default 30), Weekly allows 30/90/180 (default 90); switching dimensions resets `days` when the current value isn't in the new dimension's set. - Reuse `aggregateByWeek` from runtimes/utils for cost / tokens (signature relaxed to accept the wider DashboardUsageDaily shape). Add `aggregateWeeklyTime` / `aggregateWeeklyTasks` in dashboard/utils with identical pre-zeroed trailing-week semantics. Workspace dashboard uses the user-chosen timezone (existing TimezoneSelect) as the week-boundary tz; runtime page continues to use the runtime's IANA tz. - New `WeeklyTimeChart` / `WeeklyTasksChart` mirror their daily counterparts plus partial-week half-opacity bars and rangeLabel tooltips, matching the existing Weekly cost / tokens charts. - Tests: drop hourly-related setup; add weekly run-time / tasks coverage asserting pre-zeroed trailing buckets and the same MUL-2382 sparse window-scoping regression we caught on the runtime side. Co-authored-by: multica-agent <github@multica.ai> * fix(usage): correct workspace Weekly window + lock tz to UTC (MUL-2382) Two blocking correctness bugs from Emacs's PR #2822 review: 1. The Weekly chart paints `ceil(days/7)` trailing calendar weeks but the API was still asked for exactly `days`. Worst case (today = Sunday on a 30D request) the leftmost Monday sits 34 days back, so the first week's bucket was silently truncated. Over-fetch the per-date queries to `weekCount * 7` days when Weekly is active; per-agent rollups stay at `days` so the KPI / leaderboard labels keep their advertised window. Daily-aggregation surfaces (cost/tokens/time/tasks KPIs and the Daily chart) re-scope the over-fetched rows back to `days` so the labels stay consistent. 2. The backend dashboard rollup buckets data by UTC `bucket_date` (and the raw fallback queries by `DATE(tu.created_at)`, also UTC), but the frontend was driving Weekly boundaries from the user-chosen `TimezoneSelect`. Near midnight UTC that put cross-boundary rows into the wrong calendar week. Lock workspace Weekly to UTC and remove the timezone picker from this page; the runtime detail page keeps its own `runtime.timezone`-anchored aggregation, which is consistent because its rollup is materialized in that runtime's tz. Verification: pnpm --filter @multica/views test (636 passed), typecheck clean, lint 0 errors / 13 pre-existing warnings. Co-authored-by: multica-agent <github@multica.ai> --------- Co-authored-by: multica-agent <github@multica.ai>
59 lines
1.6 KiB
JSON
59 lines
1.6 KiB
JSON
{
|
|
"title": "Usage",
|
|
"subtitle": "Token spend and agent activity across this workspace.",
|
|
"filter": {
|
|
"project_label": "Project",
|
|
"all_projects": "All projects",
|
|
"period_label": "Period"
|
|
},
|
|
"kpi": {
|
|
"cost_label": "Cost · {{days}}D",
|
|
"tokens_label": "Tokens · {{days}}D",
|
|
"tokens_hint": "Input {{input}} · Output {{output}}",
|
|
"run_time_label": "Run time · {{days}}D",
|
|
"run_time_hint": "Across {{tasks}} tasks",
|
|
"tasks_label": "Tasks · {{days}}D",
|
|
"tasks_hint": "{{failed}} failed"
|
|
},
|
|
"dim": {
|
|
"label": "Dimension",
|
|
"daily": "Daily",
|
|
"weekly": "Weekly"
|
|
},
|
|
"daily": {
|
|
"title_cost": "Daily cost",
|
|
"title_tokens": "Daily tokens",
|
|
"title_time": "Daily run time",
|
|
"title_tasks": "Daily tasks",
|
|
"metric_cost": "Cost",
|
|
"metric_tokens": "Tokens",
|
|
"metric_time": "Time",
|
|
"metric_tasks": "Tasks",
|
|
"no_data": "No usage in this window."
|
|
},
|
|
"weekly": {
|
|
"title_cost": "Weekly cost",
|
|
"title_tokens": "Weekly tokens",
|
|
"title_time": "Weekly run time",
|
|
"title_tasks": "Weekly tasks",
|
|
"partial_label": "{{range}} (partial · {{covered}} / 7 days)"
|
|
},
|
|
"leaderboard": {
|
|
"title": "Leaderboard",
|
|
"caption": "{{count}} agents",
|
|
"header_agent": "Agent",
|
|
"header_tokens": "Tokens",
|
|
"header_cost": "Cost",
|
|
"header_time": "Time",
|
|
"header_tasks": "Tasks",
|
|
"no_data": "No agent activity in this window."
|
|
},
|
|
"empty": {
|
|
"title": "No usage yet",
|
|
"body": "Once agents start running tasks here, their token spend and run time will appear in this view."
|
|
},
|
|
"duration": {
|
|
"less_than_minute": "<1m"
|
|
}
|
|
}
|