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.

feat(visual-review): let agents quarantine flaky snapshots through mcp (#109788)

Julian Bez3a033fc6e177
diff --git a/products/visual_review/README.md b/products/visual_review/README.md
index 4344cd75fd08..db83e4149adc 100644
--- a/products/visual_review/README.md
+++ b/products/visual_review/README.md
@@ -257,6 +257,7 @@ The cap is measured against the committed baseline on every run, so absorbed shi
**Quarantine** — known-flaky identifiers can be quarantined per repo and run type.
Quarantined snapshots are still captured and diffed but excluded from gating.
+A quarantine opened through MCP expires within `AGENT_QUARANTINE_MAX_DAYS`: an omitted or later expiry becomes that cap, because no agent comes back to lift it.
A quarantined snapshot reaches the baseline only when a person approves it by identifier, because "Approve all" skips quarantined snapshots.
This is how a quarantined story's entry keeps up with the story.
The story still renders on every run, so a code change to it makes the entry stale while the quarantine hides the drift, and every run fails on the day the quarantine is lifted or expires.
diff --git a/products/visual_review/backend/facade/contracts.py b/products/visual_review/backend/facade/contracts.py
index 578a3a43e08f..e4bacb3b5354 100644
--- a/products/visual_review/backend/facade/contracts.py
+++ b/products/visual_review/backend/facade/contracts.py
@@ -656,6 +656,10 @@ FLAKINESS_MIN_HEADROOM = 0.2
# lapse, so it counts toward `needs_decision`.
FLAKINESS_EXPIRY_SOON_DAYS = 7
+# Latest expiry an agent's quarantine gets, and the one it gets when the call names
+# none. A quarantine without an expiry never lifts itself, and no agent comes back to lift it.
+AGENT_QUARANTINE_MAX_DAYS = 30
+
# Safety cap on rows returned by the flakiness endpoint. The population is
# already narrow (only identifiers carrying variants or a quarantine), so this
# is a backstop against a repo whose diff threshold is misconfigured and
diff --git a/products/visual_review/backend/logic/quarantine.py b/products/visual_review/backend/logic/quarantine.py
index 7dba06587497..1395c0caf590 100644
--- a/products/visual_review/backend/logic/quarantine.py
+++ b/products/visual_review/backend/logic/quarantine.py
@@ -11,7 +11,7 @@ from django.db.models import Q, QuerySet
from django.utils import timezone
from ..db import READER_DB, WRITER_DB
-from ..facade.contracts import FLAKINESS_EXPIRY_SOON_DAYS
+from ..facade.contracts import AGENT_QUARANTINE_MAX_DAYS, FLAKINESS_EXPIRY_SOON_DAYS
from ..facade.enums import ActorType
from ..models import QuarantinedIdentifier, Run
from . import errors, github_api, repos
@@ -122,6 +122,10 @@ def quarantine_identifier(
) -> QuarantinedIdentifier:
repos.get_repo(repo_id, team_id) # raises RepoNotFoundError if repo not owned by team
now = timezone.now()
+ if source == ActorType.AGENT:
+ latest = now + timedelta(days=AGENT_QUARANTINE_MAX_DAYS)
+ if expires_at is None or expires_at > latest:
+ expires_at = latest
# Resolve the source run inside the team scope so a malicious caller can't
# attach a quarantine to an unrelated run. Silently drop on mismatch — the
# quarantine itself still wins; we just lose the "what was wrong" pointer.
diff --git a/products/visual_review/backend/presentation/serializers.py b/products/visual_review/backend/presentation/serializers.py
index d5d55df2d9da..2752e298154c 100644
--- a/products/visual_review/backend/presentation/serializers.py
+++ b/products/visual_review/backend/presentation/serializers.py
@@ -8,6 +8,7 @@ from rest_framework import serializers
from rest_framework_dataclasses.serializers import DataclassSerializer
from ..facade.contracts import (
+ AGENT_QUARANTINE_MAX_DAYS,
FLAKINESS_RATE_DAYS,
FLAKINESS_WINDOW_DAYS,
PIXEL_DIFF_THRESHOLD_PERCENT,
@@ -376,6 +377,14 @@ class BaselineQuarantineSummarySerializer(DataclassSerializer):
class QuarantineInputSerializer(DataclassSerializer):
identifier = serializers.CharField(max_length=512, help_text="Snapshot identifier to quarantine.")
reason = serializers.CharField(max_length=255, help_text="Why this snapshot is being quarantined.")
+ expires_at = serializers.DateTimeField(
+ required=False,
+ allow_null=True,
+ help_text=(
+ "When the quarantine lifts itself, as an ISO 8601 datetime. Through MCP an omitted or later "
+ f"expiry becomes {AGENT_QUARANTINE_MAX_DAYS} days from now; anywhere else omitting it means no expiry."
+ ),
+ )
source_run_id = serializers.UUIDField(
required=False,
allow_null=True,
diff --git a/products/visual_review/backend/tests/test_presentation.py b/products/visual_review/backend/tests/test_presentation.py
index fe83bd320bb7..51793ef61cca 100644
--- a/products/visual_review/backend/tests/test_presentation.py
+++ b/products/visual_review/backend/tests/test_presentation.py
@@ -1,19 +1,26 @@
"""Integration tests for visual_review DRF views."""
+from datetime import timedelta
from urllib.parse import quote, urlencode
from uuid import uuid4
from posthog.test.base import APIBaseTest
from unittest.mock import patch
+from django.utils import timezone
+
from parameterized import parameterized
from rest_framework import status
from posthog.helpers.trigram_search import MAX_SEARCH_LENGTH
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 RunPurpose, RunStatus, RunType, SnapshotResult
+from products.visual_review.backend.facade.contracts import (
+ AGENT_QUARANTINE_MAX_DAYS,
+ CreateRunInput,
+ SnapshotManifestItem,
+)
+from products.visual_review.backend.facade.enums import ActorType, RunPurpose, RunStatus, RunType, SnapshotResult
from products.visual_review.backend.logic import artifact_store, quarantine, runs
from products.visual_review.backend.models import Run, RunSnapshot
from products.visual_review.backend.tests.conftest import PRODUCT_DATABASES, VisualReviewTeamScopedTestMixin
@@ -95,6 +102,38 @@ class TestRepoViewSet(VisualReviewTeamScopedTestMixin, APIBaseTest):
assert response.status_code == status.HTTP_204_NO_CONTENT
assert quarantine.list_quarantined_identifiers(repo.id, team_id=self.team.id) == []
+ @parameterized.expand(
+ [
+ ("agent_without_expiry", ActorType.AGENT, None, AGENT_QUARANTINE_MAX_DAYS),
+ ("agent_past_the_cap", ActorType.AGENT, 365, AGENT_QUARANTINE_MAX_DAYS),
+ ("agent_within_the_cap", ActorType.AGENT, 7, 7),
+ ("human_without_expiry", ActorType.HUMAN, None, None),
+ ("human_past_the_cap", ActorType.HUMAN, 365, 365),
+ ]
+ )
+ def test_an_agent_quarantine_always_expires_within_the_cap(self, _name, source, requested_days, expected_days):
+ repo = api.create_repo(team_id=self.team.id, repo_external_id=666, repo_full_name="org/agent")
+ before = timezone.now()
+ requested = None if requested_days is None else before + timedelta(days=requested_days)
+
+ entry = quarantine.quarantine_identifier(
+ repo_id=repo.id,
+ identifier="Button",
+ run_type=RunType.STORYBOOK,
+ reason="flaky",
+ user_id=self.user.id,
+ team_id=self.team.id,
+ expires_at=requested,
+ source=source,
+ )
+
+ if expected_days is None:
+ assert entry.expires_at is None
+ else:
+ window = timedelta(days=expected_days)
+ assert entry.expires_at is not None
+ assert before + window <= entry.expires_at <= timezone.now() + window
+
def test_opening_a_quarantine_still_needs_a_reason(self):
repo = api.create_repo(team_id=self.team.id, repo_external_id=555, repo_full_name="org/open")
diff --git a/products/visual_review/frontend/generated/api.schemas.ts b/products/visual_review/frontend/generated/api.schemas.ts
index 67d335d52844..28173207bec9 100644
--- a/products/visual_review/frontend/generated/api.schemas.ts
+++ b/products/visual_review/frontend/generated/api.schemas.ts
@@ -286,6 +286,11 @@ export interface QuarantineInputApi {
* @maxLength 255
*/
reason: string
+ /**
+ * When the quarantine lifts itself, as an ISO 8601 datetime. Through MCP an omitted or later expiry becomes 30 days from now; anywhere else omitting it means no expiry.
+ * @nullable
+ */
+ expires_at?: string | null
/**
* Optional pointer to the run whose failing snapshot prompted this quarantine — used to surface a 'view the failing run' link later.
* @nullable
@@ -293,8 +298,6 @@ export interface QuarantineInputApi {
source_run_id?: string | null
/** Post the quarantine to the Slack channel of the team that owns the story, naming the user who quarantined it. Only Storybook snapshots have an owning team. Best effort: skipped when the story has no owning team or the project has no Slack integration. */
notify_owners?: boolean
- /** @nullable */
- expires_at?: string | null
}
export interface UnquarantineQueryApi {
diff --git a/products/visual_review/frontend/generated/api.zod.ts b/products/visual_review/frontend/generated/api.zod.ts
index 7566e3e4f729..d5ef2808a51e 100644
--- a/products/visual_review/frontend/generated/api.zod.ts
+++ b/products/visual_review/frontend/generated/api.zod.ts
@@ -52,6 +52,12 @@ export const VisualReviewReposQuarantineCreateBody = /* @__PURE__ */ zod.object(
.string()
.max(visualReviewReposQuarantineCreateBodyReasonMax)
.describe('Why this snapshot is being quarantined.'),
+ expires_at: zod.iso
+ .datetime({ offset: true })
+ .nullish()
+ .describe(
+ 'When the quarantine lifts itself, as an ISO 8601 datetime. Through MCP an omitted or later expiry becomes 30 days from now; anywhere else omitting it means no expiry.'
+ ),
source_run_id: zod
.uuid()
.nullish()
@@ -64,7 +70,6 @@ export const VisualReviewReposQuarantineCreateBody = /* @__PURE__ */ zod.object(
.describe(
'Post the quarantine to the Slack channel of the team that owns the story, naming the user who quarantined it. Only Storybook snapshots have an owning team. Best effort: skipped when the story has no owning team or the project has no Slack integration.'
),
- expires_at: zod.iso.datetime({ offset: true }).nullish(),
})
/**
diff --git a/products/visual_review/mcp/tools.yaml b/products/visual_review/mcp/tools.yaml
index 0134668bdb71..11f0d4672405 100644
--- a/products/visual_review/mcp/tools.yaml
+++ b/products/visual_review/mcp/tools.yaml
@@ -33,17 +33,12 @@ tools:
idempotent: true
title: Visual review flakiness overview
description: >
- Snapshots in a repo whose rendering cannot be trusted: those carrying a live tolerated variant against their
- current baseline, those that failed the gate on a recent default-branch run, and those under an active
- quarantine. Recency changes an entry's state rather than excluding it, so a snapshot that has gone quiet is
- still listed. This is the triage view, and it is far smaller than the baselines universe, so start here when
- asked why a suite is unreliable, which snapshots to quarantine, or which quarantines to lift. Each entry
- carries `hard_rate`, the share of recent default-branch runs that failed the gate, and `soft_rate`, the
- share a toleration absorbed, plus `headroom`, the fraction of the diff threshold its worst absorbed run
- leaves free. Every `totals` field except `listed` covers the whole population even when the entry list is
- capped; `listed` counts the entries actually returned, so it stops at the cap. Takes no filter parameters:
- filter the returned entries yourself, and pass `fields` to keep the response small when you only need a few
- of them.
+ Snapshots in a repo whose rendering is untrusted: a live tolerated variant, a gate failure on a recent
+ default-branch run, or an active quarantine. Start here to decide what to quarantine or lift. Each entry has
+ `flakiness_state`, `hard_rate` (share of recent default-branch runs that failed the gate), `soft_rate`
+ (share a toleration absorbed), `window_runs`, `headroom` and `needs_decision`. `totals` covers every
+ snapshot; `listed` stops at the cap. Takes no filters: filter the entries yourself, and pass `fields` to
+ trim the response.
param_overrides:
id:
description: The repo's UUID, from `visual-review-repos-list`.
@@ -91,9 +86,8 @@ tools:
list: true
title: List visual review repos
description: >
- List visual review repos (test suites) for the current project. A repo typically maps to a GitHub repository
- and owns the baselines, runs, and tolerated hashes for that codebase. Returns repo id, external id, full
- name, baseline file paths, and pr-comment configuration.
+ List the visual review repos in the project. A repo maps to one GitHub repository and owns its baselines,
+ runs and tolerated hashes.
feature_flag: visual-review
visual-review-repos-partial-update:
operation: visual_review_repos_partial_update
@@ -106,14 +100,11 @@ tools:
idempotent: true
title: Update visual review repo settings
description: >
- Change one repo's settings. `enable_pr_comments` controls whether a run that finds visual changes posts a
- pull request comment asking for a review. `debt_digest_enabled` controls whether the debt digest runs for
- the repo, which posts expiring quarantines and piled-up variants to the Slack channels of the teams that own
- the snapshots; it is off until somebody turns it on, and it posts every Monday morning.
- `baseline_file_paths` maps each run type to the file holding its committed baseline hashes, for example
- `{"storybook": ".storybook/snapshots.yml"}`, and finalize reads and commits the path named there; a
- `default` key covers every run type that has no entry of its own. Every field is optional, and a field you
- leave out keeps its current value.
+ Change a repo's settings; a field you leave out keeps its value. `enable_pr_comments` posts a review request
+ on pull requests with visual changes. `debt_digest_enabled` posts a Monday Slack digest of expiring
+ quarantines and piled-up variants to the owning teams. `baseline_file_paths` maps a run type to its
+ committed baseline file, for example `{"storybook": ".storybook/snapshots.yml"}`, with `default` as the
+ fallback; finalize commits to that path.
param_overrides:
id:
description: The repo's UUID, from `visual-review-repos-list`.
@@ -122,10 +113,54 @@ tools:
feature_flag: visual-review
visual-review-repos-quarantine-create:
operation: visual_review_repos_quarantine_create
- enabled: false
+ enabled: true
+ scopes:
+ - visual_review:write
+ annotations:
+ readOnly: false
+ destructive: false
+ idempotent: false
+ title: Quarantine a visual review snapshot
+ description: >
+ Stop one identifier of one run type from failing any run in the repo until the quarantine expires. It is
+ still captured and diffed. Use it only for a story that flakes on the default branch (`unstable` in
+ `visual-review-repos-flakiness-retrieve`, `hard_count` of 5 or more, and a failure in the last 7 days),
+ never for a `broken` entry (its baseline needs a fix) or a diff your own change caused. Pass the failing run
+ as `source_run_id` and a `reason` with the evidence. An omitted or later `expires_at` becomes 30 days. A
+ repeat call replaces the quarantine. Then call `visual-review-runs-recompute-create` to update the open pull
+ request's gate.
+ param_overrides:
+ id:
+ description: |
+ The repo's UUID, the run's `repo_id`.
+ aliases:
+ - repo_id
+ run_type:
+ description: |
+ The failing run's `run_type`, `storybook` or `playwright`. The quarantine covers only this run type.
+ feature_flag: visual-review
visual-review-repos-quarantine-expire-create:
operation: visual_review_repos_quarantine_expire_create
- enabled: false
+ enabled: true
+ scopes:
+ - visual_review:write
+ annotations:
+ readOnly: false
+ destructive: false
+ idempotent: true
+ title: Lift a visual review quarantine
+ description: >
+ Lift every active quarantine on one identifier and run type, so the snapshot gates runs again. Lift one
+ after the fix that stabilizes the story merges, or when its flakiness entry has `needs_decision`. If the
+ story still flakes, the next pull request that renders it fails.
+ param_overrides:
+ id:
+ description: The repo's UUID, from `visual-review-repos-list`.
+ aliases:
+ - repo_id
+ run_type:
+ description: The run type of the quarantine to lift (`storybook` or `playwright`).
+ feature_flag: visual-review
visual-review-repos-quarantine-list:
operation: visual_review_repos_quarantine_list
enabled: true
@@ -138,11 +173,8 @@ tools:
list: true
title: List quarantined snapshots
description: >
- Quarantined snapshot identifiers in a repo, with the reason, who opened it, when, when it expires, and the
- run whose failure prompted it. A quarantined snapshot is still captured, classified and diffed; it is only
- excluded when a run decides pass or fail. Returns active entries by default. Pass `identifier` for that one
- identifier's full history including expired entries, which is how you tell a long-standing mute from one
- somebody opened this morning. Pass `run_type` to narrow to one kind of run.
+ Quarantines in a repo, with reason, author, expiry and the run that prompted each. Returns active entries by
+ default. Pass `identifier` for that identifier's full history, or `run_type` to narrow.
param_overrides:
id:
description: The repo's UUID, from `visual-review-repos-list`.
@@ -165,9 +197,8 @@ tools:
destructive: false
idempotent: true
title: Get visual review repo
- description: >
- Get a visual review repo by id. Returns baseline file paths keyed by run_type (e.g. storybook → baseline
- YAML path in the repo), pr-comment setting, and repo metadata.
+ description: |
+ Get one repo: baseline file paths per run type, the PR-comment setting and repo metadata.
feature_flag: visual-review
visual-review-repos-runs-counts-retrieve:
operation: visual_review_repos_runs_counts_retrieve
@@ -179,9 +210,8 @@ tools:
destructive: false
idempotent: true
title: Visual review run counts for a repo
- description: >
- Review state counts (`needs_review`, `clean`, `processing`, `stale`) for one repo's runs. The repo-scoped
- counterpart to `visual-review-runs-counts-retrieve`, which spans every repo in the project.
+ description: |
+ Review state counts (`needs_review`, `clean`, `processing`, `stale`) for one repo's runs.
param_overrides:
repo_id:
description: The repo's UUID, from `visual-review-repos-list`.
@@ -201,10 +231,9 @@ tools:
list: true
title: List runs in a visual review repo
description: >
- Runs belonging to one repo. Prefer this over `visual-review-runs-list` whenever you know the repo: that tool
- spans every repo in the project and cannot be narrowed to one, so its results mix repos together. Filter by
- `review_state` to triage, or `search` for a free-text match over branch, commit SHA, run type and PR number.
- For a specific PR, commit or branch, use `visual-review-runs-list`, which takes those filters.
+ Runs in one repo. Prefer it over `visual-review-runs-list`, which mixes every repo. Filter by
+ `review_state`, or `search` over branch, commit SHA, run type and PR number. For an exact PR, commit or
+ branch filter, use `visual-review-runs-list`.
param_overrides:
repo_id:
description: The repo's UUID, from `visual-review-repos-list`.
@@ -228,15 +257,11 @@ tools:
idempotent: true
title: Visual review toleration pile-ups
description: >
- Snapshots in a repo that keep getting tolerated, counted across baselines, most manual tolerations first. A
- toleration accepts one exact rendering, so a snapshot that keeps needing them renders differently from run
- to run, and the fix belongs in the story (a pinned date, a disabled animation, a wait for a loader). Called
- with only the repo `id` it applies the weekly debt digest's rule and keeps quarantined snapshots, marked
- with `is_quarantined`. Tune it with `min_tolerations`, `min_automatic_tolerations`, `window_days`,
- `include_quarantined`, `run_type` and `limit`; the response echoes the rule it applied. The list is short
- and returns quickly, so use it instead of the flakiness overview to find flaky stories worth fixing, then
- read one snapshot's history with `visual-review-runs-snapshot-history-list` or its tolerations with
- `visual-review-runs-tolerated-hashes-list`.
+ Snapshots that keep getting tolerated, most manual tolerations first. Such a story renders differently from
+ run to run, and the fix belongs in the story (a pinned date, a disabled animation, a wait for a loader).
+ With only `id`, it applies the weekly debt digest rule. Tune it with `min_tolerations`,
+ `min_automatic_tolerations`, `window_days`, `include_quarantined`, `run_type` and `limit`. Faster than the
+ flakiness overview for finding stories to fix.
param_overrides:
id:
description: The repo's UUID, from `visual-review-repos-list`.
@@ -257,13 +282,10 @@ tools:
idempotent: true
title: Mark visual review snapshots reviewed
description: >
- Mark specific snapshots as reviewed (approved) in a run. Pass a `snapshots` list, each entry being
- `{identifier, new_hash}` — `new_hash` is the `content_hash` of the snapshot's `current_artifact`. This only
- records the review in the database (the per-snapshot "Accept change" action) — it does NOT update the
- baseline, push a commit, or change the GitHub gate, and it can be re-run safely. To actually ship the visual
- change (commit the baseline + green the gate), use `visual-review-runs-finalize-create`. Approving a
- quarantined `new` snapshot here makes finalize commit its baseline entry while the quarantine stays in place
- — the way to give a quarantined story an entry without failing other runs.
+ Record snapshots as approved in a run, in the database only. Pass `snapshots: [{identifier, new_hash}]`,
+ where `new_hash` is the snapshot's `current_artifact.content_hash`. It does not commit the baseline or
+ change the gate; `visual-review-runs-finalize-create` ships it. An approved quarantined `new` snapshot gets
+ its baseline entry at finalize while the quarantine stays.
feature_flag: visual-review
visual-review-runs-complete-create:
operation: visual_review_runs_complete_create
@@ -278,9 +300,8 @@ tools:
destructive: false
idempotent: true
title: Visual review run counts
- description: >
- Return review state counts across all runs for the current project: `needs_review`, `clean`, `processing`,
- `stale`. Useful as a single call to show reviewer workload before drilling into the list.
+ description: |
+ Review state counts (`needs_review`, `clean`, `processing`, `stale`) across every run in the project.
feature_flag: visual-review
visual-review-runs-create:
operation: visual_review_runs_create
@@ -296,19 +317,12 @@ tools:
idempotent: false
title: Finalize a visual review run
description: >
- Finalize a fully-reviewed run: commit the approved baseline to the PR branch and green the GitHub
- visual-review check. Commits exactly the snapshots approved in the DB (tolerated snapshots keep their
- baseline and are never overwritten) and is all-or-nothing — it only succeeds once every changed/new snapshot
- is resolved (approved, tolerated, or quarantined), otherwise it returns the unresolved list. With
- `approve_all: true` every still-pending changed/new snapshot is approved first; quarantined snapshots are
- skipped by that, but a quarantined `new` snapshot approved by identifier through
- `visual-review-runs-approve-create` is committed, so a quarantined story can get its baseline entry while
- the quarantine stays in place. When a baseline commit is pushed its SHA comes back on the run's
- `metadata.baseline_commit_sha`; it's absent when nothing needed committing (all changes resolved by
- toleration/quarantine — the gate still greens) or when the commit was skipped (no PR, or a `409
- sha_mismatch` from newer PR commits, which leaves the gate red — re-run CI and finalize again). STOP: never
- finalize on your own initiative. Require explicit, per-run human confirmation first — finalizing ships the
- visual change and rewrites the committed baseline.
+ Ship a fully reviewed run: commit the approved snapshots to the pull request's baseline file and pass the
+ gate. All or nothing: it returns the unresolved list until every changed or new snapshot is approved,
+ tolerated or quarantined. `approve_all: true` approves the pending ones first, but not quarantined ones.
+ With nothing to commit, it posts a green status, and the required check follows when its job re-runs. On
+ `409 stale_run`, finalize the newest run; on `409 sha_mismatch`, re-run CI and finalize the new run. STOP:
+ never finalize without an explicit human yes for this run.
feature_flag: visual-review
visual-review-runs-list:
operation: visual_review_runs_list
@@ -323,15 +337,26 @@ tools:
list: true
title: List visual review runs
description: >
- List visual review runs for the current project. Each run represents a single CI execution that captured
- screenshots for a commit. Filter by `review_state` (e.g. `needs_review`, `clean`, `processing`, `stale`) to
- triage workload, or by `pr_number` / `commit_sha` / `branch` to find the specific run(s) blocking a PR.
- Returns status, review decision, commit sha, branch, pr number, and a summary of changed / new / removed /
- unchanged snapshots.
+ Runs in the project; each is one CI capture for one commit. Filter by `review_state`, or by `pr_number`,
+ `commit_sha` or `branch` to find the run that blocks a pull request. Returns status, review decision,
+ commit, branch, PR and a change summary.
feature_flag: visual-review
visual-review-runs-recompute-create:
operation: visual_review_runs_recompute_create
- enabled: false
+ enabled: true
+ scopes:
+ - visual_review:write
+ annotations:
+ readOnly: false
+ destructive: false
+ idempotent: false
+ title: Re-check a visual review run's gate
+ description: >
+ Re-check the gate of a completed, unfinalized run after a quarantine or toleration: recount unresolved
+ snapshots, post the commit status, and re-run the CI job recorded on the run, so the required check reads
+ the new verdict. Call it on the pull request's latest non-stale run. Approved changes keep the gate red
+ until finalize commits them. `ci_rerun_triggered` and `ci_rerun_error` report the re-run.
+ feature_flag: visual-review
visual-review-runs-retrieve:
operation: visual_review_runs_retrieve
enabled: true
@@ -344,9 +369,8 @@ tools:
enrich_url: runs/{id}
title: Get visual review run
description: >
- Get a visual review run by id. Returns run status, review decision, commit/branch/pr context, a summary
- (total, changed, new, removed, unchanged, tolerated-matched snapshot counts), and staleness info if a newer
- run supersedes this one. Use `visual-review-runs-snapshots-list` for per-snapshot diff details.
+ Get one run: status, review decision, commit, branch, PR, change summary, and the newer run that supersedes
+ it, if any. Per-snapshot results come from `visual-review-runs-snapshots-list`.
feature_flag: visual-review
visual-review-runs-snapshot-history-list:
operation: visual_review_runs_snapshot_history_list
@@ -359,24 +383,17 @@ tools:
idempotent: true
title: Snapshot change history
description: >
- List recent change history for one snapshot across previous runs in the same repo. Useful for diagnosing
- flaky snapshots — if the same identifier flips between changed and clean across runs, it is a candidate for
- tolerated hashes or quarantine. Both parameters are required, and one snapshot from
- `visual-review-runs-snapshots-list` gives you both: pass its `run_id` as `id`, and its `identifier` as
- `identifier`. Passing the snapshot's own `id` as `id` does not work, and neither parameter can be left out.
+ One snapshot's baseline changes on the default branch, newest first. Pass a snapshot's `run_id` as `id` and
+ its `identifier`; the snapshot's own `id` does not work.
param_overrides:
id:
- description: >
- UUID of the visual review run to look the snapshot up from — a run id, not the `id` of a snapshot
- inside the run. Use the snapshot's `run_id`, or a run id from `visual-review-runs-list`. Required,
- and `identifier` is required alongside it.
+ description: |
+ A run UUID, such as the snapshot's `run_id`. Not a snapshot `id`.
aliases:
- run_id
identifier:
- description: >
- Identifier of the snapshot to trace, for example a Storybook story id plus theme. Copy the
- `identifier` field of a snapshot in the run — it is a name, not a UUID. Required in addition to
- `id`; without it the call is rejected rather than returning history for the whole run.
+ description: |
+ The snapshot's `identifier`, a name such as a story id plus theme. Required.
feature_flag: visual-review
visual-review-runs-snapshots-list:
operation: visual_review_runs_snapshots_list
@@ -390,17 +407,12 @@ tools:
list: true
title: List run snapshots
description: >
- List the snapshots captured in a run with their diff results. Each snapshot carries an `identifier` (e.g.
- Storybook story id + theme), a `result` (`unchanged`, `changed`, `new`, `removed`), an optional
- `classification_reason` (`tolerated_hash`, `below_threshold`, `exact`), diff percentage / pixel count, and
- `review_state` (`pending`, `approved`). Currently-quarantined snapshots are EXCLUDED by default — they are
- known-flaky noise, not changes to review — and reported only as a `quarantined_count` on the response; pass
- `include_quarantined=true` to fetch them too. Pass `exclude_unchanged=true` to list only the changed, new
- and removed snapshots; a large run holds thousands of unchanged ones. Pass `snapshot_id` to fetch one
- snapshot by its `id`. Renders an interactive diff viewer with baseline / current / diff images and approve /
- tolerate actions. Paginated — pass a `limit` (e.g. 50) when a run might have many snapshots (a broken run
- can produce 3000+ pairs); the diff viewer caps the visible list at 100 and prioritises actionable results
- regardless.
+ Snapshots in a run with their diff results: `identifier`, `result` (`unchanged`, `changed`, `new`,
+ `removed`), `classification_reason`, diff percentage and pixels, `review_state`, and signed baseline and
+ current image URLs. Quarantined snapshots are left out and counted in `quarantined_count`; pass
+ `include_quarantined=true` to get them. Pass `exclude_unchanged=true` to list only the changed, new and
+ removed snapshots; a large run holds thousands of unchanged ones. Pass `snapshot_id` to fetch one snapshot
+ by its `id`. Pass a `limit`, such as 50. Renders a diff viewer.
ui_app: visual-review-snapshots
feature_flag: visual-review
visual-review-runs-tolerate-create:
@@ -413,13 +425,13 @@ tools:
destructive: false
idempotent: true
title: Tolerate visual review snapshot
- description:
- Mark a single changed snapshot as a known tolerated alternate. The snapshot's current hash is recorded
- alongside the existing baseline so future runs producing the same alternate are not flagged as changes —
- useful for benign rendering variants (anti-aliasing noise, blinking cursors, etc.). Pass `snapshot_id` — the
- UUID of the snapshot in this run. Does not change the baseline. To accept the change instead, use
- `visual-review-runs-approve-create` to record the review, then `visual-review-runs-finalize-create` to
- actually commit the new baseline.
+ description: >
+ Accept one changed snapshot's current rendering as an alternative to its baseline, in every future run. Only
+ for named render noise over the threshold (anti-aliasing, font hinting, a cursor) at the same size, with
+ `change_kind: pixel`, so check the images first. It cannot be undone through the API. Never use it to pass a
+ gate: a story that renders differently from run to run gets `visual-review-repos-quarantine-create`, and an
+ intended change gets approved and finalized. Pass the snapshot's UUID as `snapshot_id`, then call
+ `visual-review-runs-recompute-create`.
feature_flag: visual-review
visual-review-runs-tolerated-hashes-list:
operation: visual_review_runs_tolerated_hashes_list
@@ -432,22 +444,15 @@ tools:
idempotent: true
title: List tolerated hashes
description: >
- List known tolerated alternate hashes for one snapshot in the run's repo. Tolerated hashes catalog
- acceptable rendering variants (e.g. anti-aliasing noise) so future runs don't flag them as changes. This
- covers a single snapshot, not the whole run or repo. Both parameters are required, and one snapshot from
- `visual-review-runs-snapshots-list` gives you both: pass its `run_id` as `id`, and its `identifier` as
+ Tolerated alternate hashes for one snapshot in the run's repo. Pass a snapshot's `run_id` as `id` and its
`identifier`.
param_overrides:
id:
- description: >
- UUID of the visual review run whose repo holds the tolerated hashes — a run id, not the `id` of a
- snapshot inside the run. Use the snapshot's `run_id`, or a run id from `visual-review-runs-list`.
- Required, and `identifier` is required alongside it.
+ description: |
+ A run UUID, such as the snapshot's `run_id`. Not a snapshot `id`.
aliases:
- run_id
identifier:
- description: >
- Identifier of the snapshot whose tolerated hashes you want, for example a Storybook story id plus
- theme. Copy the `identifier` field of a snapshot in the run — it is a name, not a UUID. Required in
- addition to `id`; there is no way to list every tolerated hash in the repo from this tool.
+ description: |
+ The snapshot's `identifier`, a name such as a story id plus theme. Required.
feature_flag: visual-review
diff --git a/products/visual_review/skills/triaging-visual-review-runs/SKILL.md b/products/visual_review/skills/triaging-visual-review-runs/SKILL.md
index 5005ff593c4f..7a9596f0213d 100644
--- a/products/visual_review/skills/triaging-visual-review-runs/SKILL.md
+++ b/products/visual_review/skills/triaging-visual-review-runs/SKILL.md
@@ -3,8 +3,8 @@ name: triaging-visual-review-runs
description: >
Inspects PostHog Visual Review (VR) runs that gate PR merges with screenshot regression checks.
Use when the user mentions "visual review", "VR", "snapshot diff", "screenshot test", "storybook regression",
- "playwright snapshot", asks why a PR is blocked or what changed visually, wants to triage the VR backlog,
- decide whether a snapshot diff is real vs flaky, or check whether a story has been changing across runs.
+ "playwright snapshot", "quarantine", asks why a PR is blocked or what changed visually, wants to triage the VR backlog,
+ decide whether a snapshot diff is real vs flaky, quarantine or lift a flaky story, or check whether a story has been changing across runs.
Also invoke when a PR has a failing `visual-review` status check, when a PR comment mentions "Visual review",
when a PR from a fork fails `Visual regression tests pass`, or when the user is on a branch with an open VR run.
---
@@ -12,17 +12,40 @@ description: >
# Triaging visual review runs
Visual Review is PostHog's screenshot-regression product: CI captures storybook + playwright screenshots,
-diffs them against committed baseline hashes, and gates the PR until a human approves the visible changes.
-A PR with visual changes carries a `visual-review` GitHub status check that stays red until each diffed
-snapshot is approved or tolerated in the [VR UI](https://us.posthog.com/project/2/visual_review).
+diffs them against committed baseline hashes, and gates the PR until every changed snapshot is resolved.
+A PR with visual changes carries a `visual-review` GitHub status check and a required "Visual regression tests pass" job check.
+Both stay red until each diffed snapshot is approved and finalized, tolerated, or quarantined, and the job re-runs:
+finalize does that for approvals, `recompute-create` for tolerations and quarantines. The [VR UI](https://us.posthog.com/project/2/visual_review) offers the same actions.
A PR from a fork is the exception: it gets no Visual Review run at all.
See [Fork PRs have no Visual Review run](#fork-prs-have-no-visual-review-run).
This skill teaches an agent how to answer the questions a human reviewer would actually ask, by chaining
the VR MCP tools — instead of reaching for `gh pr view` and tab-hopping to the VR web UI. The read tools
-cover status / scope / history / triage. Two are reversible DB-only triage marks (`approve-create`,
-`tolerate-create`); one ships the change (`finalize-create`) — it commits the baseline and greens the gate,
-and only that one needs explicit per-run human confirmation.
+cover status / scope / history / triage. An agent may resolve flakes on its own, with a quarantine or, rarely, a toleration.
+It may not ship a visual change on its own: `finalize-create` commits the baseline and needs explicit per-run human confirmation.
+
+## Decide first
+
+Gather the evidence with [Is the diff real or unrelated?](#is-the-diff-real-or-unrelated) and the [flake check](#flake-check-has-this-story-been-changing),
+then take the first row that matches each changed snapshot.
+
+| Evidence | Action | Human yes needed |
+| ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | ---------------------------------- |
+| PR comes from a fork (`isCrossRepository: true`) | Report only. See [Fork PRs](#fork-prs-have-no-visual-review-run) | No VR writes possible |
+| The diff comes from your change and is intended | `approve-create`, then ask for finalize | Yes, for each run, before finalize |
+| The diff comes from your change and is not intended | Fix the code and push. No VR write | No |
+| Story outside your change, flakiness entry `unstable`, `hard_count` ≥ 5, `last_flaked_at` in the last 7 days | `quarantine-create`, then `recompute-create`. Report it | No |
+| Story outside your change, flakiness entry `broken` | Do not quarantine. Its baseline on the default branch is wrong. Report it and recommend a re-baseline | Yes |
+| Story outside your change, quiet history, same width and height, `change_kind: pixel`, a noise source you can name | `tolerate-create`, then `recompute-create` | No |
+| Anything else: `unstable` with fewer failures, a real-looking change you did not make, unsure | Stop and report what you saw | Yes |
+
+Each theme is its own identifier.
+Judge the `--light` and `--dark` snapshots of a story separately, and quarantine only the ones that match.
+
+Expect tolerations to be rare.
+The diff already absorbs most real render noise below the threshold, and a small diff percentage is often a real structural change.
+A toleration accepts one exact hash forever and cannot be undone through the API, so it is never a way past a gate.
+A story that renders differently from run to run and meets the quarantine row above gets a quarantine, which also protects every other developer. With less evidence, report it instead.
## When this skill applies
@@ -93,24 +116,33 @@ See [Pull requests from forks](../../../../docs/published/handbook/engineering/f
Read tools (safe to call freely):
-| Tool | Purpose |
-| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `posthog:visual-review-runs-list` | List runs, filter by `pr_number` / `commit_sha` / `branch` / `review_state`. Start here. |
-| `posthog:visual-review-runs-retrieve` | Full detail for a single run (status, summary counts, supersession). Carries the `repo_id` the repo tools need. |
-| `posthog:visual-review-runs-snapshots-list` | Per-snapshot results inside a run: identifier, `result`, diff %, classification, baseline + current artifact URLs. Quarantined snapshots are excluded by default (see `quarantined_count`); pass `include_quarantined=true` to see them. Pass `exclude_unchanged=true` to skip the thousands of unchanged rows a large run holds. |
-| `posthog:visual-review-repos-flakiness-retrieve` | Repo snapshots whose rendering is untrusted, with a `flakiness_state` and flake rates for each. The flake check starts here. |
-| `posthog:visual-review-runs-snapshot-history-list` | One story's baseline timeline on the default branch: one row per baseline change. Takes `{ id: <run_id>, identifier: <identifier> }`. |
-| `posthog:visual-review-runs-counts-retrieve` | Aggregate counts for queue triage (how many runs in `needs_review`, etc.). |
-| `posthog:visual-review-runs-tolerated-hashes-list` | Hashes the team has explicitly accepted as "known flake / acceptable variation". Takes the same two parameters as the history tool. |
-| `posthog:visual-review-repos-list` | Repos (one per GitHub repo) — usually only one matters; useful for filtering. |
-| `posthog:visual-review-repos-retrieve` | Repo metadata: baseline file paths, PR-comment configuration. |
-
-Triage tools (reversible, DB-only — they record a review decision but do NOT change the baseline or the gate):
-
-| Tool | Purpose |
-| -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
-| `posthog:visual-review-runs-approve-create` | Mark `changed` / `new` snapshots reviewed (approved) in the DB. Does NOT commit or green the gate — ship via finalize. |
-| `posthog:visual-review-runs-tolerate-create` | Mark a single changed snapshot as a known tolerated alternate. Does NOT change the baseline — use for benign variants. |
+| Tool | Purpose |
+| --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `posthog:visual-review-runs-list` | List runs, filter by `pr_number` / `commit_sha` / `branch` / `review_state`. Start here. |
+| `posthog:visual-review-runs-retrieve` | Full detail for a single run (status, summary counts, supersession). Carries the `repo_id` the repo tools need. |
+| `posthog:visual-review-runs-snapshots-list` | Per-snapshot results inside a run: identifier, `result`, diff %, classification, baseline + current artifact URLs. Quarantined snapshots are excluded by default (see `quarantined_count`); pass `include_quarantined=true` to see them. Pass `exclude_unchanged=true` to skip the thousands of unchanged rows a large run holds. |
+| `posthog:visual-review-repos-flakiness-retrieve` | Repo snapshots whose rendering is untrusted, with a `flakiness_state` and flake rates for each. The flake check starts here. |
+| `posthog:visual-review-runs-snapshot-history-list` | One story's baseline timeline on the default branch: one row per baseline change. Takes `{ id: <run_id>, identifier: <identifier> }`. |
+| `posthog:visual-review-runs-counts-retrieve` | Aggregate counts for queue triage (how many runs in `needs_review`, etc.). |
+| `posthog:visual-review-runs-tolerated-hashes-list` | Hashes the team has explicitly accepted as "known flake / acceptable variation". Takes the same two parameters as the history tool. |
+| `posthog:visual-review-repos-list` | Repos (one per GitHub repo) — usually only one matters; useful for filtering. |
+| `posthog:visual-review-repos-retrieve` | Repo metadata: baseline file paths, PR-comment configuration. |
+| `posthog:visual-review-repos-quarantine-list` | Active quarantines with reason, author, expiry and source run. Pass `identifier` for its full history. |
+| `posthog:visual-review-repos-toleration-pileups-retrieve` | Stories that keep getting tolerated: candidates for a fix in the story. |
+
+Triage tools (they do NOT change the baseline; the gate changes only after `recompute-create`):
+
+| Tool | Purpose |
+| ------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `posthog:visual-review-runs-approve-create` | Mark `changed` / `new` snapshots reviewed (approved) in the DB. Does NOT commit or green the gate — ship via finalize. |
+| `posthog:visual-review-runs-tolerate-create` | Accept one changed snapshot's current hash as an alternate in every future run. Render noise only, see [Decide first](#decide-first). Cannot be undone through the API. |
+| `posthog:visual-review-repos-quarantine-create` | Remove one identifier of one run type from pass or fail on every PR until it expires (30 days if `expires_at` is omitted). Undo with `quarantine-expire-create`. |
+| `posthog:visual-review-repos-quarantine-expire-create` | Lift a quarantine, so the story gates runs again. |
+| `posthog:visual-review-runs-recompute-create` | Recount a completed, unfinalized run, post the `visual-review` status, and re-run the CI job recorded on the run, so the required check reads the new verdict. |
+
+Branch protection requires the `Visual regression tests pass` and `Playwright tests pass` job checks, not the `visual-review` status.
+So a quarantine or toleration unblocks the PR only after `recompute-create` re-runs the CI job recorded on the run.
+Approved changes keep the gate red until finalize commits them, so recompute never ships an approval.
Ship tool (irreversible, outward-facing — requires explicit per-run human confirmation; see [the gate](#the-finalize-gate)):
@@ -123,6 +155,14 @@ Mark-reviewed call shape (`approve-create`):
- `id` (required) — the run UUID. It's the route parameter, so the call fails without it.
- `snapshots: [{identifier, new_hash}]` — `new_hash` is the `content_hash` of each snapshot's `current_artifact`. This only records the review in the DB; nothing is committed and the gate stays red until you finalize.
+Quarantine call shape (`quarantine-create`):
+
+- `id` — the repo UUID (the run's `repo_id`), and `run_type` — the failing run's `run_type`. Both are route parameters.
+- `identifier`, and a `reason` with the evidence, for example "unstable on master: 7 failed default-branch runs in 7 days, chart animation timing; unrelated to PR 1234".
+- `source_run_id` — the run that failed. `expires_at` — omit it for 30 days, or set an earlier date, never a later one.
+- `notify_owners: true` — posts the quarantine to the owning team's Slack channel, so the people who must fix the story hear about it.
+- Then call `recompute-create { id: <run_id> }` on the PR's newest non-stale run of the same `run_type`, and check `ci_rerun_triggered`.
+
Toleration call shape — both fields are required:
- `id` (required) — the run UUID. It's the route parameter, so the call fails without it.
@@ -133,7 +173,7 @@ Finalize call shape (`finalize-create`) — the all-or-nothing ship action:
- `id` (required) — the run UUID.
- `approve_all: true` — approve every still-pending `changed`/`new` snapshot before finalizing (tolerated ones are left alone). Use when you've verified every remaining diff is intended.
- Omit `approve_all` (default false) to finalize a run you've already reviewed snapshot-by-snapshot. Finalize is all-or-nothing: it fails with `409 not_fully_resolved` (and lists what's left) unless every changed/new snapshot is approved, tolerated, or quarantined.
-- It commits exactly the snapshots approved in the DB — tolerated snapshots keep their baseline and are never overwritten. When a baseline commit is pushed, its SHA comes back on the run's `metadata.baseline_commit_sha`. It's absent when nothing needed committing (everything resolved by toleration/quarantine — the gate still greens) or when the commit was skipped: no PR, or a `409 sha_mismatch` because the PR has newer commits (that one leaves the gate red — re-run CI on the latest commit and finalize again).
+- It commits exactly the snapshots approved in the DB — tolerated snapshots keep their baseline and are never overwritten. When a baseline commit is pushed, its SHA comes back on the run's `metadata.baseline_commit_sha`. It's absent when nothing needed committing (everything resolved by toleration/quarantine — finalize posts a green status, and the required check turns green when its job re-runs) or when the commit was skipped: no PR, or a `409 sha_mismatch` because the PR has newer commits (that one leaves the gate red — re-run CI on the latest commit and finalize again).
If finalize fails with `409 stale_run`, the run has been superseded — `visual-review-runs-list { pr_number }` and finalize the newest one. A successful finalize often kicks off a fresh CI run, which is normal.
@@ -151,8 +191,8 @@ Before _any_ `finalize-create` call, all of these must hold:
investigate and recommend — NOT to finalize. When the task implies finalizing but the human hasn't said it for
this specific run, ask.
-`approve-create` and `tolerate-create` are reversible triage and don't need this gate — but they don't ship anything
-either. The moment you're about to `finalize-create` and can't point to a specific human "yes" for this run, stop and ask.
+`approve-create`, `tolerate-create`, `quarantine-create` and `recompute-create` don't need this gate when [Decide first](#decide-first) allows them.
+The moment you're about to `finalize-create` and can't point to a specific human "yes" for this run, stop and ask.
## Vocabulary cheat sheet
@@ -207,13 +247,15 @@ and **the actual rendered images**. The agent should look at the screenshots —
(e.g. 54% diff but the images look near-identical → screenshot framing changed, not the UI).
- Whether the baseline and current have different dimensions (`width` / `height` fields). Mismatched
dimensions usually mean the story rendered to a different viewport or didn't fully render before
- screenshot — a flake signal, not a regression.
+ screenshot — a flake signal, not a regression, and never render noise to tolerate.
+ - `change_kind`: `pixel` for scattered pixel noise, `structural` for a perceptual change. A small diff percentage
+ is often a real structural change.
3. **Flake history** — run the flake check below for any story that looks suspect.
4. **Verdict** — combine all three:
- Scope plausible + visible regression matches the code change → real diff, recommend approval.
- - Scope mismatch + dimensions mismatch + frequent prior changes → flake, recommend tolerating the hash.
+ - Scope mismatch + the story flakes on the default branch → quarantine it, per [Decide first](#decide-first).
- Scope plausible + visible regression looks unintended → push a fix; do not approve.
Always include a one-line description of what you saw in the images — the user uses this to decide whether to
@@ -229,11 +271,14 @@ Once you have a suspect snapshot row from `visual-review-runs-snapshots-list`, a
`run_type` match your snapshot. That entry carries the flake signal:
- `flakiness_state`: `broken`, `unstable`, `at_risk`, `noisy`, or `clean`.
-- `hard_rate`: the share of recent default-branch runs that failed the gate.
+- `hard_rate` and `hard_count`: the share and number of recent default-branch runs that failed the gate.
+ `last_flaked_at`: the latest of them.
- `soft_rate`: the share that a toleration absorbed.
-- `window_runs`: the number of runs behind those two rates.
+- `window_runs`: the repo's default-branch runs behind those rates. It is the same for every entry of a run type and says nothing about the story.
-A story with no entry is quiet. Nothing is tolerated for it, and it did not fail recently.
+A story with no entry is quiet only when the response has `truncated: false`.
+With `truncated: true`, an absent story can be in any state, so absence proves nothing.
+Do not tolerate or quarantine on absence alone: check `visual-review-runs-tolerated-hashes-list` and the snapshot history, or report it.
**Did the baseline move?** Call
`posthog:visual-review-runs-snapshot-history-list { id: <run_id>, identifier: <identifier> }`. It returns one row for
@@ -246,9 +291,11 @@ Both parameters are required. Copy them from the snapshot row: its `run_id` goes
Verdicts:
-- `flakiness_state` is `clean`, or the story has no entry → likely a real regression caused by this PR.
-- `flakiness_state` is `unstable` or `broken`, and `window_runs` is large enough to trust the rate → flaky story;
- recommend tolerating the hash or a quarantine via the UI.
+- `flakiness_state` is `clean`, or the story has no entry in an untruncated list → likely a real regression caused by this PR.
+- `flakiness_state` is `unstable` with `hard_count` ≥ 5 and a recent `last_flaked_at` → flaky story; quarantine it.
+ One failure is enough for `unstable`, and a single failure is often a real change that merged, so trust the count.
+- `flakiness_state` is `broken` → the baseline is wrong, not the story. Do not quarantine; recommend a re-baseline.
+- `at_risk` and `noisy` never fail a run, so they need no action on a PR.
- Recent `removed`, a large-jump dimension change, or a baseline that last moved long ago → baseline likely stale;
recommend re-baselining on master.
@@ -262,6 +309,9 @@ When the user is doing housekeeping rather than asking about a specific PR:
component change" usually means a single underlying root cause to address).
4. Prefer surfacing runs whose `summary.changed > 0` over runs that are only `new` — `new` means no baseline
yet, which is usually trivial to approve; `changed` is the real review work.
+5. Lift stale quarantines: entries in `visual-review-repos-flakiness-retrieve` with `needs_decision: true` stopped failing
+ or expire soon. Lift one with `posthog:visual-review-repos-quarantine-expire-create { id, run_type, identifier }`
+ only when it had no hard failure in the window, or a merged fix removed the cause.
## Output expectations
@@ -273,8 +323,7 @@ For triage / aggregate questions, a short table beats prose. Group by what the u
## What NOT to do
-- Do not approve or tolerate without explicit user confirmation. The verdict is yours to recommend; the
- decision to ship belongs to the user. Once they say "approve those" / "tolerate that", call the tool.
+- Do not tolerate to get past a gate, and do not quarantine a diff your own change caused or a `broken` entry.
- Do not assume the failing GitHub check on a PR is unrelated to VR — if a `visual-review` check is red on
a PR you're working on, that's the trigger to run this skill.
- Do not read an empty run list on a fork PR as a broken or pending run.
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index cf37d5d10c0c..295f10e21e78 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -13869,7 +13869,7 @@
}
},
"visual-review-repos-flakiness-retrieve": {
- "description": "Snapshots in a repo whose rendering cannot be trusted: those carrying a live tolerated variant against their current baseline, those that failed the gate on a recent default-branch run, and those under an active quarantine. Recency changes an entry's state rather than excluding it, so a snapshot that has gone quiet is still listed. This is the triage view, and it is far smaller than the baselines universe, so start here when asked why a suite is unreliable, which snapshots to quarantine, or which quarantines to lift. Each entry carries `hard_rate`, the share of recent default-branch runs that failed the gate, and `soft_rate`, the share a toleration absorbed, plus `headroom`, the fraction of the diff threshold its worst absorbed run leaves free. Every `totals` field except `listed` covers the whole population even when the entry list is capped; `listed` counts the entries actually returned, so it stops at the cap. Takes no filter parameters: filter the returned entries yourself, and pass `fields` to keep the response small when you only need a few of them.",
+ "description": "Snapshots in a repo whose rendering is untrusted: a live tolerated variant, a gate failure on a recent default-branch run, or an active quarantine. Start here to decide what to quarantine or lift. Each entry has `flakiness_state`, `hard_rate` (share of recent default-branch runs that failed the gate), `soft_rate` (share a toleration absorbed), `window_runs`, `headroom` and `needs_decision`. `totals` covers every snapshot; `listed` stops at the cap. Takes no filters: filter the entries yourself, and pass `fields` to trim the response.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Visual review flakiness overview",
@@ -13884,7 +13884,7 @@
"feature_flag": "visual-review"
},
"visual-review-repos-list": {
- "description": "List visual review repos (test suites) for the current project. A repo typically maps to a GitHub repository and owns the baselines, runs, and tolerated hashes for that codebase. Returns repo id, external id, full name, baseline file paths, and pr-comment configuration.",
+ "description": "List the visual review repos in the project. A repo maps to one GitHub repository and owns its baselines, runs and tolerated hashes.",
"category": "Visual review",
"feature": "visual_review",
"summary": "List visual review repos",
@@ -13899,7 +13899,7 @@
"feature_flag": "visual-review"
},
"visual-review-repos-partial-update": {
- "description": "Change one repo's settings. `enable_pr_comments` controls whether a run that finds visual changes posts a pull request comment asking for a review. `debt_digest_enabled` controls whether the debt digest runs for the repo, which posts expiring quarantines and piled-up variants to the Slack channels of the teams that own the snapshots; it is off until somebody turns it on, and it posts every Monday morning. `baseline_file_paths` maps each run type to the file holding its committed baseline hashes, for example `{\"storybook\": \".storybook/snapshots.yml\"}`, and finalize reads and commits the path named there; a `default` key covers every run type that has no entry of its own. Every field is optional, and a field you leave out keeps its current value.",
+ "description": "Change a repo's settings; a field you leave out keeps its value. `enable_pr_comments` posts a review request on pull requests with visual changes. `debt_digest_enabled` posts a Monday Slack digest of expiring quarantines and piled-up variants to the owning teams. `baseline_file_paths` maps a run type to its committed baseline file, for example `{\"storybook\": \".storybook/snapshots.yml\"}`, with `default` as the fallback; finalize commits to that path.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Update visual review repo settings",
@@ -13913,8 +13913,38 @@
},
"feature_flag": "visual-review"
},
+ "visual-review-repos-quarantine-create": {
+ "description": "Stop one identifier of one run type from failing any run in the repo until the quarantine expires. It is still captured and diffed. Use it only for a story that flakes on the default branch (`unstable` in `visual-review-repos-flakiness-retrieve`, `hard_count` of 5 or more, and a failure in the last 7 days), never for a `broken` entry (its baseline needs a fix) or a diff your own change caused. Pass the failing run as `source_run_id` and a `reason` with the evidence. An omitted or later `expires_at` becomes 30 days. A repeat call replaces the quarantine. Then call `visual-review-runs-recompute-create` to update the open pull request's gate.",
+ "category": "Visual review",
+ "feature": "visual_review",
+ "summary": "Quarantine a visual review snapshot",
+ "title": "Quarantine a visual review snapshot",
+ "required_scopes": ["visual_review:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "visual-review"
+ },
+ "visual-review-repos-quarantine-expire-create": {
+ "description": "Lift every active quarantine on one identifier and run type, so the snapshot gates runs again. Lift one after the fix that stabilizes the story merges, or when its flakiness entry has `needs_decision`. If the story still flakes, the next pull request that renders it fails.",
+ "category": "Visual review",
+ "feature": "visual_review",
+ "summary": "Lift a visual review quarantine",
+ "title": "Lift a visual review quarantine",
+ "required_scopes": ["visual_review:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "visual-review"
+ },
"visual-review-repos-quarantine-list": {
- "description": "Quarantined snapshot identifiers in a repo, with the reason, who opened it, when, when it expires, and the run whose failure prompted it. A quarantined snapshot is still captured, classified and diffed; it is only excluded when a run decides pass or fail. Returns active entries by default. Pass `identifier` for that one identifier's full history including expired entries, which is how you tell a long-standing mute from one somebody opened this morning. Pass `run_type` to narrow to one kind of run.",
+ "description": "Quarantines in a repo, with reason, author, expiry and the run that prompted each. Returns active entries by default. Pass `identifier` for that identifier's full history, or `run_type` to narrow.",
"category": "Visual review",
"feature": "visual_review",
"summary": "List quarantined snapshots",
@@ -13929,7 +13959,7 @@
"feature_flag": "visual-review"
},
"visual-review-repos-retrieve": {
- "description": "Get a visual review repo by id. Returns baseline file paths keyed by run_type (e.g. storybook → baseline YAML path in the repo), pr-comment setting, and repo metadata.",
+ "description": "Get one repo: baseline file paths per run type, the PR-comment setting and repo metadata.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Get visual review repo",
@@ -13944,7 +13974,7 @@
"feature_flag": "visual-review"
},
"visual-review-repos-runs-counts-retrieve": {
- "description": "Review state counts (`needs_review`, `clean`, `processing`, `stale`) for one repo's runs. The repo-scoped counterpart to `visual-review-runs-counts-retrieve`, which spans every repo in the project.",
+ "description": "Review state counts (`needs_review`, `clean`, `processing`, `stale`) for one repo's runs.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Visual review run counts for a repo",
@@ -13959,7 +13989,7 @@
"feature_flag": "visual-review"
},
"visual-review-repos-runs-list": {
- "description": "Runs belonging to one repo. Prefer this over `visual-review-runs-list` whenever you know the repo: that tool spans every repo in the project and cannot be narrowed to one, so its results mix repos together. Filter by `review_state` to triage, or `search` for a free-text match over branch, commit SHA, run type and PR number. For a specific PR, commit or branch, use `visual-review-runs-list`, which takes those filters.",
+ "description": "Runs in one repo. Prefer it over `visual-review-runs-list`, which mixes every repo. Filter by `review_state`, or `search` over branch, commit SHA, run type and PR number. For an exact PR, commit or branch filter, use `visual-review-runs-list`.",
"category": "Visual review",
"feature": "visual_review",
"summary": "List runs in a visual review repo",
@@ -13974,7 +14004,7 @@
"feature_flag": "visual-review"
},
"visual-review-repos-toleration-pileups-retrieve": {
- "description": "Snapshots in a repo that keep getting tolerated, counted across baselines, most manual tolerations first. A toleration accepts one exact rendering, so a snapshot that keeps needing them renders differently from run to run, and the fix belongs in the story (a pinned date, a disabled animation, a wait for a loader). Called with only the repo `id` it applies the weekly debt digest's rule and keeps quarantined snapshots, marked with `is_quarantined`. Tune it with `min_tolerations`, `min_automatic_tolerations`, `window_days`, `include_quarantined`, `run_type` and `limit`; the response echoes the rule it applied. The list is short and returns quickly, so use it instead of the flakiness overview to find flaky stories worth fixing, then read one snapshot's history with `visual-review-runs-snapshot-history-list` or its tolerations with `visual-review-runs-tolerated-hashes-list`.",
+ "description": "Snapshots that keep getting tolerated, most manual tolerations first. Such a story renders differently from run to run, and the fix belongs in the story (a pinned date, a disabled animation, a wait for a loader). With only `id`, it applies the weekly debt digest rule. Tune it with `min_tolerations`, `min_automatic_tolerations`, `window_days`, `include_quarantined`, `run_type` and `limit`. Faster than the flakiness overview for finding stories to fix.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Visual review toleration pile-ups",
@@ -13989,7 +14019,7 @@
"feature_flag": "visual-review"
},
"visual-review-runs-approve-create": {
- "description": "Mark specific snapshots as reviewed (approved) in a run. Pass a `snapshots` list, each entry being `{identifier, new_hash}` — `new_hash` is the `content_hash` of the snapshot's `current_artifact`. This only records the review in the database (the per-snapshot \"Accept change\" action) — it does NOT update the baseline, push a commit, or change the GitHub gate, and it can be re-run safely. To actually ship the visual change (commit the baseline + green the gate), use `visual-review-runs-finalize-create`. Approving a quarantined `new` snapshot here makes finalize commit its baseline entry while the quarantine stays in place — the way to give a quarantined story an entry without failing other runs.",
+ "description": "Record snapshots as approved in a run, in the database only. Pass `snapshots: [{identifier, new_hash}]`, where `new_hash` is the snapshot's `current_artifact.content_hash`. It does not commit the baseline or change the gate; `visual-review-runs-finalize-create` ships it. An approved quarantined `new` snapshot gets its baseline entry at finalize while the quarantine stays.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Mark visual review snapshots reviewed",
@@ -14004,7 +14034,7 @@
"feature_flag": "visual-review"
},
"visual-review-runs-counts-retrieve": {
- "description": "Return review state counts across all runs for the current project: `needs_review`, `clean`, `processing`, `stale`. Useful as a single call to show reviewer workload before drilling into the list.",
+ "description": "Review state counts (`needs_review`, `clean`, `processing`, `stale`) across every run in the project.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Visual review run counts",
@@ -14019,7 +14049,7 @@
"feature_flag": "visual-review"
},
"visual-review-runs-finalize-create": {
- "description": "Finalize a fully-reviewed run: commit the approved baseline to the PR branch and green the GitHub visual-review check. Commits exactly the snapshots approved in the DB (tolerated snapshots keep their baseline and are never overwritten) and is all-or-nothing — it only succeeds once every changed/new snapshot is resolved (approved, tolerated, or quarantined), otherwise it returns the unresolved list. With `approve_all: true` every still-pending changed/new snapshot is approved first; quarantined snapshots are skipped by that, but a quarantined `new` snapshot approved by identifier through `visual-review-runs-approve-create` is committed, so a quarantined story can get its baseline entry while the quarantine stays in place. When a baseline commit is pushed its SHA comes back on the run's `metadata.baseline_commit_sha`; it's absent when nothing needed committing (all changes resolved by toleration/quarantine — the gate still greens) or when the commit was skipped (no PR, or a `409 sha_mismatch` from newer PR commits, which leaves the gate red — re-run CI and finalize again). STOP: never finalize on your own initiative. Require explicit, per-run human confirmation first — finalizing ships the visual change and rewrites the committed baseline.",
+ "description": "Ship a fully reviewed run: commit the approved snapshots to the pull request's baseline file and pass the gate. All or nothing: it returns the unresolved list until every changed or new snapshot is approved, tolerated or quarantined. `approve_all: true` approves the pending ones first, but not quarantined ones. With nothing to commit, it posts a green status, and the required check follows when its job re-runs. On `409 stale_run`, finalize the newest run; on `409 sha_mismatch`, re-run CI and finalize the new run. STOP: never finalize without an explicit human yes for this run.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Finalize a visual review run",
@@ -14034,7 +14064,7 @@
"feature_flag": "visual-review"
},
"visual-review-runs-list": {
- "description": "List visual review runs for the current project. Each run represents a single CI execution that captured screenshots for a commit. Filter by `review_state` (e.g. `needs_review`, `clean`, `processing`, `stale`) to triage workload, or by `pr_number` / `commit_sha` / `branch` to find the specific run(s) blocking a PR. Returns status, review decision, commit sha, branch, pr number, and a summary of changed / new / removed / unchanged snapshots.",
+ "description": "Runs in the project; each is one CI capture for one commit. Filter by `review_state`, or by `pr_number`, `commit_sha` or `branch` to find the run that blocks a pull request. Returns status, review decision, commit, branch, PR and a change summary.",
"category": "Visual review",
"feature": "visual_review",
"summary": "List visual review runs",
@@ -14048,8 +14078,23 @@
},
"feature_flag": "visual-review"
},
+ "visual-review-runs-recompute-create": {
+ "description": "Re-check the gate of a completed, unfinalized run after a quarantine or toleration: recount unresolved snapshots, post the commit status, and re-run the CI job recorded on the run, so the required check reads the new verdict. Call it on the pull request's latest non-stale run. Approved changes keep the gate red until finalize commits them. `ci_rerun_triggered` and `ci_rerun_error` report the re-run.",
+ "category": "Visual review",
+ "feature": "visual_review",
+ "summary": "Re-check a visual review run's gate",
+ "title": "Re-check a visual review run's gate",
+ "required_scopes": ["visual_review:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "visual-review"
+ },
"visual-review-runs-retrieve": {
- "description": "Get a visual review run by id. Returns run status, review decision, commit/branch/pr context, a summary (total, changed, new, removed, unchanged, tolerated-matched snapshot counts), and staleness info if a newer run supersedes this one. Use `visual-review-runs-snapshots-list` for per-snapshot diff details.",
+ "description": "Get one run: status, review decision, commit, branch, PR, change summary, and the newer run that supersedes it, if any. Per-snapshot results come from `visual-review-runs-snapshots-list`.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Get visual review run",
@@ -14064,7 +14109,7 @@
"feature_flag": "visual-review"
},
"visual-review-runs-snapshot-history-list": {
- "description": "List recent change history for one snapshot across previous runs in the same repo. Useful for diagnosing flaky snapshots — if the same identifier flips between changed and clean across runs, it is a candidate for tolerated hashes or quarantine. Both parameters are required, and one snapshot from `visual-review-runs-snapshots-list` gives you both: pass its `run_id` as `id`, and its `identifier` as `identifier`. Passing the snapshot's own `id` as `id` does not work, and neither parameter can be left out.",
+ "description": "One snapshot's baseline changes on the default branch, newest first. Pass a snapshot's `run_id` as `id` and its `identifier`; the snapshot's own `id` does not work.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Snapshot change history",
@@ -14079,7 +14124,7 @@
"feature_flag": "visual-review"
},
"visual-review-runs-snapshots-list": {
- "description": "List the snapshots captured in a run with their diff results. Each snapshot carries an `identifier` (e.g. Storybook story id + theme), a `result` (`unchanged`, `changed`, `new`, `removed`), an optional `classification_reason` (`tolerated_hash`, `below_threshold`, `exact`), diff percentage / pixel count, and `review_state` (`pending`, `approved`). Currently-quarantined snapshots are EXCLUDED by default — they are known-flaky noise, not changes to review — and reported only as a `quarantined_count` on the response; pass `include_quarantined=true` to fetch them too. Pass `exclude_unchanged=true` to list only the changed, new and removed snapshots; a large run holds thousands of unchanged ones. Pass `snapshot_id` to fetch one snapshot by its `id`. Renders an interactive diff viewer with baseline / current / diff images and approve / tolerate actions. Paginated — pass a `limit` (e.g. 50) when a run might have many snapshots (a broken run can produce 3000+ pairs); the diff viewer caps the visible list at 100 and prioritises actionable results regardless.",
+ "description": "Snapshots in a run with their diff results: `identifier`, `result` (`unchanged`, `changed`, `new`, `removed`), `classification_reason`, diff percentage and pixels, `review_state`, and signed baseline and current image URLs. Quarantined snapshots are left out and counted in `quarantined_count`; pass `include_quarantined=true` to get them. Pass `exclude_unchanged=true` to list only the changed, new and removed snapshots; a large run holds thousands of unchanged ones. Pass `snapshot_id` to fetch one snapshot by its `id`. Pass a `limit`, such as 50. Renders a diff viewer.",
"category": "Visual review",
"feature": "visual_review",
"summary": "List run snapshots",
@@ -14094,7 +14139,7 @@
"feature_flag": "visual-review"
},
"visual-review-runs-tolerate-create": {
- "description": "Mark a single changed snapshot as a known tolerated alternate. The snapshot's current hash is recorded alongside the existing baseline so future runs producing the same alternate are not flagged as changes — useful for benign rendering variants (anti-aliasing noise, blinking cursors, etc.). Pass `snapshot_id` — the UUID of the snapshot in this run. Does not change the baseline. To accept the change instead, use `visual-review-runs-approve-create` to record the review, then `visual-review-runs-finalize-create` to actually commit the new baseline.",
+ "description": "Accept one changed snapshot's current rendering as an alternative to its baseline, in every future run. Only for named render noise over the threshold (anti-aliasing, font hinting, a cursor) at the same size, with `change_kind: pixel`, so check the images first. It cannot be undone through the API. Never use it to pass a gate: a story that renders differently from run to run gets `visual-review-repos-quarantine-create`, and an intended change gets approved and finalized. Pass the snapshot's UUID as `snapshot_id`, then call `visual-review-runs-recompute-create`.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Tolerate visual review snapshot",
@@ -14109,7 +14154,7 @@
"feature_flag": "visual-review"
},
"visual-review-runs-tolerated-hashes-list": {
- "description": "List known tolerated alternate hashes for one snapshot in the run's repo. Tolerated hashes catalog acceptable rendering variants (e.g. anti-aliasing noise) so future runs don't flag them as changes. This covers a single snapshot, not the whole run or repo. Both parameters are required, and one snapshot from `visual-review-runs-snapshots-list` gives you both: pass its `run_id` as `id`, and its `identifier` as `identifier`.",
+ "description": "Tolerated alternate hashes for one snapshot in the run's repo. Pass a snapshot's `run_id` as `id` and its `identifier`.",
"category": "Visual review",
"feature": "visual_review",
"summary": "List tolerated hashes",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index b491aa5677f7..bd05fa13bc6a 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -14547,7 +14547,7 @@
}
},
"visual-review-repos-flakiness-retrieve": {
- "description": "Snapshots in a repo whose rendering cannot be trusted: those carrying a live tolerated variant against their current baseline, those that failed the gate on a recent default-branch run, and those under an active quarantine. Recency changes an entry's state rather than excluding it, so a snapshot that has gone quiet is still listed. This is the triage view, and it is far smaller than the baselines universe, so start here when asked why a suite is unreliable, which snapshots to quarantine, or which quarantines to lift. Each entry carries `hard_rate`, the share of recent default-branch runs that failed the gate, and `soft_rate`, the share a toleration absorbed, plus `headroom`, the fraction of the diff threshold its worst absorbed run leaves free. Every `totals` field except `listed` covers the whole population even when the entry list is capped; `listed` counts the entries actually returned, so it stops at the cap. Takes no filter parameters: filter the returned entries yourself, and pass `fields` to keep the response small when you only need a few of them.",
+ "description": "Snapshots in a repo whose rendering is untrusted: a live tolerated variant, a gate failure on a recent default-branch run, or an active quarantine. Start here to decide what to quarantine or lift. Each entry has `flakiness_state`, `hard_rate` (share of recent default-branch runs that failed the gate), `soft_rate` (share a toleration absorbed), `window_runs`, `headroom` and `needs_decision`. `totals` covers every snapshot; `listed` stops at the cap. Takes no filters: filter the entries yourself, and pass `fields` to trim the response.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Visual review flakiness overview",
@@ -14562,7 +14562,7 @@
"feature_flag": "visual-review"
},
"visual-review-repos-list": {
- "description": "List visual review repos (test suites) for the current project. A repo typically maps to a GitHub repository and owns the baselines, runs, and tolerated hashes for that codebase. Returns repo id, external id, full name, baseline file paths, and pr-comment configuration.",
+ "description": "List the visual review repos in the project. A repo maps to one GitHub repository and owns its baselines, runs and tolerated hashes.",
"category": "Visual review",
"feature": "visual_review",
"summary": "List visual review repos",
@@ -14577,7 +14577,7 @@
"feature_flag": "visual-review"
},
"visual-review-repos-partial-update": {
- "description": "Change one repo's settings. `enable_pr_comments` controls whether a run that finds visual changes posts a pull request comment asking for a review. `debt_digest_enabled` controls whether the debt digest runs for the repo, which posts expiring quarantines and piled-up variants to the Slack channels of the teams that own the snapshots; it is off until somebody turns it on, and it posts every Monday morning. `baseline_file_paths` maps each run type to the file holding its committed baseline hashes, for example `{\"storybook\": \".storybook/snapshots.yml\"}`, and finalize reads and commits the path named there; a `default` key covers every run type that has no entry of its own. Every field is optional, and a field you leave out keeps its current value.",
+ "description": "Change a repo's settings; a field you leave out keeps its value. `enable_pr_comments` posts a review request on pull requests with visual changes. `debt_digest_enabled` posts a Monday Slack digest of expiring quarantines and piled-up variants to the owning teams. `baseline_file_paths` maps a run type to its committed baseline file, for example `{\"storybook\": \".storybook/snapshots.yml\"}`, with `default` as the fallback; finalize commits to that path.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Update visual review repo settings",
@@ -14591,8 +14591,38 @@
},
"feature_flag": "visual-review"
},
+ "visual-review-repos-quarantine-create": {
+ "description": "Stop one identifier of one run type from failing any run in the repo until the quarantine expires. It is still captured and diffed. Use it only for a story that flakes on the default branch (`unstable` in `visual-review-repos-flakiness-retrieve`, `hard_count` of 5 or more, and a failure in the last 7 days), never for a `broken` entry (its baseline needs a fix) or a diff your own change caused. Pass the failing run as `source_run_id` and a `reason` with the evidence. An omitted or later `expires_at` becomes 30 days. A repeat call replaces the quarantine. Then call `visual-review-runs-recompute-create` to update the open pull request's gate.",
+ "category": "Visual review",
+ "feature": "visual_review",
+ "summary": "Quarantine a visual review snapshot",
+ "title": "Quarantine a visual review snapshot",
+ "required_scopes": ["visual_review:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "visual-review"
+ },
+ "visual-review-repos-quarantine-expire-create": {
+ "description": "Lift every active quarantine on one identifier and run type, so the snapshot gates runs again. Lift one after the fix that stabilizes the story merges, or when its flakiness entry has `needs_decision`. If the story still flakes, the next pull request that renders it fails.",
+ "category": "Visual review",
+ "feature": "visual_review",
+ "summary": "Lift a visual review quarantine",
+ "title": "Lift a visual review quarantine",
+ "required_scopes": ["visual_review:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "visual-review"
+ },
"visual-review-repos-quarantine-list": {
- "description": "Quarantined snapshot identifiers in a repo, with the reason, who opened it, when, when it expires, and the run whose failure prompted it. A quarantined snapshot is still captured, classified and diffed; it is only excluded when a run decides pass or fail. Returns active entries by default. Pass `identifier` for that one identifier's full history including expired entries, which is how you tell a long-standing mute from one somebody opened this morning. Pass `run_type` to narrow to one kind of run.",
+ "description": "Quarantines in a repo, with reason, author, expiry and the run that prompted each. Returns active entries by default. Pass `identifier` for that identifier's full history, or `run_type` to narrow.",
"category": "Visual review",
"feature": "visual_review",
"summary": "List quarantined snapshots",
@@ -14607,7 +14637,7 @@
"feature_flag": "visual-review"
},
"visual-review-repos-retrieve": {
- "description": "Get a visual review repo by id. Returns baseline file paths keyed by run_type (e.g. storybook → baseline YAML path in the repo), pr-comment setting, and repo metadata.",
+ "description": "Get one repo: baseline file paths per run type, the PR-comment setting and repo metadata.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Get visual review repo",
@@ -14622,7 +14652,7 @@
"feature_flag": "visual-review"
},
"visual-review-repos-runs-counts-retrieve": {
- "description": "Review state counts (`needs_review`, `clean`, `processing`, `stale`) for one repo's runs. The repo-scoped counterpart to `visual-review-runs-counts-retrieve`, which spans every repo in the project.",
+ "description": "Review state counts (`needs_review`, `clean`, `processing`, `stale`) for one repo's runs.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Visual review run counts for a repo",
@@ -14637,7 +14667,7 @@
"feature_flag": "visual-review"
},
"visual-review-repos-runs-list": {
- "description": "Runs belonging to one repo. Prefer this over `visual-review-runs-list` whenever you know the repo: that tool spans every repo in the project and cannot be narrowed to one, so its results mix repos together. Filter by `review_state` to triage, or `search` for a free-text match over branch, commit SHA, run type and PR number. For a specific PR, commit or branch, use `visual-review-runs-list`, which takes those filters.",
+ "description": "Runs in one repo. Prefer it over `visual-review-runs-list`, which mixes every repo. Filter by `review_state`, or `search` over branch, commit SHA, run type and PR number. For an exact PR, commit or branch filter, use `visual-review-runs-list`.",
"category": "Visual review",
"feature": "visual_review",
"summary": "List runs in a visual review repo",
@@ -14652,7 +14682,7 @@
"feature_flag": "visual-review"
},
"visual-review-repos-toleration-pileups-retrieve": {
- "description": "Snapshots in a repo that keep getting tolerated, counted across baselines, most manual tolerations first. A toleration accepts one exact rendering, so a snapshot that keeps needing them renders differently from run to run, and the fix belongs in the story (a pinned date, a disabled animation, a wait for a loader). Called with only the repo `id` it applies the weekly debt digest's rule and keeps quarantined snapshots, marked with `is_quarantined`. Tune it with `min_tolerations`, `min_automatic_tolerations`, `window_days`, `include_quarantined`, `run_type` and `limit`; the response echoes the rule it applied. The list is short and returns quickly, so use it instead of the flakiness overview to find flaky stories worth fixing, then read one snapshot's history with `visual-review-runs-snapshot-history-list` or its tolerations with `visual-review-runs-tolerated-hashes-list`.",
+ "description": "Snapshots that keep getting tolerated, most manual tolerations first. Such a story renders differently from run to run, and the fix belongs in the story (a pinned date, a disabled animation, a wait for a loader). With only `id`, it applies the weekly debt digest rule. Tune it with `min_tolerations`, `min_automatic_tolerations`, `window_days`, `include_quarantined`, `run_type` and `limit`. Faster than the flakiness overview for finding stories to fix.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Visual review toleration pile-ups",
@@ -14667,7 +14697,7 @@
"feature_flag": "visual-review"
},
"visual-review-runs-approve-create": {
- "description": "Mark specific snapshots as reviewed (approved) in a run. Pass a `snapshots` list, each entry being `{identifier, new_hash}` — `new_hash` is the `content_hash` of the snapshot's `current_artifact`. This only records the review in the database (the per-snapshot \"Accept change\" action) — it does NOT update the baseline, push a commit, or change the GitHub gate, and it can be re-run safely. To actually ship the visual change (commit the baseline + green the gate), use `visual-review-runs-finalize-create`. Approving a quarantined `new` snapshot here makes finalize commit its baseline entry while the quarantine stays in place — the way to give a quarantined story an entry without failing other runs.",
+ "description": "Record snapshots as approved in a run, in the database only. Pass `snapshots: [{identifier, new_hash}]`, where `new_hash` is the snapshot's `current_artifact.content_hash`. It does not commit the baseline or change the gate; `visual-review-runs-finalize-create` ships it. An approved quarantined `new` snapshot gets its baseline entry at finalize while the quarantine stays.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Mark visual review snapshots reviewed",
@@ -14682,7 +14712,7 @@
"feature_flag": "visual-review"
},
"visual-review-runs-counts-retrieve": {
- "description": "Return review state counts across all runs for the current project: `needs_review`, `clean`, `processing`, `stale`. Useful as a single call to show reviewer workload before drilling into the list.",
+ "description": "Review state counts (`needs_review`, `clean`, `processing`, `stale`) across every run in the project.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Visual review run counts",
@@ -14697,7 +14727,7 @@
"feature_flag": "visual-review"
},
"visual-review-runs-finalize-create": {
- "description": "Finalize a fully-reviewed run: commit the approved baseline to the PR branch and green the GitHub visual-review check. Commits exactly the snapshots approved in the DB (tolerated snapshots keep their baseline and are never overwritten) and is all-or-nothing — it only succeeds once every changed/new snapshot is resolved (approved, tolerated, or quarantined), otherwise it returns the unresolved list. With `approve_all: true` every still-pending changed/new snapshot is approved first; quarantined snapshots are skipped by that, but a quarantined `new` snapshot approved by identifier through `visual-review-runs-approve-create` is committed, so a quarantined story can get its baseline entry while the quarantine stays in place. When a baseline commit is pushed its SHA comes back on the run's `metadata.baseline_commit_sha`; it's absent when nothing needed committing (all changes resolved by toleration/quarantine — the gate still greens) or when the commit was skipped (no PR, or a `409 sha_mismatch` from newer PR commits, which leaves the gate red — re-run CI and finalize again). STOP: never finalize on your own initiative. Require explicit, per-run human confirmation first — finalizing ships the visual change and rewrites the committed baseline.",
+ "description": "Ship a fully reviewed run: commit the approved snapshots to the pull request's baseline file and pass the gate. All or nothing: it returns the unresolved list until every changed or new snapshot is approved, tolerated or quarantined. `approve_all: true` approves the pending ones first, but not quarantined ones. With nothing to commit, it posts a green status, and the required check follows when its job re-runs. On `409 stale_run`, finalize the newest run; on `409 sha_mismatch`, re-run CI and finalize the new run. STOP: never finalize without an explicit human yes for this run.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Finalize a visual review run",
@@ -14712,7 +14742,7 @@
"feature_flag": "visual-review"
},
"visual-review-runs-list": {
- "description": "List visual review runs for the current project. Each run represents a single CI execution that captured screenshots for a commit. Filter by `review_state` (e.g. `needs_review`, `clean`, `processing`, `stale`) to triage workload, or by `pr_number` / `commit_sha` / `branch` to find the specific run(s) blocking a PR. Returns status, review decision, commit sha, branch, pr number, and a summary of changed / new / removed / unchanged snapshots.",
+ "description": "Runs in the project; each is one CI capture for one commit. Filter by `review_state`, or by `pr_number`, `commit_sha` or `branch` to find the run that blocks a pull request. Returns status, review decision, commit, branch, PR and a change summary.",
"category": "Visual review",
"feature": "visual_review",
"summary": "List visual review runs",
@@ -14726,8 +14756,23 @@
},
"feature_flag": "visual-review"
},
+ "visual-review-runs-recompute-create": {
+ "description": "Re-check the gate of a completed, unfinalized run after a quarantine or toleration: recount unresolved snapshots, post the commit status, and re-run the CI job recorded on the run, so the required check reads the new verdict. Call it on the pull request's latest non-stale run. Approved changes keep the gate red until finalize commits them. `ci_rerun_triggered` and `ci_rerun_error` report the re-run.",
+ "category": "Visual review",
+ "feature": "visual_review",
+ "summary": "Re-check a visual review run's gate",
+ "title": "Re-check a visual review run's gate",
+ "required_scopes": ["visual_review:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "visual-review"
+ },
"visual-review-runs-retrieve": {
- "description": "Get a visual review run by id. Returns run status, review decision, commit/branch/pr context, a summary (total, changed, new, removed, unchanged, tolerated-matched snapshot counts), and staleness info if a newer run supersedes this one. Use `visual-review-runs-snapshots-list` for per-snapshot diff details.",
+ "description": "Get one run: status, review decision, commit, branch, PR, change summary, and the newer run that supersedes it, if any. Per-snapshot results come from `visual-review-runs-snapshots-list`.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Get visual review run",
@@ -14742,7 +14787,7 @@
"feature_flag": "visual-review"
},
"visual-review-runs-snapshot-history-list": {
- "description": "List recent change history for one snapshot across previous runs in the same repo. Useful for diagnosing flaky snapshots — if the same identifier flips between changed and clean across runs, it is a candidate for tolerated hashes or quarantine. Both parameters are required, and one snapshot from `visual-review-runs-snapshots-list` gives you both: pass its `run_id` as `id`, and its `identifier` as `identifier`. Passing the snapshot's own `id` as `id` does not work, and neither parameter can be left out.",
+ "description": "One snapshot's baseline changes on the default branch, newest first. Pass a snapshot's `run_id` as `id` and its `identifier`; the snapshot's own `id` does not work.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Snapshot change history",
@@ -14757,7 +14802,7 @@
"feature_flag": "visual-review"
},
"visual-review-runs-snapshots-list": {
- "description": "List the snapshots captured in a run with their diff results. Each snapshot carries an `identifier` (e.g. Storybook story id + theme), a `result` (`unchanged`, `changed`, `new`, `removed`), an optional `classification_reason` (`tolerated_hash`, `below_threshold`, `exact`), diff percentage / pixel count, and `review_state` (`pending`, `approved`). Currently-quarantined snapshots are EXCLUDED by default — they are known-flaky noise, not changes to review — and reported only as a `quarantined_count` on the response; pass `include_quarantined=true` to fetch them too. Pass `exclude_unchanged=true` to list only the changed, new and removed snapshots; a large run holds thousands of unchanged ones. Pass `snapshot_id` to fetch one snapshot by its `id`. Renders an interactive diff viewer with baseline / current / diff images and approve / tolerate actions. Paginated — pass a `limit` (e.g. 50) when a run might have many snapshots (a broken run can produce 3000+ pairs); the diff viewer caps the visible list at 100 and prioritises actionable results regardless.",
+ "description": "Snapshots in a run with their diff results: `identifier`, `result` (`unchanged`, `changed`, `new`, `removed`), `classification_reason`, diff percentage and pixels, `review_state`, and signed baseline and current image URLs. Quarantined snapshots are left out and counted in `quarantined_count`; pass `include_quarantined=true` to get them. Pass `exclude_unchanged=true` to list only the changed, new and removed snapshots; a large run holds thousands of unchanged ones. Pass `snapshot_id` to fetch one snapshot by its `id`. Pass a `limit`, such as 50. Renders a diff viewer.",
"category": "Visual review",
"feature": "visual_review",
"summary": "List run snapshots",
@@ -14772,7 +14817,7 @@
"feature_flag": "visual-review"
},
"visual-review-runs-tolerate-create": {
- "description": "Mark a single changed snapshot as a known tolerated alternate. The snapshot's current hash is recorded alongside the existing baseline so future runs producing the same alternate are not flagged as changes — useful for benign rendering variants (anti-aliasing noise, blinking cursors, etc.). Pass `snapshot_id` — the UUID of the snapshot in this run. Does not change the baseline. To accept the change instead, use `visual-review-runs-approve-create` to record the review, then `visual-review-runs-finalize-create` to actually commit the new baseline.",
+ "description": "Accept one changed snapshot's current rendering as an alternative to its baseline, in every future run. Only for named render noise over the threshold (anti-aliasing, font hinting, a cursor) at the same size, with `change_kind: pixel`, so check the images first. It cannot be undone through the API. Never use it to pass a gate: a story that renders differently from run to run gets `visual-review-repos-quarantine-create`, and an intended change gets approved and finalized. Pass the snapshot's UUID as `snapshot_id`, then call `visual-review-runs-recompute-create`.",
"category": "Visual review",
"feature": "visual_review",
"summary": "Tolerate visual review snapshot",
@@ -14787,7 +14832,7 @@
"feature_flag": "visual-review"
},
"visual-review-runs-tolerated-hashes-list": {
- "description": "List known tolerated alternate hashes for one snapshot in the run's repo. Tolerated hashes catalog acceptable rendering variants (e.g. anti-aliasing noise) so future runs don't flag them as changes. This covers a single snapshot, not the whole run or repo. Both parameters are required, and one snapshot from `visual-review-runs-snapshots-list` gives you both: pass its `run_id` as `id`, and its `identifier` as `identifier`.",
+ "description": "Tolerated alternate hashes for one snapshot in the run's repo. Pass a snapshot's `run_id` as `id` and its `identifier`.",
"category": "Visual review",
"feature": "visual_review",
"summary": "List tolerated hashes",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 8700009f02ee..a4cd82620c0c 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -85894,6 +85894,11 @@ export namespace Schemas {
* @maxLength 255
*/
reason: string;
+ /**
+ * When the quarantine lifts itself, as an ISO 8601 datetime. Through MCP an omitted or later expiry becomes 30 days from now; anywhere else omitting it means no expiry.
+ * @nullable
+ */
+ expires_at?: string | null;
/**
* Optional pointer to the run whose failing snapshot prompted this quarantine — used to surface a 'view the failing run' link later.
* @nullable
@@ -85901,8 +85906,6 @@ export namespace Schemas {
source_run_id?: string | null;
/** Post the quarantine to the Slack channel of the team that owns the story, naming the user who quarantined it. Only Storybook snapshots have an owning team. Best effort: skipped when the story has no owning team or the project has no Slack integration. */
notify_owners?: boolean;
- /** @nullable */
- expires_at?: string | null;
}
/**
diff --git a/services/mcp/src/generated/visual_review/api.ts b/services/mcp/src/generated/visual_review/api.ts
index 3a2289964d39..cd35d43f90a4 100644
--- a/services/mcp/src/generated/visual_review/api.ts
+++ b/services/mcp/src/generated/visual_review/api.ts
@@ -3,7 +3,7 @@
* MCP service uses these Zod schemas for generated tool handlers.
* To regenerate: hogli build:openapi
*
- * PostHog API - MCP 17 enabled ops
+ * PostHog API - MCP 20 enabled ops
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
@@ -93,6 +93,80 @@ export const VisualReviewReposQuarantineListQueryParams = () => zod.object({
run_type: zod.string().optional().describe('Filter by run type'),
})
+/**
+ * Quarantine a snapshot identifier for a specific run type.
+ */
+export const visualReviewReposQuarantineCreatePathRunTypeRegExp = new RegExp('^[^\/]+$')
+
+export const VisualReviewReposQuarantineCreateParams = () => zod.object({
+ id: zod.string(),
+ project_id: zod
+ .string()
+ .describe(
+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
+ ),
+ run_type: zod.string().regex(visualReviewReposQuarantineCreatePathRunTypeRegExp),
+})
+
+export const visualReviewReposQuarantineCreateBodyIdentifierMax = 512
+
+export const visualReviewReposQuarantineCreateBodyReasonMax = 255
+
+export const visualReviewReposQuarantineCreateBodyNotifyOwnersDefault = false
+
+export const VisualReviewReposQuarantineCreateBody = () => zod.object({
+ identifier: zod
+ .string()
+ .max(visualReviewReposQuarantineCreateBodyIdentifierMax)
+ .describe('Snapshot identifier to quarantine.'),
+ reason: zod
+ .string()
+ .max(visualReviewReposQuarantineCreateBodyReasonMax)
+ .describe('Why this snapshot is being quarantined.'),
+ expires_at: zod.iso
+ .datetime({ offset: true })
+ .nullish()
+ .describe(
+ 'When the quarantine lifts itself, as an ISO 8601 datetime. Through MCP an omitted or later expiry becomes 30 days from now; anywhere else omitting it means no expiry.'
+ ),
+ source_run_id: zod
+ .string()
+ .nullish()
+ .describe(
+ "Optional pointer to the run whose failing snapshot prompted this quarantine — used to surface a 'view the failing run' link later."
+ ),
+ notify_owners: zod
+ .boolean()
+ .default(visualReviewReposQuarantineCreateBodyNotifyOwnersDefault)
+ .describe(
+ 'Post the quarantine to the Slack channel of the team that owns the story, naming the user who quarantined it. Only Storybook snapshots have an owning team. Best effort: skipped when the story has no owning team or the project has no Slack integration.'
+ ),
+})
+
+/**
+ * Expire all active quarantine entries for an identifier.
+ */
+export const visualReviewReposQuarantineExpireCreatePathRunTypeRegExp = new RegExp('^[^\/]+$')
+
+export const VisualReviewReposQuarantineExpireCreateParams = () => zod.object({
+ id: zod.string(),
+ project_id: zod
+ .string()
+ .describe(
+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
+ ),
+ run_type: zod.string().regex(visualReviewReposQuarantineExpireCreatePathRunTypeRegExp),
+})
+
+export const visualReviewReposQuarantineExpireCreateBodyIdentifierMax = 512
+
+export const VisualReviewReposQuarantineExpireCreateBody = () => zod.object({
+ identifier: zod
+ .string()
+ .max(visualReviewReposQuarantineExpireCreateBodyIdentifierMax)
+ .describe('Snapshot identifier to unquarantine'),
+})
+
/**
* Snapshots that keep getting tolerated, counted across baselines, most manual tolerations first. A toleration accepts one exact rendering, so a snapshot that keeps needing them renders differently from run to run, and the fix belongs in the story. With no parameters this is the weekly debt digest's rule (3 or more tolerations by a person or agent in 30 days), except that quarantined snapshots are kept and marked with `is_quarantined`. The list is small and returns fast; start here to find flaky stories worth fixing, then read one snapshot's history with the per-snapshot tools.
*/
@@ -304,6 +378,18 @@ export const VisualReviewRunsFinalizeCreateBody = () => zod.object({
),
})
+/**
+ * Re-evaluate quarantine and counts, update commit status, and optionally rerun the CI job.
+ */
+export const VisualReviewRunsRecomputeCreateParams = () => zod.object({
+ id: zod.string(),
+ project_id: zod
+ .string()
+ .describe(
+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
+ ),
+})
+
/**
* Recent change history for a snapshot identifier across runs.
*/
diff --git a/services/mcp/src/tools/generated/visual_review.ts b/services/mcp/src/tools/generated/visual_review.ts
index 2b9c07650a62..83e5f7330982 100644
--- a/services/mcp/src/tools/generated/visual_review.ts
+++ b/services/mcp/src/tools/generated/visual_review.ts
@@ -175,6 +175,99 @@ const visualReviewReposPartialUpdate = (): ToolBase<
},
})
+const VisualReviewReposQuarantineCreateSchema = () => {
+ const VisualReviewReposQuarantineCreateBody = orvalSchemas.VisualReviewReposQuarantineCreateBody()
+ const VisualReviewReposQuarantineCreateParams = orvalSchemas.VisualReviewReposQuarantineCreateParams()
+ return z.preprocess(
+ normalizeParamAliases({ id: ['repo_id'] }),
+ VisualReviewReposQuarantineCreateParams.omit({ project_id: true })
+ .extend(VisualReviewReposQuarantineCreateBody.shape)
+ .extend({
+ id: VisualReviewReposQuarantineCreateParams.shape['id'].describe(
+ "The repo's UUID, the run's `repo_id`."
+ ),
+ run_type: VisualReviewReposQuarantineCreateParams.shape['run_type'].describe(
+ "The failing run's `run_type`, `storybook` or `playwright`. The quarantine covers only this run type."
+ ),
+ })
+ )
+}
+
+const visualReviewReposQuarantineCreate = (): ToolBase<
+ ReturnType<typeof VisualReviewReposQuarantineCreateSchema>,
+ Schemas.QuarantinedIdentifierEntry
+> => ({
+ name: 'visual-review-repos-quarantine-create',
+ schema: VisualReviewReposQuarantineCreateSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof VisualReviewReposQuarantineCreateSchema>>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const body: Record<string, unknown> = {}
+ if (params.identifier !== undefined) {
+ body['identifier'] = params.identifier
+ }
+ if (params.reason !== undefined) {
+ body['reason'] = params.reason
+ }
+ if (params.expires_at !== undefined) {
+ body['expires_at'] = params.expires_at
+ }
+ if (params.source_run_id !== undefined) {
+ body['source_run_id'] = params.source_run_id
+ }
+ if (params.notify_owners !== undefined) {
+ body['notify_owners'] = params.notify_owners
+ }
+ const result = await context.api.request<Schemas.QuarantinedIdentifierEntry>({
+ method: 'POST',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/visual_review/repos/${encodeURIComponent(String(params.id))}/quarantine/${encodeURIComponent(String(params.run_type))}/`,
+ body,
+ })
+ return result
+ },
+})
+
+const VisualReviewReposQuarantineExpireCreateSchema = () => {
+ const VisualReviewReposQuarantineExpireCreateBody = orvalSchemas.VisualReviewReposQuarantineExpireCreateBody()
+ const VisualReviewReposQuarantineExpireCreateParams = orvalSchemas.VisualReviewReposQuarantineExpireCreateParams()
+ return z.preprocess(
+ normalizeParamAliases({ id: ['repo_id'] }),
+ VisualReviewReposQuarantineExpireCreateParams.omit({ project_id: true })
+ .extend(VisualReviewReposQuarantineExpireCreateBody.shape)
+ .extend({
+ id: VisualReviewReposQuarantineExpireCreateParams.shape['id'].describe(
+ "The repo's UUID, from `visual-review-repos-list`."
+ ),
+ run_type: VisualReviewReposQuarantineExpireCreateParams.shape['run_type'].describe(
+ 'The run type of the quarantine to lift (`storybook` or `playwright`).'
+ ),
+ })
+ )
+}
+
+const visualReviewReposQuarantineExpireCreate = (): ToolBase<
+ ReturnType<typeof VisualReviewReposQuarantineExpireCreateSchema>,
+ unknown
+> => ({
+ name: 'visual-review-repos-quarantine-expire-create',
+ schema: VisualReviewReposQuarantineExpireCreateSchema(),
+ handler: async (
+ context: Context,
+ params: z.infer<ReturnType<typeof VisualReviewReposQuarantineExpireCreateSchema>>
+ ) => {
+ const projectId = await context.stateManager.getProjectId()
+ const body: Record<string, unknown> = {}
+ if (params.identifier !== undefined) {
+ body['identifier'] = params.identifier
+ }
+ const result = await context.api.request<unknown>({
+ method: 'POST',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/visual_review/repos/${encodeURIComponent(String(params.id))}/quarantine/${encodeURIComponent(String(params.run_type))}/expire/`,
+ body,
+ })
+ return result
+ },
+})
+
const VisualReviewReposQuarantineListSchema = () => {
const VisualReviewReposQuarantineListParams = orvalSchemas.VisualReviewReposQuarantineListParams()
const VisualReviewReposQuarantineListQueryParams = orvalSchemas.VisualReviewReposQuarantineListQueryParams()
@@ -480,6 +573,27 @@ const visualReviewRunsList = (): ToolBase<
},
})
+const VisualReviewRunsRecomputeCreateSchema = () => {
+ const VisualReviewRunsRecomputeCreateParams = orvalSchemas.VisualReviewRunsRecomputeCreateParams()
+ return VisualReviewRunsRecomputeCreateParams.omit({ project_id: true })
+}
+
+const visualReviewRunsRecomputeCreate = (): ToolBase<
+ ReturnType<typeof VisualReviewRunsRecomputeCreateSchema>,
+ Schemas.RecomputeResult
+> => ({
+ name: 'visual-review-runs-recompute-create',
+ schema: VisualReviewRunsRecomputeCreateSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof VisualReviewRunsRecomputeCreateSchema>>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const result = await context.api.request<Schemas.RecomputeResult>({
+ method: 'POST',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/visual_review/runs/${encodeURIComponent(String(params.id))}/recompute/`,
+ })
+ return result
+ },
+})
+
const VisualReviewRunsRetrieveSchema = () => {
const VisualReviewRunsRetrieveParams = orvalSchemas.VisualReviewRunsRetrieveParams()
return VisualReviewRunsRetrieveParams.omit({ project_id: true })
@@ -510,10 +624,10 @@ const VisualReviewRunsSnapshotHistoryListSchema = () => {
.extend(VisualReviewRunsSnapshotHistoryListQueryParams.shape)
.extend({
id: VisualReviewRunsSnapshotHistoryListParams.shape['id'].describe(
- "UUID of the visual review run to look the snapshot up from — a run id, not the `id` of a snapshot inside the run. Use the snapshot's `run_id`, or a run id from `visual-review-runs-list`. Required, and `identifier` is required alongside it."
+ "A run UUID, such as the snapshot's `run_id`. Not a snapshot `id`."
),
identifier: VisualReviewRunsSnapshotHistoryListQueryParams.shape['identifier'].describe(
- 'Identifier of the snapshot to trace, for example a Storybook story id plus theme. Copy the `identifier` field of a snapshot in the run — it is a name, not a UUID. Required in addition to `id`; without it the call is rejected rather than returning history for the whole run.'
+ "The snapshot's `identifier`, a name such as a story id plus theme. Required."
),
})
)
@@ -613,10 +727,10 @@ const VisualReviewRunsToleratedHashesListSchema = () => {
.extend(VisualReviewRunsToleratedHashesListQueryParams.shape)
.extend({
id: VisualReviewRunsToleratedHashesListParams.shape['id'].describe(
- "UUID of the visual review run whose repo holds the tolerated hashes — a run id, not the `id` of a snapshot inside the run. Use the snapshot's `run_id`, or a run id from `visual-review-runs-list`. Required, and `identifier` is required alongside it."
+ "A run UUID, such as the snapshot's `run_id`. Not a snapshot `id`."
),
identifier: VisualReviewRunsToleratedHashesListQueryParams.shape['identifier'].describe(
- 'Identifier of the snapshot whose tolerated hashes you want, for example a Storybook story id plus theme. Copy the `identifier` field of a snapshot in the run — it is a name, not a UUID. Required in addition to `id`; there is no way to list every tolerated hash in the repo from this tool.'
+ "The snapshot's `identifier`, a name such as a story id plus theme. Required."
),
})
)
@@ -650,6 +764,8 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'visual-review-repos-flakiness-retrieve': visualReviewReposFlakinessRetrieve,
'visual-review-repos-list': visualReviewReposList,
'visual-review-repos-partial-update': visualReviewReposPartialUpdate,
+ 'visual-review-repos-quarantine-create': visualReviewReposQuarantineCreate,
+ 'visual-review-repos-quarantine-expire-create': visualReviewReposQuarantineExpireCreate,
'visual-review-repos-quarantine-list': visualReviewReposQuarantineList,
'visual-review-repos-retrieve': visualReviewReposRetrieve,
'visual-review-repos-runs-counts-retrieve': visualReviewReposRunsCountsRetrieve,
@@ -659,6 +775,7 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'visual-review-runs-counts-retrieve': visualReviewRunsCountsRetrieve,
'visual-review-runs-finalize-create': visualReviewRunsFinalizeCreate,
'visual-review-runs-list': visualReviewRunsList,
+ 'visual-review-runs-recompute-create': visualReviewRunsRecomputeCreate,
'visual-review-runs-retrieve': visualReviewRunsRetrieve,
'visual-review-runs-snapshot-history-list': visualReviewRunsSnapshotHistoryList,
'visual-review-runs-snapshots-list': visualReviewRunsSnapshotsList,