Skip to content

feat: add PR insights analytics dashboard#23215

Merged
kylecarbs merged 1 commit intomainfrom
kylecarbs/pr-insights-dashboard
Mar 18, 2026
Merged

feat: add PR insights analytics dashboard#23215
kylecarbs merged 1 commit intomainfrom
kylecarbs/pr-insights-dashboard

Conversation

@kylecarbs
Copy link
Copy Markdown
Member

What

Adds a new admin-only PR Insights page for the /agents analytics view — a dashboard for engineering leaders to understand code shipped by AI agents.

Backend

  • GET /api/v2/chats/insights/pull-requests — admin-only endpoint
  • 4 SQL queries in chatinsights.sql aggregating chat_diff_statuses joined with chat cost data (via root chat tree rollup)
  • Runs 5 parallel DB queries: current summary, previous summary (for trends), time series, per-model breakdown, recent PRs
  • SDK types auto-generate to TypeScript

Frontend (PRInsightsView)

  • Stat cards: PRs created, Merged, Merge rate, Lines shipped, Cost/merged PR — with trend badges comparing to previous period
  • Activity chart: Stacked area chart (created/merged/closed) using git color tokens (git-added-bright, git-merged-bright, git-deleted-bright)
  • Model performance table: Per-model PR counts, inline merge rate bars, diff stats, cost breakdown
  • Recent PRs table: Status badges, review state icons, author info, external links
  • Time range filter: 7d/14d/30d/90d button group
  • 4 Storybook stories: Default, HighPerformance, LowVolume, NoPRs

Data source

All PR data comes from the existing chat_diff_statuses table (populated by the gitsync.Worker background job that polls GitHub every 120s). No new data collection required.

Screenshot

View in Storybook: pages/AgentsPage/PRInsightsView

@kylecarbs kylecarbs force-pushed the kylecarbs/pr-insights-dashboard branch from 87f5d5b to 74d01a5 Compare March 18, 2026 13:38
@coder-tasks
Copy link
Copy Markdown
Contributor

coder-tasks bot commented Mar 18, 2026

Documentation Check

New Documentation Needed

  • docs/ai-coder/agents/insights.md (or similar) — The new admin-only PR Insights dashboard is a significant feature for engineering leaders but has no user-facing documentation. A new page in the Agents section should cover what the dashboard shows (stat cards, activity chart, model performance table, recent PRs table), who can access it (admins only), and how to interpret the metrics (merge rate, lines shipped, cost/merged PR, time range filter).

    Add a corresponding entry to docs/manifest.json under the Agents children with "state": ["early access"] to match adjacent pages.


Automated review via Coder Tasks

@kylecarbs kylecarbs force-pushed the kylecarbs/pr-insights-dashboard branch from 74d01a5 to 7be5a1b Compare March 18, 2026 13:53
@kylecarbs kylecarbs changed the title feat(agents): add PR insights analytics dashboard feat: add PR insights analytics dashboard Mar 18, 2026
Copy link
Copy Markdown
Contributor

@DanielleMaywood DanielleMaywood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stamping so we can iterate, will definitely need to ensure we review this properly if we keep though

Copy link
Copy Markdown
Member

@deansheather deansheather left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly backend review, didn't really check the frontend

avatar: "https://avatars.githubusercontent.com/u/14044910",
},
{
login: "deansheather",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣

COALESCE(SUM(cc.cost_micros), 0)::bigint AS total_cost_micros,
COALESCE(SUM(cc.cost_micros) FILTER (WHERE cds.pull_request_state = 'merged'), 0)::bigint AS merged_cost_micros
FROM chat_diff_statuses cds
JOIN chats c ON c.id = cds.chat_id
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there only ever one diff row per chat? If so, this is fine, otherwise we probably should COUNT(DISTINCT c.id) in the counts above instead...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly one row per chat — chat_diff_statuses PK is chat_id, so it's a strict 1:1 relationship. No risk of double-counting.

@kylecarbs kylecarbs force-pushed the kylecarbs/pr-insights-dashboard branch 5 times, most recently from 00cac68 to c9b6c5a Compare March 18, 2026 14:36
@kylecarbs kylecarbs enabled auto-merge (squash) March 18, 2026 14:43
@kylecarbs kylecarbs force-pushed the kylecarbs/pr-insights-dashboard branch 2 times, most recently from 8e8f671 to be722a4 Compare March 18, 2026 15:05
Adds a new admin-only PR Insights page for the /agents analytics view,
giving engineering leaders visibility into code shipped by AI agents.

Backend:
- New SQL queries in chatinsights.sql aggregating chat_diff_statuses
  with chat cost data (summary, time series, per-model, recent PRs)
- New GET /api/v2/chats/insights/pull-requests endpoint (admin-only)
- SDK types for PRInsightsResponse and related structs
- Auto-generated TypeScript types

Frontend:
- PRInsightsView component with stat cards, stacked area chart
  (created/merged/closed using git color tokens), model performance
  table with inline merge rate bars, and recent PRs table
- Time range filter (7d/14d/30d/90d) using Button component group
- Review badges with contextual icons (approved/changes requested/reviewing)
- 4 Storybook stories (Default, HighPerformance, LowVolume, NoPRs)
@kylecarbs kylecarbs force-pushed the kylecarbs/pr-insights-dashboard branch from be722a4 to cd3201f Compare March 18, 2026 15:16
@kylecarbs kylecarbs merged commit d6fef96 into main Mar 18, 2026
30 of 31 checks passed
@kylecarbs kylecarbs deleted the kylecarbs/pr-insights-dashboard branch March 18, 2026 15:29
@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants