feat(panel): Issues section + four new Home charts#219
Open
upsetbit wants to merge 6 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
/sessions?session=<id>).Four new charts
TZ), peak hour highlighted.The KPI strip also gains tokens, estimated spend, and error rate.
How
prosa analyticscommand, and the panel:hours,usage_by_model,errors_by_model. No proto change (thereportfield is a free string; only its doc comment + gen updated).internal/panel/charts/package (the documented-but-deferred helpers): deterministicDonut+Areareturningtemplate.HTML, design-tokens only, with golden tests.buildBarRowsrefactored onto a sharedbarsFromPairscore.Tests
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
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.