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): name repos by owner/name in URLs (#115554)

Julian Beze4d9c8a98ca2
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 8e68216e2a0e..544e3c4dc270 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -14491,33 +14491,33 @@ snapshots:
scenes-app-visual-review-flakiness--unstable--light:
hash: v1.k794b7964.ce4999b498ff455fedeeb554f5ea6cbaaed7b91b92f77b674e7fad59a79bcc60.epcReErfeQQrr2dQujDtIXAwrSGAbIf7OpXZ1m3xXe4
scenes-app-visual-review-run--clean-quarantined-stories--dark:
- hash: v1.k794b7964.453c5fceef7e5351174d1391762ed725663a12ff3f494a06744b4dcec0573fc1.EBH6vLSFPVFcutmHJ_MeoOgN_Wl-Ss5mwBy-U1ENPgE
+ hash: v1.k794b7964.8a2b36e8638fd30147c3d870e4ab65c70dda6449c3dbdb4165000806e91c1d50.i14DmWYdw5-cvI6PBh7QAdFwQA1umf_vSHgQ4uvgz9I
scenes-app-visual-review-run--clean-quarantined-stories--light:
- hash: v1.k794b7964.ebe90530f36ee954d553fc5d27edc7e0cf1c4237b1c66077210c6387b8d920e2.-SMSm-K-ZYPI1uNN8QpBGaEtKrhsQ11S9IwZ8gnD6PE
+ hash: v1.k794b7964.123f86747701954dffef57ffc1b25105bcae1e3c72d229e8edb5f47bb7e3349b.x1A2L1eKFND1lDqqcXn9HEaZidgICW5xsL8bKLPOxnM
scenes-app-visual-review-run--quarantined-snapshot-lifts-on-merge--dark:
- hash: v1.k794b7964.61cbf7191d25eb4bbe628b9bfd6fd7dce57a547fae68581be85a9f521e4e6ac4.A-q--iJVKmTtkol71YByFS0IgqVLQ5GH59AytaCDKhM
+ hash: v1.k794b7964.b0febf291695ed3a388484a0938db385c4011d5feac43350f38b905591ea1665.qYfoXIuDGhweXo-9--isDFr_mE6lq1w3iTNpGwlzEvI
scenes-app-visual-review-run--quarantined-snapshot-lifts-on-merge--light:
- hash: v1.k794b7964.3e199f340fd11e8d9a365cbe117fed44035841aa7b2caba0b928660c81113225.EAkTb5zAiucZZ6Z5SoU0aphNKQh5VqR04bpMY_1as0w
+ hash: v1.k794b7964.b1bae34c45793150d5e79f58dc091c5459a9a1c1f938457ef7878875740f523a.5SXHzII-W6aKoJjq6WIp5ZYESKFJ_SUT1JKKzxF-0BA
scenes-app-visual-review-run--ready-to-finalize--dark:
- hash: v1.k794b7964.2ddf6d3c5eea469705d81ec0489b029e21e3d06d119b0365ddebe1340677e69c.MPAF7Dn_bpbKyhuQ2l_aoj6czH6TKBlFE2nXSKVqx4I
+ hash: v1.k794b7964.469648c13c5f83718e559092f86041b7cfe06c96646bc571e125009c5b9626ee.BkQaqC0hbd4XsLh-2alyivv20DR0a3CM10BEMyhre8I
scenes-app-visual-review-run--ready-to-finalize--light:
- hash: v1.k794b7964.197e6fe1cc9dba0da720ef1e1cfc94b3601d775aa389e49230465a2b65797d47.Tqyss84UbEfq4Gra3v9eMtLs4zfONfl5fSfff9FlmZA
+ hash: v1.k794b7964.78e8e3d169ab737d5145be5eb7eb11d554f11cbb4e6fc2c53b08f4e2ea111803.x14eTb25_EfIwVgxs5fINuJFaajNiXaLtgt-rIC0l04
scenes-app-visual-review-run--removed-snapshot--dark:
- hash: v1.k794b7964.cf6e85f2cd90ce4e409779ef1bfbee5d10393bc479f41d3e50d03cba33693312.NmmpL2GTe2k2F-HE9fFlM5VWtpfPt8EZ5VuE3-JLE9c
+ hash: v1.k794b7964.7dfb31fbe84f000462b519f36720f5dde92b9bf88e1e2a8c1e2a40d2aa65007e.PdmwWF8RFe4aEWnBX2AWFxWzC_8_B1yEePiMV_p6kwY
scenes-app-visual-review-run--removed-snapshot--light:
- hash: v1.k794b7964.0a560a35b82eb383220ef16017363f6aed5f6fc9b376517753dc7de6bd80a0f5.EdWHF5M5586Q6V9-hmDTM_OfZHDiZiJ2Si2DtO3ijf8
+ hash: v1.k794b7964.63430839ab2dcc678bcb731b63e8309eb22da18cdc088d9e76372df704742507.i8q7G6r0hu6XACX2ruX0e7Wg8bc2CzdDPXt5ZAgKcsA
scenes-app-visual-review-run--tolerate-suggests-quarantine--dark:
hash: v1.k794b7964.01b906bdb8448973bb5a655f0ea96dbf42ba0def73d179ce3f1c2779d603d1cd.ZVbpVkiu1tofZS8NcQ8DpGM57DqjoiC5vDWQnPKEscw
scenes-app-visual-review-run--tolerate-suggests-quarantine--light:
hash: v1.k794b7964.423d5d2ad0d7ef00ba976f5455835ba0c518c8d7c86a7a2a359c8af4b1eab648.V47tBu61Pg3UnMCcefNn1D4VzvUXv5-qQU8_qkyk3_k
scenes-app-visual-review-run--tracking-only-master-run--dark:
- hash: v1.k794b7964.e59e3231d8f3819b93e106857cf4facc9f1b0869ab5e811ac34e426d71231122.U_WoHysJq5Ejuf0w4Y3p2DvGbfug2wbN4bpwLRRmoRY
+ hash: v1.k794b7964.9a175931f578d780ac935d02c50561703dfcff8b0b56d5f44e6c1a4ba2b63efd.iE8sIdTT6n3aecTxe8Zz_tyFNKwKTe2IWGTB59tGTtU
scenes-app-visual-review-run--tracking-only-master-run--light:
- hash: v1.k794b7964.9df045cf6656b4a3368311725e6a2ebe7bc219a623f2261c4d413a1de46dfe46.VisEM7d1gjJ-3JYkN8dDNK0_aerTjYCZz0q6x9DA0KE
+ hash: v1.k794b7964.d7be6b0c43071afbc3ed01c81b4c1e18d8bce85bdb3e4cffb4d073167fb85ce7.WpQwDYvjm1SkaTMGPZYT6vDx3hvUSpljplnsEAIBjaU
scenes-app-visual-review-run--tracking-only-merge-queue-run--dark:
- hash: v1.k794b7964.263baaa86027f58e5dc7a282d2142703e8761e4a5048d0438aeea7f36c2a13cb.mhocFfJnwA7n9J-yj1jIvCVUZPHlXw5dxn-mRhHnDY8
+ hash: v1.k794b7964.3d5e3f4a31aecb360cadbd144ace71c2c8568a68b4b498ea1541028f44c34729.AVLOsZEY1wUK9L27wjL4T4nJeGRQwPwuIVcJgpMBjro
scenes-app-visual-review-run--tracking-only-merge-queue-run--light:
- hash: v1.k794b7964.e43050321d087de05b71ba56cc2324af5fb9e593b2cc47e43dd7028b6a8333b9.cU1JJMaO53XDwKdykPxvEAiRWiyJloyITpU5-Ctg4N8
+ hash: v1.k794b7964.a3a1aaa87471fb8e9992f64e51be9a51aa12c9be25391f26e77bf3e591cbb4b5.OxPRm-RWdZ9Cyq9v2B8-XC0AF2OxDxyftKHtsMx0WZ0
scenes-app-web-analytics--web-analytics-dashboard--dark:
hash: v1.k794b7964.d633e702e43e79c58f10610a823818f7d79717d49a670e6c85c6410d894b7d58.cegK9GTI0OfzEn0BkTrnAKcM5Q6u1KpT53hyljMVPBU
scenes-app-web-analytics--web-analytics-dashboard--light:
diff --git a/frontend/src/products.tsx b/frontend/src/products.tsx
index adfd6ae6f48b..ae84219c07e1 100644
--- a/frontend/src/products.tsx
+++ b/frontend/src/products.tsx
@@ -310,14 +310,25 @@ export const productRoutes: Record<string, [string, string]> = {
'/tracing/retention-rules/:id': ['TracingRetentionDetail', 'tracingRetentionDetail'],
'/visual_review': ['VisualReviewIndex', 'visualReviewIndex'],
'/visual_review/settings': ['VisualReviewSettings', 'visualReviewSettings'],
- '/visual_review/runs/:runId': ['VisualReviewRun', 'visualReviewRun'],
- '/visual_review/repos/:repoId/runs': ['VisualReviewRuns', 'visualReviewRepoRuns'],
- '/visual_review/repos/:repoId/snapshots': ['VisualReviewSnapshotOverview', 'visualReviewSnapshotOverview'],
- '/visual_review/repos/:repoId/flakiness': ['VisualReviewFlakiness', 'visualReviewFlakiness'],
- '/visual_review/repos/:repoId/:runType/snapshots/:identifier': [
+ '/visual_review/repos/:repoOwner/:repoName/runs': ['VisualReviewRuns', 'visualReviewRepoRuns'],
+ '/visual_review/repos/:repoOwner/:repoName/runs/:runId': ['VisualReviewRun', 'visualReviewRun'],
+ '/visual_review/repos/:repoOwner/:repoName/snapshots': [
+ 'VisualReviewSnapshotOverview',
+ 'visualReviewSnapshotOverview',
+ ],
+ '/visual_review/repos/:repoOwner/:repoName/flakiness': ['VisualReviewFlakiness', 'visualReviewFlakiness'],
+ '/visual_review/repos/:repoOwner/:repoName/:runType/snapshots/:identifier': [
'VisualReviewSnapshotHistory',
'visualReviewSnapshotHistory',
],
+ '/visual_review/runs/:runId': ['VisualReviewIndex', 'visualReviewLegacyRun'],
+ '/visual_review/repos/:repoId/runs': ['VisualReviewIndex', 'visualReviewLegacyRepoRuns'],
+ '/visual_review/repos/:repoId/snapshots': ['VisualReviewIndex', 'visualReviewLegacySnapshotOverview'],
+ '/visual_review/repos/:repoId/flakiness': ['VisualReviewIndex', 'visualReviewLegacyFlakiness'],
+ '/visual_review/repos/:repoId/:runType/snapshots/:identifier': [
+ 'VisualReviewIndex',
+ 'visualReviewLegacySnapshotHistory',
+ ],
'/etl': ['PipelineOverview', 'pipelineOverview'],
'/web/content-autopilot': ['WebAnalytics', 'webAnalyticsContentAutopilot'],
'/heatmaps': ['Heatmaps', 'heatmaps'],
@@ -1844,11 +1855,16 @@ export const productUrls = {
visualReviewRuns: (): string => '/visual_review',
visualReviewSettings: (): string => '/visual_review/settings',
visualReviewRun: (runId: string): string => `/visual_review/runs/${runId}`,
- visualReviewRepoRuns: (repoId: string): string => `/visual_review/repos/${repoId}/runs`,
- visualReviewSnapshotOverview: (repoId: string): string => `/visual_review/repos/${repoId}/snapshots`,
- visualReviewFlakiness: (repoId: string): string => `/visual_review/repos/${repoId}/flakiness`,
- visualReviewSnapshotHistory: (repoId: string, runType: string, identifier: string): string =>
- `/visual_review/repos/${repoId}/${encodeURIComponent(runType)}/snapshots/${encodeURIComponent(identifier)}`,
+ visualReviewRepoRun: (repoOwner: string, repoName: string, runId: string): string =>
+ `/visual_review/repos/${encodeURIComponent(repoOwner)}/${encodeURIComponent(repoName)}/runs/${runId}`,
+ visualReviewRepoRuns: (repoOwner: string, repoName: string): string =>
+ `/visual_review/repos/${encodeURIComponent(repoOwner)}/${encodeURIComponent(repoName)}/runs`,
+ visualReviewSnapshotOverview: (repoOwner: string, repoName: string): string =>
+ `/visual_review/repos/${encodeURIComponent(repoOwner)}/${encodeURIComponent(repoName)}/snapshots`,
+ visualReviewFlakiness: (repoOwner: string, repoName: string): string =>
+ `/visual_review/repos/${encodeURIComponent(repoOwner)}/${encodeURIComponent(repoName)}/flakiness`,
+ visualReviewSnapshotHistory: (repoOwner: string, repoName: string, runType: string, identifier: string): string =>
+ `/visual_review/repos/${encodeURIComponent(repoOwner)}/${encodeURIComponent(repoName)}/${encodeURIComponent(runType)}/snapshots/${encodeURIComponent(identifier)}`,
etlOverview: (): string => '/etl',
webAnalytics: (): string => `/web`,
webAnalyticsWebVitals: (): string => `/web/web-vitals`,
diff --git a/products/visual_review/backend/logic/app_urls.py b/products/visual_review/backend/logic/app_urls.py
new file mode 100644
index 000000000000..c73136fa359c
--- /dev/null
+++ b/products/visual_review/backend/logic/app_urls.py
@@ -0,0 +1,28 @@
+"""Links into the visual review app for PR comments, check runs and Slack messages.
+
+These links outlive the message that carries them, but `repo_full_name` changes when GitHub renames or transfers
+the repo. So a posted link names the repo and the run by id. The app forwards each id path to its owner/name page.
+"""
+
+from __future__ import annotations
+
+from django.conf import settings
+
+from ..models import Repo, Run, RunSnapshot
+
+
+def _app_url(repo: Repo) -> str:
+ return f"{settings.SITE_URL}/project/{repo.team_id}/visual_review"
+
+
+def repo_url(repo: Repo) -> str:
+ return f"{_app_url(repo)}/repos/{repo.id}"
+
+
+def run_url(run: Run, repo: Repo) -> str:
+ return f"{_app_url(repo)}/runs/{run.id}"
+
+
+def snapshot_url(run: Run, repo: Repo, snapshot: RunSnapshot) -> str:
+ """Deep link straight to a single snapshot on the run page."""
+ return f"{run_url(run, repo)}#snapshot={snapshot.id}"
diff --git a/products/visual_review/backend/logic/ci_status.py b/products/visual_review/backend/logic/ci_status.py
index cdffb0608603..54f3a8aaf641 100644
--- a/products/visual_review/backend/logic/ci_status.py
+++ b/products/visual_review/backend/logic/ci_status.py
@@ -6,7 +6,7 @@ import structlog
from ..facade.enums import RunPurpose
from ..models import Repo, Run
-from . import comment_markdown, github_api
+from . import app_urls, github_api
logger = structlog.get_logger(__name__)
@@ -129,7 +129,7 @@ def _post_commit_status(
logger.debug("visual_review.status_check_skipped", run_id=str(run.id), reason="no_github_integration")
return
- target_url = comment_markdown._run_url(run, repo)
+ target_url = app_urls.run_url(run, repo)
try:
response = github.api_request(
diff --git a/products/visual_review/backend/logic/comment_markdown.py b/products/visual_review/backend/logic/comment_markdown.py
index 2b758bb2ccd2..9720ea1322c8 100644
--- a/products/visual_review/backend/logic/comment_markdown.py
+++ b/products/visual_review/backend/logic/comment_markdown.py
@@ -7,13 +7,13 @@ import html
from collections import Counter
from dataclasses import dataclass
-from django.conf import settings
from django.db import models as db_models
from ..db import READER_DB
from ..facade.enums import ReviewState, SnapshotResult
from ..models import Artifact, Repo, Run, RunSnapshot
from ..storage import ArtifactStorage
+from . import app_urls
def _format_change_counts(changed: int, new: int, removed: int) -> str:
@@ -73,16 +73,6 @@ def _comment_image_url(repo: Repo, artifact: Artifact | None) -> str | None:
_TABLE_BREAKING_CHARS_RE = re.compile(r"[\x00-\x1f\x7f]")
-def _run_url(run: Run, repo: Repo) -> str:
- """Link to the run page in PostHog."""
- return f"{settings.SITE_URL}/project/{repo.team_id}/visual_review/runs/{run.id}"
-
-
-def _snapshot_url(run: Run, repo: Repo, snapshot: RunSnapshot) -> str:
- """Deep link straight to a single snapshot on the run page."""
- return f"{_run_url(run, repo)}?snapshot={snapshot.id}"
-
-
def _snapshot_name_cell(identifier: str, suffix: str = "") -> str:
"""Render a snapshot identifier as a single-line table cell (code span, pipe-safe).
@@ -99,7 +89,7 @@ def _snapshot_name_cell(identifier: str, suffix: str = "") -> str:
def _snapshot_link_cell(run: Run, repo: Repo, snapshot: RunSnapshot, suffix: str = "") -> str:
"""Snapshot identifier linked to its deep link on the run page, so a reviewer can jump
straight to that snapshot rather than the run as a whole."""
- return f"[{_snapshot_name_cell(snapshot.identifier)}]({_snapshot_url(run, repo, snapshot)}){suffix}"
+ return f"[{_snapshot_name_cell(snapshot.identifier)}]({app_urls.snapshot_url(run, repo, snapshot)}){suffix}"
def _image_cell(url: str | None, alt: str) -> str:
@@ -189,7 +179,7 @@ def _build_snapshot_image_tables(run: Run, repo: Repo) -> str:
sections = [table(heading, rows) for heading, rows in (("Changed", changed_rows), ("New", new_rows)) if rows]
if shown < total:
- sections.append(f"…and {total - shown} more — [view all in PostHog]({_run_url(run, repo)}).")
+ sections.append(f"…and {total - shown} more — [view all in PostHog]({app_urls.run_url(run, repo)}).")
return "\n\n".join(sections)
@@ -206,7 +196,7 @@ def _build_review_prompt_body(run: Run, repo: Repo) -> str:
"""Build the markdown body of the PR comment that asks for a visual review."""
return (
"👋 **Visual changes detected** for this PR.\n\n"
- f"[Review and approve in PostHog Visual Review]({_run_url(run, repo)})\n\n"
+ f"[Review and approve in PostHog Visual Review]({app_urls.run_url(run, repo)})\n\n"
"If these changes are unexpected, they may be caused by a flaky test or a "
"broken snapshot on master. Don't approve — rerun the job or wait for a fix.\n\n"
f"{_EXTENSION_FOOTER}"
@@ -252,7 +242,7 @@ def _build_approval_comment_body(run: Run, repo: Repo, approver: _Approver | Non
sections = [
f"✅ **Visual changes approved** by {approver_text}{sha_text}.",
- f"[View this run in PostHog]({_run_url(run, repo)})",
+ f"[View this run in PostHog]({app_urls.run_url(run, repo)})",
]
if summary:
sections.append(f"{summary}.")
diff --git a/products/visual_review/backend/logic/debt_digest.py b/products/visual_review/backend/logic/debt_digest.py
index 829623440bcd..62f22df1f045 100644
--- a/products/visual_review/backend/logic/debt_digest.py
+++ b/products/visual_review/backend/logic/debt_digest.py
@@ -44,7 +44,6 @@ from enum import StrEnum
from typing import Any
from urllib.parse import quote
-from django.conf import settings
from django.utils import timezone
import structlog
@@ -75,7 +74,7 @@ from posthog.utils import human_list, pluralize
from ..facade.contracts import FLAKINESS_EXPIRY_SOON_DAYS, TOLERATION_PILEUP_WINDOW_DAYS
from ..facade.enums import RunType
from ..models import QuarantinedIdentifier, Repo, Run
-from . import quarantine, run_queries, story_index, team_channels, toleration
+from . import app_urls, quarantine, run_queries, story_index, team_channels, toleration
from .team_channels import SlackMessage
logger = structlog.get_logger(__name__)
@@ -243,19 +242,16 @@ class Post:
def _snapshot_url(repo: Repo, run_type: str, identifier: str) -> str:
- return (
- f"{settings.SITE_URL}/project/{repo.team_id}/visual_review/repos/{repo.id}"
- f"/{quote(run_type, safe='')}/snapshots/{quote(identifier, safe='')}"
- )
+ return f"{app_urls.repo_url(repo)}/{quote(run_type, safe='')}/snapshots/{quote(identifier, safe='')}"
def _repo_snapshots_url(repo: Repo) -> str:
"""The repo's snapshot list. It names no snapshot, so its length does not follow the identifier."""
- return f"{settings.SITE_URL}/project/{repo.team_id}/visual_review/repos/{repo.id}/snapshots"
+ return f"{app_urls.repo_url(repo)}/snapshots"
def _repo_flakiness_url(repo: Repo) -> str:
- return f"{settings.SITE_URL}/project/{repo.team_id}/visual_review/repos/{repo.id}/flakiness"
+ return f"{app_urls.repo_url(repo)}/flakiness"
def _quarantined_story_url(repo: Repo, story: str) -> str:
diff --git a/products/visual_review/backend/management/commands/seed_snapshot_history.py b/products/visual_review/backend/management/commands/seed_snapshot_history.py
index 3f34ab9a6959..b98f9ec79844 100644
--- a/products/visual_review/backend/management/commands/seed_snapshot_history.py
+++ b/products/visual_review/backend/management/commands/seed_snapshot_history.py
@@ -166,7 +166,7 @@ class Command(BaseCommand):
self.stdout.write(
self.style.SUCCESS(
f"Seeded {n} runs × 2 themes for {stem} on repo {repo.repo_full_name} ({run_type})\n"
- f"Light: /visual_review/repos/{repo.id}/{run_type}/snapshots/{stem}--light\n"
- f"Dark: /visual_review/repos/{repo.id}/{run_type}/snapshots/{stem}--dark"
+ f"Light: /visual_review/repos/{repo.repo_full_name}/{run_type}/snapshots/{stem}--light\n"
+ f"Dark: /visual_review/repos/{repo.repo_full_name}/{run_type}/snapshots/{stem}--dark"
)
)
diff --git a/products/visual_review/backend/tests/logic/test_comments.py b/products/visual_review/backend/tests/logic/test_comments.py
index 2236b4017498..f0cd2118e4c3 100644
--- a/products/visual_review/backend/tests/logic/test_comments.py
+++ b/products/visual_review/backend/tests/logic/test_comments.py
@@ -2,6 +2,7 @@
import pytest
+from django.conf import settings
from django.db.models import F
from parameterized import parameterized
@@ -403,9 +404,9 @@ class TestApprovalComment:
body = comment_markdown._build_approval_comment_body(run_with_artifacts, repo, None, add_images=True)
- # Each snapshot name links straight to its deep link on the run page
changed = run_with_artifacts.snapshots.get(identifier="Login/Form")
- assert f"[`Login/Form`]({comment_markdown._run_url(run_with_artifacts, repo)}?snapshot={changed.id})" in body
+ deep_link = f"{settings.SITE_URL}/project/{repo.team_id}/visual_review/runs/{run_with_artifacts.id}#snapshot={changed.id}"
+ assert f"[`Login/Form`]({deep_link})" in body
def test_build_approval_comment_body_caps_at_eight_and_links_out(self, repo, mocker):
mocker.patch.object(comment_markdown, "ArtifactStorage", self._fake_storage())
diff --git a/products/visual_review/frontend/components/RepoSwitcher.tsx b/products/visual_review/frontend/components/RepoSwitcher.tsx
index f2364ba0890a..8c94925dcdb7 100644
--- a/products/visual_review/frontend/components/RepoSwitcher.tsx
+++ b/products/visual_review/frontend/components/RepoSwitcher.tsx
@@ -4,26 +4,28 @@ import { IconChevronDown } from '@posthog/icons'
import { LemonButton } from '@posthog/lemon-ui'
import { LemonMenu } from 'lib/lemon-ui/LemonMenu/LemonMenu'
+import { urls } from 'scenes/urls'
import type { RepoApi } from '../generated/api.schemas'
+import { splitRepoFullName } from '../lib/repoPaths'
import { visualReviewRepoLogic } from '../scenes/visualReviewRepoLogic'
import type { VisualReviewTabKey } from './VisualReviewTabs'
interface RepoSwitcherProps {
- repoId: string
- // Where to land on the other repo — preserves the user's current tab so
- // switching from Snapshots on repo A goes to Snapshots on repo B.
+ repoFullName: string
+ // Where to land on the other repo. It preserves the user's current tab, so
+ // switching from Snapshots on repo A goes to Snapshots on repo B. A detail page passes the tab that owns it.
activeTab: VisualReviewTabKey
}
-const TAB_TO_PATH: Record<VisualReviewTabKey, (repoId: string) => string> = {
- runs: (repoId) => `/visual_review/repos/${repoId}/runs`,
- snapshots: (repoId) => `/visual_review/repos/${repoId}/snapshots`,
- flakiness: (repoId) => `/visual_review/repos/${repoId}/flakiness`,
+const TAB_TO_PATH: Record<VisualReviewTabKey, (repoFullName: string) => string> = {
+ runs: (repoFullName) => urls.visualReviewRepoRuns(...splitRepoFullName(repoFullName)),
+ snapshots: (repoFullName) => urls.visualReviewSnapshotOverview(...splitRepoFullName(repoFullName)),
+ flakiness: (repoFullName) => urls.visualReviewFlakiness(...splitRepoFullName(repoFullName)),
}
-export function RepoSwitcher({ repoId, activeTab }: RepoSwitcherProps): JSX.Element | null {
- const { repo, otherRepos } = useValues(visualReviewRepoLogic({ repoId }))
+export function RepoSwitcher({ repoFullName, activeTab }: RepoSwitcherProps): JSX.Element | null {
+ const { otherRepos } = useValues(visualReviewRepoLogic({ repoFullName }))
if (otherRepos.length === 0) {
return null
@@ -31,13 +33,18 @@ export function RepoSwitcher({ repoId, activeTab }: RepoSwitcherProps): JSX.Elem
const items = otherRepos.map((r: RepoApi) => ({
label: r.repo_full_name,
- to: TAB_TO_PATH[activeTab](r.id),
+ to: TAB_TO_PATH[activeTab](r.repo_full_name),
}))
return (
<LemonMenu items={items}>
- <LemonButton type="secondary" size="small" sideIcon={<IconChevronDown />}>
- {repo?.repo_full_name ?? 'Switch repo'}
+ <LemonButton
+ type="secondary"
+ size="small"
+ sideIcon={<IconChevronDown />}
+ data-attr="visual-review-repo-switcher"
+ >
+ Switch repository
</LemonButton>
</LemonMenu>
)
diff --git a/products/visual_review/frontend/components/SnapshotCard.tsx b/products/visual_review/frontend/components/SnapshotCard.tsx
index 719a149a6a27..207c5f4d3221 100644
--- a/products/visual_review/frontend/components/SnapshotCard.tsx
+++ b/products/visual_review/frontend/components/SnapshotCard.tsx
@@ -9,6 +9,7 @@ import { urls } from 'scenes/urls'
import type { BaselineEntryApi, BaselineQuarantineSummaryApi } from '../generated/api.schemas'
import { parseArea, parseTheme } from '../lib/parseIdentifier'
+import { splitRepoFullName } from '../lib/repoPaths'
// Drift is shown as a percentage with one decimal — anything less is sub-pixel
// noise and not actionable; anything more on a thumbnail-sized card is illegible.
@@ -85,11 +86,11 @@ const DRIFT_WARNING_THRESHOLD_PCT = 1
export const RECENT_DRIFT_WINDOW = 10
export function SnapshotCard({
- repoId,
+ repoFullName,
entry,
thumbnailBasePath,
}: {
- repoId: string
+ repoFullName: string
entry: BaselineEntryApi
thumbnailBasePath: string | null
}): JSX.Element {
@@ -106,7 +107,7 @@ export function SnapshotCard({
thumbnailBasePath && entry.thumbnail_hash
? `${thumbnailBasePath}/${encodeURIComponent(entry.identifier)}/`
: null
- const href = urls.visualReviewSnapshotHistory(repoId, entry.run_type, entry.identifier)
+ const href = urls.visualReviewSnapshotHistory(...splitRepoFullName(repoFullName), entry.run_type, entry.identifier)
const hasMeta = driftVisible || tolerateCount > 0 || variantCount > 0 || entry.baseline_change_count > 0
const quarantine = entry.quarantine ?? null
diff --git a/products/visual_review/frontend/components/SnapshotDiffViewer.tsx b/products/visual_review/frontend/components/SnapshotDiffViewer.tsx
index 9839dd9d228d..6b7c7aa27ca3 100644
--- a/products/visual_review/frontend/components/SnapshotDiffViewer.tsx
+++ b/products/visual_review/frontend/components/SnapshotDiffViewer.tsx
@@ -17,6 +17,7 @@ import type {
ToleratedHashEntryApi,
} from '../generated/api.schemas'
import { QUARANTINE_NUDGE_WINDOW_DAYS, type RecentTolerations, shouldSuggestQuarantine } from '../lib/quarantineNudge'
+import { splitRepoFullName } from '../lib/repoPaths'
import { visualReviewPreferencesLogic } from '../scenes/visualReviewPreferencesLogic'
import { QuarantineAction } from './QuarantineAction'
import { QuarantineLiftOnMerge } from './QuarantineLiftOnMerge'
@@ -87,7 +88,6 @@ interface SnapshotDiffViewerProps {
onCancelLiftOnMerge?: (requestId: string) => void
commitSha?: string
prNumber?: number | null
- repoId?: string | null
repoFullName?: string | null
runType?: string
githubRunId?: string | null
@@ -116,7 +116,6 @@ export function SnapshotDiffViewer({
onCancelLiftOnMerge,
commitSha,
prNumber,
- repoId,
repoFullName,
runType,
githubRunId,
@@ -530,9 +529,13 @@ export function SnapshotDiffViewer({
<h4 className="text-xs font-semibold text-muted mb-2">Identifier</h4>
<div className="space-y-2">
<div className="text-xs">
- {repoId && runType ? (
+ {repoFullName && runType ? (
<Link
- to={urls.visualReviewSnapshotHistory(repoId, runType, snapshot.identifier)}
+ to={urls.visualReviewSnapshotHistory(
+ ...splitRepoFullName(repoFullName),
+ runType,
+ snapshot.identifier
+ )}
className="font-mono text-default break-all"
title="View history"
>
@@ -559,9 +562,13 @@ export function SnapshotDiffViewer({
{snapshot.baseline_artifact?.content_hash && (
<div className="flex items-center justify-between text-xs">
<span className="text-muted">Before</span>
- {repoId && runType ? (
+ {repoFullName && runType ? (
<Link
- to={urls.visualReviewSnapshotHistory(repoId, runType, snapshot.identifier)}
+ to={urls.visualReviewSnapshotHistory(
+ ...splitRepoFullName(repoFullName),
+ runType,
+ snapshot.identifier
+ )}
className="font-mono"
title="View history"
>
@@ -577,9 +584,13 @@ export function SnapshotDiffViewer({
{snapshot.current_artifact?.content_hash && (
<div className="flex items-center justify-between text-xs">
<span className="text-muted">After</span>
- {repoId && runType ? (
+ {repoFullName && runType ? (
<Link
- to={urls.visualReviewSnapshotHistory(repoId, runType, snapshot.identifier)}
+ to={urls.visualReviewSnapshotHistory(
+ ...splitRepoFullName(repoFullName),
+ runType,
+ snapshot.identifier
+ )}
className="font-mono"
title="View history"
>
@@ -592,10 +603,14 @@ export function SnapshotDiffViewer({
)}
</div>
)}
- {repoId && runType && (
+ {repoFullName && runType && (
<div className="pt-1">
<Link
- to={urls.visualReviewSnapshotHistory(repoId, runType, snapshot.identifier)}
+ to={urls.visualReviewSnapshotHistory(
+ ...splitRepoFullName(repoFullName),
+ runType,
+ snapshot.identifier
+ )}
className="text-xs"
>
View history →
diff --git a/products/visual_review/frontend/components/VisualReviewSceneTitle.tsx b/products/visual_review/frontend/components/VisualReviewSceneTitle.tsx
new file mode 100644
index 000000000000..975213508653
--- /dev/null
+++ b/products/visual_review/frontend/components/VisualReviewSceneTitle.tsx
@@ -0,0 +1,29 @@
+import { useValues } from 'kea'
+
+import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
+
+import { visualReviewRepoLogic } from '../scenes/visualReviewRepoLogic'
+import { RepoSwitcher } from './RepoSwitcher'
+import type { VisualReviewTabKey } from './VisualReviewTabs'
+
+export interface VisualReviewSceneTitleProps {
+ /** The repository named in the URL. The title shows the stored spelling once the repository loads. */
+ repoFullName: string
+ /** The tab that owns this page. Switching repository lands on this tab in the other repository. */
+ activeTab: VisualReviewTabKey
+ actions?: JSX.Element
+}
+
+/** The title every repository page shares: the repository it shows, with the switch button beside it.
+ * The breadcrumbs above carry the product name, and a page about one run or snapshot names it in its own trail. */
+export function VisualReviewSceneTitle({ repoFullName, activeTab, actions }: VisualReviewSceneTitleProps): JSX.Element {
+ const { repo } = useValues(visualReviewRepoLogic({ repoFullName }))
+ return (
+ <SceneTitleSection
+ name={repo?.repo_full_name ?? repoFullName}
+ nameSuffix={<RepoSwitcher repoFullName={repoFullName} activeTab={activeTab} />}
+ resourceType={{ type: 'visual_review' }}
+ actions={actions}
+ />
+ )
+}
diff --git a/products/visual_review/frontend/components/VisualReviewTabs.tsx b/products/visual_review/frontend/components/VisualReviewTabs.tsx
index 17ed46ae605a..591c76022de1 100644
--- a/products/visual_review/frontend/components/VisualReviewTabs.tsx
+++ b/products/visual_review/frontend/components/VisualReviewTabs.tsx
@@ -1,19 +1,21 @@
import { LemonTabs } from 'lib/lemon-ui/LemonTabs'
import { urls } from 'scenes/urls'
+import { splitRepoFullName } from '../lib/repoPaths'
+
export type VisualReviewTabKey = 'runs' | 'snapshots' | 'flakiness'
-// Top-level tab strip for a repo workspace. Both tabs are repo-scoped and
-// share the same `:repoId` segment, so this component is purely
+// Top-level tab strip for a repo workspace. All tabs are repo-scoped and
+// share the same owner/name segments, so this component is purely
// presentational — the parent scene already knows which repo it's in.
// Settings stays out of this strip: it's a gear button in the scene's header
// actions instead, matching how other products surface team-wide settings.
export function VisualReviewTabs({
activeKey,
- repoId,
+ repoFullName,
}: {
activeKey: VisualReviewTabKey
- repoId: string
+ repoFullName: string
}): JSX.Element {
return (
<LemonTabs
@@ -23,17 +25,17 @@ export function VisualReviewTabs({
{
key: 'runs' satisfies VisualReviewTabKey,
label: 'Runs',
- link: urls.visualReviewRepoRuns(repoId),
+ link: urls.visualReviewRepoRuns(...splitRepoFullName(repoFullName)),
},
{
key: 'snapshots' satisfies VisualReviewTabKey,
label: 'Snapshots',
- link: urls.visualReviewSnapshotOverview(repoId),
+ link: urls.visualReviewSnapshotOverview(...splitRepoFullName(repoFullName)),
},
{
key: 'flakiness' satisfies VisualReviewTabKey,
label: 'Flakiness',
- link: urls.visualReviewFlakiness(repoId),
+ link: urls.visualReviewFlakiness(...splitRepoFullName(repoFullName)),
},
]}
/>
diff --git a/products/visual_review/frontend/components/VisualReviewTrail.tsx b/products/visual_review/frontend/components/VisualReviewTrail.tsx
new file mode 100644
index 000000000000..7ff415ca7234
--- /dev/null
+++ b/products/visual_review/frontend/components/VisualReviewTrail.tsx
@@ -0,0 +1,28 @@
+import { Fragment } from 'react'
+
+import { Link } from '@posthog/lemon-ui'
+
+export interface VisualReviewTrailCrumb {
+ label: string
+ to?: string
+}
+
+/** The in-page trail from the list tab to the entity on a detail page (Runs › branch). The title names the repository. */
+export function VisualReviewTrail({ crumbs }: { crumbs: VisualReviewTrailCrumb[] }): JSX.Element {
+ return (
+ <div className="flex flex-wrap items-center gap-2 min-w-0">
+ {crumbs.map((crumb, index) => (
+ <Fragment key={crumb.label}>
+ {index > 0 && <span className="text-xs text-tertiary">›</span>}
+ {crumb.to ? (
+ <Link to={crumb.to} className="text-[13px] font-medium">
+ {crumb.label}
+ </Link>
+ ) : (
+ <span className="text-[13px] font-semibold break-all">{crumb.label}</span>
+ )}
+ </Fragment>
+ ))}
+ </div>
+ )
+}
diff --git a/products/visual_review/frontend/lib/forwardUrls.test.ts b/products/visual_review/frontend/lib/forwardUrls.test.ts
new file mode 100644
index 000000000000..520f310c3590
--- /dev/null
+++ b/products/visual_review/frontend/lib/forwardUrls.test.ts
@@ -0,0 +1,89 @@
+import type { RepoApi } from '../generated/api.schemas'
+import { ForwardUrl, LegacyRoute, legacyForwardUrl, pickLandingRepo } from './forwardUrls'
+
+function makeRepo(id: string, repoFullName: string): RepoApi {
+ return {
+ id,
+ team_id: 1,
+ repo_external_id: 1,
+ repo_full_name: repoFullName,
+ baseline_file_paths: {},
+ enable_pr_comments: true,
+ debt_digest_enabled: false,
+ created_at: '2026-01-01T00:00:00Z',
+ }
+}
+
+describe('forwardUrls', () => {
+ it.each<{
+ name: string
+ route: LegacyRoute
+ search: Record<string, any>
+ hash: Record<string, any>
+ expected: ForwardUrl
+ }>([
+ {
+ name: 'a repo page keeps its filters',
+ route: { kind: 'repoPage', repoId: 'uuid', page: 'flakiness' },
+ search: {},
+ hash: { preset: 'broken' },
+ expected: {
+ path: '/visual_review/repos/PostHog/posthog/flakiness',
+ searchParams: {},
+ hashParams: { preset: 'broken' },
+ },
+ },
+ {
+ name: 'a snapshot history page encodes its segments',
+ route: { kind: 'snapshotHistory', repoId: 'uuid', runType: 'storybook', identifier: 'scenes/app--light' },
+ search: {},
+ hash: {},
+ expected: {
+ path: '/visual_review/repos/PostHog/posthog/storybook/snapshots/scenes%2Fapp--light',
+ searchParams: {},
+ hashParams: {},
+ },
+ },
+ {
+ name: 'an old PR comment link moves the snapshot into the hash',
+ route: { kind: 'run', runId: 'run-1' },
+ search: { snapshot: 'snap-1', utm_source: 'github' },
+ hash: {},
+ expected: {
+ path: '/visual_review/repos/PostHog/posthog/runs/run-1',
+ searchParams: { utm_source: 'github' },
+ hashParams: { snapshot: 'snap-1' },
+ },
+ },
+ {
+ name: 'a run link that already selects in the hash keeps it',
+ route: { kind: 'run', runId: 'run-1' },
+ search: {},
+ hash: { snapshot: 'snap-2' },
+ expected: {
+ path: '/visual_review/repos/PostHog/posthog/runs/run-1',
+ searchParams: {},
+ hashParams: { snapshot: 'snap-2' },
+ },
+ },
+ ])('legacyForwardUrl: $name', ({ route, search, hash, expected }) => {
+ expect(legacyForwardUrl(route, 'PostHog/posthog', search, hash)).toEqual(expected)
+ })
+
+ const first = makeRepo('first', 'PostHog/posthog')
+ const second = makeRepo('second', 'PostHog/posthog.com')
+
+ it.each([
+ { name: 'opens the repo used last', repos: [first, second], last: 'posthog/POSTHOG.com', expected: 'second' },
+ {
+ name: 'falls back to the first repo when the last one is gone',
+ repos: [first],
+ last: 'PostHog/gone',
+ expected: 'first',
+ },
+ { name: 'falls back to the first repo with no history', repos: [first, second], last: null, expected: 'first' },
+ { name: 'returns null with no repos', repos: [], last: 'PostHog/posthog', expected: null },
+ ])('pickLandingRepo: $name', ({ repos, last, expected }) => {
+ expect(pickLandingRepo(repos, last)?.id ?? null).toBe(expected)
+ })
+})
diff --git a/products/visual_review/frontend/lib/forwardUrls.ts b/products/visual_review/frontend/lib/forwardUrls.ts
new file mode 100644
index 000000000000..37407cabf597
--- /dev/null
+++ b/products/visual_review/frontend/lib/forwardUrls.ts
@@ -0,0 +1,58 @@
+import { urls } from 'scenes/urls'
+
+import type { RepoApi } from '../generated/api.schemas'
+import { findRepoByFullName } from './repoIds'
+import { runPath, splitRepoFullName } from './repoPaths'
+
+export type RepoPage = 'runs' | 'snapshots' | 'flakiness'
+
+// Visual review URLs used to name a repo by UUID. Links in PR comments, Slack and bookmarks still do,
+// so each old shape forwards to the owner/name path of the same page.
+export type LegacyRoute =
+ | { kind: 'repoPage'; repoId: string; page: RepoPage }
+ | { kind: 'snapshotHistory'; repoId: string; runType: string; identifier: string }
+ | { kind: 'run'; runId: string }
+
+export interface ForwardUrl {
+ path: string
+ searchParams: Record<string, any>
+ hashParams: Record<string, any>
+}
+
+function legacyPath(route: LegacyRoute, repoFullName: string): string {
+ switch (route.kind) {
+ case 'repoPage':
+ if (route.page === 'snapshots') {
+ return urls.visualReviewSnapshotOverview(...splitRepoFullName(repoFullName))
+ }
+ if (route.page === 'flakiness') {
+ return urls.visualReviewFlakiness(...splitRepoFullName(repoFullName))
+ }
+ return urls.visualReviewRepoRuns(...splitRepoFullName(repoFullName))
+ case 'snapshotHistory':
+ return urls.visualReviewSnapshotHistory(...splitRepoFullName(repoFullName), route.runType, route.identifier)
+ case 'run':
+ return runPath(route.runId, repoFullName)
+ }
+}
+
+export function legacyForwardUrl(
+ route: LegacyRoute,
+ repoFullName: string,
+ searchParams: Record<string, any>,
+ hashParams: Record<string, any>
+): ForwardUrl {
+ const path = legacyPath(route, repoFullName)
+ // Old PR comments link a snapshot as `?snapshot=<id>`. The run page keeps its selection in the hash.
+ const { snapshot, ...otherSearchParams } = searchParams
+ if (route.kind === 'run' && snapshot && !hashParams.snapshot) {
+ return { path, searchParams: otherSearchParams, hashParams: { ...hashParams, snapshot } }
+ }
+ return { path, searchParams, hashParams }
+}
+
+// `/visual_review` opens the repo this project used last, so a multi-repo team lands where it left off.
+export function pickLandingRepo(repos: RepoApi[], lastRepoFullName: string | null): RepoApi | null {
+ const lastRepo = lastRepoFullName ? findRepoByFullName(repos, lastRepoFullName) : null
+ return lastRepo ?? repos[0] ?? null
+}
diff --git a/products/visual_review/frontend/lib/repoBreadcrumbs.ts b/products/visual_review/frontend/lib/repoBreadcrumbs.ts
new file mode 100644
index 000000000000..3758fafd689c
--- /dev/null
+++ b/products/visual_review/frontend/lib/repoBreadcrumbs.ts
@@ -0,0 +1,23 @@
+import { urls } from 'scenes/urls'
+
+import { Breadcrumb } from '~/types'
+
+import { splitRepoFullName } from './repoPaths'
+
+/** The crumbs every repository page shares, so the top bar reads the same on detail pages as on tabs. */
+export function repoBreadcrumbs(repoFullName: string | null): Breadcrumb[] {
+ if (!repoFullName) {
+ return [
+ { key: 'visual_review', name: 'Visual review', path: urls.visualReviewRuns(), iconType: 'visual_review' },
+ ]
+ }
+ return [
+ {
+ key: 'visual_review',
+ name: 'Visual review',
+ path: urls.visualReviewRepoRuns(...splitRepoFullName(repoFullName)),
+ iconType: 'visual_review',
+ },
+ { key: ['visual_review_repo', repoFullName], name: repoFullName, iconType: 'visual_review' },
+ ]
+}
diff --git a/products/visual_review/frontend/lib/repoIds.test.ts b/products/visual_review/frontend/lib/repoIds.test.ts
new file mode 100644
index 000000000000..68c38110ded5
--- /dev/null
+++ b/products/visual_review/frontend/lib/repoIds.test.ts
@@ -0,0 +1,88 @@
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import type { RepoApi } from '../generated/api.schemas'
+import { RepoNotFoundError, clearRepoIdCache, findRepoByFullName, resolveRepoId } from './repoIds'
+
+const REPOS_URL = '/api/projects/:team_id/visual_review/repos/'
+
+function makeRepo(id: string, repoFullName: string, createdAt: string): RepoApi {
+ return {
+ id,
+ team_id: 1,
+ repo_external_id: 1,
+ repo_full_name: repoFullName,
+ baseline_file_paths: {},
+ enable_pr_comments: true,
+ debt_digest_enabled: false,
+ created_at: createdAt,
+ }
+}
+
+const older = makeRepo('older', 'PostHog/posthog', '2026-01-01T00:00:00Z')
+const newer = makeRepo('newer', 'PostHog/posthog', '2026-03-01T00:00:00Z')
+const other = makeRepo('other', 'PostHog/posthog.com', '2026-02-01T00:00:00Z')
+
+describe('repoIds', () => {
+ beforeEach(() => {
+ initKeaTests()
+ clearRepoIdCache()
+ })
+
+ it.each([
+ { name: 'matches regardless of case', repos: [other, older], wanted: 'posthog/POSTHOG', expected: 'older' },
+ {
+ name: 'picks the newest of two rows with one name',
+ repos: [newer, older],
+ wanted: 'PostHog/posthog',
+ expected: 'newer',
+ },
+ { name: 'returns null for an unknown name', repos: [older], wanted: 'PostHog/unknown', expected: null },
+ ])('findRepoByFullName $name', ({ repos, wanted, expected }) => {
+ expect(findRepoByFullName(repos, wanted)?.id ?? null).toBe(expected)
+ })
+
+ it('fetches the list again when a name is missing from the cached one', async () => {
+ let listed = [older]
+ let requests = 0
+ useMocks({
+ get: {
+ [REPOS_URL]: () => {
+ requests += 1
+ return [200, { count: listed.length, next: null, previous: null, results: listed }]
+ },
+ },
+ })
+
+ expect(await resolveRepoId('1', 'PostHog/posthog')).toBe('older')
+ listed = [older, other]
+ expect(await resolveRepoId('1', 'PostHog/posthog.com')).toBe('other')
+ expect(await resolveRepoId('1', 'PostHog/posthog.com')).toBe('other')
+ expect(requests).toBe(2)
+
+ await expect(resolveRepoId('1', 'PostHog/missing')).rejects.toBeInstanceOf(RepoNotFoundError)
+ expect(requests).toBe(3)
+ })
+
+ it('shares one refresh between two lookups that miss at the same time', async () => {
+ let listed = [older]
+ let requests = 0
+ useMocks({
+ get: {
+ [REPOS_URL]: () => {
+ requests += 1
+ return [200, { count: listed.length, next: null, previous: null, results: listed }]
+ },
+ },
+ })
+
+ await resolveRepoId('1', 'PostHog/posthog')
+ listed = [older, other]
+ const lookups = await Promise.all([
+ resolveRepoId('1', 'PostHog/posthog.com'),
+ resolveRepoId('1', 'PostHog/posthog.com'),
+ ])
+ expect(lookups).toEqual(['other', 'other'])
+ expect(requests).toBe(2)
+ })
+})
diff --git a/products/visual_review/frontend/lib/repoIds.ts b/products/visual_review/frontend/lib/repoIds.ts
new file mode 100644
index 000000000000..54f3cedfae8f
--- /dev/null
+++ b/products/visual_review/frontend/lib/repoIds.ts
@@ -0,0 +1,106 @@
+import { visualReviewReposList } from '../generated/api'
+import type { RepoApi } from '../generated/api.schemas'
+
+const REPOS_PAGE_SIZE = 100
+
+export class RepoNotFoundError extends Error {
+ constructor(repoRef: string) {
+ super(`No visual review repo matches ${repoRef}`)
+ this.name = 'RepoNotFoundError'
+ }
+}
+
+// GitHub treats owner and repo names as case-insensitive, so a link typed by hand still resolves.
+// A repo that was deleted and connected again has two rows with the same name, and the newest one is live.
+export function findRepoByFullName(repos: RepoApi[], repoFullName: string): RepoApi | null {
+ const wanted = repoFullName.toLowerCase()
+ let newest: RepoApi | null = null
+ for (const repo of repos) {
+ if (repo.repo_full_name.toLowerCase() !== wanted) {
+ continue
+ }
+ if (!newest || new Date(repo.created_at).getTime() > new Date(newest.created_at).getTime()) {
+ newest = repo
+ }
+ }
+ return newest
+}
+
+async function fetchAllRepos(projectId: string): Promise<RepoApi[]> {
+ const repos: RepoApi[] = []
+ for (;;) {
+ const page = await visualReviewReposList(projectId, { limit: REPOS_PAGE_SIZE, offset: repos.length })
+ repos.push(...page.results)
+ if (!page.next || page.results.length === 0) {
+ return repos
+ }
+ }
+}
+
+// One shared request per project. Every repo-scoped logic on a page resolves the same name at mount,
+// so sharing the request keeps that to a single list call.
+const repoListRequests = new Map<string, Promise<RepoApi[]>>()
+
+function loadRepos(projectId: string, refresh: boolean): Promise<RepoApi[]> {
+ const cached = repoListRequests.get(projectId)
+ if (cached && !refresh) {
+ return cached
+ }
+ const request = fetchAllRepos(projectId)
+ repoListRequests.set(projectId, request)
+ // A failed request must not stay cached, or every later lookup fails without a retry.
+ request.catch(() => {
+ if (repoListRequests.get(projectId) === request) {
+ repoListRequests.delete(projectId)
+ }
+ })
+ return request
+}
+
+// Lookups that miss at the same moment share one refresh, so a page of repo-scoped logics makes one extra call.
+const repoListRefreshes = new Map<string, Promise<RepoApi[]>>()
+
+function refreshRepos(projectId: string): Promise<RepoApi[]> {
+ const pending = repoListRefreshes.get(projectId)
+ if (pending) {
+ return pending
+ }
+ const refresh = loadRepos(projectId, true)
+ repoListRefreshes.set(projectId, refresh)
+ const clear = (): void => {
+ repoListRefreshes.delete(projectId)
+ }
+ refresh.then(clear, clear)
+ return refresh
+}
+
+// The cached list can predate a repo connected a moment ago, so a miss on it fetches the list once more.
+async function findRepo(projectId: string, matches: (repos: RepoApi[]) => RepoApi | null): Promise<RepoApi | null> {
+ const wasCached = repoListRequests.has(projectId)
+ const repo = matches(await loadRepos(projectId, false))
+ if (repo || !wasCached) {
+ return repo
+ }
+ return matches(await refreshRepos(projectId))
+}
+
+export async function resolveRepoId(projectId: string, repoFullName: string): Promise<string> {
+ const repo = await findRepo(projectId, (repos) => findRepoByFullName(repos, repoFullName))
+ if (!repo) {
+ throw new RepoNotFoundError(repoFullName)
+ }
+ return repo.id
+}
+
+export async function resolveRepoFullName(projectId: string, repoId: string): Promise<string> {
+ const repo = await findRepo(projectId, (repos) => repos.find((candidate) => candidate.id === repoId) ?? null)
+ if (!repo) {
+ throw new RepoNotFoundError(repoId)
+ }
+ return repo.repo_full_name
+}
+
+export function clearRepoIdCache(): void {
+ repoListRequests.clear()
+ repoListRefreshes.clear()
+}
diff --git a/products/visual_review/frontend/lib/repoPaths.ts b/products/visual_review/frontend/lib/repoPaths.ts
new file mode 100644
index 000000000000..ccbfb2987145
--- /dev/null
+++ b/products/visual_review/frontend/lib/repoPaths.ts
@@ -0,0 +1,19 @@
+import { urls } from 'scenes/urls'
+
+/** 'owner/name' as the owner and name the URL builders take. */
+export function splitRepoFullName(repoFullName: string): [string, string] {
+ const slash = repoFullName.indexOf('/')
+ return slash === -1 ? [repoFullName, ''] : [repoFullName.slice(0, slash), repoFullName.slice(slash + 1)]
+}
+
+// Route params arrive still encoded, so decode each segment before joining them back into a full name.
+export function repoFullNameFromParams(repoOwner: string | undefined, repoName: string | undefined): string {
+ return `${decodeURIComponent(repoOwner ?? '')}/${decodeURIComponent(repoName ?? '')}`
+}
+
+/** A run inside its repository, or the run path that forwards while the repository is not known yet. */
+export function runPath(runId: string, repoFullName: string | null | undefined): string {
+ return repoFullName
+ ? urls.visualReviewRepoRun(...splitRepoFullName(repoFullName), runId)
+ : urls.visualReviewRun(runId)
+}
diff --git a/products/visual_review/frontend/scenes/VisualReviewFlakinessScene.stories.tsx b/products/visual_review/frontend/scenes/VisualReviewFlakinessScene.stories.tsx
index 40fbe8ea0536..83b50029fc80 100644
--- a/products/visual_review/frontend/scenes/VisualReviewFlakinessScene.stories.tsx
+++ b/products/visual_review/frontend/scenes/VisualReviewFlakinessScene.stories.tsx
@@ -158,7 +158,7 @@ const meta: Meta = {
layout: 'fullscreen',
viewMode: 'story',
mockDate: '2026-06-10',
- pageUrl: `/visual_review/repos/${REPO_ID}/flakiness`,
+ pageUrl: `/visual_review/repos/PostHog/posthog/flakiness`,
testOptions: { waitForSelector: '[data-attr="visual-review-flakiness-preset-unstable"]' },
},
decorators: [
@@ -180,7 +180,7 @@ export const Unstable: StoryObj = {
// Names its own preset. Inheriting the default made this story a hostage to
// it: the default changed, no fixture matched the new one, and the story
// quietly rendered an empty table for a while before anybody noticed.
- parameters: { pageUrl: `/visual_review/repos/${REPO_ID}/flakiness#preset=unstable` },
+ parameters: { pageUrl: `/visual_review/repos/PostHog/posthog/flakiness#preset=unstable` },
}
// A repo whose snapshots all render deterministically. Two of the three repos in
diff --git a/products/visual_review/frontend/scenes/VisualReviewFlakinessScene.tsx b/products/visual_review/frontend/scenes/VisualReviewFlakinessScene.tsx
index d62985a29e37..e1cd4dad5c80 100644
--- a/products/visual_review/frontend/scenes/VisualReviewFlakinessScene.tsx
+++ b/products/visual_review/frontend/scenes/VisualReviewFlakinessScene.tsx
@@ -11,13 +11,13 @@ import {
Link,
} from '@posthog/lemon-ui'
+import { NotFound } from 'lib/components/NotFound'
import { dayjs } from 'lib/dayjs'
import { LemonDialog } from 'lib/lemon-ui/LemonDialog'
import { SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
-import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import { ActivityCell } from '../components/FlakinessActivityCell'
import { MarginCell } from '../components/FlakinessMarginCell'
@@ -25,10 +25,11 @@ import { QuarantineCell } from '../components/FlakinessQuarantineCell'
import { StateCell } from '../components/FlakinessStateCell'
import { FLAKE_RATE_DAYS, FlakinessStatRow } from '../components/FlakinessStatRow'
import { QuarantineAction } from '../components/QuarantineAction'
-import { RepoSwitcher } from '../components/RepoSwitcher'
import { SnapshotFacetSidebar } from '../components/SnapshotFacetSidebar'
+import { VisualReviewSceneTitle } from '../components/VisualReviewSceneTitle'
import { VisualReviewTabs } from '../components/VisualReviewTabs'
import type { FlakinessEntryApi } from '../generated/api.schemas'
+import { repoFullNameFromParams, splitRepoFullName } from '../lib/repoPaths'
import {
DecoratedEntry,
VisualReviewFlakinessSceneLogicProps,
@@ -38,8 +39,8 @@ import {
export const scene: SceneExport = {
component: VisualReviewFlakinessScene,
logic: visualReviewFlakinessSceneLogic,
- paramsToProps: ({ params: { repoId } }): VisualReviewFlakinessSceneLogicProps => ({
- repoId: repoId || '',
+ paramsToProps: ({ params: { repoOwner, repoName } }): VisualReviewFlakinessSceneLogicProps => ({
+ repoFullName: repoFullNameFromParams(repoOwner, repoName),
}),
}
@@ -55,8 +56,8 @@ export function VisualReviewFlakinessScene(): JSX.Element {
const {
overview,
overviewLoading,
- repo,
- repoId,
+ repoNotFound,
+ repoFullName,
filteredEntries,
statCounts,
facetGroups,
@@ -96,21 +97,22 @@ export function VisualReviewFlakinessScene(): JSX.Element {
})
}
+ if (repoNotFound) {
+ return <NotFound object="visual review repo" />
+ }
+
return (
<SceneContent>
- <SceneTitleSection
- name={repo?.repo_full_name ?? 'Visual review'}
- resourceType={{ type: 'visual_review' }}
+ <VisualReviewSceneTitle
+ repoFullName={repoFullName}
+ activeTab="flakiness"
actions={
- <div className="flex gap-2 items-center">
- <RepoSwitcher repoId={repoId} activeTab="flakiness" />
- <LemonButton size="small" type="secondary" icon={<IconGear />} to={urls.visualReviewSettings()}>
- Settings
- </LemonButton>
- </div>
+ <LemonButton size="small" type="secondary" icon={<IconGear />} to={urls.visualReviewSettings()}>
+ Settings
+ </LemonButton>
}
/>
- <VisualReviewTabs activeKey="flakiness" repoId={repoId} />
+ <VisualReviewTabs activeKey="flakiness" repoFullName={repoFullName} />
<LemonBanner type="info">
A snapshot that renders differently from its baseline either fails the run, or stays under the diff
@@ -234,7 +236,7 @@ export function VisualReviewFlakinessScene(): JSX.Element {
<div className="min-w-0">
<Link
to={urls.visualReviewSnapshotHistory(
- repoId,
+ ...splitRepoFullName(repoFullName),
entry.run_type,
entry.identifier
)}
diff --git a/products/visual_review/frontend/scenes/VisualReviewIndexScene.tsx b/products/visual_review/frontend/scenes/VisualReviewIndexScene.tsx
index 535483fa9c3f..ac50609165bc 100644
--- a/products/visual_review/frontend/scenes/VisualReviewIndexScene.tsx
+++ b/products/visual_review/frontend/scenes/VisualReviewIndexScene.tsx
@@ -1,5 +1,6 @@
import { useActions, useValues } from 'kea'
+import { NotFound } from 'lib/components/NotFound'
import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'
import { SceneExport } from 'scenes/sceneTypes'
@@ -16,17 +17,25 @@ export const scene: SceneExport = {
productKey: ProductKey.VISUAL_REVIEW,
}
-// /visual_review is a pure forwarder, so this renders only while the repo list is in flight,
-// or when it failed and there is nothing to forward to. The forward itself lives in the logic.
+// This scene is a pure forwarder, so it renders only while the lookup is in flight,
+// or when the lookup failed and there is nothing to forward to. The forward itself lives in the logic.
export function VisualReviewIndexScene(): JSX.Element {
- const { reposLoadFailed } = useValues(visualReviewIndexSceneLogic)
- const { loadRepos } = useActions(visualReviewIndexSceneLogic)
+ const { forwardFailure, forwardRoute } = useValues(visualReviewIndexSceneLogic)
+ const { forward } = useActions(visualReviewIndexSceneLogic)
+
+ if (forwardFailure === 'not_found') {
+ return <NotFound object={forwardRoute?.kind === 'run' ? 'visual review run' : 'visual review repo'} />
+ }
return (
<SceneContent>
<SceneTitleSection name="Visual review" resourceType={{ type: 'visual_review' }} />
- {reposLoadFailed ? (
- <LemonBanner type="error" action={{ children: 'Try again', onClick: loadRepos }} className="max-w-2xl">
+ {forwardFailure === 'load_failed' && forwardRoute ? (
+ <LemonBanner
+ type="error"
+ action={{ children: 'Try again', onClick: () => forward(forwardRoute) }}
+ className="max-w-2xl"
+ >
Couldn't load your connected repos.
</LemonBanner>
) : (
diff --git a/products/visual_review/frontend/scenes/VisualReviewRunScene.stories.tsx b/products/visual_review/frontend/scenes/VisualReviewRunScene.stories.tsx
index a463ed4b3b1c..00605328d6e0 100644
--- a/products/visual_review/frontend/scenes/VisualReviewRunScene.stories.tsx
+++ b/products/visual_review/frontend/scenes/VisualReviewRunScene.stories.tsx
@@ -173,7 +173,7 @@ const meta: Meta = {
layout: 'fullscreen',
viewMode: 'story',
mockDate: '2026-06-10',
- pageUrl: `/visual_review/runs/${RUN_ID}`,
+ pageUrl: `/visual_review/repos/PostHog/posthog/runs/${RUN_ID}`,
testOptions: { waitForSelector: '[data-attr="visual-review-add-images-to-comment"]' },
},
decorators: [
@@ -185,6 +185,7 @@ const meta: Meta = {
[`/api/projects/:team_id/visual_review/repos/${REPO_ID}/`]: repo,
[`/api/projects/:team_id/visual_review/repos/${REPO_ID}/quarantine/`]: emptyList,
[`/api/projects/:team_id/visual_review/runs/${RUN_ID}/quarantine_lifts/`]: [],
+ '/api/projects/:team_id/visual_review/repos/': { ...emptyList, count: 1, results: [repo] },
},
}),
],
@@ -325,7 +326,7 @@ const cleanQuarantinedTooltip = snapshot({
// A pull request that fixes a quarantined story asks for the quarantine to lift once it merges.
export const QuarantinedSnapshotLiftsOnMerge: StoryObj = {
parameters: {
- pageUrl: `/visual_review/runs/${RUN_ID}#snapshot=snapshot-changed`,
+ pageUrl: `/visual_review/repos/PostHog/posthog/runs/${RUN_ID}#snapshot=snapshot-changed`,
testOptions: { waitForSelector: '[data-attr="visual-review-lift-on-merge-pending"]' },
},
decorators: [
diff --git a/products/visual_review/frontend/scenes/VisualReviewRunScene.tsx b/products/visual_review/frontend/scenes/VisualReviewRunScene.tsx
index 169a73d527df..35de5e658f6d 100644
--- a/products/visual_review/frontend/scenes/VisualReviewRunScene.tsx
+++ b/products/visual_review/frontend/scenes/VisualReviewRunScene.tsx
@@ -12,17 +12,20 @@ import { useKeyboardHotkeys } from 'lib/hooks/useKeyboardHotkeys'
import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
import { Spinner } from 'lib/lemon-ui/Spinner/Spinner'
import { SceneExport } from 'scenes/sceneTypes'
+import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
-import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import { CleanQuarantinedSnapshots } from '../components/CleanQuarantinedSnapshots'
import { CleanQuarantinedToggle } from '../components/CleanQuarantinedToggle'
import { SnapshotChangeBadge, hasSnapshotChangeBadge } from '../components/SnapshotChangeBadge'
import { SnapshotDiffViewer } from '../components/SnapshotDiffViewer'
import { SnapshotStatusIndicator } from '../components/SnapshotStatusIndicator'
+import { VisualReviewSceneTitle } from '../components/VisualReviewSceneTitle'
import { VisualReviewTabs } from '../components/VisualReviewTabs'
+import { VisualReviewTrail } from '../components/VisualReviewTrail'
import type { SnapshotApi } from '../generated/api.schemas'
+import { repoFullNameFromParams, runPath, splitRepoFullName } from '../lib/repoPaths'
import { VisualReviewRunSceneLogicProps, visualReviewRunSceneLogic } from './visualReviewRunSceneLogic'
const HedgehogMagnifyingGlass = pngHoggie(magnifyingGlassPng)
@@ -30,11 +33,41 @@ const HedgehogMagnifyingGlass = pngHoggie(magnifyingGlassPng)
export const scene: SceneExport = {
component: VisualReviewRunScene,
logic: visualReviewRunSceneLogic,
- paramsToProps: ({ params: { runId } }): VisualReviewRunSceneLogicProps => ({
+ paramsToProps: ({ params: { repoOwner, repoName, runId } }): VisualReviewRunSceneLogicProps => ({
runId: runId || '',
+ repoFullName: repoFullNameFromParams(repoOwner, repoName),
}),
}
+/** The repository title, the tabs with Runs active, and the trail from the runs list to this run. */
+function RunSceneHeader({
+ repoFullName,
+ branch,
+ actions,
+}: {
+ repoFullName: string | null
+ branch: string | null
+ actions?: JSX.Element
+}): JSX.Element {
+ return (
+ <>
+ {repoFullName && <VisualReviewSceneTitle repoFullName={repoFullName} activeTab="runs" actions={actions} />}
+ {repoFullName && <VisualReviewTabs activeKey="runs" repoFullName={repoFullName} />}
+ <VisualReviewTrail
+ crumbs={[
+ {
+ label: 'Runs',
+ to: repoFullName
+ ? urls.visualReviewRepoRuns(...splitRepoFullName(repoFullName))
+ : urls.visualReviewRuns(),
+ },
+ ...(branch ? [{ label: branch }] : []),
+ ]}
+ />
+ </>
+ )
+}
+
function SnapshotThumbnail({
snapshot,
isSelected,
@@ -320,6 +353,7 @@ export function VisualReviewRunScene(): JSX.Element {
if (!run) {
return (
<SceneContent>
+ <RunSceneHeader repoFullName={repoFullName} branch={null} />
<div className="space-y-4 py-4">
<LemonSkeleton className="h-8 w-1/3" />
<div className="flex gap-2">
@@ -337,7 +371,7 @@ export function VisualReviewRunScene(): JSX.Element {
if (isRunInProgress) {
return (
<SceneContent>
- <SceneTitleSection name={run.branch} resourceType={{ type: 'visual_review' }} />
+ <RunSceneHeader repoFullName={repoFullName} branch={run.branch} />
<RunInProgressEmptyState
isProcessing={isRunProcessing}
createdAt={run.created_at}
@@ -350,7 +384,7 @@ export function VisualReviewRunScene(): JSX.Element {
if (run.status === 'failed') {
return (
<SceneContent>
- <SceneTitleSection name={run.branch} resourceType={{ type: 'visual_review' }} />
+ <RunSceneHeader repoFullName={repoFullName} branch={run.branch} />
<LemonBanner type="error">
This run failed to process.{run.error_message ? ` ${run.error_message}` : ''} Check the CI logs for
details, or rerun the job to try again.
@@ -412,9 +446,9 @@ export function VisualReviewRunScene(): JSX.Element {
return (
<SceneContent>
- <SceneTitleSection
- name={run.branch}
- resourceType={{ type: 'visual_review' }}
+ <RunSceneHeader
+ repoFullName={repoFullName}
+ branch={run.branch}
actions={
!isReportingOnly && !run.approved && !run.is_stale && (reviewPending > 0 || reviewApproved > 0) ? (
<div className="flex items-center gap-2">
@@ -438,7 +472,6 @@ export function VisualReviewRunScene(): JSX.Element {
) : undefined
}
/>
- <VisualReviewTabs activeKey="runs" repoId={run.repo_id} />
{isReportingOnly && (
<LemonBanner type="info" className="mb-4">
@@ -451,7 +484,7 @@ export function VisualReviewRunScene(): JSX.Element {
<LemonBanner type="warning" className="mb-4">
This run has been superseded by a newer run.{' '}
{run.superseded_by_id && (
- <Link to={`/visual_review/runs/${run.superseded_by_id}`} className="font-semibold">
+ <Link to={runPath(run.superseded_by_id, repoFullName ?? undefined)} className="font-semibold">
View latest run
</Link>
)}
@@ -673,7 +706,6 @@ export function VisualReviewRunScene(): JSX.Element {
onCancelLiftOnMerge={cancelLiftOnMerge}
commitSha={run.commit_sha}
prNumber={run.pr_number}
- repoId={run.repo_id}
repoFullName={repoFullName}
runType={run.run_type}
githubRunId={(run.metadata?.github_run_id as string) || null}
diff --git a/products/visual_review/frontend/scenes/VisualReviewRunsScene.tsx b/products/visual_review/frontend/scenes/VisualReviewRunsScene.tsx
index 2849b6820eeb..e529e4adf852 100644
--- a/products/visual_review/frontend/scenes/VisualReviewRunsScene.tsx
+++ b/products/visual_review/frontend/scenes/VisualReviewRunsScene.tsx
@@ -12,30 +12,31 @@ import {
Link,
} from '@posthog/lemon-ui'
+import { NotFound } from 'lib/components/NotFound'
import { dayjs } from 'lib/dayjs'
import { SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
-import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
-import { RepoSwitcher } from '../components/RepoSwitcher'
import { RunSummaryStats } from '../components/RunSummaryStats'
+import { VisualReviewSceneTitle } from '../components/VisualReviewSceneTitle'
import { VisualReviewTabs } from '../components/VisualReviewTabs'
import type { RunApi } from '../generated/api.schemas'
+import { repoFullNameFromParams, runPath } from '../lib/repoPaths'
import { isReportingOnlyRun } from '../lib/runPredicates'
import { ReviewState, VisualReviewRunsSceneLogicProps, visualReviewRunsSceneLogic } from './visualReviewRunsSceneLogic'
export const scene: SceneExport = {
component: VisualReviewRunsScene,
logic: visualReviewRunsSceneLogic,
- paramsToProps: ({ params: { repoId } }): VisualReviewRunsSceneLogicProps => ({
- repoId: repoId || '',
+ paramsToProps: ({ params: { repoOwner, repoName } }): VisualReviewRunsSceneLogicProps => ({
+ repoFullName: repoFullNameFromParams(repoOwner, repoName),
}),
}
-function BranchCell({ run, repoFullName }: { run: RunApi; repoFullName?: string }): JSX.Element {
- const prUrl = run.pr_number && repoFullName ? `https://github.com/${repoFullName}/pull/${run.pr_number}` : null
+function BranchCell({ run, repoFullName }: { run: RunApi; repoFullName: string }): JSX.Element {
+ const prUrl = run.pr_number ? `https://github.com/${repoFullName}/pull/${run.pr_number}` : null
return (
<div className="flex items-center gap-2 min-w-0">
@@ -70,7 +71,7 @@ const TAB_COUNT_TYPES: Record<ReviewState, 'warning' | 'highlight' | 'default' |
}
export function VisualReviewRunsScene(): JSX.Element {
- const { runs, runsLoading, activeTab, counts, repoId, repoFullName, page, totalCount, searchQuery } =
+ const { runs, runsLoading, activeTab, counts, repoNotFound, repoFullName, page, totalCount, searchQuery } =
useValues(visualReviewRunsSceneLogic)
const { loadRuns, loadCounts, setActiveTab, setPage, setSearchQuery } = useActions(visualReviewRunsSceneLogic)
@@ -123,7 +124,7 @@ export function VisualReviewRunsScene(): JSX.Element {
size="xsmall"
onClick={(e) => {
e.stopPropagation()
- router.actions.push(`/visual_review/runs/${run.id}`)
+ router.actions.push(runPath(run.id, repoFullName))
}}
>
{needsReview ? 'Review' : 'View'}
@@ -140,21 +141,22 @@ export function VisualReviewRunsScene(): JSX.Element {
{ key: 'stale', label: 'Stale' },
]
+ if (repoNotFound) {
+ return <NotFound object="visual review repo" />
+ }
+
return (
<SceneContent>
- <SceneTitleSection
- name={repoFullName ?? 'Visual review'}
- resourceType={{ type: 'visual_review' }}
+ <VisualReviewSceneTitle
+ repoFullName={repoFullName}
+ activeTab="runs"
actions={
- <div className="flex gap-2 items-center">
- <RepoSwitcher repoId={repoId} activeTab="runs" />
- <LemonButton size="small" type="secondary" icon={<IconGear />} to={urls.visualReviewSettings()}>
- Settings
- </LemonButton>
- </div>
+ <LemonButton size="small" type="secondary" icon={<IconGear />} to={urls.visualReviewSettings()}>
+ Settings
+ </LemonButton>
}
/>
- <VisualReviewTabs activeKey="runs" repoId={repoId} />
+ <VisualReviewTabs activeKey="runs" repoFullName={repoFullName} />
<div className="mb-3 flex items-center gap-2 flex-wrap">
<LemonSegmentedButton
@@ -212,7 +214,7 @@ export function VisualReviewRunsScene(): JSX.Element {
nouns={['run', 'runs']}
emptyState={searchQuery.trim() ? `No runs match “${searchQuery.trim()}”.` : EMPTY_MESSAGES[activeTab]}
onRow={(run) => ({
- onClick: () => router.actions.push(`/visual_review/runs/${run.id}`),
+ onClick: () => router.actions.push(runPath(run.id, repoFullName)),
className: 'cursor-pointer',
})}
/>
diff --git a/products/visual_review/frontend/scenes/VisualReviewSnapshotHistoryScene.tsx b/products/visual_review/frontend/scenes/VisualReviewSnapshotHistoryScene.tsx
index d9552dd79bff..08f655662b0e 100644
--- a/products/visual_review/frontend/scenes/VisualReviewSnapshotHistoryScene.tsx
+++ b/products/visual_review/frontend/scenes/VisualReviewSnapshotHistoryScene.tsx
@@ -3,6 +3,7 @@ import { useState } from 'react'
import { LemonBanner, LemonButton, LemonSkeleton, LemonTag, Link } from '@posthog/lemon-ui'
+import { NotFound } from 'lib/components/NotFound'
import { TZLabel } from 'lib/components/TZLabel'
import { dayjs } from 'lib/dayjs'
import { LemonDialog } from 'lib/lemon-ui/LemonDialog'
@@ -11,13 +12,15 @@ import { SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
-import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import { QuarantineAction } from '../components/QuarantineAction'
import type { OnQuarantine } from '../components/QuarantineModal'
import { SnapshotChangeBadge, hasSnapshotChangeBadge } from '../components/SnapshotChangeBadge'
+import { VisualReviewSceneTitle } from '../components/VisualReviewSceneTitle'
import { VisualReviewTabs } from '../components/VisualReviewTabs'
+import { VisualReviewTrail } from '../components/VisualReviewTrail'
import type { QuarantinedIdentifierEntryApi, SnapshotHistoryEntryApi } from '../generated/api.schemas'
+import { repoFullNameFromParams, runPath, splitRepoFullName } from '../lib/repoPaths'
import {
ThemePair,
VisualReviewSnapshotHistorySceneLogicProps,
@@ -27,8 +30,10 @@ import {
export const scene: SceneExport = {
component: VisualReviewSnapshotHistoryScene,
logic: visualReviewSnapshotHistorySceneLogic,
- paramsToProps: ({ params: { repoId, runType, identifier } }): VisualReviewSnapshotHistorySceneLogicProps => ({
- repoId: repoId || '',
+ paramsToProps: ({
+ params: { repoOwner, repoName, runType, identifier },
+ }): VisualReviewSnapshotHistorySceneLogicProps => ({
+ repoFullName: repoFullNameFromParams(repoOwner, repoName),
runType: runType ? decodeURIComponent(runType) : '',
identifier: identifier ? decodeURIComponent(identifier) : '',
}),
@@ -93,8 +98,8 @@ function ThemePane({
// Deep link into the run with the identifier's snapshot pre-selected. The run scene
// reads `snapshot` from the URL hash (see `urlToAction` in visualReviewRunSceneLogic),
// not from the query string — using `?` here would land on the run overview instead.
-function runUrl(entry: SnapshotHistoryEntryApi): string {
- return `${urls.visualReviewRun(entry.run_id)}#snapshot=${encodeURIComponent(entry.snapshot_id)}`
+function runUrl(entry: SnapshotHistoryEntryApi, repoFullName: string): string {
+ return `${runPath(entry.run_id, repoFullName)}#snapshot=${encodeURIComponent(entry.snapshot_id)}`
}
function HistoryRow({
@@ -106,12 +111,12 @@ function HistoryRow({
pair: ThemePair
isCurrent: boolean
isLast: boolean
- repoFullName: string | null
+ repoFullName: string
}): JSX.Element {
const entry = pair.primary
const reason = REASON_TAGS[entry.result] ?? { label: entry.result, type: 'default' as const }
- const prUrl = entry.pr_number && repoFullName ? `https://github.com/${repoFullName}/pull/${entry.pr_number}` : null
- const commitUrl = repoFullName ? `https://github.com/${repoFullName}/commit/${entry.commit_sha}` : null
+ const prUrl = entry.pr_number ? `https://github.com/${repoFullName}/pull/${entry.pr_number}` : null
+ const commitUrl = `https://github.com/${repoFullName}/commit/${entry.commit_sha}`
const showPair = pair.primaryTheme !== null
return (
@@ -136,7 +141,7 @@ function HistoryRow({
</div>
<div className="flex items-center gap-2 flex-wrap text-xs text-muted mb-2">
- <Link to={runUrl(entry)} className="font-mono text-default">
+ <Link to={runUrl(entry, repoFullName)} className="font-mono text-default">
{entry.branch}
</Link>
{prUrl && (
@@ -148,13 +153,9 @@ function HistoryRow({
</>
)}
<span>·</span>
- {commitUrl ? (
- <Link to={commitUrl} target="_blank" className="font-mono">
- {entry.commit_sha.slice(0, 8)}
- </Link>
- ) : (
- <span className="font-mono">{entry.commit_sha.slice(0, 8)}</span>
- )}
+ <Link to={commitUrl} target="_blank" className="font-mono">
+ {entry.commit_sha.slice(0, 8)}
+ </Link>
{hasSnapshotChangeBadge(entry) && (
<>
<span>·</span>
@@ -164,12 +165,12 @@ function HistoryRow({
</div>
<div className={`grid gap-2 ${showPair ? 'grid-cols-2' : 'grid-cols-1 w-1/2'}`}>
- <Link to={runUrl(pair.primary)} className="contents">
+ <Link to={runUrl(pair.primary, repoFullName)} className="contents">
<ThemePane entry={pair.primary} theme={pair.primaryTheme} />
</Link>
{showPair &&
(pair.partner ? (
- <Link to={runUrl(pair.partner)} className="contents">
+ <Link to={runUrl(pair.partner, repoFullName)} className="contents">
<ThemePane entry={pair.partner} theme={pair.partnerTheme} />
</Link>
) : (
@@ -189,9 +190,11 @@ function QuarantineSection({
onQuarantine,
onUnquarantine,
runType,
+ repoFullName,
}: {
identifier: string
runType: string
+ repoFullName: string
label?: string | null
quarantineEntry: QuarantinedIdentifierEntryApi | null
isQuarantined: boolean
@@ -252,7 +255,7 @@ function QuarantineSection({
<div className="text-xs text-muted flex flex-wrap items-center gap-x-2 gap-y-0.5">
<span>Originally failed on</span>
<Link
- to={urls.visualReviewRun(sourceRun.id)}
+ to={runPath(sourceRun.id, repoFullName)}
className="font-mono text-default"
data-attr="visual-review-quarantine-source-run"
>
@@ -319,6 +322,7 @@ export function VisualReviewSnapshotHistoryScene(): JSX.Element {
const {
repo,
repoLoading,
+ repoNotFound,
history,
historyLoading,
identifier,
@@ -326,7 +330,7 @@ export function VisualReviewSnapshotHistoryScene(): JSX.Element {
primaryTheme,
siblingIdentifier,
runType,
- repoId,
+ repoFullName: pathRepoFullName,
quarantineEntry,
quarantineEntryLoading,
siblingQuarantineEntry,
@@ -336,17 +340,30 @@ export function VisualReviewSnapshotHistoryScene(): JSX.Element {
visualReviewSnapshotHistorySceneLogic
) as any
- const repoFullName = repo?.repo_full_name ?? null
+ const repoFullName: string = repo?.repo_full_name ?? pathRepoFullName
const firstSeen = history.length > 0 ? history[history.length - 1].created_at : null
const baselineUpdates = Math.max(0, history.length - 1)
const isQuarantined = !!quarantineEntry
const isSiblingQuarantined = !!siblingQuarantineEntry
const hasThemePair = primaryTheme !== null && siblingIdentifier !== null
+ if (repoNotFound) {
+ return <NotFound object="visual review repo" />
+ }
+
return (
<SceneContent>
- <SceneTitleSection name={identifier} resourceType={{ type: 'visual_review' }} />
- {repoId && <VisualReviewTabs activeKey="snapshots" repoId={repoId} />}
+ <VisualReviewSceneTitle repoFullName={pathRepoFullName} activeTab="snapshots" />
+ <VisualReviewTabs activeKey="snapshots" repoFullName={pathRepoFullName} />
+ <VisualReviewTrail
+ crumbs={[
+ {
+ label: 'Snapshots',
+ to: urls.visualReviewSnapshotOverview(...splitRepoFullName(pathRepoFullName)),
+ },
+ { label: identifier },
+ ]}
+ />
<div className="w-full max-w-4xl mx-auto flex flex-col gap-4">
<div className="border rounded bg-bg-light flex flex-wrap items-center gap-x-10 gap-y-3 px-4 py-3">
@@ -365,20 +382,18 @@ export function VisualReviewSnapshotHistoryScene(): JSX.Element {
label={baselineUpdates === 1 ? 'Baseline update' : 'Baseline updates'}
/>
<Stat value={firstSeen ? dayjs(firstSeen).fromNow() : '–'} label="First captured" />
- {repoFullName && (
- <Stat
- value={
- <Link
- to={`https://github.com/${repoFullName}`}
- target="_blank"
- className="font-mono text-default"
- >
- {repoFullName}
- </Link>
- }
- label="Repo"
- />
- )}
+ <Stat
+ value={
+ <Link
+ to={`https://github.com/${repoFullName}`}
+ target="_blank"
+ className="font-mono text-default"
+ >
+ {repoFullName}
+ </Link>
+ }
+ label="Repo"
+ />
</div>
{hasThemePair ? (
@@ -387,6 +402,7 @@ export function VisualReviewSnapshotHistoryScene(): JSX.Element {
<QuarantineSection
identifier={identifier}
runType={runType}
+ repoFullName={repoFullName}
label={primaryTheme}
quarantineEntry={quarantineEntry}
isQuarantined={isQuarantined}
@@ -398,6 +414,7 @@ export function VisualReviewSnapshotHistoryScene(): JSX.Element {
<QuarantineSection
identifier={siblingIdentifier}
runType={runType}
+ repoFullName={repoFullName}
label={primaryTheme === 'light' ? 'dark' : 'light'}
quarantineEntry={siblingQuarantineEntry}
isQuarantined={isSiblingQuarantined}
@@ -411,6 +428,7 @@ export function VisualReviewSnapshotHistoryScene(): JSX.Element {
<QuarantineSection
identifier={identifier}
runType={runType}
+ repoFullName={repoFullName}
quarantineEntry={quarantineEntry}
isQuarantined={isQuarantined}
onQuarantine={quarantineIdentifier}
diff --git a/products/visual_review/frontend/scenes/VisualReviewSnapshotOverviewScene.tsx b/products/visual_review/frontend/scenes/VisualReviewSnapshotOverviewScene.tsx
index 6a379bc9889a..7c01fb9f43cf 100644
--- a/products/visual_review/frontend/scenes/VisualReviewSnapshotOverviewScene.tsx
+++ b/products/visual_review/frontend/scenes/VisualReviewSnapshotOverviewScene.tsx
@@ -3,17 +3,18 @@ import { useActions, useValues } from 'kea'
import { IconFlag, IconGear, IconPulse, IconWarning } from '@posthog/icons'
import { LemonBanner, LemonButton, LemonInput, LemonSegmentedButton, LemonSkeleton } from '@posthog/lemon-ui'
+import { NotFound } from 'lib/components/NotFound'
import { SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
-import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
-import { RepoSwitcher } from '../components/RepoSwitcher'
import { RECENT_DRIFT_WINDOW, SnapshotCard } from '../components/SnapshotCard'
import { SnapshotFacetSidebar } from '../components/SnapshotFacetSidebar'
import { SnapshotStatRow } from '../components/SnapshotStatRow'
+import { VisualReviewSceneTitle } from '../components/VisualReviewSceneTitle'
import { VisualReviewTabs } from '../components/VisualReviewTabs'
+import { repoFullNameFromParams } from '../lib/repoPaths'
import {
VisualReviewSnapshotOverviewSceneLogicProps,
visualReviewSnapshotOverviewSceneLogic,
@@ -22,8 +23,8 @@ import {
export const scene: SceneExport = {
component: VisualReviewSnapshotOverviewScene,
logic: visualReviewSnapshotOverviewSceneLogic,
- paramsToProps: ({ params: { repoId } }): VisualReviewSnapshotOverviewSceneLogicProps => ({
- repoId: repoId || '',
+ paramsToProps: ({ params: { repoOwner, repoName } }): VisualReviewSnapshotOverviewSceneLogicProps => ({
+ repoFullName: repoFullNameFromParams(repoOwner, repoName),
}),
}
@@ -36,8 +37,8 @@ export function VisualReviewSnapshotOverviewScene(): JSX.Element {
const {
overview,
overviewLoading,
- repo,
- repoId,
+ repoNotFound,
+ repoFullName,
filteredEntries,
statCounts,
frequentlyToleratedCount,
@@ -59,21 +60,22 @@ export function VisualReviewSnapshotOverviewScene(): JSX.Element {
filters.stability.length > 0 ||
filters.search.length > 0
+ if (repoNotFound) {
+ return <NotFound object="visual review repo" />
+ }
+
return (
<SceneContent>
- <SceneTitleSection
- name={repo?.repo_full_name ?? 'Visual review'}
- resourceType={{ type: 'visual_review' }}
+ <VisualReviewSceneTitle
+ repoFullName={repoFullName}
+ activeTab="snapshots"
actions={
- <div className="flex gap-2 items-center">
- <RepoSwitcher repoId={repoId} activeTab="snapshots" />
- <LemonButton size="small" type="secondary" icon={<IconGear />} to={urls.visualReviewSettings()}>
- Settings
- </LemonButton>
- </div>
+ <LemonButton size="small" type="secondary" icon={<IconGear />} to={urls.visualReviewSettings()}>
+ Settings
+ </LemonButton>
}
/>
- <VisualReviewTabs activeKey="snapshots" repoId={repoId} />
+ <VisualReviewTabs activeKey="snapshots" repoFullName={repoFullName} />
<SnapshotStatRow
counts={statCounts}
@@ -209,7 +211,7 @@ export function VisualReviewSnapshotOverviewScene(): JSX.Element {
{filteredEntries.map((entry) => (
<SnapshotCard
key={`${entry.run_type}::${entry.identifier}`}
- repoId={repoId}
+ repoFullName={repoFullName}
entry={entry}
thumbnailBasePath={thumbnailBasePath}
/>
diff --git a/products/visual_review/frontend/scenes/visualReviewFlakinessSceneLogic.test.ts b/products/visual_review/frontend/scenes/visualReviewFlakinessSceneLogic.test.ts
index 899b0557ef6e..ab21b5736d7b 100644
--- a/products/visual_review/frontend/scenes/visualReviewFlakinessSceneLogic.test.ts
+++ b/products/visual_review/frontend/scenes/visualReviewFlakinessSceneLogic.test.ts
@@ -1,14 +1,33 @@
import { router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
+import { urls } from 'scenes/urls'
+
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
-import type { FlakinessOverviewApi } from '../generated/api.schemas'
+import type { FlakinessOverviewApi, RepoApi } from '../generated/api.schemas'
+import { clearRepoIdCache } from '../lib/repoIds'
+import { splitRepoFullName } from '../lib/repoPaths'
import { visualReviewFlakinessSceneLogic } from './visualReviewFlakinessSceneLogic'
const REPO_ID = '00000000-0000-0000-0000-0000000000bb'
+const REPO_FULL_NAME = 'posthog/posthog'
const FLAKINESS_URL = `/api/projects/:team_id/visual_review/repos/${REPO_ID}/flakiness/`
+const REPOS_URL = '/api/projects/:team_id/visual_review/repos/'
+const FLAKINESS_PAGE = urls.visualReviewFlakiness(...splitRepoFullName(REPO_FULL_NAME))
+
+const repo: RepoApi = {
+ id: REPO_ID,
+ team_id: 1,
+ repo_external_id: 1,
+ repo_full_name: REPO_FULL_NAME,
+ baseline_file_paths: {},
+ enable_pr_comments: true,
+ debt_digest_enabled: false,
+ created_at: '2026-01-01T00:00:00Z',
+}
+const reposList = { count: 1, next: null, previous: null, results: [repo] }
const overview: FlakinessOverviewApi = {
entries: [],
@@ -31,6 +50,10 @@ describe('visualReviewFlakinessSceneLogic', () => {
let logic: ReturnType<typeof visualReviewFlakinessSceneLogic.build>
let overviewRequests = 0
+ beforeEach(() => {
+ clearRepoIdCache()
+ })
+
afterEach(() => {
logic?.unmount()
})
@@ -38,8 +61,8 @@ describe('visualReviewFlakinessSceneLogic', () => {
describe('when the overview loads', () => {
beforeEach(() => {
initKeaTests()
- useMocks({ get: { [FLAKINESS_URL]: overview } })
- logic = visualReviewFlakinessSceneLogic({ repoId: REPO_ID })
+ useMocks({ get: { [REPOS_URL]: reposList, [FLAKINESS_URL]: overview } })
+ logic = visualReviewFlakinessSceneLogic({ repoFullName: REPO_FULL_NAME })
logic.mount()
})
@@ -105,8 +128,8 @@ describe('visualReviewFlakinessSceneLogic', () => {
beforeEach(() => {
initKeaTests()
- useMocks({ get: { [FLAKINESS_URL]: nothingNeedsADecision } })
- logic = visualReviewFlakinessSceneLogic({ repoId: REPO_ID })
+ useMocks({ get: { [REPOS_URL]: reposList, [FLAKINESS_URL]: nothingNeedsADecision } })
+ logic = visualReviewFlakinessSceneLogic({ repoFullName: REPO_FULL_NAME })
logic.mount()
})
@@ -124,13 +147,13 @@ describe('visualReviewFlakinessSceneLogic', () => {
})
it('leaves a preset the link asked for alone', async () => {
- router.actions.push(`/visual_review/repos/${REPO_ID}/flakiness`, {}, { preset: 'at_risk' })
+ router.actions.push(FLAKINESS_PAGE, {}, { preset: 'at_risk' })
await expectLogic(logic).toFinishAllListeners()
expect(logic.values.filters.preset).toBe('at_risk')
})
it('leaves the default preset alone when the link names it', async () => {
- router.actions.push(`/visual_review/repos/${REPO_ID}/flakiness`, {}, { preset: 'needs_decision' })
+ router.actions.push(FLAKINESS_PAGE, {}, { preset: 'needs_decision' })
await expectLogic(logic).toFinishAllListeners()
expect(logic.values.filters.preset).toBe('needs_decision')
})
@@ -172,6 +195,7 @@ describe('visualReviewFlakinessSceneLogic', () => {
initKeaTests()
useMocks({
get: {
+ [REPOS_URL]: reposList,
[FLAKINESS_URL]: {
...overview,
entries: [
@@ -183,13 +207,13 @@ describe('visualReviewFlakinessSceneLogic', () => {
},
},
})
- logic = visualReviewFlakinessSceneLogic({ repoId: REPO_ID })
+ logic = visualReviewFlakinessSceneLogic({ repoFullName: REPO_FULL_NAME })
logic.mount()
})
// A team's digest links here with its slug, and has to open on that team's rows.
it('shows only the rows that team owns', async () => {
- router.actions.push(`/visual_review/repos/${REPO_ID}/flakiness`, {}, { teams: 'team-replay' })
+ router.actions.push(FLAKINESS_PAGE, {}, { teams: 'team-replay' })
await expectLogic(logic).toFinishAllListeners()
expect(logic.values.filters.teams).toEqual(['team-replay'])
@@ -213,8 +237,8 @@ describe('visualReviewFlakinessSceneLogic', () => {
describe('when the preset arrives in the URL', () => {
beforeEach(() => {
initKeaTests()
- useMocks({ get: { [FLAKINESS_URL]: overview } })
- logic = visualReviewFlakinessSceneLogic({ repoId: REPO_ID })
+ useMocks({ get: { [REPOS_URL]: reposList, [FLAKINESS_URL]: overview } })
+ logic = visualReviewFlakinessSceneLogic({ repoFullName: REPO_FULL_NAME })
logic.mount()
})
@@ -229,7 +253,7 @@ describe('visualReviewFlakinessSceneLogic', () => {
['broken', 'broken'],
['nonsense', 'needs_decision'],
])('resolves %s to the %s preset', async (hashValue, expected) => {
- router.actions.push(`/visual_review/repos/${REPO_ID}/flakiness`, {}, { preset: hashValue })
+ router.actions.push(FLAKINESS_PAGE, {}, { preset: hashValue })
await expectLogic(logic).toFinishAllListeners()
expect(logic.values.filters.preset).toBe(expected)
})
@@ -241,6 +265,7 @@ describe('visualReviewFlakinessSceneLogic', () => {
overviewRequests = 0
useMocks({
get: {
+ [REPOS_URL]: reposList,
[FLAKINESS_URL]: () => {
overviewRequests += 1
return overview
@@ -248,7 +273,7 @@ describe('visualReviewFlakinessSceneLogic', () => {
},
post: { '/api/projects/:team_id/visual_review/repos/:id/quarantine/:runType/': { ok: true } },
})
- logic = visualReviewFlakinessSceneLogic({ repoId: REPO_ID })
+ logic = visualReviewFlakinessSceneLogic({ repoFullName: REPO_FULL_NAME })
logic.mount()
})
@@ -268,6 +293,7 @@ describe('visualReviewFlakinessSceneLogic', () => {
// could read before the sibling committed and land last, replacing the
// fresh response with a half-applied one.
it('reloads once, after the last write settles', async () => {
+ await expectLogic(logic).toFinishAllListeners()
overviewRequests = 0
await expectLogic(logic, () => {
logic.actions.quarantineIdentifier('story--dark', 'storybook', 'flaky', null, null)
@@ -282,8 +308,10 @@ describe('visualReviewFlakinessSceneLogic', () => {
describe('when the overview fails to load', () => {
beforeEach(() => {
initKeaTests()
- useMocks({ get: { [FLAKINESS_URL]: () => [500, { detail: 'Upstream timed out' }] } })
- logic = visualReviewFlakinessSceneLogic({ repoId: REPO_ID })
+ useMocks({
+ get: { [REPOS_URL]: reposList, [FLAKINESS_URL]: () => [500, { detail: 'Upstream timed out' }] },
+ })
+ logic = visualReviewFlakinessSceneLogic({ repoFullName: REPO_FULL_NAME })
logic.mount()
})
diff --git a/products/visual_review/frontend/scenes/visualReviewFlakinessSceneLogic.ts b/products/visual_review/frontend/scenes/visualReviewFlakinessSceneLogic.ts
index 5b8b69076a65..7d152257c0c9 100644
--- a/products/visual_review/frontend/scenes/visualReviewFlakinessSceneLogic.ts
+++ b/products/visual_review/frontend/scenes/visualReviewFlakinessSceneLogic.ts
@@ -4,6 +4,7 @@ import { actionToUrl, urlToAction } from 'kea-router'
import { lemonToast } from 'lib/lemon-ui/LemonToast'
import { teamLogic } from 'scenes/teamLogic'
+import { urls } from 'scenes/urls'
import { Breadcrumb } from '~/types'
@@ -16,10 +17,13 @@ import {
} from '../generated/api'
import type { FlakinessEntryApi, FlakinessOverviewApi, RepoApi } from '../generated/api.schemas'
import { parseArea, runTypeLabel } from '../lib/parseIdentifier'
+import { repoBreadcrumbs } from '../lib/repoBreadcrumbs'
+import { resolveRepoId } from '../lib/repoIds'
+import { repoFullNameFromParams, splitRepoFullName } from '../lib/repoPaths'
import { visualReviewRepoLogic } from './visualReviewRepoLogic'
export interface VisualReviewFlakinessSceneLogicProps {
- repoId: string
+ repoFullName: string
}
// "Most failures" ranks by how much a snapshot costs, "most recent" by urgency.
@@ -195,6 +199,7 @@ function sortEntries(entries: DecoratedEntry[], sort: FlakinessSort): DecoratedE
export interface visualReviewFlakinessSceneLogicValues {
currentProjectId: number | string // teamLogic
repo: RepoApi | null // visualReviewRepoLogic
+ repoNotFound: boolean // visualReviewRepoLogic
breadcrumbs: Breadcrumb[]
decoratedEntries: DecoratedEntry[]
entries: FlakinessEntryApi[]
@@ -207,7 +212,7 @@ export interface visualReviewFlakinessSceneLogicValues {
overviewLoading: boolean
pendingQuarantineKeys: string[]
presetChosen: boolean
- repoId: string
+ repoFullName: string
statCounts: Record<FlakinessPreset, number>
thumbnailBasePath: string | null
}
@@ -288,15 +293,15 @@ export interface visualReviewFlakinessSceneLogicActions {
export interface visualReviewFlakinessSceneLogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
- repoId: (arg: any) => string
+ repoFullName: (arg: any) => string
entries: (overview: FlakinessOverviewApi | null) => FlakinessEntryApi[]
decoratedEntries: (entries: FlakinessEntryApi[]) => DecoratedEntry[]
filteredEntries: (decoratedEntries: DecoratedEntry[], filters: Filters) => DecoratedEntry[]
statCounts: (overview: FlakinessOverviewApi | null) => Record<FlakinessPreset, number>
facetGroups: (decoratedEntries: DecoratedEntry[], filters: Filters) => FacetGroups
facetSelection: (filters: Filters) => FacetSelection
- thumbnailBasePath: (currentProjectId: number | string, arg: any) => string | null
- breadcrumbs: (repo: RepoApi | null) => Breadcrumb[]
+ thumbnailBasePath: (currentProjectId: number | string, repo: RepoApi | null) => string | null
+ breadcrumbs: (repo: RepoApi | null, repoFullName: string) => Breadcrumb[]
}
}
@@ -310,9 +315,14 @@ export type visualReviewFlakinessSceneLogicType = MakeLogicType<
export const visualReviewFlakinessSceneLogic = kea<visualReviewFlakinessSceneLogicType>([
path(['products', 'visual_review', 'frontend', 'scenes', 'visualReviewFlakinessSceneLogic']),
props({} as VisualReviewFlakinessSceneLogicProps),
- key((props) => props.repoId),
+ key((props) => props.repoFullName),
connect((props: VisualReviewFlakinessSceneLogicProps) => ({
- values: [teamLogic, ['currentProjectId'], visualReviewRepoLogic({ repoId: props.repoId }), ['repo']],
+ values: [
+ teamLogic,
+ ['currentProjectId'],
+ visualReviewRepoLogic({ repoFullName: props.repoFullName }),
+ ['repo', 'repoNotFound'],
+ ],
})),
actions({
setPreset: (preset: FlakinessPreset) => ({ preset }),
@@ -408,13 +418,16 @@ export const visualReviewFlakinessSceneLogic = kea<visualReviewFlakinessSceneLog
overview: [
null as FlakinessOverviewApi | null,
{
- loadOverview: async () =>
- visualReviewReposFlakinessRetrieve(String(values.currentProjectId), props.repoId),
+ loadOverview: async () => {
+ const projectId = String(values.currentProjectId)
+ const repoId = await resolveRepoId(projectId, props.repoFullName)
+ return visualReviewReposFlakinessRetrieve(projectId, repoId)
+ },
},
],
})),
selectors({
- repoId: [() => [(_, p) => p.repoId], (repoId: string): string => repoId],
+ repoFullName: [() => [(_, p) => p.repoFullName], (repoFullName: string): string => repoFullName],
entries: [
(s) => [s.overview],
(overview: FlakinessOverviewApi | null): FlakinessEntryApi[] => overview?.entries ?? [],
@@ -473,19 +486,14 @@ export const visualReviewFlakinessSceneLogic = kea<visualReviewFlakinessSceneLog
}),
],
thumbnailBasePath: [
- (s) => [s.currentProjectId, (_, p) => p.repoId],
- (projectId: number | string, repoId: string): string | null =>
- projectId ? `/api/projects/${projectId}/visual_review/repos/${repoId}/thumbnails` : null,
+ (s) => [s.currentProjectId, s.repo],
+ (projectId: number | string, repo: RepoApi | null): string | null =>
+ projectId && repo ? `/api/projects/${projectId}/visual_review/repos/${repo.id}/thumbnails` : null,
],
- // Single scene crumb, matching the runs and snapshots scenes.
breadcrumbs: [
- (s) => [s.repo],
- (repo: RepoApi | null): Breadcrumb[] => [
- {
- key: ['visual_review_repo', repo?.id ?? 'unknown'],
- name: repo?.repo_full_name ?? 'Visual review',
- },
- ],
+ (s) => [s.repo, s.repoFullName],
+ (repo: RepoApi | null, repoFullName: string): Breadcrumb[] =>
+ repoBreadcrumbs(repo?.repo_full_name ?? repoFullName),
],
}),
listeners(({ actions, values, props }) => ({
@@ -517,7 +525,9 @@ export const visualReviewFlakinessSceneLogic = kea<visualReviewFlakinessSceneLog
},
quarantineIdentifier: async ({ identifier, runType, reason, expiresAt, sourceRunId, notifyOwners }) => {
try {
- await visualReviewReposQuarantineCreate(String(values.currentProjectId), props.repoId, runType, {
+ const projectId = String(values.currentProjectId)
+ const repoId = await resolveRepoId(projectId, props.repoFullName)
+ await visualReviewReposQuarantineCreate(projectId, repoId, runType, {
identifier,
reason,
expires_at: expiresAt,
@@ -539,7 +549,9 @@ export const visualReviewFlakinessSceneLogic = kea<visualReviewFlakinessSceneLog
},
unquarantineIdentifier: async ({ identifier, runType }) => {
try {
- await visualReviewReposQuarantineExpireCreate(String(values.currentProjectId), props.repoId, runType, {
+ const projectId = String(values.currentProjectId)
+ const repoId = await resolveRepoId(projectId, props.repoFullName)
+ await visualReviewReposQuarantineExpireCreate(projectId, repoId, runType, {
identifier,
})
lemonToast.success('Quarantine lifted. Runs gate on this snapshot again.')
@@ -577,7 +589,7 @@ export const visualReviewFlakinessSceneLogic = kea<visualReviewFlakinessSceneLog
}
return hash
}
- const path = `/visual_review/repos/${props.repoId}/flakiness`
+ const path = urls.visualReviewFlakiness(...splitRepoFullName(props.repoFullName))
const toUrl = (): [string, Record<string, string>, Record<string, string>] => [path, {}, buildHash()]
return {
setPreset: toUrl,
@@ -593,8 +605,8 @@ export const visualReviewFlakinessSceneLogic = kea<visualReviewFlakinessSceneLog
}
}),
urlToAction(({ actions, values, props }) => ({
- '/visual_review/repos/:repoId/flakiness': (params, _searchParams, hash) => {
- if (params.repoId !== props.repoId) {
+ '/visual_review/repos/:repoOwner/:repoName/flakiness': (params, _searchParams, hash) => {
+ if (repoFullNameFromParams(params.repoOwner, params.repoName) !== props.repoFullName) {
return
}
const current: Filters = values.filters
diff --git a/products/visual_review/frontend/scenes/visualReviewIndexSceneLogic.test.ts b/products/visual_review/frontend/scenes/visualReviewIndexSceneLogic.test.ts
new file mode 100644
index 000000000000..2af646e42894
--- /dev/null
+++ b/products/visual_review/frontend/scenes/visualReviewIndexSceneLogic.test.ts
@@ -0,0 +1,62 @@
+import { router } from 'kea-router'
+import { expectLogic } from 'kea-test-utils'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import { clearRepoIdCache } from '../lib/repoIds'
+import { visualReviewIndexSceneLogic } from './visualReviewIndexSceneLogic'
+
+const RUN_ID = '00000000-0000-0000-0000-0000000000aa'
+
+describe('visualReviewIndexSceneLogic', () => {
+ let releaseRun: () => void = () => {}
+
+ beforeEach(() => {
+ const runGate = new Promise<void>((resolve) => {
+ releaseRun = resolve
+ })
+ useMocks({
+ get: {
+ [`/api/projects/:team_id/visual_review/runs/${RUN_ID}/`]: async () => {
+ await runGate
+ return [200, { id: RUN_ID, repo_id: 'repo' }]
+ },
+ '/api/projects/:team_id/visual_review/repos/': [
+ 200,
+ {
+ count: 1,
+ next: null,
+ previous: null,
+ results: [{ id: 'repo', repo_full_name: 'PostHog/posthog', created_at: '2026-01-01' }],
+ },
+ ],
+ },
+ })
+ initKeaTests()
+ clearRepoIdCache()
+ })
+
+ it.each([
+ {
+ name: 'forwards an old run link to the owner/name URL',
+ leave: false,
+ expected: '/visual_review/repos/PostHog/posthog/runs/',
+ },
+ { name: 'stays on the page the user moved to during the lookup', leave: true, expected: '/settings/project' },
+ ])('$name', async ({ leave, expected }) => {
+ router.actions.push(`/visual_review/runs/${RUN_ID}`, {}, { snapshot: 'kept' })
+ const logic = visualReviewIndexSceneLogic()
+ logic.mount()
+ logic.actions.forward({ kind: 'run', runId: RUN_ID })
+ if (leave) {
+ router.actions.push('/settings/project')
+ }
+
+ releaseRun()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(router.values.location.pathname).toContain(expected)
+ expect(router.values.hashParams).toEqual(leave ? {} : { snapshot: 'kept' })
+ logic.unmount()
+ })
+})
diff --git a/products/visual_review/frontend/scenes/visualReviewIndexSceneLogic.ts b/products/visual_review/frontend/scenes/visualReviewIndexSceneLogic.ts
index bca4aa13e58e..acc29b004778 100644
--- a/products/visual_review/frontend/scenes/visualReviewIndexSceneLogic.ts
+++ b/products/visual_review/frontend/scenes/visualReviewIndexSceneLogic.ts
@@ -1,40 +1,37 @@
-import { MakeLogicType, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'
-import { loaders } from 'kea-loaders'
-import { router } from 'kea-router'
+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import { router, urlToAction } from 'kea-router'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { Breadcrumb } from '~/types'
-import { visualReviewReposList } from '../generated/api'
-import type { RepoApi } from '../generated/api.schemas'
+import { visualReviewReposList, visualReviewRunsRetrieve } from '../generated/api'
+import { ForwardUrl, LegacyRoute, legacyForwardUrl, pickLandingRepo } from '../lib/forwardUrls'
+import { RepoNotFoundError, resolveRepoFullName } from '../lib/repoIds'
+import { splitRepoFullName } from '../lib/repoPaths'
+import { visualReviewPreferencesLogic } from './visualReviewPreferencesLogic'
+
+export type ForwardRoute = { kind: 'index' } | LegacyRoute
+export type ForwardFailure = 'not_found' | 'load_failed'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface visualReviewIndexSceneLogicValues {
currentProjectId: number | string // teamLogic
+ currentTeamId: number | null // teamLogic
+ lastRepoByTeam: Record<string, string> // visualReviewPreferencesLogic
breadcrumbs: Breadcrumb[]
- repos: RepoApi[]
- reposLoadFailed: boolean
- reposLoading: boolean
+ forwardFailure: ForwardFailure | null
+ forwardRoute: ForwardRoute | null
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface visualReviewIndexSceneLogicActions {
- loadRepos: () => any
- loadReposFailure: (
- error: string,
- errorObject?: any
- ) => {
- error: string
- errorObject?: any
+ forward: (route: ForwardRoute) => {
+ route: ForwardRoute
}
- loadReposSuccess: (
- repos: RepoApi[],
- payload?: any
- ) => {
- repos: RepoApi[]
- payload?: any
+ forwardFailed: (failure: ForwardFailure) => {
+ failure: ForwardFailure
}
}
@@ -43,47 +40,96 @@ export type visualReviewIndexSceneLogicType = MakeLogicType<
visualReviewIndexSceneLogicActions
>
-// Index scene logic. Loads the team's repos and forwards to the first repo's Runs page, or to
-// Settings when none are connected. The header-bar repo switcher handles the multi-repo case.
-// Forwarding from the success action rather than from the loaded list keeps a failed load
-// distinguishable from an empty one: on failure `repos` is also `[]`, so a component deciding
-// from the list alone would send a team with repos to the connect-a-repo page.
+function isNotFound(error: any): boolean {
+ return error instanceof RepoNotFoundError || error?.status === 404
+}
+
+// Forwarding scene logic. `/visual_review` goes to the repo the team used last, else the first
+// connected repo, else Settings. URLs that name a repo or a run by UUID go to the owner/name URL
+// of the same page. A failed or unresolvable lookup stays here to show its state, so it cannot loop.
export const visualReviewIndexSceneLogic = kea<visualReviewIndexSceneLogicType>([
path(['products', 'visual_review', 'frontend', 'scenes', 'visualReviewIndexSceneLogic']),
connect(() => ({
- values: [teamLogic, ['currentProjectId']],
+ values: [teamLogic, ['currentProjectId', 'currentTeamId'], visualReviewPreferencesLogic, ['lastRepoByTeam']],
})),
- loaders(({ values }) => ({
- repos: [
- [] as RepoApi[],
+ actions({
+ forward: (route: ForwardRoute) => ({ route }),
+ forwardFailed: (failure: ForwardFailure) => ({ failure }),
+ }),
+ reducers({
+ forwardRoute: [
+ null as ForwardRoute | null,
{
- loadRepos: async () => {
- const response = await visualReviewReposList(String(values.currentProjectId))
- return response.results
- },
+ forward: (_, { route }) => route,
},
],
- })),
- reducers({
- reposLoadFailed: [
- false,
+ forwardFailure: [
+ null as ForwardFailure | null,
{
- loadRepos: () => false,
- loadReposFailure: () => true,
+ forward: () => null,
+ forwardFailed: (_, { failure }) => failure,
},
],
}),
selectors({
breadcrumbs: [() => [], (): Breadcrumb[] => [{ key: 'visual_review', name: 'Visual review' }]],
}),
- listeners(({ values }) => ({
- loadReposSuccess: () => {
- router.actions.replace(
- values.repos.length >= 1 ? urls.visualReviewRepoRuns(values.repos[0].id) : urls.visualReviewSettings()
- )
+ listeners(({ actions, values }) => ({
+ forward: async ({ route }) => {
+ const projectId = String(values.currentProjectId)
+ // The lookups below are async, so read the URL now, before the user can move to another page.
+ const { pathname } = router.values.location
+ const { searchParams, hashParams } = router.values
+ let destination: ForwardUrl
+ try {
+ if (route.kind === 'index') {
+ const response = await visualReviewReposList(projectId)
+ const lastRepoFullName = values.currentTeamId
+ ? (values.lastRepoByTeam[values.currentTeamId] ?? null)
+ : null
+ const repo = pickLandingRepo(response.results, lastRepoFullName)
+ destination = {
+ path: repo
+ ? urls.visualReviewRepoRuns(...splitRepoFullName(repo.repo_full_name))
+ : urls.visualReviewSettings(),
+ searchParams: {},
+ hashParams: {},
+ }
+ } else {
+ const repoId =
+ route.kind === 'run'
+ ? (await visualReviewRunsRetrieve(projectId, route.runId)).repo_id
+ : route.repoId
+ const repoFullName = await resolveRepoFullName(projectId, repoId)
+ destination = legacyForwardUrl(route, repoFullName, searchParams, hashParams)
+ }
+ } catch (error) {
+ if (router.values.location.pathname === pathname) {
+ actions.forwardFailed(isNotFound(error) ? 'not_found' : 'load_failed')
+ }
+ return
+ }
+ if (router.values.location.pathname !== pathname) {
+ return
+ }
+ router.actions.replace(destination.path, destination.searchParams, destination.hashParams)
},
})),
- afterMount(({ actions }) => {
- actions.loadRepos()
- }),
+ urlToAction(({ actions }) => ({
+ '/visual_review': () => actions.forward({ kind: 'index' }),
+ '/visual_review/runs/:runId': ({ runId }) => actions.forward({ kind: 'run', runId: runId ?? '' }),
+ '/visual_review/repos/:repoId/runs': ({ repoId }) =>
+ actions.forward({ kind: 'repoPage', repoId: repoId ?? '', page: 'runs' }),
+ '/visual_review/repos/:repoId/snapshots': ({ repoId }) =>
+ actions.forward({ kind: 'repoPage', repoId: repoId ?? '', page: 'snapshots' }),
+ '/visual_review/repos/:repoId/flakiness': ({ repoId }) =>
+ actions.forward({ kind: 'repoPage', repoId: repoId ?? '', page: 'flakiness' }),
+ '/visual_review/repos/:repoId/:runType/snapshots/:identifier': ({ repoId, runType, identifier }) =>
+ actions.forward({
+ kind: 'snapshotHistory',
+ repoId: repoId ?? '',
+ runType: decodeURIComponent(runType ?? ''),
+ identifier: decodeURIComponent(identifier ?? ''),
+ }),
+ })),
])
diff --git a/products/visual_review/frontend/scenes/visualReviewPreferencesLogic.ts b/products/visual_review/frontend/scenes/visualReviewPreferencesLogic.ts
index 16cfaeb6b2b3..e397457bb68a 100644
--- a/products/visual_review/frontend/scenes/visualReviewPreferencesLogic.ts
+++ b/products/visual_review/frontend/scenes/visualReviewPreferencesLogic.ts
@@ -6,10 +6,18 @@ import type { ComparisonMode } from 'lib/components/VisualImageDiffViewer/Visual
export interface visualReviewPreferencesLogicValues {
addImagesToComment: boolean
comparisonMode: ComparisonMode
+ lastRepoByTeam: Record<string, string>
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface visualReviewPreferencesLogicActions {
+ rememberRepo: (
+ teamId: number,
+ repoFullName: string
+ ) => {
+ repoFullName: string
+ teamId: number
+ }
setAddImagesToComment: (enabled: boolean) => {
enabled: boolean
}
@@ -28,6 +36,7 @@ export const visualReviewPreferencesLogic = kea<visualReviewPreferencesLogicType
actions({
setComparisonMode: (mode: ComparisonMode) => ({ mode }),
setAddImagesToComment: (enabled: boolean) => ({ enabled }),
+ rememberRepo: (teamId: number, repoFullName: string) => ({ teamId, repoFullName }),
}),
reducers({
comparisonMode: [
@@ -44,5 +53,13 @@ export const visualReviewPreferencesLogic = kea<visualReviewPreferencesLogicType
setAddImagesToComment: (_, { enabled }) => enabled,
},
],
+ // The `/visual_review` entry point opens the repo a team used last.
+ lastRepoByTeam: [
+ {} as Record<string, string>,
+ { persist: true, prefix: 'visual_review_' },
+ {
+ rememberRepo: (state, { teamId, repoFullName }) => ({ ...state, [teamId]: repoFullName }),
+ },
+ ],
}),
])
diff --git a/products/visual_review/frontend/scenes/visualReviewRepoLogic.ts b/products/visual_review/frontend/scenes/visualReviewRepoLogic.ts
index 1f223bf564b3..507d9bfdaec5 100644
--- a/products/visual_review/frontend/scenes/visualReviewRepoLogic.ts
+++ b/products/visual_review/frontend/scenes/visualReviewRepoLogic.ts
@@ -1,13 +1,15 @@
-import { MakeLogicType, afterMount, connect, kea, key, path, props, selectors } from 'kea'
+import { MakeLogicType, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
import { teamLogic } from 'scenes/teamLogic'
import { visualReviewReposList, visualReviewReposRetrieve } from '../generated/api'
import type { RepoApi } from '../generated/api.schemas'
+import { RepoNotFoundError, resolveRepoId } from '../lib/repoIds'
+import { visualReviewPreferencesLogic } from './visualReviewPreferencesLogic'
export interface VisualReviewRepoLogicProps {
- repoId: string
+ repoFullName: string
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -17,12 +19,19 @@ export interface visualReviewRepoLogicValues {
allReposLoading: boolean
otherRepos: RepoApi[]
repo: RepoApi | null
- repoFullName: string | undefined
repoLoading: boolean
+ repoNotFound: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface visualReviewRepoLogicActions {
+ rememberRepo: (
+ teamId: number,
+ repoFullName: string
+ ) => {
+ repoFullName: string
+ teamId: number
+ } // visualReviewPreferencesLogic
loadAllRepos: () => any
loadAllReposFailure: (
error: string,
@@ -59,7 +68,6 @@ export interface visualReviewRepoLogicActions {
export interface visualReviewRepoLogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
- repoFullName: (repo: RepoApi | null) => string | undefined
otherRepos: (allRepos: RepoApi[], arg: any) => RepoApi[]
}
}
@@ -71,23 +79,25 @@ export type visualReviewRepoLogicType = MakeLogicType<
visualReviewRepoLogicMeta
>
-// Shared repo state for both Runs and Snapshots scenes — keyed by repoId so
-// the data only loads once per workspace and survives tab navigation. Without
-// this, each scene's own loadRepo re-fetches on mount and the title/tab
+// Shared repo state for the Runs, Snapshots and Flakiness scenes. It is keyed by the repo's
+// full name from the URL so the data only loads once per workspace and survives tab navigation.
+// Without this, each scene's own loadRepo re-fetches on mount and the title/tab
// strip flicker as the response comes back.
export const visualReviewRepoLogic = kea<visualReviewRepoLogicType>([
path(['products', 'visual_review', 'frontend', 'scenes', 'visualReviewRepoLogic']),
props({} as VisualReviewRepoLogicProps),
- key((props) => props.repoId),
+ key((props) => props.repoFullName),
connect(() => ({
values: [teamLogic, ['currentProjectId']],
+ actions: [visualReviewPreferencesLogic, ['rememberRepo']],
})),
loaders(({ props, values }) => ({
repo: [
null as RepoApi | null,
{
loadRepo: async () => {
- return visualReviewReposRetrieve(String(values.currentProjectId), props.repoId)
+ const projectId = String(values.currentProjectId)
+ return visualReviewReposRetrieve(projectId, await resolveRepoId(projectId, props.repoFullName))
},
},
],
@@ -104,13 +114,27 @@ export const visualReviewRepoLogic = kea<visualReviewRepoLogicType>([
},
],
})),
+ reducers({
+ repoNotFound: [
+ false,
+ {
+ loadRepo: () => false,
+ loadRepoFailure: (_, { errorObject }) => errorObject instanceof RepoNotFoundError,
+ },
+ ],
+ }),
selectors({
- repoFullName: [(s) => [s.repo], (repo: RepoApi | null): string | undefined => repo?.repo_full_name],
otherRepos: [
- (s) => [s.allRepos, (_, p) => p.repoId],
- (allRepos: RepoApi[], repoId: string): RepoApi[] => allRepos.filter((r) => r.id !== repoId),
+ (s) => [s.allRepos, (_, p) => p.repoFullName],
+ (allRepos: RepoApi[], repoFullName: string): RepoApi[] =>
+ allRepos.filter((r) => r.repo_full_name.toLowerCase() !== repoFullName.toLowerCase()),
],
}),
+ listeners(({ actions }) => ({
+ loadRepoSuccess: ({ repo }) => {
+ actions.rememberRepo(repo.team_id, repo.repo_full_name)
+ },
+ })),
afterMount(({ actions }) => {
actions.loadRepo()
actions.loadAllRepos()
diff --git a/products/visual_review/frontend/scenes/visualReviewRunSceneLogic.test.ts b/products/visual_review/frontend/scenes/visualReviewRunSceneLogic.test.ts
index 7406763064e8..30b98806f438 100644
--- a/products/visual_review/frontend/scenes/visualReviewRunSceneLogic.test.ts
+++ b/products/visual_review/frontend/scenes/visualReviewRunSceneLogic.test.ts
@@ -1,3 +1,4 @@
+import { router } from 'kea-router'
import { expectLogic, partial } from 'kea-test-utils'
import { useMocks } from '~/mocks/jest'
@@ -267,4 +268,53 @@ describe('visualReviewRunSceneLogic', () => {
selectedLiftOnMergeDisabledReason: disabledReason,
})
})
+
+ it.each([
+ {
+ name: 'moves a renamed repo path to the run repo',
+ pathName: 'PostHog/old-name',
+ leaveTo: null,
+ expectedPath: '/visual_review/repos/PostHog/posthog/runs/',
+ },
+ {
+ name: 'keeps a path that differs only in case',
+ pathName: 'posthog/POSTHOG',
+ leaveTo: null,
+ expectedPath: '/visual_review/repos/posthog/POSTHOG/runs/',
+ },
+ {
+ name: 'stays on the page the user moved to before the repo loaded',
+ pathName: 'PostHog/old-name',
+ leaveTo: '/insights',
+ expectedPath: '/insights',
+ },
+ ])('$name', async ({ pathName, leaveTo, expectedPath }) => {
+ // A run of its own, because the shared logic already loaded the run without a repo name.
+ const NAMED_RUN_ID = '00000000-0000-0000-0000-0000000000bb'
+ useMocks({
+ get: {
+ [`/api/projects/:team_id/visual_review/runs/${NAMED_RUN_ID}/`]: [
+ 200,
+ { id: NAMED_RUN_ID, repo_id: 'repo', run_type: 'storybook', pr_number: 7, status: 'completed' },
+ ],
+ '/api/projects/:team_id/visual_review/repos/repo/': [
+ 200,
+ { id: 'repo', team_id: 1, repo_full_name: 'PostHog/posthog' },
+ ],
+ },
+ })
+ const [owner, name] = pathName.split('/')
+ router.actions.push(`/visual_review/repos/${owner}/${name}/runs/${NAMED_RUN_ID}`, {}, { snapshot: 'kept' })
+ const namedLogic = visualReviewRunSceneLogic({ runId: NAMED_RUN_ID, repoFullName: pathName })
+ namedLogic.mount()
+ if (leaveTo) {
+ router.actions.push(leaveTo, {}, { snapshot: 'kept' })
+ }
+
+ await expectLogic(namedLogic).toDispatchActions(['loadRepoSuccess'])
+ await expectLogic(namedLogic).toMatchValues({ repoFullName: 'PostHog/posthog' })
+ expect(router.values.location.pathname).toContain(expectedPath)
+ expect(router.values.hashParams).toEqual({ snapshot: 'kept' })
+ namedLogic.unmount()
+ })
})
diff --git a/products/visual_review/frontend/scenes/visualReviewRunSceneLogic.ts b/products/visual_review/frontend/scenes/visualReviewRunSceneLogic.ts
index 0e04df1bac1d..fe9e48fe83ed 100644
--- a/products/visual_review/frontend/scenes/visualReviewRunSceneLogic.ts
+++ b/products/visual_review/frontend/scenes/visualReviewRunSceneLogic.ts
@@ -1,6 +1,6 @@
import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
-import { actionToUrl, urlToAction } from 'kea-router'
+import { actionToUrl, router, urlToAction } from 'kea-router'
import posthog from 'posthog-js'
import { dayjs } from 'lib/dayjs'
@@ -40,11 +40,15 @@ import {
liftRequestsByIdentifier,
} from '../lib/liftOnMerge'
import { type RecentTolerations, countRecentTolerations } from '../lib/quarantineNudge'
+import { repoBreadcrumbs } from '../lib/repoBreadcrumbs'
+import { runPath } from '../lib/repoPaths'
import { isReportingOnlyRun } from '../lib/runPredicates'
import { visualReviewPreferencesLogic } from './visualReviewPreferencesLogic'
export interface VisualReviewRunSceneLogicProps {
runId: string
+ // The repo named in the URL. Links use it until the run's repo loads.
+ repoFullName?: string
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -102,6 +106,13 @@ export interface visualReviewRunSceneLogicValues {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface visualReviewRunSceneLogicActions {
+ rememberRepo: (
+ teamId: number,
+ repoFullName: string
+ ) => {
+ repoFullName: string
+ teamId: number
+ } // visualReviewPreferencesLogic
setAddImagesToComment: (enabled: boolean) => {
enabled: boolean
} // visualReviewPreferencesLogic
@@ -346,12 +357,12 @@ export interface visualReviewRunSceneLogicMeta {
quarantineLiftsLoading: boolean,
quarantineLiftsLoadFailed: boolean
) => string | null
- repoFullName: (repo: RepoApi | null) => string | null
+ repoFullName: (repo: RepoApi | null, arg: any) => string | null
thumbnailBasePath: (run: RunApi | null, currentProjectId: number | string) => string | null
isRunInProgress: (run: RunApi | null) => boolean
isRunProcessing: (run: RunApi | null) => boolean
isReportingOnly: (run: RunApi | null) => boolean
- breadcrumbs: (run: RunApi | null) => Breadcrumb[]
+ breadcrumbs: (repo: RepoApi | null, repoFullName: string | null) => Breadcrumb[]
}
}
@@ -378,7 +389,7 @@ export const visualReviewRunSceneLogic = kea<visualReviewRunSceneLogicType>([
key((props) => props.runId),
connect(() => ({
values: [teamLogic, ['currentProjectId'], visualReviewPreferencesLogic, ['addImagesToComment']],
- actions: [visualReviewPreferencesLogic, ['setAddImagesToComment']],
+ actions: [visualReviewPreferencesLogic, ['setAddImagesToComment', 'rememberRepo']],
})),
actions({
setSelectedSnapshotId: (snapshotId: string | null) => ({ snapshotId }),
@@ -814,7 +825,12 @@ export const visualReviewRunSceneLogic = kea<visualReviewRunSceneLogicType>([
return selectedSnapshot ? liftOnMergeDisabledReason(selectedSnapshot) : null
},
],
- repoFullName: [(s) => [s.repo], (repo: RepoApi | null): string | null => repo?.repo_full_name || null],
+ // The URL can name another repo after a rename or a hand edit, so the run's own repo wins once it loads.
+ repoFullName: [
+ (s) => [s.repo, (_, p) => p.repoFullName],
+ (repo: RepoApi | null, repoFullName: string | undefined): string | null =>
+ repo?.repo_full_name || repoFullName || null,
+ ],
thumbnailBasePath: [
(s) => [s.run, s.currentProjectId],
(run: RunApi | null, projectId: number | string): string | null => {
@@ -830,19 +846,11 @@ export const visualReviewRunSceneLogic = kea<visualReviewRunSceneLogicType>([
],
isRunProcessing: [(s) => [s.run], (run: RunApi | null): boolean => run?.status === 'processing'],
isReportingOnly: [(s) => [s.run], (run: RunApi | null): boolean => isReportingOnlyRun(run)],
+ // The branch names the run in the page's own trail, so the top bar stops at the repository like the tabs do.
breadcrumbs: [
- (s) => [s.run],
- (run: RunApi | null): Breadcrumb[] => [
- {
- key: 'visual_review',
- name: 'Visual review',
- path: '/visual_review',
- },
- {
- key: 'visual_review_run',
- name: run?.branch || 'Run',
- },
- ],
+ (s) => [s.repo, s.repoFullName],
+ (repo: RepoApi | null, repoFullName: string | null): Breadcrumb[] =>
+ repoBreadcrumbs(repo?.repo_full_name ?? repoFullName),
],
}),
listeners(({ actions, values, props }) => ({
@@ -865,6 +873,25 @@ export const visualReviewRunSceneLogic = kea<visualReviewRunSceneLogicType>([
actions.loadQuarantineLifts()
actions.loadQuarantinedRunSnapshots()
},
+ loadRepoSuccess: ({ repo }) => {
+ if (!repo) {
+ return
+ }
+ actions.rememberRepo(repo.team_id, repo.repo_full_name)
+ // The repo request can finish after the user moved on while this logic is still mounted.
+ const stillOnThisRun = router.values.location.pathname.endsWith(`/runs/${props.runId}`)
+ if (
+ stillOnThisRun &&
+ props.repoFullName &&
+ props.repoFullName.toLowerCase() !== repo.repo_full_name.toLowerCase()
+ ) {
+ router.actions.replace(
+ runPath(props.runId, repo.repo_full_name),
+ router.values.searchParams,
+ router.values.hashParams
+ )
+ }
+ },
loadSnapshotsSuccess: () => {
const snapshot = values.selectedSnapshot
if (snapshot) {
@@ -1083,21 +1110,26 @@ export const visualReviewRunSceneLogic = kea<visualReviewRunSceneLogicType>([
},
})),
urlToAction(({ actions, values, props }) => ({
- '/visual_review/runs/:runId': ({ runId }, _searchParams, { snapshot }) => {
+ '/visual_review/repos/:repoOwner/:repoName/runs/:runId': ({ runId }, searchParams, hashParams) => {
if (runId !== props.runId) {
return
}
+ // Old PR comments carry the selection as `?snapshot=`, so read it when the hash has none.
+ const snapshot = hashParams.snapshot ?? searchParams.snapshot
if (snapshot && snapshot !== values.selectedSnapshotId) {
actions.setSelectedSnapshotId(snapshot)
}
},
})),
- actionToUrl(({ props }) => ({
+ actionToUrl(({ props, values }) => ({
setSelectedSnapshotId: ({ snapshotId }) => {
+ const path = runPath(props.runId, values.repoFullName ?? undefined)
+ // The hash now carries the selection, so an old `?snapshot=` must not outlive it.
+ const { snapshot: _oldSnapshot, ...searchParams } = router.values.searchParams
if (snapshotId) {
- return [`/visual_review/runs/${props.runId}`, {}, { snapshot: snapshotId }]
+ return [path, searchParams, { snapshot: snapshotId }]
}
- return [`/visual_review/runs/${props.runId}`]
+ return [path, searchParams]
},
})),
afterMount(({ actions }) => {
diff --git a/products/visual_review/frontend/scenes/visualReviewRunsSceneLogic.ts b/products/visual_review/frontend/scenes/visualReviewRunsSceneLogic.ts
index 4e9857d1031d..16392d4aed35 100644
--- a/products/visual_review/frontend/scenes/visualReviewRunsSceneLogic.ts
+++ b/products/visual_review/frontend/scenes/visualReviewRunsSceneLogic.ts
@@ -12,6 +12,8 @@ import type {
ReviewStateCountsApi,
VisualReviewReposRunsListReviewState,
} from '../generated/api.schemas'
+import { repoBreadcrumbs } from '../lib/repoBreadcrumbs'
+import { resolveRepoId } from '../lib/repoIds'
import { visualReviewRepoLogic } from './visualReviewRepoLogic'
export type ReviewState = VisualReviewReposRunsListReviewState
@@ -19,20 +21,20 @@ export type ReviewState = VisualReviewReposRunsListReviewState
const RUNS_PAGE_SIZE = 20
export interface VisualReviewRunsSceneLogicProps {
- repoId: string
+ repoFullName: string
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface visualReviewRunsSceneLogicValues {
currentProjectId: number | string // teamLogic
repo: RepoApi | null // visualReviewRepoLogic
- repoFullName: string | undefined // visualReviewRepoLogic
+ repoNotFound: boolean // visualReviewRepoLogic
activeTab: ReviewState
breadcrumbs: Breadcrumb[]
counts: ReviewStateCountsApi
countsLoading: boolean
page: number
- repoId: string
+ repoFullName: string
runs: PaginatedRunListApi['results']
runsLoading: boolean
runsResponse: PaginatedRunListApi
@@ -88,11 +90,11 @@ export interface visualReviewRunsSceneLogicActions {
export interface visualReviewRunsSceneLogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
- repoId: (arg: any) => string
+ repoFullName: (arg: any) => string
runs: (runsResponse: PaginatedRunListApi) => PaginatedRunListApi['results']
runsLoading: (runsResponseLoading: boolean) => boolean
totalCount: (runsResponse: PaginatedRunListApi) => number
- breadcrumbs: (repo: RepoApi | null) => Breadcrumb[]
+ breadcrumbs: (repo: RepoApi | null, repoFullName: string) => Breadcrumb[]
}
}
@@ -106,14 +108,14 @@ export type visualReviewRunsSceneLogicType = MakeLogicType<
export const visualReviewRunsSceneLogic = kea<visualReviewRunsSceneLogicType>([
path(['products', 'visual_review', 'frontend', 'scenes', 'visualReviewRunsSceneLogic']),
props({} as VisualReviewRunsSceneLogicProps),
- key((props) => props.repoId),
+ key((props) => props.repoFullName),
connect((props: VisualReviewRunsSceneLogicProps) => ({
values: [
teamLogic,
['currentProjectId'],
- visualReviewRepoLogic({ repoId: props.repoId }),
- ['repo', 'repoFullName'],
+ visualReviewRepoLogic({ repoFullName: props.repoFullName }),
+ ['repo', 'repoNotFound'],
],
})),
@@ -156,7 +158,9 @@ export const visualReviewRunsSceneLogic = kea<visualReviewRunsSceneLogicType>([
const search = values.searchQuery.trim()
// Tag each request; a slower, superseded one must not overwrite a newer one's results.
const requestId = (cache.loadRunsSeq = (cache.loadRunsSeq ?? 0) + 1)
- const response = await visualReviewReposRunsList(String(values.currentProjectId), props.repoId, {
+ const projectId = String(values.currentProjectId)
+ const repoId = await resolveRepoId(projectId, props.repoFullName)
+ const response = await visualReviewReposRunsList(projectId, repoId, {
review_state: values.activeTab,
limit: RUNS_PAGE_SIZE,
offset,
@@ -173,33 +177,26 @@ export const visualReviewRunsSceneLogic = kea<visualReviewRunsSceneLogicType>([
{ needs_review: 0, clean: 0, processing: 0, stale: 0 } as ReviewStateCountsApi,
{
loadCounts: async () => {
- return await visualReviewReposRunsCountsRetrieve(String(values.currentProjectId), props.repoId)
+ const projectId = String(values.currentProjectId)
+ const repoId = await resolveRepoId(projectId, props.repoFullName)
+ return await visualReviewReposRunsCountsRetrieve(projectId, repoId)
},
},
],
})),
selectors({
- repoId: [() => [(_, p) => p.repoId], (repoId: string): string => repoId],
+ repoFullName: [() => [(_, p) => p.repoFullName], (repoFullName: string): string => repoFullName],
runs: [
(s) => [s.runsResponse],
(runsResponse: PaginatedRunListApi): PaginatedRunListApi['results'] => runsResponse.results,
],
runsLoading: [(s) => [s.runsResponseLoading], (loading: boolean): boolean => loading],
totalCount: [(s) => [s.runsResponse], (runsResponse: PaginatedRunListApi): number => runsResponse.count ?? 0],
- // Only one scene-level crumb — the project crumb is prepended
- // automatically. With two scene crumbs the SceneTitleSection back
- // button kicks in (it shows when total breadcrumbs > 2), and
- // clicking back lands on /visual_review which immediately redirects
- // straight here, so the back arrow does nothing useful.
breadcrumbs: [
- (s) => [s.repo],
- (repo: RepoApi | null): Breadcrumb[] => [
- {
- key: ['visual_review_repo', repo?.id ?? 'unknown'],
- name: repo?.repo_full_name ?? 'Visual review',
- },
- ],
+ (s) => [s.repo, s.repoFullName],
+ (repo: RepoApi | null, repoFullName: string): Breadcrumb[] =>
+ repoBreadcrumbs(repo?.repo_full_name ?? repoFullName),
],
}),
diff --git a/products/visual_review/frontend/scenes/visualReviewSnapshotHistorySceneLogic.ts b/products/visual_review/frontend/scenes/visualReviewSnapshotHistorySceneLogic.ts
index efdf6b623d37..16e766979240 100644
--- a/products/visual_review/frontend/scenes/visualReviewSnapshotHistorySceneLogic.ts
+++ b/products/visual_review/frontend/scenes/visualReviewSnapshotHistorySceneLogic.ts
@@ -3,7 +3,6 @@ import { loaders } from 'kea-loaders'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { teamLogic } from 'scenes/teamLogic'
-import { urls } from 'scenes/urls'
import { Breadcrumb } from '~/types'
@@ -11,13 +10,15 @@ import {
visualReviewReposQuarantineCreate,
visualReviewReposQuarantineExpireCreate,
visualReviewReposQuarantineList,
- visualReviewReposRetrieve,
visualReviewReposSnapshotsList,
} from '../generated/api'
import type { QuarantinedIdentifierEntryApi, RepoApi, SnapshotHistoryEntryApi } from '../generated/api.schemas'
+import { repoBreadcrumbs } from '../lib/repoBreadcrumbs'
+import { resolveRepoId } from '../lib/repoIds'
+import { visualReviewRepoLogic } from './visualReviewRepoLogic'
export interface VisualReviewSnapshotHistorySceneLogicProps {
- repoId: string
+ repoFullName: string
runType: string
identifier: string
}
@@ -46,6 +47,9 @@ function detectTheme(identifier: string): { stem: string; theme: 'light' | 'dark
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface visualReviewSnapshotHistorySceneLogicValues {
currentProjectId: number | string // teamLogic
+ repo: RepoApi | null // visualReviewRepoLogic
+ repoLoading: boolean // visualReviewRepoLogic
+ repoNotFound: boolean // visualReviewRepoLogic
breadcrumbs: Breadcrumb[]
history: SnapshotHistoryEntryApi[]
historyLoading: boolean
@@ -56,9 +60,7 @@ export interface visualReviewSnapshotHistorySceneLogicValues {
primaryTheme: 'dark' | 'light' | null
quarantineEntry: QuarantinedIdentifierEntryApi | null
quarantineEntryLoading: boolean
- repo: RepoApi | null
- repoId: string
- repoLoading: boolean
+ repoFullName: string
runType: string
siblingIdentifier: string | null
siblingQuarantineEntry: QuarantinedIdentifierEntryApi | null
@@ -112,21 +114,6 @@ export interface visualReviewSnapshotHistorySceneLogicActions {
quarantineEntry: QuarantinedIdentifierEntryApi | null
payload?: any
}
- loadRepo: () => any
- loadRepoFailure: (
- error: string,
- errorObject?: any
- ) => {
- error: string
- errorObject?: any
- }
- loadRepoSuccess: (
- repo: RepoApi,
- payload?: any
- ) => {
- repo: RepoApi
- payload?: any
- }
loadSiblingQuarantineEntry: () => any
loadSiblingQuarantineEntryFailure: (
error: string,
@@ -169,7 +156,7 @@ export interface visualReviewSnapshotHistorySceneLogicMeta {
__keaTypeGenInternalSelectorTypes: {
identifier: (arg: any) => string
runType: (arg: any) => string
- repoId: (arg: any) => string
+ repoFullName: (arg: any) => string
primaryTheme: (arg: any) => 'dark' | 'light' | null
siblingIdentifier: (arg: any) => string | null
pairedHistory: (
@@ -177,7 +164,7 @@ export interface visualReviewSnapshotHistorySceneLogicMeta {
partnerHistory: SnapshotHistoryEntryApi[],
primaryTheme: 'dark' | 'light' | null
) => ThemePair[]
- breadcrumbs: (arg: any, arg2: any) => Breadcrumb[]
+ breadcrumbs: (repo: RepoApi | null, arg: any) => Breadcrumb[]
}
}
@@ -191,9 +178,14 @@ export type visualReviewSnapshotHistorySceneLogicType = MakeLogicType<
export const visualReviewSnapshotHistorySceneLogic = kea<visualReviewSnapshotHistorySceneLogicType>([
path(['products', 'visual_review', 'frontend', 'scenes', 'visualReviewSnapshotHistorySceneLogic']),
props({} as VisualReviewSnapshotHistorySceneLogicProps),
- key(({ repoId, runType, identifier }) => `${repoId}::${runType}::${identifier}`),
- connect(() => ({
- values: [teamLogic, ['currentProjectId']],
+ key(({ repoFullName, runType, identifier }) => `${repoFullName}::${runType}::${identifier}`),
+ connect((props: VisualReviewSnapshotHistorySceneLogicProps) => ({
+ values: [
+ teamLogic,
+ ['currentProjectId'],
+ visualReviewRepoLogic({ repoFullName: props.repoFullName }),
+ ['repo', 'repoLoading', 'repoNotFound'],
+ ],
})),
actions({
quarantineIdentifier: (
@@ -213,21 +205,15 @@ export const visualReviewSnapshotHistorySceneLogic = kea<visualReviewSnapshotHis
unquarantineSibling: true,
}),
loaders(({ props, values }) => ({
- repo: [
- null as RepoApi | null,
- {
- loadRepo: async () => {
- return visualReviewReposRetrieve(String(values.currentProjectId), props.repoId)
- },
- },
- ],
history: [
[] as SnapshotHistoryEntryApi[],
{
loadHistory: async () => {
+ const projectId = String(values.currentProjectId)
+ const repoId = await resolveRepoId(projectId, props.repoFullName)
const response = await visualReviewReposSnapshotsList(
- String(values.currentProjectId),
- props.repoId,
+ projectId,
+ repoId,
props.runType,
encodeURIComponent(props.identifier),
{ limit: 100 }
@@ -245,9 +231,11 @@ export const visualReviewSnapshotHistorySceneLogic = kea<visualReviewSnapshotHis
return []
}
const partner = `${stem}--${theme === 'light' ? 'dark' : 'light'}`
+ const projectId = String(values.currentProjectId)
+ const repoId = await resolveRepoId(projectId, props.repoFullName)
const response = await visualReviewReposSnapshotsList(
- String(values.currentProjectId),
- props.repoId,
+ projectId,
+ repoId,
props.runType,
encodeURIComponent(partner),
{ limit: 100 }
@@ -260,11 +248,12 @@ export const visualReviewSnapshotHistorySceneLogic = kea<visualReviewSnapshotHis
null as QuarantinedIdentifierEntryApi | null,
{
loadQuarantineEntry: async () => {
- const response = await visualReviewReposQuarantineList(
- String(values.currentProjectId),
- props.repoId,
- { identifier: props.identifier, run_type: props.runType }
- )
+ const projectId = String(values.currentProjectId)
+ const repoId = await resolveRepoId(projectId, props.repoFullName)
+ const response = await visualReviewReposQuarantineList(projectId, repoId, {
+ identifier: props.identifier,
+ run_type: props.runType,
+ })
const now = Date.now()
return (
response.results.find(
@@ -287,11 +276,12 @@ export const visualReviewSnapshotHistorySceneLogic = kea<visualReviewSnapshotHis
if (!sibling) {
return null
}
- const response = await visualReviewReposQuarantineList(
- String(values.currentProjectId),
- props.repoId,
- { identifier: sibling, run_type: props.runType }
- )
+ const projectId = String(values.currentProjectId)
+ const repoId = await resolveRepoId(projectId, props.repoFullName)
+ const response = await visualReviewReposQuarantineList(projectId, repoId, {
+ identifier: sibling,
+ run_type: props.runType,
+ })
const now = Date.now()
return (
response.results.find(
@@ -306,7 +296,7 @@ export const visualReviewSnapshotHistorySceneLogic = kea<visualReviewSnapshotHis
selectors({
identifier: [() => [(_, p) => p.identifier], (identifier: string): string => identifier],
runType: [() => [(_, p) => p.runType], (runType: string): string => runType],
- repoId: [() => [(_, p) => p.repoId], (repoId: string): string => repoId],
+ repoFullName: [() => [(_, p) => p.repoFullName], (repoFullName: string): string => repoFullName],
primaryTheme: [
() => [(_, p) => p.identifier],
(identifier: string): 'light' | 'dark' | null => detectTheme(identifier).theme,
@@ -344,39 +334,30 @@ export const visualReviewSnapshotHistorySceneLogic = kea<visualReviewSnapshotHis
}))
},
],
+ // The identifier names the snapshot in the page's own trail, so the top bar stops at the repository like the tabs do.
breadcrumbs: [
- () => [(_, p) => p.identifier, (_, p) => p.repoId],
- (identifier: string, repoId: string): Breadcrumb[] => [
- { key: 'visual_review', name: 'Visual review', path: '/visual_review' },
- {
- key: ['visual_review_snapshots', repoId],
- name: 'Snapshots',
- path: urls.visualReviewSnapshotOverview(repoId),
- },
- { key: ['visual_review_snapshot_history', identifier], name: identifier },
- ],
+ (s) => [s.repo, (_, p) => p.repoFullName],
+ (repo: RepoApi | null, repoFullName: string): Breadcrumb[] =>
+ repoBreadcrumbs(repo?.repo_full_name ?? repoFullName),
],
}),
listeners(({ actions, values, props }) => ({
quarantineIdentifier: async ({ reason, identifiers, expiresAt, sourceRunId, notifyOwners }) => {
try {
+ const projectId = String(values.currentProjectId)
+ const repoId = await resolveRepoId(projectId, props.repoFullName)
await Promise.all(
identifiers.map((identifier, index) =>
- visualReviewReposQuarantineCreate(
- String(values.currentProjectId),
- props.repoId,
- props.runType,
- {
- identifier,
- reason,
- expires_at: expiresAt,
- // Forward the prior source when extending — keeps the "view
- // the failing run" link intact across renewals.
- source_run_id: sourceRunId,
- // Theme variants of one story share a team, so only the first asks for a notice.
- notify_owners: notifyOwners && index === 0,
- }
- )
+ visualReviewReposQuarantineCreate(projectId, repoId, props.runType, {
+ identifier,
+ reason,
+ expires_at: expiresAt,
+ // Forward the prior source when extending — keeps the "view
+ // the failing run" link intact across renewals.
+ source_run_id: sourceRunId,
+ // Theme variants of one story share a team, so only the first asks for a notice.
+ notify_owners: notifyOwners && index === 0,
+ })
)
)
const count = identifiers.length
@@ -389,12 +370,11 @@ export const visualReviewSnapshotHistorySceneLogic = kea<visualReviewSnapshotHis
},
unquarantineIdentifier: async () => {
try {
- await visualReviewReposQuarantineExpireCreate(
- String(values.currentProjectId),
- props.repoId,
- props.runType,
- { identifier: props.identifier }
- )
+ const projectId = String(values.currentProjectId)
+ const repoId = await resolveRepoId(projectId, props.repoFullName)
+ await visualReviewReposQuarantineExpireCreate(projectId, repoId, props.runType, {
+ identifier: props.identifier,
+ })
lemonToast.success('Identifier unquarantined — future runs will gate on it again')
actions.loadQuarantineEntry()
} catch (e: any) {
@@ -407,12 +387,9 @@ export const visualReviewSnapshotHistorySceneLogic = kea<visualReviewSnapshotHis
return
}
try {
- await visualReviewReposQuarantineExpireCreate(
- String(values.currentProjectId),
- props.repoId,
- props.runType,
- { identifier: sibling }
- )
+ const projectId = String(values.currentProjectId)
+ const repoId = await resolveRepoId(projectId, props.repoFullName)
+ await visualReviewReposQuarantineExpireCreate(projectId, repoId, props.runType, { identifier: sibling })
lemonToast.success('Sibling unquarantined — future runs will gate on it again')
actions.loadSiblingQuarantineEntry()
} catch (e: any) {
@@ -421,7 +398,6 @@ export const visualReviewSnapshotHistorySceneLogic = kea<visualReviewSnapshotHis
},
})),
afterMount(({ actions }) => {
- actions.loadRepo()
actions.loadHistory()
actions.loadPartnerHistory()
actions.loadQuarantineEntry()
diff --git a/products/visual_review/frontend/scenes/visualReviewSnapshotOverviewSceneLogic.ts b/products/visual_review/frontend/scenes/visualReviewSnapshotOverviewSceneLogic.ts
index 2ee2a379d3ec..2b47d9f13000 100644
--- a/products/visual_review/frontend/scenes/visualReviewSnapshotOverviewSceneLogic.ts
+++ b/products/visual_review/frontend/scenes/visualReviewSnapshotOverviewSceneLogic.ts
@@ -3,6 +3,7 @@ import { loaders } from 'kea-loaders'
import { actionToUrl, urlToAction } from 'kea-router'
import { teamLogic } from 'scenes/teamLogic'
+import { urls } from 'scenes/urls'
import { Breadcrumb } from '~/types'
@@ -12,10 +13,13 @@ import { visualReviewReposBaselinesRetrieve } from '../generated/api'
import type { BaselineEntryApi, BaselineOverviewApi } from '../generated/api.schemas'
import type { RepoApi } from '../generated/api.schemas'
import { parseArea, parseTheme, runTypeLabel } from '../lib/parseIdentifier'
+import { repoBreadcrumbs } from '../lib/repoBreadcrumbs'
+import { resolveRepoId } from '../lib/repoIds'
+import { repoFullNameFromParams, splitRepoFullName } from '../lib/repoPaths'
import { visualReviewRepoLogic } from './visualReviewRepoLogic'
export interface VisualReviewSnapshotOverviewSceneLogicProps {
- repoId: string
+ repoFullName: string
}
// We deliberately don't model "show both themes" — for snapshot identifiers
@@ -160,6 +164,7 @@ function applyFilters(
export interface visualReviewSnapshotOverviewSceneLogicValues {
currentProjectId: number | string // teamLogic
repo: RepoApi | null // visualReviewRepoLogic
+ repoNotFound: boolean // visualReviewRepoLogic
breadcrumbs: Breadcrumb[]
decoratedEntries: Array<
BaselineEntryApi & {
@@ -177,7 +182,8 @@ export interface visualReviewSnapshotOverviewSceneLogicValues {
frequentlyToleratedCount: number
overview: BaselineOverviewApi | null
overviewLoading: boolean
- repoId: string
+ overviewRepoId: string | null
+ repoFullName: string
statCounts: Record<StatPreset, number>
thumbnailBasePath: string | null
}
@@ -202,6 +208,9 @@ export interface visualReviewSnapshotOverviewSceneLogicActions {
overview: BaselineOverviewApi
payload?: any
}
+ setOverviewRepoId: (repoId: string) => {
+ repoId: string
+ }
setSearch: (search: string) => {
search: string
}
@@ -226,7 +235,7 @@ export interface visualReviewSnapshotOverviewSceneLogicActions {
export interface visualReviewSnapshotOverviewSceneLogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
- repoId: (arg: any) => string
+ repoFullName: (arg: any) => string
entries: (overview: BaselineOverviewApi | null) => BaselineEntryApi[]
decoratedEntries: (entries: BaselineEntryApi[]) => Array<
BaselineEntryApi & {
@@ -273,8 +282,8 @@ export interface visualReviewSnapshotOverviewSceneLogicMeta {
filters: Filters
) => FacetGroups
facetSelection: (filters: Filters) => FacetSelection
- thumbnailBasePath: (currentProjectId: number | string, arg: any) => string | null
- breadcrumbs: (repo: RepoApi | null) => Breadcrumb[]
+ thumbnailBasePath: (currentProjectId: number | string, overviewRepoId: string | null) => string | null
+ breadcrumbs: (repo: RepoApi | null, repoFullName: string) => Breadcrumb[]
}
}
@@ -288,9 +297,14 @@ export type visualReviewSnapshotOverviewSceneLogicType = MakeLogicType<
export const visualReviewSnapshotOverviewSceneLogic = kea<visualReviewSnapshotOverviewSceneLogicType>([
path(['products', 'visual_review', 'frontend', 'scenes', 'visualReviewSnapshotOverviewSceneLogic']),
props({} as VisualReviewSnapshotOverviewSceneLogicProps),
- key((props) => props.repoId),
+ key((props) => props.repoFullName),
connect((props: VisualReviewSnapshotOverviewSceneLogicProps) => ({
- values: [teamLogic, ['currentProjectId'], visualReviewRepoLogic({ repoId: props.repoId }), ['repo']],
+ values: [
+ teamLogic,
+ ['currentProjectId'],
+ visualReviewRepoLogic({ repoFullName: props.repoFullName }),
+ ['repo', 'repoNotFound'],
+ ],
})),
actions({
setStatPreset: (preset: StatPreset) => ({ preset }),
@@ -300,8 +314,15 @@ export const visualReviewSnapshotOverviewSceneLogic = kea<visualReviewSnapshotOv
setTheme: (theme: ThemeFilter) => ({ theme }),
setSearch: (search: string) => ({ search }),
clearAllFilters: true,
+ setOverviewRepoId: (repoId: string) => ({ repoId }),
}),
reducers({
+ overviewRepoId: [
+ null as string | null,
+ {
+ setOverviewRepoId: (_, { repoId }) => repoId,
+ },
+ ],
filters: [
EMPTY_FILTERS,
{
@@ -330,18 +351,21 @@ export const visualReviewSnapshotOverviewSceneLogic = kea<visualReviewSnapshotOv
},
],
}),
- loaders(({ props, values }) => ({
+ loaders(({ actions, props, values }) => ({
overview: [
null as BaselineOverviewApi | null,
{
loadOverview: async () => {
- return visualReviewReposBaselinesRetrieve(String(values.currentProjectId), props.repoId)
+ const projectId = String(values.currentProjectId)
+ const repoId = await resolveRepoId(projectId, props.repoFullName)
+ actions.setOverviewRepoId(repoId)
+ return visualReviewReposBaselinesRetrieve(projectId, repoId)
},
},
],
})),
selectors({
- repoId: [() => [(_, p) => p.repoId], (repoId: string): string => repoId],
+ repoFullName: [() => [(_, p) => p.repoFullName], (repoFullName: string): string => repoFullName],
entries: [
(s) => [s.overview],
(overview: BaselineOverviewApi | null): BaselineEntryApi[] => overview?.entries ?? [],
@@ -490,20 +514,16 @@ export const visualReviewSnapshotOverviewSceneLogic = kea<visualReviewSnapshotOv
team: new Set<string>(),
}),
],
+ // The overview request already resolved the repo, so a failed repo load does not hide every thumbnail.
thumbnailBasePath: [
- (s) => [s.currentProjectId, (_, p) => p.repoId],
- (projectId: number | string, repoId): string | null =>
- projectId ? `/api/projects/${projectId}/visual_review/repos/${repoId}/thumbnails` : null,
+ (s) => [s.currentProjectId, s.overviewRepoId],
+ (projectId: number | string, repoId: string | null): string | null =>
+ projectId && repoId ? `/api/projects/${projectId}/visual_review/repos/${repoId}/thumbnails` : null,
],
- // Single scene crumb — see runs scene for why we collapse to one.
breadcrumbs: [
- (s) => [s.repo],
- (repo: null | import('../generated/api.schemas').RepoApi): Breadcrumb[] => [
- {
- key: ['visual_review_repo', repo?.id ?? 'unknown'],
- name: repo?.repo_full_name ?? 'Visual review',
- },
- ],
+ (s) => [s.repo, s.repoFullName],
+ (repo: RepoApi | null, repoFullName: string): Breadcrumb[] =>
+ repoBreadcrumbs(repo?.repo_full_name ?? repoFullName),
],
}),
actionToUrl(({ values, props }) => {
@@ -530,7 +550,7 @@ export const visualReviewSnapshotOverviewSceneLogic = kea<visualReviewSnapshotOv
}
return out
}
- const path = `/visual_review/repos/${props.repoId}/snapshots`
+ const path = urls.visualReviewSnapshotOverview(...splitRepoFullName(props.repoFullName))
return {
setStatPreset: () => [path, {}, buildHash()],
toggleType: () => [path, {}, buildHash()],
@@ -542,8 +562,8 @@ export const visualReviewSnapshotOverviewSceneLogic = kea<visualReviewSnapshotOv
}
}),
urlToAction(({ actions, values, props }) => ({
- '/visual_review/repos/:repoId/snapshots': (params, _searchParams, hash) => {
- if (params.repoId !== props.repoId) {
+ '/visual_review/repos/:repoOwner/:repoName/snapshots': (params, _searchParams, hash) => {
+ if (repoFullNameFromParams(params.repoOwner, params.repoName) !== props.repoFullName) {
return
}
const f = values.filters
diff --git a/products/visual_review/manifest.tsx b/products/visual_review/manifest.tsx
index ffabee5b5134..4bdf7e0f7738 100644
--- a/products/visual_review/manifest.tsx
+++ b/products/visual_review/manifest.tsx
@@ -67,18 +67,36 @@ export const manifest: ProductManifest = {
// nosemgrep: frontend-route-hyphen -- shipped app URL, existing links point here
'/visual_review/settings': ['VisualReviewSettings', 'visualReviewSettings'],
// nosemgrep: frontend-route-hyphen -- shipped app URL, existing links point here
- '/visual_review/runs/:runId': ['VisualReviewRun', 'visualReviewRun'],
+ '/visual_review/repos/:repoOwner/:repoName/runs': ['VisualReviewRuns', 'visualReviewRepoRuns'],
// nosemgrep: frontend-route-hyphen -- shipped app URL, existing links point here
- '/visual_review/repos/:repoId/runs': ['VisualReviewRuns', 'visualReviewRepoRuns'],
+ '/visual_review/repos/:repoOwner/:repoName/runs/:runId': ['VisualReviewRun', 'visualReviewRun'],
// nosemgrep: frontend-route-hyphen -- shipped app URL, existing links point here
- '/visual_review/repos/:repoId/snapshots': ['VisualReviewSnapshotOverview', 'visualReviewSnapshotOverview'],
+ '/visual_review/repos/:repoOwner/:repoName/snapshots': [
+ 'VisualReviewSnapshotOverview',
+ 'visualReviewSnapshotOverview',
+ ],
// nosemgrep: frontend-route-hyphen -- shipped app URL, existing links point here
- '/visual_review/repos/:repoId/flakiness': ['VisualReviewFlakiness', 'visualReviewFlakiness'],
+ '/visual_review/repos/:repoOwner/:repoName/flakiness': ['VisualReviewFlakiness', 'visualReviewFlakiness'],
// nosemgrep: frontend-route-hyphen -- shipped app URL, existing links point here
- '/visual_review/repos/:repoId/:runType/snapshots/:identifier': [
+ '/visual_review/repos/:repoOwner/:repoName/:runType/snapshots/:identifier': [
'VisualReviewSnapshotHistory',
'visualReviewSnapshotHistory',
],
+ // URLs that name a repo or run by UUID. PR comments and bookmarks still carry them, so the index
+ // scene looks the repo up and forwards to its owner/name URL.
+ // nosemgrep: frontend-route-hyphen -- shipped app URL, existing links point here
+ '/visual_review/runs/:runId': ['VisualReviewIndex', 'visualReviewLegacyRun'],
+ // nosemgrep: frontend-route-hyphen -- shipped app URL, existing links point here
+ '/visual_review/repos/:repoId/runs': ['VisualReviewIndex', 'visualReviewLegacyRepoRuns'],
+ // nosemgrep: frontend-route-hyphen -- shipped app URL, existing links point here
+ '/visual_review/repos/:repoId/snapshots': ['VisualReviewIndex', 'visualReviewLegacySnapshotOverview'],
+ // nosemgrep: frontend-route-hyphen -- shipped app URL, existing links point here
+ '/visual_review/repos/:repoId/flakiness': ['VisualReviewIndex', 'visualReviewLegacyFlakiness'],
+ // nosemgrep: frontend-route-hyphen -- shipped app URL, existing links point here
+ '/visual_review/repos/:repoId/:runType/snapshots/:identifier': [
+ 'VisualReviewIndex',
+ 'visualReviewLegacySnapshotHistory',
+ ],
},
redirects: {},
urls: {
@@ -86,12 +104,23 @@ export const manifest: ProductManifest = {
// workspace. Sidebar/nav callers stay zero-arg as before.
visualReviewRuns: (): string => '/visual_review',
visualReviewSettings: (): string => '/visual_review/settings',
+ // The run path that names no repository. It forwards once the run says which repository it belongs to.
visualReviewRun: (runId: string): string => `/visual_review/runs/${runId}`,
- visualReviewRepoRuns: (repoId: string): string => `/visual_review/repos/${repoId}/runs`,
- visualReviewSnapshotOverview: (repoId: string): string => `/visual_review/repos/${repoId}/snapshots`,
- visualReviewFlakiness: (repoId: string): string => `/visual_review/repos/${repoId}/flakiness`,
- visualReviewSnapshotHistory: (repoId: string, runType: string, identifier: string): string =>
- `/visual_review/repos/${repoId}/${encodeURIComponent(runType)}/snapshots/${encodeURIComponent(identifier)}`,
+ visualReviewRepoRun: (repoOwner: string, repoName: string, runId: string): string =>
+ `/visual_review/repos/${encodeURIComponent(repoOwner)}/${encodeURIComponent(repoName)}/runs/${runId}`,
+ visualReviewRepoRuns: (repoOwner: string, repoName: string): string =>
+ `/visual_review/repos/${encodeURIComponent(repoOwner)}/${encodeURIComponent(repoName)}/runs`,
+ visualReviewSnapshotOverview: (repoOwner: string, repoName: string): string =>
+ `/visual_review/repos/${encodeURIComponent(repoOwner)}/${encodeURIComponent(repoName)}/snapshots`,
+ visualReviewFlakiness: (repoOwner: string, repoName: string): string =>
+ `/visual_review/repos/${encodeURIComponent(repoOwner)}/${encodeURIComponent(repoName)}/flakiness`,
+ visualReviewSnapshotHistory: (
+ repoOwner: string,
+ repoName: string,
+ runType: string,
+ identifier: string
+ ): string =>
+ `/visual_review/repos/${encodeURIComponent(repoOwner)}/${encodeURIComponent(repoName)}/${encodeURIComponent(runType)}/snapshots/${encodeURIComponent(identifier)}`,
},
fileSystemTypes: {},
treeItemsNew: [],
diff --git a/services/mcp/src/tools/links/app-url-manifest.json b/services/mcp/src/tools/links/app-url-manifest.json
index a1dace3eff46..2be69c348d1c 100644
--- a/services/mcp/src/tools/links/app-url-manifest.json
+++ b/services/mcp/src/tools/links/app-url-manifest.json
@@ -1835,13 +1835,18 @@
"scope": "project"
},
"visualReviewFlakiness": {
- "template": "/visual_review/repos/{repoId}/flakiness",
- "params": ["repoId"],
+ "template": "/visual_review/repos/{repoOwner}/{repoName}/flakiness",
+ "params": ["repoOwner", "repoName"],
+ "scope": "project"
+ },
+ "visualReviewRepoRun": {
+ "template": "/visual_review/repos/{repoOwner}/{repoName}/runs/{runId}",
+ "params": ["repoOwner", "repoName", "runId"],
"scope": "project"
},
"visualReviewRepoRuns": {
- "template": "/visual_review/repos/{repoId}/runs",
- "params": ["repoId"],
+ "template": "/visual_review/repos/{repoOwner}/{repoName}/runs",
+ "params": ["repoOwner", "repoName"],
"scope": "project"
},
"visualReviewRun": {
@@ -1860,13 +1865,13 @@
"scope": "project"
},
"visualReviewSnapshotHistory": {
- "template": "/visual_review/repos/{repoId}/{runType}/snapshots/{identifier}",
- "params": ["repoId", "runType", "identifier"],
+ "template": "/visual_review/repos/{repoOwner}/{repoName}/{runType}/snapshots/{identifier}",
+ "params": ["repoOwner", "repoName", "runType", "identifier"],
"scope": "project"
},
"visualReviewSnapshotOverview": {
- "template": "/visual_review/repos/{repoId}/snapshots",
- "params": ["repoId"],
+ "template": "/visual_review/repos/{repoOwner}/{repoName}/snapshots",
+ "params": ["repoOwner", "repoName"],
"scope": "project"
},
"warehouseDestinations": {
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/generate-app-url.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/generate-app-url.json
index a98c9c1e8d4c..6cc4e2269b17 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/generate-app-url.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/generate-app-url.json
@@ -13,7 +13,7 @@
"type": "object"
},
"url": {
- "description": "A path template copied verbatim from the catalog below (e.g. `/persons/{uuid}`). Its `{placeholders}` are filled from `params`. These slugs come from PostHog's canonical route table, so they are always correct — never pass a path that is not in this list.\n\n/account-connected/{kind}\n/account/credential-review\n/account/social-connected\n/activity-logs\n/activity/{tab}\n/agentic/account-mismatch\n/agentic/authorize\n/ai\n/ai-enrichment\n/ai-evals/datasets\n/ai-evals/datasets/{id}\n/ai-evals/evaluations\n/ai-evals/evaluations/offline/experiments\n/ai-evals/evaluations/offline/experiments/{experimentId}\n/ai-evals/evaluations/scorers\n/ai-evals/evaluations/scorers/{scorerId}\n/ai-evals/evaluations/scorers/{scorerId}/offline\n/ai-evals/evaluations/templates\n/ai-evals/evaluations/{id}\n/ai-evals/taggers\n/ai-evals/taggers/{id}\n/ai-observability/clusters\n/ai-observability/clusters/{runId}/{clusterId}\n/ai-observability/dashboard\n/ai-observability/errors\n/ai-observability/generations\n/ai-observability/playground\n/ai-observability/reviews\n/ai-observability/self-driving\n/ai-observability/sentiment\n/ai-observability/sessions\n/ai-observability/sessions/{id}\n/ai-observability/tools\n/ai-observability/traces\n/ai-observability/traces/{id}\n/ai-observability/users\n/ai/history\n/alerts\n/approvals/{id}\n/autoresearch\n/autoresearch/new\n/autoresearch/{id}\n/bi\n/bi/new\n/bi/{insightShortId}\n/billing/authorization_status\n/broadcasts\n/broadcasts/new\n/broadcasts/{id}\n/business-knowledge\n/business-knowledge/playground\n/business-knowledge/settings\n/business-knowledge/{id}\n/canvas\n/canvases\n/canvases/new\n/canvases/{id}\n/cli/authorize\n/cli/live\n/code-review\n/code/canvas/{channelId}/{dashboardId}\n/code/channel/{channelId}\n/code/loop/{loopId}\n/code/task/{taskId}\n/cohorts\n/cohorts/{id}\n/cohorts/{id}/calculation-history\n/connect/vercel/link\n/coupons/{campaign}\n/create-organization\n/cross-project-dashboards\n/cross-project-dashboards/{id}\n/customer_analytics\n/customer_analytics/accounts\n/customer_analytics/accounts/by-external-id/{externalId}\n/customer_analytics/accounts/{accountId}\n/customer_analytics/announcements\n/customer_analytics/configuration\n/customer_analytics/dashboard\n/customer_analytics/feature-requests\n/customer_analytics/feed\n/customer_analytics/journeys\n/customer_analytics/journeys/new\n/customer_analytics/journeys/templates\n/customer_analytics/journeys/{id}/edit\n/customer_analytics/notes\n/customer_analytics/tasks\n/dashboard\n/dashboard/templates/{templateId}/copy-to-project\n/dashboard/{id}\n/dashboard/{id}/sharing\n/dashboard/{id}/subscriptions\n/dashboard/{id}/subscriptions/{subscriptionId}\n/dashboard/{id}/tiles/{tileId}\n/data-catalog\n/data-catalog/metrics/{name}\n/data-management/actions\n/data-management/actions/new\n/data-management/actions/new/\n/data-management/actions/{id}\n/data-management/annotations\n/data-management/annotations/{id}\n/data-management/core-events\n/data-management/database\n/data-management/destinations\n/data-management/event-filtering\n/data-management/events\n/data-management/events/{id}\n/data-management/events/{id}/edit\n/data-management/history\n/data-management/ingestion-warnings\n/data-management/ingestion-warnings-v2\n/data-management/managed-viewsets\n/data-management/materialized-columns\n/data-management/properties\n/data-management/properties/{id}\n/data-management/properties/{id}/edit\n/data-management/revenue\n/data-management/schema\n/data-management/sources\n/data-management/sources/{id}/schemas\n/data-management/sources/{sourceId}/schemas/{schemaId}\n/data-management/transformations\n/data-management/variables\n/data-management/variables/{id}\n/data-management/variables/{id}/edit\n/data-management/warehouse-destinations\n/data-management/warehouse-properties\n/data-ops\n/data-warehouse/connect\n/data-warehouse/new-source\n/debug\n/debug/hog\n/debug/precompute\n/early_access_features\n/early_access_features/{id}\n/embedded/{token}\n/endpoints\n/endpoints/{name}\n/engineering-analytics/authors\n/engineering-analytics/authors/{handle}\n/engineering-analytics/deploys\n/engineering-analytics/overview\n/engineering-analytics/pull-requests\n/engineering-analytics/repos/{repoOwner}/{repoName}/actions/runs/{runId}\n/engineering-analytics/repos/{repoOwner}/{repoName}/actions/workflows/{workflowName}\n/engineering-analytics/repos/{repoOwner}/{repoName}/pull-requests/{number}\n/engineering-analytics/repos/{repoOwner}/{repoName}/pull-requests/{number}/ci-explorer\n/engineering-analytics/teams\n/engineering-analytics/teams/{ownerTeam}\n/engineering-analytics/tests\n/engineering-analytics/workflows\n/error_tracking\n/error_tracking/alerts/new/{templateId}\n/error_tracking/alerts/{id}\n/error_tracking/fingerprint/{fingerprint}\n/error_tracking/{id}\n/etl\n/events/{id}/{timestamp}\n/experiments\n/experiments/shared-metrics\n/experiments/shared-metrics/{id}\n/experiments/staff\n/experiments/{id}\n/exports\n/feature_flags\n/feature_flags/new\n/feature_flags/staff\n/feature_flags/staff/cohorts\n/feature_flags/templates\n/feature_flags/{id}\n/files\n/functions/new/{templateId}\n/functions/{id}\n/games/368hedgehogs\n/games/flappyhog\n/games/shipit\n/groups/{groupTypeIndex}\n/groups/{groupTypeIndex}/new\n/groups/{groupTypeIndex}/{groupKey}\n/health\n/health/alerts\n/health/pipeline-status\n/health/sdk-health\n/health/{category}\n/heatmaps\n/heatmaps/new\n/heatmaps/recording\n/heatmaps/{id}\n/home\n/identity-matching\n/inbox\n/inbox/reports/triage\n/inbox/scout-trials\n/inbox/scouts/findings\n/inbox/scouts/runs\n/inbox/scouts/scratchpad\n/inbox/scouts/{skillName}\n/inbox/{tab}/{reportId}\n/insights\n/insights/new\n/insights/quick-start\n/insights/{id}\n/insights/{id}/edit\n/insights/{id}/sharing\n/insights/{id}/subscriptions\n/insights/{id}/subscriptions/{subscriptionId}\n/insights/{insightShortId}/alerts\n/instance/async_migrations\n/instance/async_migrations/future\n/instance/async_migrations/settings\n/instance/dead_letter_queue\n/instance/kafka_inspector\n/instance/metrics\n/instance/settings\n/instance/staff_users\n/instance/status\n/integrations/stripe/confirm-install\n/integrations/vercel/link-error\n/integrations/{kind}/callback\n/integrations/{slug}\n/legal\n/legal/new/{type}\n/login\n/login/2fa\n/login/2fa_setup\n/logs\n/logs/alerts/{alertId}/notifications/{hogFunctionId}\n/logs/alerts/{id}\n/logs/drop-rules/new\n/logs/drop-rules/{id}\n/logs/retention-rules/new\n/logs/retention-rules/{id}\n/managed_migrations\n/managed_migrations/new\n/marketing\n/mcp-analytics\n/mcp-analytics/activity\n/mcp-analytics/dashboard\n/mcp-analytics/intent-clustering\n/mcp-analytics/missing-capabilities\n/mcp-analytics/notifications\n/mcp-analytics/sessions\n/mcp-analytics/tool-quality\n/mcp-analytics/tool-quality/{toolName}\n/mcp-registry\n/mcp-servers\n/mcp-servers/agent/{id}\n/mcp-servers/member/{id}\n/mcp-servers/server/{id}\n/mcp-servers/{tab}\n/metrics\n/models\n/models/{id}\n/move-to-cloud\n/my-tickets\n/notebooks\n/notebooks/widgets/{widgetId}\n/notebooks/{shortId}\n/oauth/authorize\n/onboarding\n/organization-deactivated\n/organization-pending-deletion\n/organization/billing\n/organization/billing/overview\n/organization/billing/real-time-usage\n/organization/confirm-creation\n/organization/create-project\n/person/{id}\n/persons\n/persons/{uuid}\n/pipeline/batch-exports/new/{service}\n/pipeline/batch-exports/{id}\n/pipeline/new/\n/pipeline/plugins/{id}\n/platform-alerts\n/platform-alerts/{id}\n/preflight\n/product_tours\n/product_tours/{id}\n/project-pending-deletion\n/prompt-management/prompts\n/prompt-management/prompts/{name}\n/pulse\n/replay-vision\n/replay-vision/new/template\n/replay-vision/observations/{observationId}\n/replay-vision/{id}/budget\n/replay-vision/{id}/configure\n/replay-vision/{id}/details\n/replay-vision/{id}/overview\n/replay-vision/{id}/template\n/replay-vision/{id}/triggers\n/replay/file-playback\n/replay/home\n/replay/kiosk\n/replay/playlists/{id}\n/replay/settings\n/replay/{id}\n/reset\n/reset/{userUuid}/{token}\n/reset_2fa/{userUuid}/{token}\n/resource-transfer/{resourceKind}/{resourceId}\n/sessions/{id}\n/settings/environment-approvals\n/settings/organization-authentication/{feature}/{configId}\n/settings/project\n/settings/user-feature-previews\n/shared/{token}\n/shared_dashboard/{shareToken}\n/signup\n/signup/{id}\n/site/{url}\n/skills\n/skills/community\n/skills/{categoryTab}\n/skills/{name}\n/slack-task-context\n/spaces\n/spaces/new\n/spaces/{id}\n/spaces/{id}/canvases\n/spaces/{id}/new\n/spaces/{id}/settings\n/sql\n/stamphog\n/stamphog/digests\n/stamphog/install/callback\n/stamphog/runs\n/startups\n/streamlit-apps\n/streamlit-apps/new\n/streamlit-apps/{id}\n/streamlit-apps/{id}/edit\n/subscriptions\n/subscriptions/new\n/subscriptions/{id}\n/subscriptions/{id}/edit\n/support\n/support/settings\n/support/tickets\n/support/tickets/{ticketId}\n/surveys\n/surveys/form/new\n/surveys/guided/new\n/surveys/{id}\n/tasks\n/tasks/new\n/tasks/{taskId}\n/terminal\n/themes/custom-css\n/toolbar\n/tools\n/tracing\n/tracing/retention-rules/new\n/tracing/retention-rules/{id}\n/unsubscribe\n/verify_email\n/views\n/views/new\n/visual_review\n/visual_review/repos/{repoId}/flakiness\n/visual_review/repos/{repoId}/runs\n/visual_review/repos/{repoId}/snapshots\n/visual_review/repos/{repoId}/{runType}/snapshots/{identifier}\n/visual_review/runs/{runId}\n/visual_review/settings\n/web\n/web-scripts\n/web-scripts/new\n/web/agents\n/web/bots\n/web/content-autopilot\n/web/health\n/web/live\n/web/marketing\n/web/page-performance\n/web/page-reports\n/web/recap\n/web/session-attribution-explorer\n/web/web-vitals\n/wizard/runs\n/workflows\n/workflows/library/messages/{id}\n/workflows/library/templates/new\n/workflows/library/templates/{id}\n/workflows/new/workflow\n/workflows/{id}/{tab}",
+ "description": "A path template copied verbatim from the catalog below (e.g. `/persons/{uuid}`). Its `{placeholders}` are filled from `params`. These slugs come from PostHog's canonical route table, so they are always correct — never pass a path that is not in this list.\n\n/account-connected/{kind}\n/account/credential-review\n/account/social-connected\n/activity-logs\n/activity/{tab}\n/agentic/account-mismatch\n/agentic/authorize\n/ai\n/ai-enrichment\n/ai-evals/datasets\n/ai-evals/datasets/{id}\n/ai-evals/evaluations\n/ai-evals/evaluations/offline/experiments\n/ai-evals/evaluations/offline/experiments/{experimentId}\n/ai-evals/evaluations/scorers\n/ai-evals/evaluations/scorers/{scorerId}\n/ai-evals/evaluations/scorers/{scorerId}/offline\n/ai-evals/evaluations/templates\n/ai-evals/evaluations/{id}\n/ai-evals/taggers\n/ai-evals/taggers/{id}\n/ai-observability/clusters\n/ai-observability/clusters/{runId}/{clusterId}\n/ai-observability/dashboard\n/ai-observability/errors\n/ai-observability/generations\n/ai-observability/playground\n/ai-observability/reviews\n/ai-observability/self-driving\n/ai-observability/sentiment\n/ai-observability/sessions\n/ai-observability/sessions/{id}\n/ai-observability/tools\n/ai-observability/traces\n/ai-observability/traces/{id}\n/ai-observability/users\n/ai/history\n/alerts\n/approvals/{id}\n/autoresearch\n/autoresearch/new\n/autoresearch/{id}\n/bi\n/bi/new\n/bi/{insightShortId}\n/billing/authorization_status\n/broadcasts\n/broadcasts/new\n/broadcasts/{id}\n/business-knowledge\n/business-knowledge/playground\n/business-knowledge/settings\n/business-knowledge/{id}\n/canvas\n/canvases\n/canvases/new\n/canvases/{id}\n/cli/authorize\n/cli/live\n/code-review\n/code/canvas/{channelId}/{dashboardId}\n/code/channel/{channelId}\n/code/loop/{loopId}\n/code/task/{taskId}\n/cohorts\n/cohorts/{id}\n/cohorts/{id}/calculation-history\n/connect/vercel/link\n/coupons/{campaign}\n/create-organization\n/cross-project-dashboards\n/cross-project-dashboards/{id}\n/customer_analytics\n/customer_analytics/accounts\n/customer_analytics/accounts/by-external-id/{externalId}\n/customer_analytics/accounts/{accountId}\n/customer_analytics/announcements\n/customer_analytics/configuration\n/customer_analytics/dashboard\n/customer_analytics/feature-requests\n/customer_analytics/feed\n/customer_analytics/journeys\n/customer_analytics/journeys/new\n/customer_analytics/journeys/templates\n/customer_analytics/journeys/{id}/edit\n/customer_analytics/notes\n/customer_analytics/tasks\n/dashboard\n/dashboard/templates/{templateId}/copy-to-project\n/dashboard/{id}\n/dashboard/{id}/sharing\n/dashboard/{id}/subscriptions\n/dashboard/{id}/subscriptions/{subscriptionId}\n/dashboard/{id}/tiles/{tileId}\n/data-catalog\n/data-catalog/metrics/{name}\n/data-management/actions\n/data-management/actions/new\n/data-management/actions/new/\n/data-management/actions/{id}\n/data-management/annotations\n/data-management/annotations/{id}\n/data-management/core-events\n/data-management/database\n/data-management/destinations\n/data-management/event-filtering\n/data-management/events\n/data-management/events/{id}\n/data-management/events/{id}/edit\n/data-management/history\n/data-management/ingestion-warnings\n/data-management/ingestion-warnings-v2\n/data-management/managed-viewsets\n/data-management/materialized-columns\n/data-management/properties\n/data-management/properties/{id}\n/data-management/properties/{id}/edit\n/data-management/revenue\n/data-management/schema\n/data-management/sources\n/data-management/sources/{id}/schemas\n/data-management/sources/{sourceId}/schemas/{schemaId}\n/data-management/transformations\n/data-management/variables\n/data-management/variables/{id}\n/data-management/variables/{id}/edit\n/data-management/warehouse-destinations\n/data-management/warehouse-properties\n/data-ops\n/data-warehouse/connect\n/data-warehouse/new-source\n/debug\n/debug/hog\n/debug/precompute\n/early_access_features\n/early_access_features/{id}\n/embedded/{token}\n/endpoints\n/endpoints/{name}\n/engineering-analytics/authors\n/engineering-analytics/authors/{handle}\n/engineering-analytics/deploys\n/engineering-analytics/overview\n/engineering-analytics/pull-requests\n/engineering-analytics/repos/{repoOwner}/{repoName}/actions/runs/{runId}\n/engineering-analytics/repos/{repoOwner}/{repoName}/actions/workflows/{workflowName}\n/engineering-analytics/repos/{repoOwner}/{repoName}/pull-requests/{number}\n/engineering-analytics/repos/{repoOwner}/{repoName}/pull-requests/{number}/ci-explorer\n/engineering-analytics/teams\n/engineering-analytics/teams/{ownerTeam}\n/engineering-analytics/tests\n/engineering-analytics/workflows\n/error_tracking\n/error_tracking/alerts/new/{templateId}\n/error_tracking/alerts/{id}\n/error_tracking/fingerprint/{fingerprint}\n/error_tracking/{id}\n/etl\n/events/{id}/{timestamp}\n/experiments\n/experiments/shared-metrics\n/experiments/shared-metrics/{id}\n/experiments/staff\n/experiments/{id}\n/exports\n/feature_flags\n/feature_flags/new\n/feature_flags/staff\n/feature_flags/staff/cohorts\n/feature_flags/templates\n/feature_flags/{id}\n/files\n/functions/new/{templateId}\n/functions/{id}\n/games/368hedgehogs\n/games/flappyhog\n/games/shipit\n/groups/{groupTypeIndex}\n/groups/{groupTypeIndex}/new\n/groups/{groupTypeIndex}/{groupKey}\n/health\n/health/alerts\n/health/pipeline-status\n/health/sdk-health\n/health/{category}\n/heatmaps\n/heatmaps/new\n/heatmaps/recording\n/heatmaps/{id}\n/home\n/identity-matching\n/inbox\n/inbox/reports/triage\n/inbox/scout-trials\n/inbox/scouts/findings\n/inbox/scouts/runs\n/inbox/scouts/scratchpad\n/inbox/scouts/{skillName}\n/inbox/{tab}/{reportId}\n/insights\n/insights/new\n/insights/quick-start\n/insights/{id}\n/insights/{id}/edit\n/insights/{id}/sharing\n/insights/{id}/subscriptions\n/insights/{id}/subscriptions/{subscriptionId}\n/insights/{insightShortId}/alerts\n/instance/async_migrations\n/instance/async_migrations/future\n/instance/async_migrations/settings\n/instance/dead_letter_queue\n/instance/kafka_inspector\n/instance/metrics\n/instance/settings\n/instance/staff_users\n/instance/status\n/integrations/stripe/confirm-install\n/integrations/vercel/link-error\n/integrations/{kind}/callback\n/integrations/{slug}\n/legal\n/legal/new/{type}\n/login\n/login/2fa\n/login/2fa_setup\n/logs\n/logs/alerts/{alertId}/notifications/{hogFunctionId}\n/logs/alerts/{id}\n/logs/drop-rules/new\n/logs/drop-rules/{id}\n/logs/retention-rules/new\n/logs/retention-rules/{id}\n/managed_migrations\n/managed_migrations/new\n/marketing\n/mcp-analytics\n/mcp-analytics/activity\n/mcp-analytics/dashboard\n/mcp-analytics/intent-clustering\n/mcp-analytics/missing-capabilities\n/mcp-analytics/notifications\n/mcp-analytics/sessions\n/mcp-analytics/tool-quality\n/mcp-analytics/tool-quality/{toolName}\n/mcp-registry\n/mcp-servers\n/mcp-servers/agent/{id}\n/mcp-servers/member/{id}\n/mcp-servers/server/{id}\n/mcp-servers/{tab}\n/metrics\n/models\n/models/{id}\n/move-to-cloud\n/my-tickets\n/notebooks\n/notebooks/widgets/{widgetId}\n/notebooks/{shortId}\n/oauth/authorize\n/onboarding\n/organization-deactivated\n/organization-pending-deletion\n/organization/billing\n/organization/billing/overview\n/organization/billing/real-time-usage\n/organization/confirm-creation\n/organization/create-project\n/person/{id}\n/persons\n/persons/{uuid}\n/pipeline/batch-exports/new/{service}\n/pipeline/batch-exports/{id}\n/pipeline/new/\n/pipeline/plugins/{id}\n/platform-alerts\n/platform-alerts/{id}\n/preflight\n/product_tours\n/product_tours/{id}\n/project-pending-deletion\n/prompt-management/prompts\n/prompt-management/prompts/{name}\n/pulse\n/replay-vision\n/replay-vision/new/template\n/replay-vision/observations/{observationId}\n/replay-vision/{id}/budget\n/replay-vision/{id}/configure\n/replay-vision/{id}/details\n/replay-vision/{id}/overview\n/replay-vision/{id}/template\n/replay-vision/{id}/triggers\n/replay/file-playback\n/replay/home\n/replay/kiosk\n/replay/playlists/{id}\n/replay/settings\n/replay/{id}\n/reset\n/reset/{userUuid}/{token}\n/reset_2fa/{userUuid}/{token}\n/resource-transfer/{resourceKind}/{resourceId}\n/sessions/{id}\n/settings/environment-approvals\n/settings/organization-authentication/{feature}/{configId}\n/settings/project\n/settings/user-feature-previews\n/shared/{token}\n/shared_dashboard/{shareToken}\n/signup\n/signup/{id}\n/site/{url}\n/skills\n/skills/community\n/skills/{categoryTab}\n/skills/{name}\n/slack-task-context\n/spaces\n/spaces/new\n/spaces/{id}\n/spaces/{id}/canvases\n/spaces/{id}/new\n/spaces/{id}/settings\n/sql\n/stamphog\n/stamphog/digests\n/stamphog/install/callback\n/stamphog/runs\n/startups\n/streamlit-apps\n/streamlit-apps/new\n/streamlit-apps/{id}\n/streamlit-apps/{id}/edit\n/subscriptions\n/subscriptions/new\n/subscriptions/{id}\n/subscriptions/{id}/edit\n/support\n/support/settings\n/support/tickets\n/support/tickets/{ticketId}\n/surveys\n/surveys/form/new\n/surveys/guided/new\n/surveys/{id}\n/tasks\n/tasks/new\n/tasks/{taskId}\n/terminal\n/themes/custom-css\n/toolbar\n/tools\n/tracing\n/tracing/retention-rules/new\n/tracing/retention-rules/{id}\n/unsubscribe\n/verify_email\n/views\n/views/new\n/visual_review\n/visual_review/repos/{repoOwner}/{repoName}/flakiness\n/visual_review/repos/{repoOwner}/{repoName}/runs\n/visual_review/repos/{repoOwner}/{repoName}/runs/{runId}\n/visual_review/repos/{repoOwner}/{repoName}/snapshots\n/visual_review/repos/{repoOwner}/{repoName}/{runType}/snapshots/{identifier}\n/visual_review/runs/{runId}\n/visual_review/settings\n/web\n/web-scripts\n/web-scripts/new\n/web/agents\n/web/bots\n/web/content-autopilot\n/web/health\n/web/live\n/web/marketing\n/web/page-performance\n/web/page-reports\n/web/recap\n/web/session-attribution-explorer\n/web/web-vitals\n/wizard/runs\n/workflows\n/workflows/library/messages/{id}\n/workflows/library/templates/new\n/workflows/library/templates/{id}\n/workflows/new/workflow\n/workflows/{id}/{tab}",
"type": "string"
}
},