Fix zeroed "caught before merge" metric and empty severity trend chart#74
Conversation
Two independent bugs surfaced on the Impact/Overview pages of live instances (both masked by demo-mode fixtures): 1. "critical & major caught before merge" / "merged PRs" always read 0. prs.merged_at was never written on a live instance: the webhook pull_request.closed handler only aborted in-flight reviews, and the review path upserts merged_at back to NULL on every review. The Impact/Overview metrics (and cross-PR memory) filter on merged_at IS NOT NULL, so they stayed 0 unless the manual backfill CLI was run. Fix: add markPRClosed() and call it from the closed handler to persist merged/merged_at/closed_at from the payload. (Existing merged PRs still need `npm run backfill` to populate historically.) 2. "Findings by severity over time" chart rendered empty on the Impact page. StackedSeverityBar uses percentage-height segments, which only resolve against a definite ancestor height. .chart-bar had flex:1 1 0% + min-height (not definite); it worked on Overview only because a grid row stretched the card. Standalone on Impact the columns collapsed to 0. Fix: give .chart-bar a definite `height` (flex:1 1 auto; height:200px) so it renders in any layout while still growing to fill a stretched card. Verified: backend + web tsc clean, smoke:dao/smoke:webhooks pass, a temp-DB script drives getImpact() showing caught-before-merge flip 0->2, and the Impact chart renders live in demo mode. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
📝 WalkthroughWalkthroughFixed live PR merge persistence so Impact and Overview metrics no longer stayed at zero after reviewed PRs were merged. Also corrected the severity trend chart layout by giving chart bars a definite height so stacked columns render outside the stretched Overview grid. Changes
Sequence Diagram(s)sequenceDiagram
participant GitHub
participant Webhook as Webhook Dispatcher
participant DAO as DAO
participant Reviewer
GitHub->>Webhook: pull_request.closed event
Webhook->>DAO: markPRClosed(owner repo number merged mergedAt closedAt)
DAO-->>Webhook: update prs row
Webhook->>Reviewer: handlePRClose(owner repo number)
Reviewer-->>Webhook: abort in-flight review
Webhook-->>GitHub: 200 ok
sequenceDiagram
participant UI as Impact Page
participant CSS as Chart Layout
participant Bar as StackedSeverityBar
UI->>Bar: render severity columns with percentage segments
Bar->>CSS: resolve parent bar height
CSS-->>Bar: definite 200px or stretched card height
Bar-->>UI: visible stacked columns
Estimated code review effort🎯 2 (Simple) | ⏱️ ~20 minutes Suggested Labels
Risk AssessmentScore: 10/100 — 🟢 Low
Test Coverage Signal🔴 53 line(s) of production code added with no test changes.
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in your ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Generate docstrings (beta)
🧹 Simplify (beta)
🪄 Autofix unresolved comments (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
The PR cleanly addresses both reported production-only regressions with focused, low-risk changes. The webhook/DAO fix correctly persists merge state on pull_request.closed, and the CSS change gives the stacked bars a definite height so the Impact chart can render outside the stretched grid layout. I did not find any blocking issues in the diff.
ℹ️ Review info
⚙️ Run configuration
Configuration used: .diffsentry.yaml
Review profile: ASSERTIVE
Run ID: 6eb17dee-de61-4bcd-b6cf-ebfde36d0cf7
📥 Commits
Reviewing files at c72bc58 (base SHA unavailable).
📒 Files selected for processing (3)
src/storage/dao.tssrc/webhook/dispatch.tsweb/src/styles/base.css
📌 Status — last updated
|
| Risk score | 10/100 (Low) ▁ |
| Unresolved threads | 0 |
| Failing checks | 0 |
| Pending checks | 1 |
| Files reviewed | 3 |
| Updated | 2026-07-05 00:43Z |
Live-updated by DiffSentry on every push. Use @diffsentry ship for a verdict, @diffsentry timeline for full history.
Summary
Fixes two independent bugs on the Impact / Overview pages that appeared on real instances but were hidden in demo mode (demo uses hardcoded fixtures).
Bug 1 — "critical & major caught before merge" and "merged PRs" stuck at 0
prs.merged_atwas 永 NULL on any live instance. The webhookpull_request.closedhandler only aborted in-flight reviews and never recorded the merge, while the live review path re-upsertsmerged_at = NULLon every review. The Impact/Overview "caught before merge" & "merged PRs" metrics (and cross-PR memory) filter onmerged_at IS NOT NULL, so they stayed 0 unless the manualbackfillCLI was run.Fix: new
markPRClosed()insrc/storage/dao.ts, called from theclosedhandler insrc/webhook/dispatch.ts, persistsmerged/merged_at/closed_atfrom the payload (UPDATE-only — reviewed PRs already have a row).Bug 2 — "Findings by severity over time" chart empty on the Impact page
A CSS layout bug, not data.
StackedSeverityBarrenders percentage-height segments, which only resolve against a definite ancestor height..chart-barusedflex: 1 1 0%+min-height(not definite). It worked on Overview only because a grid row stretched the card; standalone on Impact every column collapsed to 0 — even though the legend totals were correct.Fix:
.chart-barnow usesflex: 1 1 auto; height: 200px(web/src/styles/base.css) — a definite fallback height in any layout while still growing to fill a stretched card.Post-deploy note
The webhook fix records merges going forward. Existing merged PRs still have
merged_at = NULL, so runnpm run backfill(optionally-- --repo owner/name) after deploying to populate historical data.Verification
tscclean, webtsccleansmoke:daoandsmoke:webhookspassgetImpact(): caught-before-merge flips 0 → 2, merged PRs 0 → 1, unmerged close keepsmerged_atNULL🤖 Generated with Claude Code
Summary
Fixed live PR merge persistence so Impact and Overview metrics no longer stayed at zero after reviewed PRs were merged. Also corrected the severity trend chart layout by giving chart bars a definite height so stacked columns render outside the stretched Overview grid.
Changes
src/storage/dao.tssrc/webhook/dispatch.tsweb/src/styles/base.css