Skip to content

feat(panel): Issues section + four new Home charts#219

Open
upsetbit wants to merge 6 commits into
masterfrom
feat/panel-issues-and-charts
Open

feat(panel): Issues section + four new Home charts#219
upsetbit wants to merge 6 commits into
masterfrom
feat/panel-issues-and-charts

Conversation

@upsetbit
Copy link
Copy Markdown
Contributor

@upsetbit upsetbit commented Jun 6, 2026

What & why

The Home page's old Errors card was a dumb recent-rows table — no insight into which models or projects are problematic. This replaces it with a useful Issues section and adds four new Home charts for spotting errors and usage patterns in AI-agent work.

Issues section (replaces the Errors card)

Full-width, right below the new Projects chart:

  • Error-rate indicator (flagged ÷ total sessions), flagged count, and the most error-prone model.
  • Errors per model bar leaderboard.
  • Recent flagged sessions — actionable list: agent badge + linked project + timestamp, each row deep-links to the transcript (/sessions?session=<id>).

Honesty note: there is no structured error flag in the data (Claude Code's is_error, Codex/Gemini status are dropped at import), so Issues is built on the existing content heuristic (error|exception|traceback|panic|fatal) and is labeled as such. Capturing real tool/API failures (schema + importer + projection bump) is a deliberate follow-up.

Four new charts

  1. Errors per model (in Issues).
  2. Tokens & cost per model — token bars + a cost-share donut with a color-matched legend.
  3. Most worked-on projects — bar leaderboard.
  4. Activity by hour of day — inline-SVG area chart; UTC buckets rotated into the panel's local zone (whole-hour, DST-naive; honors TZ), peak hour highlighted.

The KPI strip also gains tokens, estimated spend, and error rate.

How

  • 3 new analytics reports with full parity — added to the SQLite store (CLI), the Postgres handler (panel), the prosa analytics command, and the panel: hours, usage_by_model, errors_by_model. No proto change (the report field is a free string; only its doc comment + gen updated).
  • New internal/panel/charts/ package (the documented-but-deferred helpers): deterministic Donut + Area returning template.HTML, design-tokens only, with golden tests.
  • Handler fan-out grows from 6 → 9 reports; buildBarRows refactored onto a shared barsFromPairs core.

Tests

  • Store reports (SQLite), CLI dispatch wiring, panel builders (incl. timezone rotation), and charts golden/determinism — all unit-tested.
  • A PG-guarded e2e validates the Postgres SQL for all three reports (run locally against real Postgres).
  • A full Home render test drives the real handler against a fake upstream to catch any handler↔template key mismatch.
  • Local pipeline green: gen-check, vet, golangci-lint (0 issues), test-race (with Postgres), test-integration, build, quality.

Screenshot

Home rendered with seeded test data — the hour-of-day peak is correctly rotated to local time, and the Issues section + cost donut render as designed (shared separately in chat).

🤖 Generated with Claude Code


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

upsetbit and others added 6 commits June 6, 2026 16:36
Three new SQLite reports feeding the panel's new Home charts:

- AnalyticsHours buckets sessions by UTC start-hour (substr off the
  RFC3339Nano started_at, mirroring the heatmap day idiom).
- AnalyticsErrorsByModel groups the FTS error heuristic by model and,
  unlike AnalyticsErrors, is uncapped so its row sum is the true
  flagged-session count for an error-rate indicator.
- AnalyticsUsageByModel mirrors AnalyticsUsage but groups by model and
  estimates per-model cost via pricing.CostUSD.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Postgres mirrors of the new store reports, wired into the AnalyticsService
GetReport dispatch so the panel (and `prosa --remote analytics`) can reach
them:

- queryHours buckets by UTC start-hour via to_char(... AT TIME ZONE 'UTC').
- queryErrorsByModel groups the tsvector error heuristic by model, uncapped.
- runUsageByModel groups token usage by model and estimates per-model cost.

Headers are kept byte-identical to internal/store/analytics.go so the
store↔server mirror holds. Adds a PG-guarded e2e test (PROSA_TEST_PG_URL)
covering all three.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds the three new reports to `prosa analytics`: the valid-report list,
the dispatch switch, and the cobra Long help. The --remote path needs no
change — it forwards the report name and the server now serves it. Adds
tests for the dispatch wiring (the SQL is covered by the store tests).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Lands the deferred internal/panel/charts/ helpers from
docs/panel/components.md: Donut (percentage distribution, for cost-per-model)
and Area (line + soft fill, for activity by hour). Both return template.HTML,
color only via design tokens, and are deterministic — same input yields
byte-identical SVG, locked down with golden files and -update support.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Reworks the Home dashboard around AI-agent error/usage insight:

- New Issues section (full-width, below Projects) replaces the old
  recent-errors table: an error-rate indicator, the most error-prone
  model, an errors-per-model leaderboard, and an actionable list of
  recent flagged sessions (agent badge + linked project + deep link to
  the transcript). Honestly labeled as a content heuristic.
- Four new charts: errors per model (in Issues), tokens & cost per model
  (token bars + cost donut with a color-matched legend), most worked-on
  projects, and activity by hour of day (area chart, UTC buckets rotated
  to the panel's local zone, peak hour highlighted).
- KPI strip gains tokens, estimated spend, and error rate.

The handler fans out three more reports (usage_by_model, errors_by_model,
hours) alongside the existing six. buildBarRows is refactored onto a
shared barsFromPairs core. Unit tests cover the builders, and a full
render test drives handleHome against a fake upstream to catch any
handler↔template key mismatch (which a parse-only test cannot).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Keep the docs in lockstep with the new analytics reports and the Home
rework:

- analytics.proto: list hours/usage_by_model/errors_by_model in the
  report field comment (gen/ regenerated).
- usage.md: add the three reports to the `prosa analytics` list.
- panel/components.md: flip Donut and the trend sketch (now `Area`) from
  "deferred" to landed, with signatures matching internal/panel/charts/.
- panel/screens.md: six KPIs, the new Projects / Hour of day / Tokens &
  cost per model cards, and the Issues section replacing the Errors table.
- architecture/panel.md: charts package landed (Donut + Area; sparkline
  still deferred); refreshed the Home card list.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant