: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
fix(review-hog): show the running turn's mode and stage in the reviews table (#117592)
Julian Bezf0884cda0751
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 9af22a4f8203..d9c2c2fc4d20 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -15063,9 +15063,9 @@ snapshots:scenes-code-review--review-drawer-standard-not-posted--light:hash: v1.k794b7964.1f2729d4f72a0b200706fecc71d0a880d1c0da159b71a6342bfb6ab218042d5d.RMo8djjV8-BU963H8KhzgPXukflny-UCghN5R_66QPAscenes-code-review--running-review--dark:- hash: v1.k794b7964.87f5476c9160c4ce232cd07fe62d94ba7ff15b137019050b195c5d29a936edd6.fJjSg26nVP5DUQUs5F-4NCKXAuEOuJhkXLvp7c0tNt4+ hash: v1.k794b7964.ad0833a4ea783aa02056d623620c99c2acfe7e19e36072882a1b26f99f9d285f.eV_fbCa4XXcDtxwrhgCklfdd4bFv1mluWSzH66ZcOk8scenes-code-review--running-review--light:- hash: v1.k794b7964.c2a355223797720fb333a696034be89185b0da48d9041e525d4710d806e60dd9.zgiSOOYkxBSkGu3Ph6HwXbZFtGg0i8W_lqwK8MH4aG4+ hash: v1.k794b7964.317b100710a85c42982c056b8d6c6105056b7a384ba0d0e478ab6b93e4baf28b.5WQ2gVh9oGhAA8f_jyqZljHyK8mp0vppnvwV0uGtv_kscenes-code-review--saved-inbox-opt-ins--dark:hash: v1.k794b7964.7a38f3e4fb34402bf9347186b800559706cedaa0244425b177cc5ee2a2deba26.imt_YryGDIqYUHC0X1sEQm32A7Kwp0O7X0CgElZyCr4scenes-code-review--saved-inbox-opt-ins--light:diff --git a/products/review_hog/backend/facade/contracts.py b/products/review_hog/backend/facade/contracts.pyindex cc357b25740d..cf8abbe0ca07 100644--- a/products/review_hog/backend/facade/contracts.py+++ b/products/review_hog/backend/facade/contracts.py@@ -449,6 +449,7 @@ class ReviewProgress:review_stage: strdone: int | Nonetotal: int | None+ review_mode: str | None = None@frozendiff --git a/products/review_hog/backend/presentation/views/reviews.py b/products/review_hog/backend/presentation/views/reviews.pyindex 7bfaa572a46e..b2edd6492166 100644--- a/products/review_hog/backend/presentation/views/reviews.py+++ b/products/review_hog/backend/presentation/views/reviews.py@@ -115,6 +115,11 @@ class PerspectiveStatsParamsSerializer(serializers.Serializer):)+class ReviewTriggerReviewMode(models.TextChoices):+ FULL = REVIEW_MODE_FULL, "Deep"+ FLASH = REVIEW_MODE_FLASH, "Standard"++class ReviewProgressSerializer(serializers.Serializer):review_stage = serializers.ChoiceField(choices=REVIEW_STAGES,@@ -130,6 +135,13 @@ class ReviewProgressSerializer(serializers.Serializer):total = serializers.IntegerField(allow_null=True, help_text="Work units the stage expects in total; null when unknown.")+ review_mode = serializers.ChoiceField(+ choices=ReviewTriggerReviewMode.choices,+ allow_null=True,+ help_text="What the in-flight turn runs: 'full' (Deep) or 'flash' (Standard). The row's `review_mode` "+ "describes the last completed turn, which can differ. Null until the turn records its mode, "+ "shortly before its review sessions start.",+ )class ResolutionStatus(models.TextChoices):@@ -153,11 +165,6 @@ class ReviewResolutionStatusSerializer(serializers.Serializer):)-class ReviewTriggerReviewMode(models.TextChoices):- FULL = REVIEW_MODE_FULL, "Deep"- FLASH = REVIEW_MODE_FLASH, "Standard"--class ReviewTurnDesign(models.TextChoices):PIPELINE = REVIEW_DESIGN_PIPELINE, "Pipeline"SINGLE_AGENT = REVIEW_DESIGN_SINGLE_AGENT, "Single agent"diff --git a/products/review_hog/backend/review_listing.py b/products/review_hog/backend/review_listing.pyindex b6a39e385fe7..62038c415ef6 100644--- a/products/review_hog/backend/review_listing.py+++ b/products/review_hog/backend/review_listing.py@@ -55,6 +55,7 @@ from products.review_hog.backend.reviewer.progress import (finding_counts,in_progress_report_ids,latest_resolution_summaries,+ live_turn_markers,progress_payload,resolution_states,running_q,@@ -106,6 +107,7 @@ def _turn_progress(in_progress_ids: set[str],resolutions: dict[str, ResolutionRunState],bundle: TurnFindingsBundle,+ markers: dict[tuple[str, int], TurnMarker],) -> dict[str, ReviewProgress]:"""The in-flight review turn's stage for each visibly running report.@@ -121,6 +123,7 @@ def _turn_progress(live_heads = {str(report.id): report.head_sha for report in in_flight}live_snapshots = snapshot_stats(team_id, live_heads)live_turns = turn_stats(team_id, live_heads)+ live_markers = live_turn_markers(team_id, in_flight, markers)return {str(report.id): ReviewProgress(**progress_payload(@@ -130,6 +133,8 @@ def _turn_progress(live_turns.get(str(report.id), TurnStats()),# The in-flight turn's findings live one run_index ahead of the completed watermark.bundle.turn(str(report.id), report.run_count + 1),+ live_markers.get(str(report.id)),+ markers.get((str(report.id), report.run_count)),))for report in in_flight@@ -260,8 +265,8 @@ def _summaries(team_id: int, reports: list[ReviewReport], in_progress_ids: set[sreport_ids = [str(report.id) for report in reports]bundle = load_findings_bundle(team_id=team_id, report_ids=report_ids)resolution_map = resolution_states(team_id, reports)- progress_map = _turn_progress(team_id, reports, in_progress_ids, resolution_map, bundle)markers = turn_markers(team_id, report_ids)+ progress_map = _turn_progress(team_id, reports, in_progress_ids, resolution_map, bundle, markers)latest_resolutions = latest_resolution_summaries(team_id, reports)items = []for report in reports:@@ -436,7 +441,8 @@ class ReviewListing:team_id = self.team_idkey = str(report.id)- marker = turn_markers(team_id, [key]).get((key, run_index))+ markers = turn_markers(team_id, [key])+ marker = markers.get((key, run_index))# Everything the detail returns (stats, chunk set, link-anchoring head) describes the same# completed turn the findings come from, never an in-flight turn's watermark.if is_latest:@@ -450,7 +456,7 @@ class ReviewListing:chunk_set = load_chunk_set(team_id=team_id, report_id=key, head_sha=turn_head) if turn_head else Noneresolutions = resolution_states(team_id, [report])in_progress_ids = in_progress_report_ids(team_id, [report])- progress = _turn_progress(team_id, [report], in_progress_ids, resolutions, bundle).get(key)+ progress = _turn_progress(team_id, [report], in_progress_ids, resolutions, bundle, markers).get(key)valid = [_finding(f, v) for f, v in pairs if v is not None and v.is_valid]dismissed = [_finding(f, v) for f, v in pairs if v is not None and not v.is_valid]diff --git a/products/review_hog/backend/reviewer/progress.py b/products/review_hog/backend/reviewer/progress.pyindex 8425908ffb20..6ec172087231 100644--- a/products/review_hog/backend/reviewer/progress.py+++ b/products/review_hog/backend/reviewer/progress.py@@ -53,7 +53,11 @@ from products.review_hog.backend.reviewer.artefact_content import (RunOutcomeNote,ValidationVerdict,)-from products.review_hog.backend.reviewer.constants import BLIND_SPOT_PASS_NUMBER, effective_priority+from products.review_hog.backend.reviewer.constants import (+ BLIND_SPOT_PASS_NUMBER,+ effective_priority,+ is_single_agent_pass,+)from products.review_hog.backend.reviewer.models.github_meta import PRMetadatafrom products.review_hog.backend.reviewer.models.issues_review import IssuePriorityfrom products.review_hog.backend.reviewer.models.perspective_selection import ChunkPerspectiveSelection@@ -98,12 +102,11 @@ class TurnStats:blind_spot_issue_count: int | None = None# (pass, chunk) review units completed this turn — the in-flight "reviewing" progress counter.perspective_reads: int | None = None+ single_agent_reads: int | None = None# The selector's persisted plan for the turn: the full menu + the normalized per-chunk picks.# None when the turn ran without a selection (failed, skipped, or predates the feature).selection_roster: list[str] | None = Noneselection_chunks: list[ChunkPerspectiveSelection] | None = None- # The turn marker is written right before the review sessions start, so it ends the preparing step.- has_turn_marker: bool = Falsedef finding_counts(@@ -219,15 +222,6 @@ def turn_stats(team_id: int, heads: dict[str, str | None]) -> dict[str, TurnStatfor row in chunk_rows: # oldest-first, so the turn's latest chunking winsstats[str(row["report_id"])].chunk_count = row["chunk_count"]- marker_report_ids = (- ReviewReportArtefact.objects.for_team(team_id)- .filter(head_q, type=ReviewReportArtefact.ArtefactType.TURN_MARKER)- .values_list("report_id", flat=True)- .distinct()- )- for report_id in marker_report_ids:- stats[str(report_id)].has_turn_marker = True-result_rows = (ReviewReportArtefact.objects.for_team(team_id).filter(head_q, type=ReviewReportArtefact.ArtefactType.PERSPECTIVE_RESULT)@@ -267,8 +261,11 @@ def turn_stats(team_id: int, heads: dict[str, str | None]) -> dict[str, TurnStatfor report_id, units in issues_by_unit.items():wave_units = {unit: count for unit, count in units.items() if unit[0] != BLIND_SPOT_PASS_NUMBER}blind_units = {unit: count for unit, count in units.items() if unit[0] == BLIND_SPOT_PASS_NUMBER}- if units:- stats[report_id].perspective_reads = len(units)+ single_agent_units = [unit for unit in units if is_single_agent_pass(unit[0])]+ if len(units) > len(single_agent_units):+ stats[report_id].perspective_reads = len(units) - len(single_agent_units)+ if single_agent_units:+ stats[report_id].single_agent_reads = len(single_agent_units)if wave_units:stats[report_id].perspective_count = len({pass_number for pass_number, _ in wave_units})stats[report_id].perspective_issue_count = sum(wave_units.values())@@ -417,6 +414,37 @@ def run_outcome_markers(return markers+def live_turn_markers(+ team_id: int, reports: Sequence[ReviewReport], markers: dict[tuple[str, int], TurnMarker]+) -> dict[str, TurnMarker]:+ """The marker of each report's running turn `run_count + 1`, keyed by report id.++ An attempt that fails or is skipped leaves its marker at that index, and the next attempt+ reuses the index. So a marker counts only on the report's current head, and only when no+ outcome note of its turn came after it.+ """+ candidates: dict[str, tuple[int, TurnMarker]] = {}+ for report in reports:+ report_id = str(report.id)+ marker = markers.get((report_id, report.run_count + 1))+ if marker is not None and marker.head_sha == report.head_sha:+ candidates[report_id] = (report.run_count + 1, marker)+ if not candidates:+ return {}+ since = min(marker.started_at for _, marker in candidates.values())+ outcomes = run_outcome_markers(team_id, list(candidates), since=since)+ return {+ report_id: marker+ for report_id, (run_index, marker) in candidates.items()+ if not any(+ outcome.stage == RUN_STAGE_REVIEW+ and outcome.run_index == run_index+ and outcome.created_at >= marker.started_at+ for outcome in outcomes.get(report_id, [])+ )+ }++@frozenclass _ThreadVerdictRow:outcome: str@@ -729,22 +757,30 @@ def _expected_reads(team_id: int, report: ReviewReport, turn: TurnStats) -> intreturn chunk_count * (perspectives + 1)-def in_publish_window(report: ReviewReport) -> bool:+def in_publish_window(report: ReviewReport, live_marker: TurnMarker | None) -> bool:"""Whether the turn finished but has not published yet.On publishing runs finalize defers the idle write to the publish stage, so the report is stillACTIVE with `run_count` already bumped and no in-flight findings. Scoped to the not-yet-publishedhead so a resolution run's ACTIVE window (published head) keeps its current label.++ `live_marker` is the marker of turn `run_count + 1`. When it exists, a new turn started after the+ finished one. A finished turn that published nothing, such as a clean Standard review, leaves the+ head unpublished, so the head check alone would put the next turn on that head in this window."""return bool(- report.completed_head_sha+ live_marker is None+ and report.completed_head_shaand report.completed_head_sha == report.head_shaand report.published_head_sha != report.head_sha)def _single_agent_progress(- turn: TurnStats, current_pairs: list[tuple[ReviewIssueFinding, ValidationVerdict | None]], in_publish_window: bool+ turn: TurnStats,+ current_pairs: list[tuple[ReviewIssueFinding, ValidationVerdict | None]],+ in_publish_window: bool,+ started: bool,) -> dict[str, Any]:"""Stage for a single-agent turn: preparing → reviewing (main and lens sessions) → finalizing.@@ -754,28 +790,30 @@ def _single_agent_progress("""if current_pairs or in_publish_window:stage = "single_agent_finalizing"- elif turn.has_turn_marker or turn.perspective_reads:+ elif started or turn.single_agent_reads:stage = "single_agent_reviewing"else:stage = "single_agent_preparing"return {"review_stage": stage, "done": None, "total": None}-def progress_payload(+def _stage_payload(team_id: int,report: ReviewReport,snapshot: SnapshotStats,turn: TurnStats,current_pairs: list[tuple[ReviewIssueFinding, ValidationVerdict | None]],+ live_marker: TurnMarker | None,) -> dict[str, Any]:- """Stage + counters for the in-flight turn, inferred from which working state exists at the head.-- Covers the full pipeline: fetching → chunking → selecting → reviewing → deduplicating →- validating → finalizing (body build + publish, the moments before the turn completes).- A single-agent turn gets its own stages once its fetch has recorded the design.- """- if snapshot.head_matched and snapshot.review_design == REVIEW_DESIGN_SINGLE_AGENT:- return _single_agent_progress(turn, current_pairs, in_publish_window(report))+ # The newest snapshot at the head can belong to an earlier turn of the other design on the same+ # head, so the marker's design wins once the turn has one.+ if live_marker is not None:+ review_design: str | None = live_marker.review_design+ else:+ review_design = snapshot.review_design if snapshot.head_matched else None+ publish_window = in_publish_window(report, live_marker)+ if review_design == REVIEW_DESIGN_SINGLE_AGENT:+ return _single_agent_progress(turn, current_pairs, publish_window, started=live_marker is not None)if current_pairs:judged = sum(1 for _, verdict in current_pairs if verdict is not None)if judged >= len(current_pairs):@@ -783,9 +821,9 @@ def progress_payload(return {"review_stage": "validating", "done": judged, "total": len(current_pairs)}# Without this check the branches below would misread the finished turn's working state as# "deduplicating". Relabeling a resolution run's ACTIVE window properly is its own change.- # Trade-off: an unpublished same-head re-run reads "finalizing" until dedup persists its first- # findings, a brief stretch because such a turn resumes its chunk and perspective state.- if in_publish_window(report):+ # Trade-off: a same-head re-run after an unpublished turn reads "finalizing" until its marker+ # lands, a brief stretch before its review sessions start.+ if publish_window:return {"review_stage": "finalizing", "done": None, "total": None}if turn.chunk_count is not None:done = turn.perspective_reads or 0@@ -800,3 +838,31 @@ def progress_payload(if snapshot.head_matched:return {"review_stage": "chunking", "done": None, "total": None}return {"review_stage": "fetching", "done": None, "total": None}+++def progress_payload(+ team_id: int,+ report: ReviewReport,+ snapshot: SnapshotStats,+ turn: TurnStats,+ current_pairs: list[tuple[ReviewIssueFinding, ValidationVerdict | None]],+ live_marker: TurnMarker | None,+ finished_marker: TurnMarker | None = None,+) -> dict[str, Any]:+ """Stage, counters and mode of the in-flight turn, inferred from which working state exists at the head.++ Covers the full pipeline: fetching → chunking → selecting → reviewing → deduplicating →+ validating → finalizing (body build + publish, the moments before the turn completes).+ A single-agent turn gets its own stages once its fetch has recorded the design.++ `live_marker` is the marker of turn `run_count + 1`, written right before the turn's review+ sessions start. Until it exists, the mode is unknown and the design comes from the snapshot.+ `finished_marker` is the marker of turn `run_count`. It gives the mode while that turn publishes.+ """+ if live_marker is not None:+ review_mode = live_marker.review_mode+ elif finished_marker is not None and in_publish_window(report, None):+ review_mode = finished_marker.review_mode+ else:+ review_mode = None+ return {**_stage_payload(team_id, report, snapshot, turn, current_pairs, live_marker), "review_mode": review_mode}diff --git a/products/review_hog/backend/reviewer/status_comment.py b/products/review_hog/backend/reviewer/status_comment.pyindex 984bc20d7ad7..5808705c29cd 100644--- a/products/review_hog/backend/reviewer/status_comment.py+++ b/products/review_hog/backend/reviewer/status_comment.py@@ -51,6 +51,7 @@ from products.review_hog.backend.reviewer.progress import (TurnMarker,TurnStats,finding_counts,+ live_turn_markers,progress_payload,snapshot_stats,turn_markers,@@ -641,9 +642,19 @@ def _render_live_body(team_id: int, report: ReviewReport, review_mode: str, review_design: str, *, run_index: int, failed: bool) -> str:state = _turn_state(team_id, report, run_index)+ # A run that dies in the publish window renders its finished turn, which is not a live turn. A+ # failed turn renders its own marker, because `_fail_run` writes the failure note before this render.+ if run_index <= report.run_count or state.marker is None:+ live_marker = None+ elif failed:+ live_marker = state.marker+ else:+ live_marker = live_turn_markers(team_id, [report], {(str(report.id), run_index): state.marker}).get(+ str(report.id)+ )return render_in_progress_body(str(report.id),- progress_payload(team_id, report, state.snapshot, state.turn, state.pairs),+ progress_payload(team_id, report, state.snapshot, state.turn, state.pairs, live_marker),review_mode=review_mode,review_design=state.review_design(review_design),head_sha=report.head_sha,diff --git a/products/review_hog/backend/temporal/activities.py b/products/review_hog/backend/temporal/activities.pyindex 89f15a8ec3b7..571d38d87fff 100644--- a/products/review_hog/backend/temporal/activities.py+++ b/products/review_hog/backend/temporal/activities.py@@ -117,7 +117,9 @@ from products.review_hog.backend.reviewer.progress import (RUN_OUTCOME_SKIPPED,RUN_STAGE_REVIEW,in_publish_window,+ live_turn_markers,record_run_outcome,+ turn_markers,)from products.review_hog.backend.reviewer.push_gate import (SYSTEM_ONE_SKIP_BELOW,@@ -2571,7 +2573,8 @@ def _fail_run(returnif run_index is None:# A run that dies in the publish window already counts its turn in `run_count`.- run_index = report.run_count if in_publish_window(report) else report.run_count + 1+ live_marker = live_turn_markers(team_id, [report], turn_markers(team_id, [report_id])).get(report_id)+ run_index = report.run_count if in_publish_window(report, live_marker) else report.run_count + 1record_run_outcome(team_id,report_id,diff --git a/products/review_hog/backend/tests/test_reviews_api.py b/products/review_hog/backend/tests/test_reviews_api.pyindex 2138810aaae9..49e4a327d02e 100644--- a/products/review_hog/backend/tests/test_reviews_api.py+++ b/products/review_hog/backend/tests/test_reviews_api.py@@ -26,7 +26,12 @@ from products.review_hog.backend.reviewer.artefact_content import (TurnMarkerArtefact,ValidationVerdict,)-from products.review_hog.backend.reviewer.constants import DEFAULT_REVIEW_ARM, REVIEW_MODE_FLASH, REVIEW_MODE_FULL+from products.review_hog.backend.reviewer.constants import (+ DEFAULT_REVIEW_ARM,+ REVIEW_MODE_FLASH,+ REVIEW_MODE_FULL,+ SINGLE_AGENT_PASS_NUMBER,+)from products.review_hog.backend.reviewer.models.github_meta import PRFile, PRMetadatafrom products.review_hog.backend.reviewer.models.issues_review import (DropDisposition,@@ -692,7 +697,7 @@ class TestRecentReviewsAPI(APIBaseTest):rows = self.client.get(self.url).json()["results"]assert [r["pr_number"] for r in rows] == [2, 1]assert rows[0]["in_progress"] is True- assert rows[0]["progress"] == {"review_stage": "fetching", "done": None, "total": None}+ assert rows[0]["progress"] == {"review_stage": "fetching", "done": None, "total": None, "review_mode": None}assert rows[1]["in_progress"] is Falseassert rows[1]["progress"] is None@@ -717,6 +722,7 @@ class TestRecentReviewsAPI(APIBaseTest):"review_stage": "selecting","done": None,"total": None,+ "review_mode": None,}persist_perspective_results(@@ -732,6 +738,7 @@ class TestRecentReviewsAPI(APIBaseTest):"review_stage": "reviewing","done": 2,"total": 8,+ "review_mode": None,}# Once the selector's plan lands, the total is exact: planned wave units + one blind spot per@@ -752,6 +759,7 @@ class TestRecentReviewsAPI(APIBaseTest):"review_stage": "reviewing","done": 2,"total": 3,+ "review_mode": None,}# All planned reads in (1 selected wave unit + 2 blind spots = 3) → the dedup window.@@ -766,6 +774,7 @@ class TestRecentReviewsAPI(APIBaseTest):"review_stage": "deduplicating","done": 3,"total": 3,+ "review_mode": None,}self._finding(running, "1-a", priority=IssuePriority.MUST_FIX)@@ -774,6 +783,7 @@ class TestRecentReviewsAPI(APIBaseTest):"review_stage": "validating","done": 1,"total": 2,+ "review_mode": None,}# Every finding judged → the turn is building + publishing, the moments before it completes.@@ -782,6 +792,7 @@ class TestRecentReviewsAPI(APIBaseTest):"review_stage": "finalizing","done": 2,"total": 2,+ "review_mode": None,}def test_single_agent_turn_reports_its_own_stages(self) -> None:@@ -800,24 +811,29 @@ class TestRecentReviewsAPI(APIBaseTest):pr_files=[],review_design=REVIEW_DESIGN_SINGLE_AGENT,)- assert stage() == {"review_stage": "single_agent_preparing", "done": None, "total": None}+ assert stage() == {"review_stage": "single_agent_preparing", "done": None, "total": None, "review_mode": None}- ReviewReportArtefact.add_turn_marker(- team_id=self.team.id,- report_id=running_id,- content=TurnMarkerArtefact(- head_sha="sha1",- run_index=1,- review_mode=REVIEW_MODE_FLASH,- reviewhog_version="v",- reviewhog_fingerprint="f",- ),- attribution=ArtefactAttribution.system(),+ self._turn_marker(+ running,+ run_index=1,+ review_mode=REVIEW_MODE_FLASH,+ head_sha="sha1",+ review_design=REVIEW_DESIGN_SINGLE_AGENT,)- assert stage() == {"review_stage": "single_agent_reviewing", "done": None, "total": None}+ assert stage() == {+ "review_stage": "single_agent_reviewing",+ "done": None,+ "total": None,+ "review_mode": REVIEW_MODE_FLASH,+ }self._finding(running, "1-a", priority=IssuePriority.MUST_FIX)- assert stage() == {"review_stage": "single_agent_finalizing", "done": None, "total": None}+ assert stage() == {+ "review_stage": "single_agent_finalizing",+ "done": None,+ "total": None,+ "review_mode": REVIEW_MODE_FLASH,+ }@parameterized.expand([@@ -1052,12 +1068,18 @@ class TestRecentReviewsAPI(APIBaseTest):head_sha="sha1",completed_head_sha="sha1",)+ self._turn_marker(report, run_index=1, review_mode=REVIEW_MODE_FULL, head_sha="sha1")row = self.client.get(self.url).json()["results"][0]assert row["pr_number"] == 3assert row["in_progress"] is Trueassert row["published"] is False- assert row["progress"] == {"review_stage": "finalizing", "done": None, "total": None}+ assert row["progress"] == {+ "review_stage": "finalizing",+ "done": None,+ "total": None,+ "review_mode": REVIEW_MODE_FULL,+ }# A resolution run holds the same ACTIVE-at-completed-head shape but with the head already# published — that window keeps its pre-existing label until the run's `resolution_run`@@ -1067,6 +1089,76 @@ class TestRecentReviewsAPI(APIBaseTest):assert row["in_progress"] is Trueassert row["progress"]["review_stage"] != "finalizing"+ def test_deep_re_review_after_an_unpublished_standard_turn_reads_its_own_progress(self) -> None:+ report = self._report(+ pr_number=3,+ acting_user=self.user,+ status=ReviewReport.Status.ACTIVE,+ head_sha="sha1",+ completed_head_sha="sha1",+ )+ report_id = str(report.id)+ persist_pr_snapshot(+ team_id=self.team.id,+ report_id=report_id,+ head_sha="sha1",+ pr_metadata=_pr_metadata("sha1", "same head"),+ pr_comments=[],+ pr_files=[],+ review_design=REVIEW_DESIGN_SINGLE_AGENT,+ )+ persist_perspective_results(+ team_id=self.team.id,+ report_id=report_id,+ head_sha="sha1",+ results={(SINGLE_AGENT_PASS_NUMBER, 0): _issues_review(0)},+ review_arm=DEFAULT_REVIEW_ARM,+ )+ self._turn_marker(+ report,+ run_index=1,+ review_mode=REVIEW_MODE_FLASH,+ head_sha="sha1",+ review_design=REVIEW_DESIGN_SINGLE_AGENT,+ )+ self._turn_marker(+ report, run_index=2, review_mode=REVIEW_MODE_FULL, head_sha="sha1", review_design=REVIEW_DESIGN_PIPELINE+ )+ persist_chunk_set(+ team_id=self.team.id,+ report_id=report_id,+ head_sha="sha1",+ chunks=ChunksList(chunks=[Chunk(chunk_id=0, files=[FileInfo(filename="a.py")])]),+ )++ row = self.client.get(self.url).json()["results"][0]++ assert row["review_mode"] == REVIEW_MODE_FLASH+ assert row["progress"] == {+ "review_stage": "selecting",+ "done": None,+ "total": None,+ "review_mode": REVIEW_MODE_FULL,+ }++ @parameterized.expand([("on_an_older_head", "sha2", False), ("that_failed_on_the_same_head", "sha1", True)])+ def test_the_marker_of_an_ended_attempt_does_not_describe_the_running_one(+ self, _name: str, head_sha: str, record_failure: bool+ ) -> None:+ report = self._report(pr_number=3, acting_user=self.user, completed=False, run_count=0, head_sha=head_sha)+ self._turn_marker(+ report, run_index=1, review_mode=REVIEW_MODE_FULL, head_sha="sha1", review_design=REVIEW_DESIGN_PIPELINE+ )+ if record_failure:+ record_run_outcome(+ self.team.id, str(report.id), stage="review", outcome="failed", reason="review_failed", run_index=1+ )++ row = self.client.get(self.url).json()["results"][0]++ assert row["in_progress"] is True+ assert row["progress"]["review_mode"] is None+def test_row_and_detail_anchor_to_the_completed_turn_during_a_re_review(self) -> None:# A re-review advances the live head_sha at turn START while run_count still points at the# previous turn — row stats and the detail's link-anchoring head must describe the COMPLETEDdiff --git a/products/review_hog/backend/tests/test_status_comment.py b/products/review_hog/backend/tests/test_status_comment.pyindex 9c5ca5616458..c9a884bf4ad5 100644--- a/products/review_hog/backend/tests/test_status_comment.py+++ b/products/review_hog/backend/tests/test_status_comment.py@@ -13,18 +13,28 @@ from parameterized import parameterizedfrom posthog.egress.github.transport import GitHubEgressBudgetExhausted-from products.review_hog.backend.models import ReviewReport-from products.review_hog.backend.reviewer.artefact_content import ReviewIssueFinding, ValidationVerdict+from products.review_hog.backend.models import ReviewReport, ReviewReportArtefact+from products.review_hog.backend.reviewer.artefact_content import (+ ReviewIssueFinding,+ TurnMarkerArtefact,+ ValidationVerdict,+)from products.review_hog.backend.reviewer.constants import REVIEW_MODE_FLASH, REVIEW_MODE_FULLfrom products.review_hog.backend.reviewer.fingerprint import ReviewHogMarkerfrom products.review_hog.backend.reviewer.models.github_meta import PRMetadatafrom products.review_hog.backend.reviewer.models.issue_validation import IssueValidationfrom products.review_hog.backend.reviewer.models.issues_review import Issue, IssuePriority, LineRangefrom products.review_hog.backend.reviewer.models.perspective_selection import ChunkPerspectiveSelection+from products.review_hog.backend.reviewer.models.split_pr_into_chunks import Chunk, ChunksList, FileInfofrom products.review_hog.backend.reviewer.models.thread_resolution import CommitHold-from products.review_hog.backend.reviewer.persistence import persist_findings, persist_verdict, upsert_review_report+from products.review_hog.backend.reviewer.persistence import (+ persist_chunk_set,+ persist_findings,+ persist_verdict,+ upsert_review_report,+)from products.review_hog.backend.reviewer.progress import SnapshotStats, TurnStats, run_outcome_markers-from products.review_hog.backend.reviewer.review_design import REVIEW_DESIGN_SINGLE_AGENT+from products.review_hog.backend.reviewer.review_design import REVIEW_DESIGN_PIPELINE, REVIEW_DESIGN_SINGLE_AGENTfrom products.review_hog.backend.reviewer.status_comment import (FinalizeStatusCommentInput,_splice_resolution_row,@@ -44,6 +54,7 @@ from products.review_hog.backend.reviewer.status_comment import (from products.review_hog.backend.reviewer.tools.github_client import GitHubAPIErrorfrom products.review_hog.backend.reviewer.tools.issue_deduplicator import AlreadyRaisedfrom products.review_hog.backend.temporal.activities import _fail_run+from products.signals.backend.artefact_attribution import ArtefactAttribution_MODULE = "products.review_hog.backend.reviewer.status_comment"_REQUEST = f"{_MODULE}.github_api_request"@@ -509,6 +520,41 @@ class TestFinalizeStatusComment(BaseTest):assert body.startswith("### PostHog Review · Standard · couldn't finish reviewing ")assert "1 kept, 0 dismissed" in body+ def test_a_failed_rerun_after_an_unpublished_turn_names_the_step_it_died_in(+ self, mock_request: MagicMock, mock_integration: MagicMock+ ) -> None:+ _wire_auth(mock_integration)+ report_id = upsert_review_report(team_id=self.team.id, repository="o/r", pr_url="u", pr_metadata=_pr_metadata())+ report = ReviewReport.objects.for_team(self.team.id).get(id=report_id)+ report.status_comment_id = 555+ report.run_count = 1+ report.head_sha = report.completed_head_sha = "a" * 40+ report.save(update_fields=["status_comment_id", "run_count", "head_sha", "completed_head_sha"])+ ReviewReportArtefact.add_turn_marker(+ team_id=self.team.id,+ report_id=report_id,+ content=TurnMarkerArtefact(+ head_sha=report.head_sha,+ run_index=2,+ review_mode=REVIEW_MODE_FULL,+ reviewhog_version="v",+ reviewhog_fingerprint="f",+ review_design=REVIEW_DESIGN_PIPELINE,+ ),+ attribution=ArtefactAttribution.system(),+ )+ persist_chunk_set(+ team_id=self.team.id,+ report_id=report_id,+ head_sha=report.head_sha,+ chunks=ChunksList(chunks=[Chunk(chunk_id=0, files=[FileInfo(filename="a.py")])]),+ )++ _fail_run(self.team.id, report_id, review_mode=REVIEW_MODE_FULL)++ body = mock_request.call_args.kwargs["json"]["body"]+ assert 'The review failed at "Pick perspectives".' in body+_DONE_BODY = f"### reviewed\n\n| Step | Status | Result |\n|---|---|---|\n| Publish | done | 1 posted |\n\n{status_marker('rid')}"_OLD_BODY = (diff --git a/products/review_hog/frontend/CodeReviewScene.stories.tsx b/products/review_hog/frontend/CodeReviewScene.stories.tsxindex 0704eefc0ff9..54aa89e392a5 100644--- a/products/review_hog/frontend/CodeReviewScene.stories.tsx+++ b/products/review_hog/frontend/CodeReviewScene.stories.tsx@@ -166,7 +166,7 @@ const runningReview = completedReview({status_comment_url: null,full_review_published: false,in_progress: true,- progress: { review_stage: 'reviewing', done: 3, total: 8 },+ progress: { review_stage: 'reviewing', done: 3, total: 8, review_mode: 'full' },must_fix_count: 0,should_fix_count: 0,consider_count: 0,diff --git a/products/review_hog/frontend/ReviewsTable.tsx b/products/review_hog/frontend/ReviewsTable.tsxindex 1439f5a53584..c937c930d487 100644--- a/products/review_hog/frontend/ReviewsTable.tsx+++ b/products/review_hog/frontend/ReviewsTable.tsx@@ -6,7 +6,7 @@ import { TZLabel } from 'lib/components/TZLabel'import { LemonTableColumns } from 'lib/lemon-ui/LemonTable'import { ReviewHogReviewsListScope, type ReviewRecentReviewApi } from './generated/api.schemas'-import { reviewTitle, runningStageLabel } from './reviewDisplay'+import { displayedReviewMode, reviewTitle, runningStageLabel } from './reviewDisplay'import { REVIEWS_PAGE_SIZE, reviewHogSettingsLogic } from './reviewHogSettingsLogic'import { ReviewModeTag } from './ReviewModeTag'@@ -165,7 +165,7 @@ export function ReviewsTable(): JSX.Element {{title: 'Mode',key: 'mode',- render: (_, review) => <ReviewModeTag mode={review.review_mode} />,+ render: (_, review) => <ReviewModeTag mode={displayedReviewMode(review)} />,},{title: 'Findings',diff --git a/products/review_hog/frontend/generated/api.schemas.ts b/products/review_hog/frontend/generated/api.schemas.tsindex 90a4b934bea7..32d3acb90a88 100644--- a/products/review_hog/frontend/generated/api.schemas.ts+++ b/products/review_hog/frontend/generated/api.schemas.ts@@ -687,6 +687,11 @@ export interface ReviewProgressApi {* @nullable*/total: number | null+ /** What the in-flight turn runs: 'full' (Deep) or 'flash' (Standard). The row's `review_mode` describes the last completed turn, which can differ. Null until the turn records its mode, shortly before its review sessions start.+ *+ * * `full` - Deep+ * * `flash` - Standard */+ review_mode: ReviewTriggerReviewModeEnumApi | null}/**diff --git a/products/review_hog/frontend/reviewDisplay.ts b/products/review_hog/frontend/reviewDisplay.tsindex 69897aa222ca..51349cc2a69b 100644--- a/products/review_hog/frontend/reviewDisplay.ts+++ b/products/review_hog/frontend/reviewDisplay.ts@@ -11,6 +11,11 @@ export function reviewTitle(return review.pr_title ?? `${review.repository}#${review.pr_number ?? review.head_branch}`}+// A running turn can run another mode than the last completed turn, which `review_mode` describes.+export function displayedReviewMode(review: ReviewRecentReviewApi): ReviewTriggerReviewModeEnumApi | null {+ return review.progress ? review.progress.review_mode : review.review_mode+}+function withCounter(label: string, done: number | null, total: number | null): string {return done !== null && total !== null && total > 0 ? `${label} ${done}/${total}` : label}diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex edcac3c08523..f83db674e5b3 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -96991,6 +96991,11 @@ export namespace Schemas {* @nullable*/total: number | null;+ /** What the in-flight turn runs: 'full' (Deep) or 'flash' (Standard). The row's `review_mode` describes the last completed turn, which can differ. Null until the turn records its mode, shortly before its review sessions start.+ *+ * * `full` - Deep+ * * `flash` - Standard */+ review_mode: ReviewTriggerReviewModeEnum | null;}export interface ReviewResolutionStatus {