:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(reviewhog): colored severity badges on inline review comments (#71775)
Alex Lebedev4500ddcf31d6
diff --git a/products/review_hog/ARCHITECTURE.md b/products/review_hog/ARCHITECTURE.mdindex 779c42c5228a..388c2058eb79 100644--- a/products/review_hog/ARCHITECTURE.md+++ b/products/review_hog/ARCHITECTURE.md@@ -265,6 +265,17 @@ read `FINAL_REPORT.md` there first (config glossary + coverage matrix + ranking)rate drops materially (toward ≤50%) on frozen-PR evals with the valid-finding set intact (item 5'scoverage matrix as the guard); kill if valid findings drop with the noise.+### ✅ BUILT 2026-07-16 — inline finding comments: colored severity badges replace the text meta++The inline comment `_format_issue_comment` builds (`publish_review.py`) had its meta line recolored after comparing it against Greptile's PR comments — a deliberately minimal change that leaves the four collapsed sections (`Issue description`, `Suggested fix`, `Why we think it's a valid issue`, `Prompt to fix with AI`) exactly as they were.+Before: a plain `### title` followed by a text meta line (`**Priority:** should_fix | **Category:** performance | **Lines:** …`).+Now the comment keeps the **title**, then a line of colored [shields.io](https://shields.io) badges just beneath — a lowercase severity chip (`must fix` red `D1242F`, `should fix` orange `E36209`, `consider` blue `0969DA`) plus a neutral-grey lowercase category chip — and the four `<details>` follow unchanged.+No line reference is shown up top: the comment is anchored inline (GitHub renders the code above it) and the lines already appear in the AI-fix prompt, so the `**Lines:**` part of the meta was dropped.+Badge alt text is the raw enum value (``) so the priority still reads in email digests, when images are blocked, and to screen readers — and the existing publish-gate test's `should_fix`-in-body assertion still holds.+Helpers `_shields_badge` / `_finding_badge_line` + `_PRIORITY_BADGE` carry the label/color map.+Color mechanism was a user decision (badge images, Greptile-style, accepting the external-image dependency) over the GitHub-native emoji/alert alternative.+An earlier iteration also surfaced the problem/fix inline and un-collapsed two sections; that was reverted — the collapsed structure is intentional and stays.+### ✅ BUILT 2026-07-15 — reviewing-stage progress copy: "Reviewing chunks" → "Running review passes"Live misread on [posthog#71025](https://github.com/PostHog/posthog/pull/71025) (63 additions): thediff --git a/products/review_hog/backend/reviewer/tests/test_publish_review.py b/products/review_hog/backend/reviewer/tests/test_publish_review.pyindex 99b74a04559a..eabd84de2339 100644--- a/products/review_hog/backend/reviewer/tests/test_publish_review.py+++ b/products/review_hog/backend/reviewer/tests/test_publish_review.py@@ -14,6 +14,7 @@ from products.review_hog.backend.reviewer.tools.github_client import GitHubAPIErfrom products.review_hog.backend.reviewer.tools.publish_review import (ReviewComment,_build_inline_comments,+ _format_issue_comment,_post_github_review,publish_review,)@@ -357,3 +358,40 @@ class TestPublishReviewGate:assert len(comments) == expected_countif expected_count:assert "should_fix" in comments[0]["body"] # the emitted comment displays the effective priority+++class TestFormatIssueComment:+ @parameterized.expand(+ [+ (IssuePriority.MUST_FIX, "must_fix-D1242F", "must_fix"),+ (IssuePriority.SHOULD_FIX, "should_fix-E36209", "should_fix"),+ (IssuePriority.CONSIDER, "consider-0969DA", "consider"),+ ]+ )+ def test_severity_badge_tracks_priority(self, priority: IssuePriority, badge_fragment: str, alt: str) -> None:+ # The colored severity badge is the redesign's whole point: a swapped or recolored mapping (e.g.+ # must_fix rendering blue) ships a misleading comment, and no other test pins priority→badge.+ body = _format_issue_comment(_finding(priority=priority), _verdict())++ assert f"/badge/{badge_fragment}" in body+ # Alt text is the raw enum value, so the priority still reads when the badge image can't load.+ assert f"![{alt}]" in body++ def test_layout_is_title_then_badges_then_unchanged_collapsed_sections(self) -> None:+ # The change only swapped the text meta for badges and dropped the line ref: title leads, badges+ # tag it just beneath, and all four sections stay folded. Catches a badge/title reorder, a+ # re-added `Priority | Lines` meta, or a section being surfaced inline instead of collapsed.+ finding = _finding()+ body = _format_issue_comment(finding, _verdict())++ assert body.index(f"### {finding.title}") < body.index("![should_fix]") < body.index("<details>")+ for label in (+ "Issue description",+ "Suggested fix",+ "Why we think it's a valid issue",+ "Prompt to fix with AI (copy-paste)",+ ):+ assert f"<summary><strong>{label}</strong></summary>" in body+ # Problem and fix stay inside <details>, not surfaced above the first one.+ assert finding.body not in body[: body.index("<details>")]+ assert "**Priority:**" not in body and "**Lines:**" not in bodydiff --git a/products/review_hog/backend/reviewer/tools/publish_review.py b/products/review_hog/backend/reviewer/tools/publish_review.pyindex 46277c473e89..dd54e9e4c803 100644--- a/products/review_hog/backend/reviewer/tools/publish_review.py+++ b/products/review_hog/backend/reviewer/tools/publish_review.py@@ -7,11 +7,7 @@ from posthog.egress.github.transport import GitHubRateLimitErrorfrom products.review_hog.backend.models import ReviewReportfrom products.review_hog.backend.reviewer.artefact_content import ReviewIssueFinding, ValidationVerdictfrom products.review_hog.backend.reviewer.constants import effective_priority-from products.review_hog.backend.reviewer.diff_position import (- build_diff_line_map,- find_diff_position,- format_line_ranges,-)+from products.review_hog.backend.reviewer.diff_position import build_diff_line_map, find_diff_positionfrom products.review_hog.backend.reviewer.models.github_meta import PRFilefrom products.review_hog.backend.reviewer.models.issues_review import IssuePriorityfrom products.review_hog.backend.reviewer.persistence import load_pr_snapshot, load_valid_findings@@ -180,20 +176,48 @@ def publish_review(return PublishOutcome(posted=True, review_url=review_url)+# Severity badge (label, shields.io hex color) per priority. The badge is a shields.io image, so its+# alt text is the raw enum value: the priority still reads in email digests and when images are+# blocked, and screen readers announce it. Colors track a red → orange → blue calm-down scale.+_PRIORITY_BADGE: dict[IssuePriority, tuple[str, str]] = {+ IssuePriority.MUST_FIX: ("must fix", "D1242F"),+ IssuePriority.SHOULD_FIX: ("should fix", "E36209"),+ IssuePriority.CONSIDER: ("consider", "0969DA"),+}+# Neutral grey for the category chip — it's context, not severity, so it shouldn't compete for color.+_CATEGORY_BADGE_COLOR = "656D76"+++def _shields_badge(label: str, color: str, *, alt: str) -> str:+ """One shields.io badge as a markdown image. A literal space in `label` is encoded as `_` (shields+ renders `_` back as a space); `alt` is what shows when the image can't load (email, blocked, a11y).+ """+ return f"}-{color})"+++def _finding_badge_line(priority: IssuePriority, category: str | None) -> str:+ """The colored severity (+ optional category) badge line leading an inline finding comment."""+ label, color = _PRIORITY_BADGE[priority]+ badges = [_shields_badge(label, color, alt=priority.value)]+ if category:+ # `code_quality` renders as "code quality" — shields already turns a single `_` into a space.+ badges.append(_shields_badge(category, _CATEGORY_BADGE_COLOR, alt=category))+ return " ".join(badges)++def _format_issue_comment(finding: ReviewIssueFinding, verdict: ValidationVerdict) -> str:- """Format a finding + its verdict as an inline comment body."""- formatted_lines = format_line_ranges(finding.lines)- priority = effective_priority(finding.priority, verdict.adjusted_priority)+ """Format a finding + its verdict as an inline comment body.- meta_parts = [f"**Priority:** {priority.value}"]- if verdict.category:- meta_parts.append(f"**Category:** {verdict.category}")- meta_parts.append(f"**Lines:** {formatted_lines}")+ Leads with the title, then a line of colored severity/category badges (replacing the old+ `Priority | Category | Lines` text meta); the four collapsed sections below are unchanged. Line+ refs are omitted from the top — the comment is anchored inline and the lines live in the AI prompt.+ """+ priority = effective_priority(finding.priority, verdict.adjusted_priority)lines = [f"### {finding.title}","",- " | ".join(meta_parts),+ _finding_badge_line(priority, verdict.category),"","<details>","<summary><strong>Issue description</strong></summary>",@@ -212,7 +236,7 @@ def _format_issue_comment(finding: ReviewIssueFinding, verdict: ValidationVerdic"</details>","","<details>",- ("<summary><strong>Why we think it's a valid issue</strong></summary>"),+ "<summary><strong>Why we think it's a valid issue</strong></summary>","<br>","",verdict.argumentation,@@ -220,7 +244,7 @@ def _format_issue_comment(finding: ReviewIssueFinding, verdict: ValidationVerdic"</details>","","<details>",- ("<summary><strong>Prompt to fix with AI (copy-paste)</strong></summary>"),+ "<summary><strong>Prompt to fix with AI (copy-paste)</strong></summary>","<br>","","```",