Skip to content

feat(webapp): improve task and dashboard activity charts#4064

Merged
samejr merged 11 commits into
mainfrom
samejr/recharts-improvements
Jun 28, 2026
Merged

feat(webapp): improve task and dashboard activity charts#4064
samejr merged 11 commits into
mainfrom
samejr/recharts-improvements

Conversation

@samejr

@samejr samejr commented Jun 28, 2026

Copy link
Copy Markdown
Member

Summary

Improves and unifies the run-activity charts by extracting a shared set of chart primitives and adopting them on the three task landing pages (agent, standard, scheduled), with the density and label fixes also carried over to the dashboard and custom query charts.

Main changes a reviewer should know about:

  • Shared primitives (DRY). New ChartCard (title + maximize/fullscreen), ChartSyncContext (cross-chart hover + zoom state), useXAxisTicks (width-aware tick selection), activityTimeAxis, and statusColors, plus a server-side activitySeries.server.ts holding chooseBucketSeconds, status grouping, and the zero-fill helpers. The three task routes and both presenters were refactored onto these, removing roughly 3x duplicated tick logic, status-color tables, and bucket-ladder code.
  • Denser bars on short ranges. Server-side bucketing now uses chooseBucketSeconds (nice-interval ladder, ~72 target, capped at 120 buckets) instead of the hardcoded 1h/6h/1d ladder, so a 5m or 1h range no longer collapses into a single bar.
  • Width-aware x-axis labels. Labels are selected to fit the measured plot width (always first + last, evenly spaced, de-duplicated by rendered text), stay horizontal, and reflow on panel/window resize. Y-axis values default to compact form (8K, 1.2M) in ChartBar/ChartLine.
  • Synced hover line. Hovering one of the agent page's three charts draws a dashed vertical line at the same bucket on the other two, and suppresses it on the hovered chart. It is opt-in via ChartSyncProvider, so single-chart pages are unaffected.
  • Maximize button. Each chart gets a fullscreen dialog toggle (reuses the existing dashboard-widget pattern, v shortcut while hovered).
  • Drag-to-zoom on task pages. Dragging across a task chart sets the Time/Date filter (from/to URL params, clearing period/cursor), with a From/To tooltip shown during the drag.
  • Custom query charts. Long categorical x labels (run IDs, task names) middle-truncate and auto-rotate only when needed, and label thinning is now width-aware for both bar and line variants. Dashboard line-chart label density is also width-aware, tuned by a TIME_AXIS_LABEL_SPACING_PX constant.
  • Tests. 46 new unit tests for the pure logic (bucket selection, tick spacing, time-axis formatting, zoom range, truncation).

