Skip to content

: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.

fix(visual-review): rerun only the complete job and stop reruns passing the gate (#109785)

Julian Bez8e62ea1cf992
diff --git a/.github/workflows/ci-e2e-playwright.yml b/.github/workflows/ci-e2e-playwright.yml
index 5d69b14e52c3..a67f65d216aa 100644
--- a/.github/workflows/ci-e2e-playwright.yml
+++ b/.github/workflows/ci-e2e-playwright.yml
@@ -1045,7 +1045,7 @@ jobs:
# PRs are gating ("review"); master pushes are tracking-only ("observe") since
# there's no PR to approve and we don't want master runs to block or prompt for approval.
VR_PURPOSE: ${{ github.event_name == 'push' && 'observe' || 'review' }}
- # Recorded on the run so the VR UI can re-trigger this job via the GitHub API.
+ # The rerun target for recompute until the complete job records its own ID.
JOB_CHECK_RUN_ID: ${{ job.check_run_id }}
# A selective run only regenerates a subset of snapshots. --partial tells VR
# not to flag the un-run baseline snapshots as REMOVED and routes the run to a
@@ -1369,6 +1369,8 @@ jobs:
continue-on-error: ${{ github.event_name == 'push' }}
env:
VR_TOKEN: ${{ secrets.VR_API_TOKEN }}
+ # Recompute re-runs this job, which re-reads the verdict without re-running the E2E suite.
+ JOB_CHECK_RUN_ID: ${{ job.check_run_id }}
run: |
node products/visual_review/cli/dist/cli/src/index.js run complete \
--run-id "${{ needs.playwright.outputs.vr_run_id }}" \
diff --git a/.github/workflows/ci-storybook.yml b/.github/workflows/ci-storybook.yml
index 316822fd215d..8853ddc885cf 100644
--- a/.github/workflows/ci-storybook.yml
+++ b/.github/workflows/ci-storybook.yml
@@ -466,7 +466,7 @@ jobs:
# Selective storybook runs only render a subset of stories. Without --partial,
# VR would flag every untouched baseline identifier as removed.
VR_PARTIAL: ${{ needs.select-stories.outputs.mode == 'selective' && '--partial' || '' }}
- # Recorded on the run so the VR UI can re-trigger this job via the GitHub API.
+ # The rerun target for recompute until the complete job records its own ID.
JOB_CHECK_RUN_ID: ${{ job.check_run_id }}
run: |
# shellcheck disable=SC2086
@@ -1054,6 +1054,8 @@ jobs:
RUN_ID: ${{ needs.vr-setup.outputs.run_id }}
VR_OBSERVE: ${{ github.event_name == 'push' || needs.changes.outputs.merge_queue == 'true' }}
VR_TOLERATE_DRIFT: ${{ github.event_name == 'push' }}
+ # Recompute re-runs this job, which re-reads the verdict without a new capture.
+ JOB_CHECK_RUN_ID: ${{ job.check_run_id }}
run: |
args=(--run-id "$RUN_ID" --baseline frontend/snapshots.yml --token "$VR_TOKEN")
if [ "$VR_OBSERVE" = 'true' ]; then
diff --git a/products/visual_review/README.md b/products/visual_review/README.md
index b2d6269612ee..4344cd75fd08 100644
--- a/products/visual_review/README.md
+++ b/products/visual_review/README.md
@@ -243,6 +243,12 @@ Future runs skip diffing entirely for cached pairs.
Developers can also manually tolerate a snapshot from the UI.
When a snapshot already has 3 manual or agent tolerations, or 10 automatic ones, in the last 30 days, the Tolerate button offers a quarantine first, because another toleration covers only that one rendering.
+**Recompute** — re-reads the gate of a completed run after a quarantine or toleration, and re-runs the CI job that completed the run, so the required check reads the new verdict.
+`run complete` records that job's ID from `JOB_CHECK_RUN_ID`; set it on the step in the workflow.
+GitHub re-runs a job with every job that depends on it, so the completing job re-runs only the verdict and the gate after it, and captures nothing.
+Without it, the target stays the `run create` job, and a re-run captures every snapshot again.
+Finalize re-runs the same job when it has no baseline to commit, because no new CI run starts then.
+
**Row alignment** — a panel that grows by a pixel moves everything below it down, which a top-aligned pixel diff reads as a page-wide change.
Before thresholding, the diff pairs the rows that exist in both images, so the classifier sees only what actually changed.
A shift of one or two rows with nothing else changed is absorbed as noise, and the snapshot keeps the shift in `diff_metadata.row_shift` plus a diff image that shows the moved row, so the run leaves a trace instead of disappearing.
diff --git a/products/visual_review/backend/facade/api.py b/products/visual_review/backend/facade/api.py
index 74c9e240b40a..7b371dc10980 100644
--- a/products/visual_review/backend/facade/api.py
+++ b/products/visual_review/backend/facade/api.py
@@ -688,14 +688,19 @@ def get_tolerated_hashes(repo_id: UUID, identifier: str) -> list[contracts.Toler
]
-def complete_run(run_id: UUID, team_id: int | None = None) -> contracts.Run:
+def complete_run(run_id: UUID, team_id: int | None = None, check_run_id: str | None = None) -> contracts.Run:
"""
Complete a run: detect removals, verify uploads, trigger diff processing.
"""
if team_id is not None:
run_queries.get_run(run_id, team_id=team_id) # validates ownership
run = runs.complete_run(run_id)
- return _to_run(run)
+ # After `complete_run`, whose baseline healing saves a whole metadata dict it may have read stale.
+ if check_run_id is not None:
+ runs.record_completing_job(run_id, check_run_id)
+ # A re-run of the completing CI job lands here on a completed run, and the CLI gates on this
+ # number, so it must be the commit status verdict and not the unprefetched default of 0.
+ return _to_run(run, unresolved=gating.count_gating(run))
def recompute_run(run_id: UUID, team_id: int | None = None) -> contracts.RecomputeResult:
diff --git a/products/visual_review/backend/logic/approvals.py b/products/visual_review/backend/logic/approvals.py
index b40ca1e4be44..cde8b0b23d42 100644
--- a/products/visual_review/backend/logic/approvals.py
+++ b/products/visual_review/backend/logic/approvals.py
@@ -7,11 +7,26 @@ from uuid import UUID
from django.db import transaction
from django.utils import timezone
+import structlog
+
from ..db import WRITER_DB
from ..facade.enums import ReviewDecision, ReviewState, RunPurpose, RunStatus, SnapshotResult
from ..models import Run
from . import artifact_store, baselines, ci_status, errors, gating, run_queries
+logger = structlog.get_logger(__name__)
+
+
+def _rerun_completing_job(run: Run, check_run_id: str) -> None:
+ """Re-run the CI job that completed a finalized run, and log a failure.
+
+ Recompute refuses a finalized run, so after a failure GitHub's "Re-run failed jobs"
+ is the way to clear the required check.
+ """
+ triggered, error = ci_status._rerun_github_job(run, check_run_id)
+ if not triggered:
+ logger.warning("visual_review.finalize_ci_rerun_failed", run_id=str(run.id), error=error)
+
@transaction.atomic(using=WRITER_DB)
def finalize_run(
@@ -101,7 +116,8 @@ def finalize_run(
# Commit first — before DB writes — so a GitHub failure aborts cleanly. Removed snapshots
# also need a commit, to prune them from the baseline, even when nothing was approved.
- if commit_to_github and (approved_updates or has_removed) and run.pr_number and repo.repo_full_name:
+ committed = bool(commit_to_github and (approved_updates or has_removed) and run.pr_number and repo.repo_full_name)
+ if committed:
baselines._commit_baseline_to_github(run, repo, approved_updates, approver_user_id=user_id)
# Removed snapshots are pruned from the baseline on commit; mark them approved for cleanup.
@@ -120,6 +136,12 @@ def finalize_run(
if commit_to_github:
ci_status._post_commit_status(run, repo, "success", "Visual changes approved")
+ # A baseline commit starts a new CI run. Without one, the job that completed this run
+ # keeps the red verdict it read before the review, so it has to read it again.
+ check_run_id = (run.metadata or {}).get("github_check_run_id")
+ if commit_to_github and not committed and run.pr_number and check_run_id:
+ transaction.on_commit(lambda: _rerun_completing_job(run, str(check_run_id)), using=WRITER_DB)
+
if commit_to_github and review_decision == ReviewDecision.HUMAN_APPROVED:
from ..tasks.tasks import post_approval_comment
diff --git a/products/visual_review/backend/logic/gating.py b/products/visual_review/backend/logic/gating.py
index b4b92c374057..0b2cb1ac5ad1 100644
--- a/products/visual_review/backend/logic/gating.py
+++ b/products/visual_review/backend/logic/gating.py
@@ -63,6 +63,24 @@ def count_unresolved(run: Run) -> int:
)
+def count_gating(run: Run) -> int:
+ """How many snapshots fail the CI job that completes the run: `_post_status`'s verdict as a count.
+
+ Approved changes fail it too until finalize commits them, because the baseline on the PR
+ branch does not hold them yet. Without this, a re-run of that job passes a run whose
+ approvals were never committed.
+ """
+ unresolved = count_unresolved(run)
+ if run.approved or run.purpose == RunPurpose.OBSERVE:
+ return unresolved
+ awaiting_commit = RunSnapshot.objects.filter(
+ run_id=run.id,
+ review_state=ReviewState.APPROVED,
+ result__in=(SnapshotResult.NEW, SnapshotResult.CHANGED),
+ ).count()
+ return unresolved + awaiting_commit
+
+
def _changes_summary(run: Run) -> str:
"""Change summary from the run's denormalized (quarantine-excluded) counts."""
return comment_markdown._format_change_counts(run.changed_count, run.new_count, run.removed_count)
diff --git a/products/visual_review/backend/logic/runs.py b/products/visual_review/backend/logic/runs.py
index 16d4e0ed374d..778228bd283e 100644
--- a/products/visual_review/backend/logic/runs.py
+++ b/products/visual_review/backend/logic/runs.py
@@ -209,6 +209,21 @@ def mark_run_processing(run_id: UUID) -> Run:
return run
+def record_completing_job(run_id: UUID, check_run_id: str) -> None:
+ """Point recompute's CI rerun at the job that completes the run.
+
+ `run create` records the job that captures the snapshots. GitHub re-runs a job
+ together with every job that depends on it, so a rerun of that job captures every
+ snapshot again and creates a new run. The completing job only reads the server
+ verdict, and the required check depends on it. It runs on every complete call, also
+ on a completed run, because a re-run of the completing job has a new job ID.
+ """
+ with transaction.atomic(using=WRITER_DB):
+ run = Run.objects.using(WRITER_DB).select_for_update().get(id=run_id)
+ run.metadata["github_check_run_id"] = check_run_id
+ run.save(using=WRITER_DB, update_fields=["metadata"])
+
+
def complete_run(run_id: UUID) -> Run:
"""
Complete a run: detect removals, classify snapshots, hand off to the diff task.
diff --git a/products/visual_review/backend/presentation/serializers.py b/products/visual_review/backend/presentation/serializers.py
index bc48c7f26bbf..a9a1cc78bf65 100644
--- a/products/visual_review/backend/presentation/serializers.py
+++ b/products/visual_review/backend/presentation/serializers.py
@@ -335,6 +335,19 @@ class MarkToleratedInputSerializer(serializers.Serializer):
)
+class CompleteRunInputSerializer(serializers.Serializer):
+ check_run_id = serializers.RegexField(
+ r"^\d+$",
+ max_length=32,
+ required=False,
+ help_text=(
+ "Numeric GitHub Actions job ID of the CI job that completes the run, from "
+ "`${{ job.check_run_id }}`. Recompute re-runs this job, so it re-reads the verdict "
+ "without capturing the snapshots again. Omit it outside GitHub Actions."
+ ),
+ )
+
+
class QuarantineSourceRunSerializer(DataclassSerializer):
class Meta:
dataclass = QuarantineSourceRun
diff --git a/products/visual_review/backend/presentation/views.py b/products/visual_review/backend/presentation/views.py
index 9aa4b35a553e..6d0c10dbb05d 100644
--- a/products/visual_review/backend/presentation/views.py
+++ b/products/visual_review/backend/presentation/views.py
@@ -48,6 +48,7 @@ from .serializers import (
AddSnapshotsResultSerializer,
ApproveRunInputSerializer,
BaselineOverviewSerializer,
+ CompleteRunInputSerializer,
CreateRepoInputSerializer,
CreateRunInputSerializer,
CreateRunResultSerializer,
@@ -734,12 +735,19 @@ class RunViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
return self.get_paginated_response(SnapshotHistoryEntrySerializer(instance=page, many=True).data)
return Response(SnapshotHistoryEntrySerializer(instance=history, many=True).data)
- @extend_schema(request=None, responses={200: RunSerializer})
+ @validated_request(
+ request_serializer=CompleteRunInputSerializer,
+ responses={200: OpenApiResponse(response=RunSerializer)},
+ )
@action(detail=True, methods=["post"])
- def complete(self, request: Request, pk: str, **kwargs) -> Response:
+ def complete(self, request: TypedRequest, pk: str, **kwargs) -> Response:
"""Complete a run: detect removals, verify uploads, trigger diff processing."""
try:
- run = api.complete_run(_parse_uuid(pk), team_id=self.team_id)
+ run = api.complete_run(
+ _parse_uuid(pk),
+ team_id=self.team_id,
+ check_run_id=request.validated_data.get("check_run_id"),
+ )
except api.RunNotFoundError:
return Response({"detail": "Run not found"}, status=status.HTTP_404_NOT_FOUND)
except api.GitHubRateLimitError as e:
diff --git a/products/visual_review/backend/tests/logic/test_approvals.py b/products/visual_review/backend/tests/logic/test_approvals.py
index d669666b6bc5..0b09f41a6015 100644
--- a/products/visual_review/backend/tests/logic/test_approvals.py
+++ b/products/visual_review/backend/tests/logic/test_approvals.py
@@ -1,9 +1,11 @@
"""Unit tests for logic/approvals.py — Approving snapshots and finalizing a run."""
import pytest
+from unittest.mock import MagicMock
from django.db import transaction
+from products.visual_review.backend.facade import api
from products.visual_review.backend.facade.contracts import CreateRunInput, SnapshotManifestItem
from products.visual_review.backend.facade.enums import ReviewState, RunType, SnapshotResult
from products.visual_review.backend.logic import (
@@ -12,6 +14,7 @@ from products.visual_review.backend.logic import (
baselines,
ci_status,
errors,
+ github_api,
repos,
run_queries,
runs,
@@ -21,6 +24,12 @@ from products.visual_review.backend.models import QuarantinedIdentifier
from products.visual_review.backend.tests.conftest import PRODUCT_DATABASES
+def _fake_github_job_api(method, repo, path, **kwargs):
+ if method == "GET":
+ return MagicMock(status_code=200, json=lambda: {"head_sha": "abc", "run_id": 777})
+ return MagicMock(status_code=201)
+
+
@pytest.mark.django_db(databases=PRODUCT_DATABASES)
class TestApproveRun:
@pytest.fixture
@@ -136,6 +145,30 @@ class TestApproveRun:
assert again.approved is True
assert again.approved_at == approved_at # unchanged — the second call did no work
+ @pytest.mark.parametrize(
+ ("approve", "tolerate", "expected"),
+ [
+ ([], [], 2),
+ (["A"], ["B"], 1),
+ ([], ["A", "B"], 0),
+ ],
+ )
+ def test_completing_again_reports_what_still_fails_the_gate(self, repo, user, mocker, approve, tolerate, expected):
+ # A re-run of the completing CI job calls complete on a finished run and gates on this
+ # count, so an untouched or approved-but-uncommitted change must still count.
+ run = self._completed_two_change_run(repo, mocker)
+ for identifier in tolerate:
+ toleration.mark_snapshot_as_tolerated(
+ run.id, run.snapshots.get(identifier=identifier).id, user.id, repo.team_id
+ )
+ approvals.approve_snapshots(
+ run_id=run.id,
+ user_id=user.id,
+ approved_snapshots=[{"identifier": i, "new_hash": f"h{i.lower()}"} for i in approve],
+ )
+
+ assert api.complete_run(run.id, team_id=repo.team_id).summary.unresolved == expected
+
@pytest.mark.parametrize("add_images", [True, False])
def test_finalize_always_comments_and_forwards_add_images(self, repo, user, mocker, add_images):
# The PR comment is always dispatched on finalize; add_images_to_comment_on_pr only
@@ -177,6 +210,9 @@ class TestApproveRun:
)
commit = mocker.patch.object(baselines, "_commit_baseline_to_github")
mocker.patch.object(ci_status, "_post_commit_status")
+ github = mocker.patch.object(github_api, "_github_api_request", side_effect=_fake_github_job_api)
+ mocker.patch.object(transaction, "on_commit", side_effect=lambda fn, *args, **kwargs: fn())
+ mocker.patch("products.visual_review.backend.tasks.tasks.post_approval_comment.delay")
updated = approvals.finalize_run(run_id=run.id, user_id=user.id, approve_all=approve_all)
@@ -185,6 +221,8 @@ class TestApproveRun:
assert commit.call_args.args[2] == [{"identifier": "Q", "new_hash": "hq"}]
else:
assert commit.called is False
+ reruns = [c.args[2] for c in github.call_args_list if c.args[0] == "POST"]
+ assert reruns == ([] if expect_committed else ["actions/jobs/42/rerun"])
def _completed_quarantined_run(self, repo, mocker, result):
artifact_store.get_or_create_artifact(repo_id=repo.id, content_hash="hq", storage_path="p/q")
@@ -198,6 +236,7 @@ class TestApproveRun:
pr_number=7,
snapshots=[SnapshotManifestItem(identifier="Q", content_hash="hq")],
baseline_hashes=baseline,
+ metadata={"github_check_run_id": "42", "github_run_id": "777"},
),
team_id=repo.team_id,
)
diff --git a/products/visual_review/backend/tests/test_presentation.py b/products/visual_review/backend/tests/test_presentation.py
index 21ce9a48d05a..7ee03f006e83 100644
--- a/products/visual_review/backend/tests/test_presentation.py
+++ b/products/visual_review/backend/tests/test_presentation.py
@@ -301,12 +301,19 @@ class TestRunViewSet(VisualReviewTeamScopedTestMixin, APIBaseTest):
team_id=self.team.id,
)
- response = self.client.post(f"/api/projects/{self.team.id}/visual_review/runs/{create_result.run_id}/complete/")
+ complete_url = f"/api/projects/{self.team.id}/visual_review/runs/{create_result.run_id}/complete/"
+ response = self.client.post(complete_url, {"check_run_id": "111"}, format="json")
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json()["status"], "completed")
mock_delay.assert_not_called()
+ response = self.client.post(complete_url, {"check_run_id": "222"}, format="json")
+
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ run = Run.objects.get(id=create_result.run_id)
+ self.assertEqual(run.metadata["github_check_run_id"], "222")
+
def test_approve_run(self):
# Create artifact directly via logic (API no longer exposes register_artifact)
artifact_store.get_or_create_artifact(
diff --git a/products/visual_review/cli/src/client.test.ts b/products/visual_review/cli/src/client.test.ts
index edf7b4aabe71..2caebd926821 100644
--- a/products/visual_review/cli/src/client.test.ts
+++ b/products/visual_review/cli/src/client.test.ts
@@ -51,6 +51,19 @@ describe('VisualReviewClient', () => {
expect(mockFetch.mock.calls[0][0]).toContain('limit=100')
})
+ it.each([
+ ['72855643533', { check_run_id: '72855643533' }],
+ [undefined, {}],
+ ])('sends the completing job ID %s when completing a run', async (checkRunId, expectedBody) => {
+ mockFetch.mockResolvedValueOnce(jsonResponse({ id: 'run-1', status: 'completed' }))
+
+ await client.completeRun('run-1', checkRunId)
+
+ const [url, init] = mockFetch.mock.calls[0]
+ expect(url).toContain('/visual_review/runs/run-1/complete/')
+ expect(JSON.parse(init.body)).toEqual(expectedBody)
+ })
+
it('throws immediately on 4xx errors without retrying', async () => {
mockFetch.mockResolvedValueOnce(jsonResponse({ error: 'unauthorized' }, 401))
diff --git a/products/visual_review/cli/src/client.ts b/products/visual_review/cli/src/client.ts
index f2655e5eb1f8..c8fe51249b1f 100644
--- a/products/visual_review/cli/src/client.ts
+++ b/products/visual_review/cli/src/client.ts
@@ -191,10 +191,13 @@ export class VisualReviewClient {
/**
* Complete a run: detect removals, verify uploads, trigger diff processing.
+ *
+ * `checkRunId` names the CI job that calls this, so a recompute re-runs only that job.
*/
- async completeRun(runId: string): Promise<RunApi> {
+ async completeRun(runId: string, checkRunId?: string): Promise<RunApi> {
return this.request<RunApi>(`/visual_review/runs/${runId}/complete/`, {
method: 'POST',
+ body: JSON.stringify(checkRunId ? { check_run_id: checkRunId } : {}),
})
}
diff --git a/products/visual_review/cli/src/index.ts b/products/visual_review/cli/src/index.ts
index 173a84095b5b..f236f1a5b454 100644
--- a/products/visual_review/cli/src/index.ts
+++ b/products/visual_review/cli/src/index.ts
@@ -459,7 +459,7 @@ async function runComplete(options: RunCompleteOptions): Promise<number> {
log(`[run:${runId}] Completing run`)
- let run = await client.completeRun(runId)
+ let run = await client.completeRun(runId, process.env.JOB_CHECK_RUN_ID)
log(`[run:${runId}] Status: ${run.status}`)
@@ -692,7 +692,7 @@ async function runSubmit(options: SubmitOptions): Promise<number> {
}
}
- let run = await client.completeRun(runId)
+ let run = await client.completeRun(runId, process.env.JOB_CHECK_RUN_ID)
log(`[run:${runId}] Status: ${run.status}`)
if (run.status !== 'completed' && run.status !== 'failed') {
diff --git a/products/visual_review/cli/src/outcome.test.ts b/products/visual_review/cli/src/outcome.test.ts
index 61b0573c1cbb..36cb36834c2d 100644
--- a/products/visual_review/cli/src/outcome.test.ts
+++ b/products/visual_review/cli/src/outcome.test.ts
@@ -108,6 +108,18 @@ describe('reportRunOutcome', () => {
expect(output).toContain('No visual changes')
})
+ it('fails a failed run even though nothing counts as unresolved', async () => {
+ const exitCode = await reportRunOutcome(
+ client,
+ { ...run({ unresolved: 0 }), status: 'failed', error_message: 'hash mismatch' } as Run,
+ 'https://vr.example.com/run-1',
+ 'review'
+ )
+
+ expect(exitCode).toBe(1)
+ expect(output).toContain('Run failed: hash mismatch')
+ })
+
it('still reports when the snapshot listing fails', async () => {
vi.spyOn(client, 'getRunSnapshots').mockRejectedValue(new Error('boom'))
diff --git a/products/visual_review/cli/src/outcome.ts b/products/visual_review/cli/src/outcome.ts
index 1cc1014b1990..10fc8c1493a8 100644
--- a/products/visual_review/cli/src/outcome.ts
+++ b/products/visual_review/cli/src/outcome.ts
@@ -87,6 +87,12 @@ export async function reportRunOutcome(
const s = run.summary
const changes = s.changed + s.new + s.removed
+ // A failed run counts nothing as unresolved, so the counts below would pass it.
+ if (run.status === 'failed') {
+ log(`[run:${runId}] Run failed: ${run.error_message ?? 'no error recorded'} — review at: ${reviewUrl}`)
+ return tolerateDrift ? 0 : 1
+ }
+
if (purpose === 'observe') {
if (changes === 0) {
log(`[run:${runId}] No visual changes`)
diff --git a/products/visual_review/frontend/generated/api.schemas.ts b/products/visual_review/frontend/generated/api.schemas.ts
index 7d16c0d6769f..d75b0394aa1b 100644
--- a/products/visual_review/frontend/generated/api.schemas.ts
+++ b/products/visual_review/frontend/generated/api.schemas.ts
@@ -568,6 +568,15 @@ export interface ApproveRunRequestInputApi {
snapshots: ApproveSnapshotInputApi[]
}
+export interface CompleteRunInputApi {
+ /**
+ * Numeric GitHub Actions job ID of the CI job that completes the run, from `${{ job.check_run_id }}`. Recompute re-runs this job, so it re-reads the verdict without capturing the snapshots again. Omit it outside GitHub Actions.
+ * @maxLength 32
+ * @pattern ^\d+$
+ */
+ check_run_id?: string
+}
+
export interface FinalizeRunRequestInputApi {
/** Approve every still-pending changed and new snapshot before finalizing (tolerated snapshots are left untouched). Leave false to finalize a run you've already reviewed — finalizing fails if any changed/new snapshot is still unreviewed. */
approve_all?: boolean
diff --git a/products/visual_review/frontend/generated/api.ts b/products/visual_review/frontend/generated/api.ts
index 100208c21c29..a7470062a962 100644
--- a/products/visual_review/frontend/generated/api.ts
+++ b/products/visual_review/frontend/generated/api.ts
@@ -13,6 +13,7 @@ import type {
AddSnapshotsResultApi,
ApproveRunRequestInputApi,
BaselineOverviewApi,
+ CompleteRunInputApi,
CreateRepoInputApi,
CreateRunInputApi,
CreateRunResultApi,
@@ -547,11 +548,14 @@ export const getVisualReviewRunsCompleteCreateUrl = (projectId: string, id: stri
export const visualReviewRunsCompleteCreate = async (
projectId: string,
id: string,
+ completeRunInputApi?: CompleteRunInputApi,
options?: RequestInit
): Promise<RunApi> => {
return apiMutator<RunApi>(getVisualReviewRunsCompleteCreateUrl(projectId, id), {
...options,
method: 'POST',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(completeRunInputApi),
})
}
diff --git a/products/visual_review/frontend/generated/api.zod.ts b/products/visual_review/frontend/generated/api.zod.ts
index b22c8d7116a3..7566e3e4f729 100644
--- a/products/visual_review/frontend/generated/api.zod.ts
+++ b/products/visual_review/frontend/generated/api.zod.ts
@@ -152,6 +152,24 @@ export const VisualReviewRunsApproveCreateBody = /* @__PURE__ */ zod.object({
),
})
+/**
+ * Complete a run: detect removals, verify uploads, trigger diff processing.
+ */
+export const visualReviewRunsCompleteCreateBodyCheckRunIdMax = 32
+
+export const visualReviewRunsCompleteCreateBodyCheckRunIdRegExp = new RegExp('^\\d+$')
+
+export const VisualReviewRunsCompleteCreateBody = /* @__PURE__ */ zod.object({
+ check_run_id: zod
+ .string()
+ .max(visualReviewRunsCompleteCreateBodyCheckRunIdMax)
+ .regex(visualReviewRunsCompleteCreateBodyCheckRunIdRegExp)
+ .optional()
+ .describe(
+ 'Numeric GitHub Actions job ID of the CI job that completes the run, from `${{ job.check_run_id }}`. Recompute re-runs this job, so it re-reads the verdict without capturing the snapshots again. Omit it outside GitHub Actions.'
+ ),
+})
+
/**
* Finalize a fully-reviewed run: commit the approved baseline and green the gate.
*
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 2b109cbe9661..23cd3440b350 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -23153,6 +23153,15 @@ export namespace Schemas {
value: string;
}
+ export interface CompleteRunInput {
+ /**
+ * Numeric GitHub Actions job ID of the CI job that completes the run, from `${{ job.check_run_id }}`. Recompute re-runs this job, so it re-reads the verdict without capturing the snapshots again. Omit it outside GitHub Actions.
+ * @maxLength 32
+ * @pattern ^\d+$
+ */
+ check_run_id?: string;
+ }
+
/**
* Global feature importance / directionality bundle for the champion model card.
*/