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): add a debt digest repo switch and skip weekends (#99772)

Julian Bez0739835d4945
diff --git a/posthog/tasks/scheduled.py b/posthog/tasks/scheduled.py
index 3cc820910552..f8b978a92f92 100644
--- a/posthog/tasks/scheduled.py
+++ b/posthog/tasks/scheduled.py
@@ -1084,7 +1084,7 @@ def setup_periodic_tasks(sender: Celery, **kwargs: Any) -> None:
add_periodic_task_with_expiry(
sender,
- crontab(hour="7", minute="30"),
+ crontab(hour="7", minute="30", day_of_week="1-5"),
send_visual_review_debt_digests.s(),
name="send visual review debt digests",
expires_seconds=60 * 60,
diff --git a/products/visual_review/README.md b/products/visual_review/README.md
index f9b616ab4041..55ca63a6d338 100644
--- a/products/visual_review/README.md
+++ b/products/visual_review/README.md
@@ -43,9 +43,9 @@ The windows and the reasons behind them are constants in `backend/logic/retentio
### Daily debt digest
-A daily Celery task, `send visual review debt digests`, posts each team a Slack reminder about the visual review debt it still carries.
+Every weekday morning a Celery task, `send visual review debt digests`, posts each team a Slack reminder about the visual review debt it still carries.
The digest is stateless: every morning both conditions below are evaluated from current data, and nothing is stored about what was sent.
-An item repeats every day while it stands, and stops the day the condition no longer holds.
+An item repeats every weekday while it stands, and stops the day the condition no longer holds.
Two conditions, and nothing else:
@@ -87,10 +87,12 @@ Routing goes to the team's `notifications` channel in the repository's root `own
A team opts out with `notifications: {visual_review: false}` under its entry.
A shared Slack channel is refused, so a name match never carries an internal reminder out of the workspace.
-There is nothing to configure.
-The daily beat task runs the digest for every repository, and a repository that owes nothing posts nothing.
+The digest is off for a repository until `debt_digest_enabled` is set on it.
+Set it through the repo API (`PATCH /api/projects/:team_id/visual_review/repos/:id/`), the `visual-review-repos-partial-update` MCP tool, or Django admin.
+The beat task runs Monday to Friday, and it fans out only to the repositories that are on.
+A repository that owes nothing posts nothing.
-`./manage.py visual_review_debt_digest --repo owner/name [--mode preview]` runs one repository by hand.
+`./manage.py visual_review_debt_digest --repo owner/name [--mode preview]` runs one repository by hand, whatever `debt_digest_enabled` says, because a run somebody starts is already a decision to send it.
`--mode preview`, the default, renders every team's message and logs it without posting.
`--mode live` posts.
diff --git a/products/visual_review/backend/admin.py b/products/visual_review/backend/admin.py
index 1e5ccdeb87ea..58b59a920b21 100644
--- a/products/visual_review/backend/admin.py
+++ b/products/visual_review/backend/admin.py
@@ -68,11 +68,12 @@ class RepoAdmin(admin.ModelAdmin):
"repo_external_id",
"team_link",
"enable_pr_comments",
+ "debt_digest_enabled",
"created_at",
"updated_at",
)
list_display_links = ("id", "repo_full_name")
- list_filter = ("enable_pr_comments", "created_at")
+ list_filter = ("enable_pr_comments", "debt_digest_enabled", "created_at")
search_fields = ("id", "repo_full_name", "repo_external_id", "team_id")
ordering = ("-created_at",)
show_full_result_count = False
@@ -89,7 +90,7 @@ class RepoAdmin(admin.ModelAdmin):
)
fieldsets = (
(None, {"fields": ("id", "team_id", "repo_external_id", "repo_full_name")}),
- ("Configuration", {"fields": ("baseline_file_paths", "enable_pr_comments")}),
+ ("Configuration", {"fields": ("baseline_file_paths", "enable_pr_comments", "debt_digest_enabled")}),
("Security", {"fields": ("signing_keys_summary",)}),
("Dates", {"fields": ("created_at", "updated_at")}),
)
diff --git a/products/visual_review/backend/facade/api.py b/products/visual_review/backend/facade/api.py
index 85ce9c37cd6d..7acab1da8428 100644
--- a/products/visual_review/backend/facade/api.py
+++ b/products/visual_review/backend/facade/api.py
@@ -260,6 +260,7 @@ def _to_repo(repo) -> contracts.Repo:
repo_full_name=repo.repo_full_name,
baseline_file_paths=repo.baseline_file_paths,
enable_pr_comments=repo.enable_pr_comments,
+ debt_digest_enabled=repo.debt_digest_enabled,
created_at=repo.created_at,
)
diff --git a/products/visual_review/backend/facade/contracts.py b/products/visual_review/backend/facade/contracts.py
index 53f04708bcc0..771d02646ef1 100644
--- a/products/visual_review/backend/facade/contracts.py
+++ b/products/visual_review/backend/facade/contracts.py
@@ -448,6 +448,7 @@ class UpdateRepoRequestInput:
baseline_file_paths: dict[str, str] | None = None
enable_pr_comments: bool | None = None
+ debt_digest_enabled: bool | None = None
@dataclass(frozen=True)
@@ -457,6 +458,7 @@ class UpdateRepoInput:
repo_id: UUID
baseline_file_paths: dict[str, str] | None = None
enable_pr_comments: bool | None = None
+ debt_digest_enabled: bool | None = None
@dataclass(frozen=True)
@@ -496,6 +498,7 @@ class Repo:
repo_full_name: str
baseline_file_paths: dict[str, str]
enable_pr_comments: bool
+ debt_digest_enabled: bool
created_at: datetime
diff --git a/products/visual_review/backend/logic/debt_digest.py b/products/visual_review/backend/logic/debt_digest.py
index f33806b86d27..2425092866e4 100644
--- a/products/visual_review/backend/logic/debt_digest.py
+++ b/products/visual_review/backend/logic/debt_digest.py
@@ -91,7 +91,7 @@ MODE_LIVE = "live"
MODES = (MODE_PREVIEW, MODE_LIVE)
_FOOTER = (
- "This repeats daily while the items stay unresolved. "
+ "This repeats every weekday while the items stay unresolved. "
"To opt out, set notifications: {visual_review: false} under your team in owners.yaml."
)
@@ -577,10 +577,12 @@ def _send_one(
def repos_in_scope() -> list[Repo]:
- """Every repo, oldest first.
+ """Every repo that opted in, oldest first.
- No allowlist: the per-repo task stops as soon as a repo owes nothing, so a repo that never
- carries debt costs one cheap read a day. The fan-out only routes, so the rows stay unhydrated.
+ The switch is the only way to stop the digest without a deploy, so the fan-out reads it rather
+ than the per-repo task: a repo that is off costs no child task at all. For the repos that are
+ on, the per-repo task stops as soon as one owes nothing, so a repo that never carries debt
+ costs one cheap read a day. The fan-out only routes, so the rows stay unhydrated.
"""
# nosemgrep: idor-lookup-without-team — cross-team beat sweep, no user input
- return list(Repo.objects.unscoped().only("id", "team_id").order_by("created_at"))
+ return list(Repo.objects.unscoped().filter(debt_digest_enabled=True).only("id", "team_id").order_by("created_at"))
diff --git a/products/visual_review/backend/logic/repos.py b/products/visual_review/backend/logic/repos.py
index 955e8e94907d..08afff5fddab 100644
--- a/products/visual_review/backend/logic/repos.py
+++ b/products/visual_review/backend/logic/repos.py
@@ -34,5 +34,7 @@ def update_repo(input: UpdateRepoInput, team_id: int) -> Repo:
repo.baseline_file_paths = input.baseline_file_paths
if input.enable_pr_comments is not None:
repo.enable_pr_comments = input.enable_pr_comments
+ if input.debt_digest_enabled is not None:
+ repo.debt_digest_enabled = input.debt_digest_enabled
repo.save()
return repo
diff --git a/products/visual_review/backend/migrations/0015_repo_debt_digest_enabled.py b/products/visual_review/backend/migrations/0015_repo_debt_digest_enabled.py
new file mode 100644
index 000000000000..65d73c2e4d68
--- /dev/null
+++ b/products/visual_review/backend/migrations/0015_repo_debt_digest_enabled.py
@@ -0,0 +1,17 @@
+# Generated by Django 5.2.17 on 2026-09-13 08:15
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("visual_review", "0014_run_search_trgm"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="repo",
+ name="debt_digest_enabled",
+ field=models.BooleanField(db_default=False, default=False),
+ ),
+ ]
diff --git a/products/visual_review/backend/migrations/max_migration.txt b/products/visual_review/backend/migrations/max_migration.txt
index b4efb6c9edc2..c0e36f42c330 100644
--- a/products/visual_review/backend/migrations/max_migration.txt
+++ b/products/visual_review/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0014_run_search_trgm
+0015_repo_debt_digest_enabled
diff --git a/products/visual_review/backend/models.py b/products/visual_review/backend/models.py
index 3eb30527e776..57094dc38e18 100644
--- a/products/visual_review/backend/models.py
+++ b/products/visual_review/backend/models.py
@@ -45,6 +45,9 @@ class Repo(ProductTeamModel):
# auto-approve rollout phases where comments would be noise.
enable_pr_comments = models.BooleanField(default=False)
+ # Off by default: the digest posts into other teams' Slack channels, so a repo opts in.
+ debt_digest_enabled = models.BooleanField(default=False, db_default=False)
+
# HMAC signing keys for baseline hash verification: {kid: secret_hex}
# Supports key rotation — new signatures use the latest key, verification
# accepts any valid kid. Auto-generated on first use.
diff --git a/products/visual_review/backend/presentation/serializers.py b/products/visual_review/backend/presentation/serializers.py
index 4f700b8d99c9..ed694d4e0a4b 100644
--- a/products/visual_review/backend/presentation/serializers.py
+++ b/products/visual_review/backend/presentation/serializers.py
@@ -207,6 +207,17 @@ class AddSnapshotsResultSerializer(DataclassSerializer):
class UpdateRepoInputSerializer(DataclassSerializer):
class Meta:
dataclass = UpdateRepoRequestInput
+ extra_kwargs = {
+ "enable_pr_comments": {
+ "help_text": "Post a pull request comment when a run finds visual changes to review."
+ },
+ "debt_digest_enabled": {
+ "help_text": (
+ "Post the visual review debt digest to the Slack channels of the teams that own the "
+ "snapshots. Off by default. The digest runs each weekday morning."
+ )
+ },
+ }
class ApproveSnapshotInputSerializer(DataclassSerializer):
diff --git a/products/visual_review/backend/presentation/views.py b/products/visual_review/backend/presentation/views.py
index 1d240db4137d..837eb7a4afd2 100644
--- a/products/visual_review/backend/presentation/views.py
+++ b/products/visual_review/backend/presentation/views.py
@@ -216,6 +216,7 @@ class RepoViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
repo_id=_parse_uuid(pk),
baseline_file_paths=body.baseline_file_paths,
enable_pr_comments=body.enable_pr_comments,
+ debt_digest_enabled=body.debt_digest_enabled,
)
try:
diff --git a/products/visual_review/backend/tests/logic/test_debt_digest.py b/products/visual_review/backend/tests/logic/test_debt_digest.py
index e4d8c4c9c489..d91fc37aa6e6 100644
--- a/products/visual_review/backend/tests/logic/test_debt_digest.py
+++ b/products/visual_review/backend/tests/logic/test_debt_digest.py
@@ -234,10 +234,14 @@ class TestRouting:
@pytest.mark.django_db(databases=PRODUCT_DATABASES)
class TestReposInScope:
- def test_every_repo_is_in_scope_whatever_team_owns_it(self, team) -> None:
+ def test_only_repos_that_opted_in_are_in_scope_whatever_team_owns_them(self, team) -> None:
mine = repos.create_repo(team_id=team.id, repo_external_id=77781, repo_full_name="org/mine")
other_team = Team.objects.create(organization=team.organization, name="other")
theirs = repos.create_repo(team_id=other_team.id, repo_external_id=77782, repo_full_name="org/theirs")
+ for repo in (mine, theirs):
+ repo.debt_digest_enabled = True
+ repo.save(update_fields=["debt_digest_enabled"])
+ repos.create_repo(team_id=team.id, repo_external_id=77783, repo_full_name="org/switched-off")
assert {(repo.team_id, repo.id) for repo in debt_digest.repos_in_scope()} == {
(mine.team_id, mine.id),
diff --git a/products/visual_review/backend/tests/test_api.py b/products/visual_review/backend/tests/test_api.py
index a94d4b0f0de8..575d8e2a6c8f 100644
--- a/products/visual_review/backend/tests/test_api.py
+++ b/products/visual_review/backend/tests/test_api.py
@@ -53,19 +53,22 @@ class TestProjectAPI:
names = {p.repo_full_name for p in result}
assert names == {"org/first", "org/second"}
- def test_update_repo_sets_baseline_paths(self, team):
+ def test_update_repo_sets_the_fields_it_is_given(self, team):
created = api.create_repo(team_id=team.id, repo_external_id=333, repo_full_name="org/test")
assert created.baseline_file_paths == {}
+ assert created.debt_digest_enabled is False
result = api.update_repo(
UpdateRepoInput(
repo_id=created.id,
baseline_file_paths={"storybook": ".storybook/snapshots.yml"},
+ debt_digest_enabled=True,
),
team_id=team.id,
)
assert result.baseline_file_paths == {"storybook": ".storybook/snapshots.yml"}
+ assert result.debt_digest_enabled is True
assert result.repo_full_name == "org/test" # unchanged
diff --git a/products/visual_review/backend/tests/test_presentation.py b/products/visual_review/backend/tests/test_presentation.py
index 5df766bfceef..a33aa4095566 100644
--- a/products/visual_review/backend/tests/test_presentation.py
+++ b/products/visual_review/backend/tests/test_presentation.py
@@ -54,6 +54,20 @@ class TestRepoViewSet(VisualReviewTeamScopedTestMixin, APIBaseTest):
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json()["repo_full_name"], "org/test")
+ def test_patch_repo_applies_every_setting_in_the_body(self):
+ repo = api.create_repo(team_id=self.team.id, repo_external_id=555, repo_full_name="org/settings")
+
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/visual_review/repos/{repo.id}/",
+ {"enable_pr_comments": True, "debt_digest_enabled": True},
+ format="json",
+ )
+
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ data = response.json()
+ self.assertTrue(data["enable_pr_comments"])
+ self.assertTrue(data["debt_digest_enabled"])
+
def test_retrieve_project_not_found(self):
import uuid
diff --git a/products/visual_review/backend/tests/test_tasks.py b/products/visual_review/backend/tests/test_tasks.py
index 664e76e86b9d..316e5064f94e 100644
--- a/products/visual_review/backend/tests/test_tasks.py
+++ b/products/visual_review/backend/tests/test_tasks.py
@@ -568,8 +568,13 @@ class TestDebtDigestTask(VisualReviewTeamScopedTestMixin, BaseTest):
# Nothing records what was sent, so an overlapping run would post every reminder twice.
assert send.call_count == 0
- def test_the_fan_out_gives_each_child_a_deadline(self) -> None:
- repo = Repo.objects.create(team_id=self.team.id, repo_external_id=55513, repo_full_name="org/fanned-out")
+ def test_the_fan_out_gives_each_child_a_deadline_and_skips_a_switched_off_repo(self) -> None:
+ repo = Repo.objects.create(
+ team_id=self.team.id, repo_external_id=55513, repo_full_name="org/fanned-out", debt_digest_enabled=True
+ )
+ switched_off = Repo.objects.create(
+ team_id=self.team.id, repo_external_id=55514, repo_full_name="org/switched-off"
+ )
with patch("products.visual_review.backend.tasks.tasks.send_visual_review_debt_digest.apply_async") as enqueue:
send_visual_review_debt_digests()
@@ -577,6 +582,7 @@ class TestDebtDigestTask(VisualReviewTeamScopedTestMixin, BaseTest):
# A child without a deadline lets a drained backlog post yesterday's digest next to today's.
enqueued = {(call.kwargs["args"], call.kwargs["expires"]) for call in enqueue.call_args_list}
assert ((repo.team_id, str(repo.id)), tasks._DEBT_DIGEST_EXPIRY_SECONDS) in enqueued
+ assert str(switched_off.id) not in {args[1] for args, _ in enqueued}
def test_the_scheduled_run_posts_rather_than_previews(self) -> None:
repo = Repo.objects.create(team_id=self.team.id, repo_external_id=55512, repo_full_name="org/scheduled")
diff --git a/products/visual_review/frontend/generated/api.schemas.ts b/products/visual_review/frontend/generated/api.schemas.ts
index dcf8b4cc2ea0..ac77f581bcc2 100644
--- a/products/visual_review/frontend/generated/api.schemas.ts
+++ b/products/visual_review/frontend/generated/api.schemas.ts
@@ -16,6 +16,7 @@ export interface RepoApi {
repo_full_name: string
baseline_file_paths: RepoApiBaselineFilePaths
enable_pr_comments: boolean
+ debt_digest_enabled: boolean
created_at: string
}
@@ -42,8 +43,16 @@ export type PatchedUpdateRepoRequestInputApiBaselineFilePaths = { [key: string]:
export interface PatchedUpdateRepoRequestInputApi {
/** @nullable */
baseline_file_paths?: PatchedUpdateRepoRequestInputApiBaselineFilePaths
- /** @nullable */
+ /**
+ * Post a pull request comment when a run finds visual changes to review.
+ * @nullable
+ */
enable_pr_comments?: boolean | null
+ /**
+ * Post the visual review debt digest to the Slack channels of the teams that own the snapshots. Off by default. The digest runs each weekday morning.
+ * @nullable
+ */
+ debt_digest_enabled?: boolean | null
}
export interface UserBasicInfoApi {
diff --git a/products/visual_review/frontend/generated/api.zod.ts b/products/visual_review/frontend/generated/api.zod.ts
index 57a4d4628cbb..9b3eedbe3068 100644
--- a/products/visual_review/frontend/generated/api.zod.ts
+++ b/products/visual_review/frontend/generated/api.zod.ts
@@ -22,7 +22,16 @@ export const VisualReviewReposCreateBody = /* @__PURE__ */ zod.object({
*/
export const VisualReviewReposPartialUpdateBody = /* @__PURE__ */ zod.object({
baseline_file_paths: zod.record(zod.string(), zod.string()).nullish(),
- enable_pr_comments: zod.boolean().nullish(),
+ enable_pr_comments: zod
+ .boolean()
+ .nullish()
+ .describe('Post a pull request comment when a run finds visual changes to review.'),
+ debt_digest_enabled: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'Post the visual review debt digest to the Slack channels of the teams that own the snapshots. Off by default. The digest runs each weekday morning.'
+ ),
})
/**
diff --git a/products/visual_review/frontend/scenes/VisualReviewFlakinessScene.stories.tsx b/products/visual_review/frontend/scenes/VisualReviewFlakinessScene.stories.tsx
index 5d99ff1e2dd3..fdffae5ed3a9 100644
--- a/products/visual_review/frontend/scenes/VisualReviewFlakinessScene.stories.tsx
+++ b/products/visual_review/frontend/scenes/VisualReviewFlakinessScene.stories.tsx
@@ -15,6 +15,7 @@ const repo: RepoApi = {
repo_full_name: 'PostHog/posthog',
baseline_file_paths: {},
enable_pr_comments: true,
+ debt_digest_enabled: false,
created_at: '2026-06-10T00:00:00Z',
}
diff --git a/products/visual_review/frontend/scenes/VisualReviewRunScene.stories.tsx b/products/visual_review/frontend/scenes/VisualReviewRunScene.stories.tsx
index 4a12f47f9a25..81279fac32f0 100644
--- a/products/visual_review/frontend/scenes/VisualReviewRunScene.stories.tsx
+++ b/products/visual_review/frontend/scenes/VisualReviewRunScene.stories.tsx
@@ -28,6 +28,7 @@ const repo: RepoApi = {
repo_full_name: 'PostHog/posthog',
baseline_file_paths: {},
enable_pr_comments: true,
+ debt_digest_enabled: false,
created_at: '2026-06-10T00:00:00Z',
}
diff --git a/products/visual_review/mcp/tools.yaml b/products/visual_review/mcp/tools.yaml
index 8d424346a8d1..73df95f606d6 100644
--- a/products/visual_review/mcp/tools.yaml
+++ b/products/visual_review/mcp/tools.yaml
@@ -94,7 +94,29 @@ tools:
feature_flag: visual-review
visual-review-repos-partial-update:
operation: visual_review_repos_partial_update
- enabled: false
+ enabled: true
+ scopes:
+ - visual_review:write
+ annotations:
+ readOnly: false
+ destructive: true
+ 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 runs Monday to Friday. `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.
+ param_overrides:
+ id:
+ description: The repo's UUID, from `visual-review-repos-list`.
+ aliases:
+ - repo_id
+ feature_flag: visual-review
visual-review-repos-quarantine-create:
operation: visual_review_repos_quarantine_create
enabled: false
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 4bac634e6140..d133d04db48b 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -12363,6 +12363,21 @@
},
"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 runs Monday to Friday. `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.",
+ "category": "Visual review",
+ "feature": "visual_review",
+ "summary": "Update visual review repo settings",
+ "title": "Update visual review repo settings",
+ "required_scopes": ["visual_review:write"],
+ "annotations": {
+ "destructiveHint": true,
+ "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.",
"category": "Visual review",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 9d21e2ec886c..e59f28875184 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -13008,6 +13008,21 @@
},
"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 runs Monday to Friday. `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.",
+ "category": "Visual review",
+ "feature": "visual_review",
+ "summary": "Update visual review repo settings",
+ "title": "Update visual review repo settings",
+ "required_scopes": ["visual_review:write"],
+ "annotations": {
+ "destructiveHint": true,
+ "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.",
"category": "Visual review",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 43da16201bd9..32ef58c141c1 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -58256,6 +58256,7 @@ export namespace Schemas {
repo_full_name: string;
baseline_file_paths: RepoBaselineFilePaths;
enable_pr_comments: boolean;
+ debt_digest_enabled: boolean;
created_at: string;
}
@@ -70963,8 +70964,16 @@ export namespace Schemas {
export interface PatchedUpdateRepoRequestInput {
/** @nullable */
baseline_file_paths?: PatchedUpdateRepoRequestInputBaselineFilePaths;
- /** @nullable */
+ /**
+ * Post a pull request comment when a run finds visual changes to review.
+ * @nullable
+ */
enable_pr_comments?: boolean | null;
+ /**
+ * Post the visual review debt digest to the Slack channels of the teams that own the snapshots. Off by default. The digest runs each weekday morning.
+ * @nullable
+ */
+ debt_digest_enabled?: boolean | null;
}
/**
diff --git a/services/mcp/src/generated/visual_review/api.ts b/services/mcp/src/generated/visual_review/api.ts
index 011c522e2824..4525871eb812 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 15 enabled ops
+ * PostHog API - MCP 16 enabled ops
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
@@ -36,6 +36,32 @@ export const VisualReviewReposRetrieveParams = () => zod.object({
),
})
+/**
+ * Update a repo's settings.
+ */
+export const VisualReviewReposPartialUpdateParams = () => 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\/."
+ ),
+})
+
+export const VisualReviewReposPartialUpdateBody = () => zod.object({
+ baseline_file_paths: zod.record(zod.string(), zod.string()).nullish(),
+ enable_pr_comments: zod
+ .boolean()
+ .nullish()
+ .describe('Post a pull request comment when a run finds visual changes to review.'),
+ debt_digest_enabled: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'Post the visual review debt digest to the Slack channels of the teams that own the snapshots. Off by default. The digest runs each weekday morning.'
+ ),
+})
+
/**
* Snapshots in a repo whose rendering cannot be trusted: those that failed the gate or were absorbed by a toleration on a recent default-branch run, and those under an active quarantine. Everything else is omitted, so this is far smaller than the baselines universe; `totals.tracked` gives the full denominator. Each entry carries the share of the last 7 days of default-branch runs that failed the gate (`hard_rate`) and the share a toleration absorbed (`soft_rate`), plus `headroom`, the fraction of the diff threshold its worst absorbed run leaves free. Capped at 2000 entries, which sets `truncated`. Filtering, faceting and search are done client-side; this endpoint takes no filter query params.
*/
diff --git a/services/mcp/src/tools/generated/visual_review.ts b/services/mcp/src/tools/generated/visual_review.ts
index 996b8a91bde7..648c425f8c89 100644
--- a/services/mcp/src/tools/generated/visual_review.ts
+++ b/services/mcp/src/tools/generated/visual_review.ts
@@ -133,6 +133,48 @@ const visualReviewReposList = (): ToolBase<
},
})
+const VisualReviewReposPartialUpdateSchema = () => {
+ const VisualReviewReposPartialUpdateBody = orvalSchemas.VisualReviewReposPartialUpdateBody()
+ const VisualReviewReposPartialUpdateParams = orvalSchemas.VisualReviewReposPartialUpdateParams()
+ return z.preprocess(
+ normalizeParamAliases({ id: ['repo_id'] }),
+ VisualReviewReposPartialUpdateParams.omit({ project_id: true })
+ .extend(VisualReviewReposPartialUpdateBody.shape)
+ .extend({
+ id: VisualReviewReposPartialUpdateParams.shape['id'].describe(
+ "The repo's UUID, from `visual-review-repos-list`."
+ ),
+ })
+ )
+}
+
+const visualReviewReposPartialUpdate = (): ToolBase<
+ ReturnType<typeof VisualReviewReposPartialUpdateSchema>,
+ Schemas.Repo
+> => ({
+ name: 'visual-review-repos-partial-update',
+ schema: VisualReviewReposPartialUpdateSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof VisualReviewReposPartialUpdateSchema>>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const body: Record<string, unknown> = {}
+ if (params.baseline_file_paths !== undefined) {
+ body['baseline_file_paths'] = params.baseline_file_paths
+ }
+ if (params.enable_pr_comments !== undefined) {
+ body['enable_pr_comments'] = params.enable_pr_comments
+ }
+ if (params.debt_digest_enabled !== undefined) {
+ body['debt_digest_enabled'] = params.debt_digest_enabled
+ }
+ const result = await context.api.request<Schemas.Repo>({
+ method: 'PATCH',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/visual_review/repos/${encodeURIComponent(String(params.id))}/`,
+ body,
+ })
+ return result
+ },
+})
+
const VisualReviewReposQuarantineListSchema = () => {
const VisualReviewReposQuarantineListParams = orvalSchemas.VisualReviewReposQuarantineListParams()
const VisualReviewReposQuarantineListQueryParams = orvalSchemas.VisualReviewReposQuarantineListQueryParams()
@@ -561,6 +603,7 @@ const visualReviewRunsToleratedHashesList = (): ToolBase<
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-list': visualReviewReposQuarantineList,
'visual-review-repos-retrieve': visualReviewReposRetrieve,
'visual-review-repos-runs-counts-retrieve': visualReviewReposRunsCountsRetrieve,