Intentionally unchanged

  • No click/drag zoom on the dashboard or custom query charts. Drag-to-zoom is wired up on the task landing pages only; zooming the dashboard and custom charts is deliberately deferred to a separate follow-up PR. A plain click (without a drag) on a task chart is a no-op.
  • The 25 mini activity charts on the Task list (_index) page are untouched. They are hand-rolled raw-Recharts sparklines kept deliberately lightweight and do not use these primitives.
  • Other raw-Recharts sparklines are untouched (the usage sparkline, errors and prompts pages).
  • No ClickHouse query semantics changed beyond the bucket-interval parameter (same filters, same FINAL / _is_deleted handling).
  • Webapp-only. No public package (packages/*) changes, so there is no changeset; the .server-changes/ entries cover it.

Testing

Added 46 unit tests covering server-side bucket selection, width-aware tick spacing, time-axis formatting, zoom-range math, and categorical label truncation (pnpm --filter webapp run test), and pnpm run typecheck --filter webapp passes. Manually exercised each task landing page (agent, standard, scheduled) plus the dashboard and custom query charts, stepping the Date/Time filter through 5m, 1h, 24h, 7d, and 30d to confirm dense bars on short ranges, non-overlapping labels that reflow on resize, the synced hover line across the agent charts, the maximize button, and drag-to-zoom updating the filter.


Changelog

The activity charts on the task landing pages and the dashboard and custom query charts now share one set of reusable primitives. X-axis labels are width-aware so they never overlap and reflow when a panel resizes, y-axis values are abbreviated (8K, 1.2M), and short time ranges render dense bars instead of collapsing into a single bar. Hovering any agent chart mirrors a vertical line on the others, every chart gains a maximize button, and dragging across a task chart zooms the Time/Date filter. Long categorical labels such as run IDs and task names middle-truncate and auto-rotate only when needed.


chart.improvements.mp4

samejr added 8 commits June 22, 2026 21:49
Improve the activity charts on the agent, standard, and scheduled task
landing pages:

- Bucket density adapts to the selected range so short ranges render many
  fine-grained bars instead of collapsing to a single 1h bar.
- X-axis labels are chosen from the available width: evenly spaced across
  the plot, first + last always shown, kept horizontal, deduped, and they
  reflow on resize.
- Synced vertical hover indicator across the agent page's charts via a
  reusable ChartSyncProvider.
- 'Maximize' button + fullscreen dialog on each chart card (shared ChartCard),
  matching the dashboard widgets.
- Abbreviated y-axis values (8000 -> 8K) by default on the compound charts.

Also de-duplicates the previously copy-pasted status colors, time-axis
formatters, and bucket/zero-fill logic into shared helpers.
Click-drag across an activity chart to zoom into that time range:

- The drag selection mirrors across every chart in the same ChartSyncProvider
  group, and on release sets the Time/Date filter (from/to) to the dragged
  window, matching how the TimeFilter applies a custom range.
- While dragging, a From/To range tooltip replaces the hovered-value tooltip
  and updates live.

Built on the existing ChartSyncProvider (shared selection state) plus a small
useZoomToTimeFilter hook; the per-chart enableZoom path is untouched.
Date-based line charts (Run metrics, AI metrics, custom dashboards, Models
pages — everything rendered by QueryResultsChart) capped the x-axis at a fixed
~8 time labels regardless of chart width, so labels were too sparse on wide
charts.

Derive the tick count from the measured chart width (one label per
TIME_AXIS_LABEL_SPACING_PX), feeding it into the existing nice-interval
generateTimeTicks. Wide charts now show more clean-interval labels, narrow
widgets fewer. The continuous time scale is kept, so data gaps still render.
Non-date x-axes on custom (Query mode) and dashboard charts — run IDs, task
names, arbitrary strings — were rendered horizontally with every label shown,
so long values overlapped into an unreadable smear.

Now, with no configuration:
- Labels are thinned to as many as fit the measured width (evenly spaced); all
  data still renders and the full value shows on hover.
- Long values are middle-truncated (run_abc…f9c2) so ids sharing a prefix stay
  distinguishable.
- The axis auto-rotates to -45° only when labels are long; short labels stay
  horizontal.

Also share one CHART_MARGIN between ChartBar and ChartLine so the two stay
aligned when toggling chart type and angled labels aren't clipped on line
charts.
Refine the cross-chart hover indicator on the task landing pages: brighter
(charcoal-500), dashed, and shown only on the charts you're not hovering — the
hovered chart already has its own tooltip cursor.
The useMeasure ref was attached only to the line/area return path, so bar
charts measured a width of 0 and never produced evenly-spaced x-axis ticks
(and, because the categorical axis sets an angle, Chart.Bar's own
useXAxisTicks was disabled too) — falling back to Recharts' default label
spacing. Wrap the bar return in the same measuring div so categorical bar
charts get the intended even-spaced label thinning.
…vements

# Conflicts:
#	apps/webapp/app/presenters/v3/AgentDetailPresenter.server.ts
#	apps/webapp/app/presenters/v3/TaskDetailPresenter.server.ts
Trim the comments added in the chart work down to the load-bearing "why", drop redundant what-narration, and run the formatter over the changed files.
@changeset-bot

changeset-bot Bot commented Jun 28, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: db45614

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ad059db1-78a7-4820-a665-2154bba85bc6

📥 Commits

Reviewing files that changed from the base of the PR and between 7c028fb and db45614.

📒 Files selected for processing (3)
  • .server-changes/custom-chart-categorical-x-axis.md
  • .server-changes/dashboard-line-chart-x-axis-density.md
  • .server-changes/task-landing-activity-charts.md
✅ Files skipped from review due to trivial changes (3)
  • .server-changes/dashboard-line-chart-x-axis-density.md
  • .server-changes/custom-chart-categorical-x-axis.md
  • .server-changes/task-landing-activity-charts.md
📜 Recent review details
⏰ Context from checks skipped due to timeout. (16)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 10)
  • GitHub Check: code-quality / code-quality
  • GitHub Check: typecheck / typecheck
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: audit
  • GitHub Check: audit

Walkthrough

This PR centralizes activity-series bucketing and zero-fill logic in activitySeries.server.ts, adds shared chart primitives for status colors, UTC activity axes, Y-axis formatting, and width-aware X-axis tick selection, and introduces chart sync state, drag-to-zoom handling, and a fullscreen chart card. It updates bar, line, and query-results charts to use the shared helpers, wires agent and task routes to the new components, and adds tests plus changelog entries for the chart behavior changes.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.16% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: improving task and dashboard activity charts.
Description check ✅ Passed The description mostly matches the required template and covers summary, testing, changelog, and screenshots.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch samejr/recharts-improvements

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

devin-ai-integration[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@samejr samejr changed the title feat(webapp): improve and unify task and dashboard activity charts feat(webapp): improve task and dashboard activity charts Jun 28, 2026
samejr added 2 commits June 28, 2026 16:26
…t x-axis tick)

Give the chart maximize button an aria-label and reveal it on focus as well as
hover, so keyboard and screen-reader users get a reachable, named control.
Preserve the final x-axis tick when pruning duplicate labels (now extracted as
dedupeTicksByLabel) so the end-of-range label is never dropped.
devin-ai-integration[bot]

This comment was marked as resolved.

@samejr samejr merged commit b2b4c51 into main Jun 28, 2026
29 checks passed
@samejr samejr deleted the samejr/recharts-improvements branch June 28, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants