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): hide clean quarantined stories behind a footer link (#112334)

Julian Bez2104dcc7675b
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 1b0fdccabd73..19d265cca984 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -13702,10 +13702,14 @@ snapshots:
hash: v1.k794b7964.12bc6373464176d7fb6b9251bb7d6342cd381a64e3ee28c8380045b06f5e97ec.BLZ-Fbl_W9xx4oAA39xVucIxMtSpBAzm5Pwp6f1Bk6w
scenes-app-visual-review-flakiness--unstable--light:
hash: v1.k794b7964.26ff0c274624f9d1ea71f4377d104d5e4feae204ba8ea0b68735c7f5fae8423e.WaXT0zPJ1WHOerBWKkJmHERCIZwpJT_L_4AHvWL3bSE
+ scenes-app-visual-review-run--clean-quarantined-stories--dark:
+ hash: v1.k794b7964.453c5fceef7e5351174d1391762ed725663a12ff3f494a06744b4dcec0573fc1.EBH6vLSFPVFcutmHJ_MeoOgN_Wl-Ss5mwBy-U1ENPgE
+ scenes-app-visual-review-run--clean-quarantined-stories--light:
+ hash: v1.k794b7964.ebe90530f36ee954d553fc5d27edc7e0cf1c4237b1c66077210c6387b8d920e2.-SMSm-K-ZYPI1uNN8QpBGaEtKrhsQ11S9IwZ8gnD6PE
scenes-app-visual-review-run--quarantined-snapshot-lifts-on-merge--dark:
- hash: v1.k794b7964.758a0e95ef8736a1c6ff3da08d559f93ae3766fb625dafe72470b69ae617af46.JMuycNcdRT6ufB9VBSNhhKJlVUq35qcQNYS7rva0Wxk
+ hash: v1.k794b7964.61cbf7191d25eb4bbe628b9bfd6fd7dce57a547fae68581be85a9f521e4e6ac4.A-q--iJVKmTtkol71YByFS0IgqVLQ5GH59AytaCDKhM
scenes-app-visual-review-run--quarantined-snapshot-lifts-on-merge--light:
- hash: v1.k794b7964.82313ef9f43904aaaee7dfb013a6949e0418f8a3094dbadfd8494d493199ee45.gOZXPTz4C9RAb_lA9fIwVXaLe_bO7UhAKa051YafvR8
+ hash: v1.k794b7964.3e199f340fd11e8d9a365cbe117fed44035841aa7b2caba0b928660c81113225.EAkTb5zAiucZZ6Z5SoU0aphNKQh5VqR04bpMY_1as0w
scenes-app-visual-review-run--ready-to-finalize--dark:
hash: v1.k794b7964.2ddf6d3c5eea469705d81ec0489b029e21e3d06d119b0365ddebe1340677e69c.MPAF7Dn_bpbKyhuQ2l_aoj6czH6TKBlFE2nXSKVqx4I
scenes-app-visual-review-run--ready-to-finalize--light:
diff --git a/products/visual_review/frontend/components/CleanQuarantinedSnapshots.tsx b/products/visual_review/frontend/components/CleanQuarantinedSnapshots.tsx
index 889423c0a2b0..2679560658fd 100644
--- a/products/visual_review/frontend/components/CleanQuarantinedSnapshots.tsx
+++ b/products/visual_review/frontend/components/CleanQuarantinedSnapshots.tsx
@@ -1,61 +1,58 @@
-import { LemonButton, LemonSkeleton } from '@posthog/lemon-ui'
+import { LemonSkeleton } from '@posthog/lemon-ui'
-import type { SnapshotApi } from '../generated/api.schemas'
+import type { CleanQuarantinedGroups } from '../lib/liftOnMerge'
+import { CleanQuarantinedStoryList } from './CleanQuarantinedStoryList'
interface CleanQuarantinedSnapshotsProps {
- snapshots: SnapshotApi[]
- loading: boolean
- loadFailed: boolean
+ groups: CleanQuarantinedGroups
+ prNumber: number
+ liftsLoading: boolean
+ liftsLoadFailed: boolean
selectedSnapshotId: string | null
onSelect: (snapshotId: string) => void
}
-/** Quarantined stories this run rendered exactly as their baseline, which the changes-only strip leaves out. */
+/** Quarantined stories this run rendered exactly as their baseline, grouped by whether a lift is requested. */
export function CleanQuarantinedSnapshots({
- snapshots,
- loading,
- loadFailed,
+ groups,
+ prNumber,
+ liftsLoading,
+ liftsLoadFailed,
selectedSnapshotId,
onSelect,
-}: CleanQuarantinedSnapshotsProps): JSX.Element | null {
- if (loading) {
- return (
- <div className="px-3 pb-3">
- <LemonSkeleton className="h-4 w-1/3" />
- </div>
- )
- }
- if (loadFailed) {
- return (
- <div className="px-3 pb-3 text-xs text-muted" data-attr="visual-review-clean-quarantined-error">
- Couldn't load the quarantined stories of this run. Reload the page to lift a quarantine when this pull
- request merges.
- </div>
- )
- }
- if (snapshots.length === 0) {
- return null
- }
+}: CleanQuarantinedSnapshotsProps): JSX.Element {
return (
- <div className="px-3 pb-3" data-attr="visual-review-clean-quarantined">
- <div className="text-xs font-semibold">Quarantined stories that rendered clean</div>
- <div className="text-xs text-muted mb-1.5">
- Select one to lift its quarantine when this pull request merges.
- </div>
- <div className="flex flex-wrap gap-1">
- {snapshots.map((snapshot) => (
- <LemonButton
- key={snapshot.id}
- type="secondary"
- size="xsmall"
- active={snapshot.id === selectedSnapshotId}
- onClick={() => onSelect(snapshot.id)}
- data-attr="visual-review-clean-quarantined-select"
- >
- {snapshot.identifier}
- </LemonButton>
- ))}
+ <div className="flex flex-col gap-2 px-3 pb-3" data-attr="visual-review-clean-quarantined">
+ <div className="text-xs text-muted">
+ These quarantined stories matched their baseline in this run. Select one to lift its quarantine when #
+ {prNumber} merges.
</div>
+ {liftsLoading ? (
+ <LemonSkeleton className="h-4 w-1/3" />
+ ) : liftsLoadFailed ? (
+ <div className="text-xs text-muted" data-attr="visual-review-clean-quarantined-error">
+ Couldn't load the quarantines and lift requests of this pull request. Reload the page.
+ </div>
+ ) : (
+ <>
+ {groups.liftRequested.length > 0 && (
+ <CleanQuarantinedStoryList
+ title={`Lift requested (${groups.liftRequested.length})`}
+ stories={groups.liftRequested}
+ selectedSnapshotId={selectedSnapshotId}
+ onSelect={onSelect}
+ />
+ )}
+ {groups.notRequested.length > 0 && (
+ <CleanQuarantinedStoryList
+ title={`Not requested (${groups.notRequested.length}), stay quarantined after the merge`}
+ stories={groups.notRequested}
+ selectedSnapshotId={selectedSnapshotId}
+ onSelect={onSelect}
+ />
+ )}
+ </>
+ )}
</div>
)
}
diff --git a/products/visual_review/frontend/components/CleanQuarantinedStoryList.tsx b/products/visual_review/frontend/components/CleanQuarantinedStoryList.tsx
new file mode 100644
index 000000000000..87788ac87e34
--- /dev/null
+++ b/products/visual_review/frontend/components/CleanQuarantinedStoryList.tsx
@@ -0,0 +1,46 @@
+import { LemonButton } from '@posthog/lemon-ui'
+
+import type { CleanQuarantinedStory } from '../lib/liftOnMerge'
+
+function storyNote(story: CleanQuarantinedStory): string | null {
+ if (story.expectsOtherPicture) {
+ return 'The request expects a different picture than this run rendered. Request the lift again.'
+ }
+ return story.liftRequest?.state === 'pending' ? story.liftRequest.detail : story.quarantineReason
+}
+
+/** One group of clean quarantined stories. Selecting a story opens it with its lift controls. */
+export function CleanQuarantinedStoryList({
+ title,
+ stories,
+ selectedSnapshotId,
+ onSelect,
+}: {
+ title: string
+ stories: CleanQuarantinedStory[]
+ selectedSnapshotId: string | null
+ onSelect: (snapshotId: string) => void
+}): JSX.Element {
+ return (
+ <div className="flex flex-col gap-0.5">
+ <div className="text-xs font-semibold">{title}</div>
+ {stories.map((story) => (
+ <LemonButton
+ key={story.snapshot.id}
+ size="xsmall"
+ fullWidth
+ active={story.snapshot.id === selectedSnapshotId}
+ onClick={() => onSelect(story.snapshot.id)}
+ data-attr="visual-review-clean-quarantined-select"
+ >
+ <span className="flex min-w-0 flex-col items-start text-xs font-normal">
+ <span className="max-w-full truncate font-mono">{story.snapshot.identifier}</span>
+ <span className={story.expectsOtherPicture ? 'text-warning-dark' : 'text-muted'}>
+ {storyNote(story)}
+ </span>
+ </span>
+ </LemonButton>
+ ))}
+ </div>
+ )
+}
diff --git a/products/visual_review/frontend/components/CleanQuarantinedToggle.tsx b/products/visual_review/frontend/components/CleanQuarantinedToggle.tsx
new file mode 100644
index 000000000000..dafbd7dd7575
--- /dev/null
+++ b/products/visual_review/frontend/components/CleanQuarantinedToggle.tsx
@@ -0,0 +1,29 @@
+/** The footer link that opens the quarantined stories this run rendered clean. */
+export function CleanQuarantinedToggle({
+ cleanCount,
+ loadFailed,
+ isExpanded,
+ onClick,
+}: {
+ cleanCount: number
+ loadFailed: boolean
+ isExpanded: boolean
+ onClick: () => void
+}): JSX.Element {
+ if (loadFailed) {
+ return <span>Couldn't load the quarantined stories. Reload the page.</span>
+ }
+ return (
+ <button
+ type="button"
+ onClick={onClick}
+ aria-expanded={isExpanded}
+ data-attr="visual-review-toggle-clean-quarantined"
+ className="shrink-0 text-xs text-muted hover:text-default hover:underline underline-offset-2 transition-colors"
+ >
+ {isExpanded
+ ? 'Hide clean quarantined stories'
+ : `${cleanCount} quarantined ${cleanCount === 1 ? 'story' : 'stories'} rendered clean`}
+ </button>
+ )
+}
diff --git a/products/visual_review/frontend/lib/liftOnMerge.test.ts b/products/visual_review/frontend/lib/liftOnMerge.test.ts
new file mode 100644
index 000000000000..4d32108aa345
--- /dev/null
+++ b/products/visual_review/frontend/lib/liftOnMerge.test.ts
@@ -0,0 +1,60 @@
+import type { QuarantineLiftEntryApi, QuarantinedIdentifierEntryApi, SnapshotApi } from '../generated/api.schemas'
+import { groupCleanQuarantinedStories } from './liftOnMerge'
+
+const snapshot = {
+ id: 'snap',
+ identifier: 'Components/Button--primary',
+ current_artifact: { content_hash: 'rendered' },
+}
+
+const quarantine = { identifier: snapshot.identifier, reason: 'Hover state renders a frame late' }
+
+function lift(state: QuarantineLiftEntryApi['state'], expectedHash: string): QuarantineLiftEntryApi {
+ return { identifier: snapshot.identifier, state, expected_hash: expectedHash } as QuarantineLiftEntryApi
+}
+
+describe('liftOnMerge', () => {
+ it.each([
+ { name: 'no request', request: null, group: 'notRequested', expectsOtherPicture: false },
+ {
+ name: 'pending for this picture',
+ request: lift('pending', 'rendered'),
+ group: 'liftRequested',
+ expectsOtherPicture: false,
+ },
+ {
+ name: 'pending for an older picture',
+ request: lift('pending', 'older'),
+ group: 'liftRequested',
+ expectsOtherPicture: true,
+ },
+ {
+ name: 'pending without a linked artifact',
+ request: lift('pending', 'older'),
+ group: 'liftRequested',
+ expectsOtherPicture: false,
+ currentArtifact: null,
+ },
+ {
+ name: 'cancelled for an older picture',
+ request: lift('cancelled', 'older'),
+ group: 'notRequested',
+ expectsOtherPicture: false,
+ },
+ ])('groups a clean quarantined story with $name', ({ request, group, expectsOtherPicture, currentArtifact }) => {
+ const rendered = currentArtifact === null ? { ...snapshot, current_artifact: null } : snapshot
+ const groups = groupCleanQuarantinedStories(
+ [rendered as SnapshotApi],
+ request ? { [snapshot.identifier]: request } : {},
+ [quarantine as QuarantinedIdentifierEntryApi]
+ )
+
+ const story = {
+ snapshot: rendered,
+ liftRequest: request,
+ quarantineReason: quarantine.reason,
+ expectsOtherPicture,
+ }
+ expect(groups).toEqual({ liftRequested: [], notRequested: [], [group]: [story] })
+ })
+})
diff --git a/products/visual_review/frontend/lib/liftOnMerge.ts b/products/visual_review/frontend/lib/liftOnMerge.ts
index e39f746166da..cd6f7e6f502a 100644
--- a/products/visual_review/frontend/lib/liftOnMerge.ts
+++ b/products/visual_review/frontend/lib/liftOnMerge.ts
@@ -1,4 +1,4 @@
-import type { QuarantineLiftEntryApi, SnapshotApi } from '../generated/api.schemas'
+import type { QuarantineLiftEntryApi, QuarantinedIdentifierEntryApi, SnapshotApi } from '../generated/api.schemas'
/**
* Why a lift on merge cannot be requested for this snapshot, or null when it can.
@@ -27,3 +27,48 @@ export function liftRequestsByIdentifier(requests: QuarantineLiftEntryApi[]): Re
}
return byIdentifier
}
+
+export interface CleanQuarantinedStory {
+ snapshot: SnapshotApi
+ liftRequest: QuarantineLiftEntryApi | null
+ quarantineReason: string | null
+ /** The pending request waits for another picture than this run rendered, so it fails after the merge. */
+ expectsOtherPicture: boolean
+}
+
+export interface CleanQuarantinedGroups {
+ liftRequested: CleanQuarantinedStory[]
+ notRequested: CleanQuarantinedStory[]
+}
+
+/** Splits the still quarantined stories that rendered clean by whether a pending lift request covers them. */
+export function groupCleanQuarantinedStories(
+ snapshots: SnapshotApi[],
+ liftRequestByIdentifier: Record<string, QuarantineLiftEntryApi>,
+ quarantinedIdentifiers: QuarantinedIdentifierEntryApi[]
+): CleanQuarantinedGroups {
+ const groups: CleanQuarantinedGroups = { liftRequested: [], notRequested: [] }
+ for (const snapshot of snapshots) {
+ // The snapshot list loads once per run, so a story unquarantined since then drops out here.
+ const quarantine = quarantinedIdentifiers.find((q) => q.identifier === snapshot.identifier)
+ if (!quarantine) {
+ continue
+ }
+ const liftRequest = liftRequestByIdentifier[snapshot.identifier] ?? null
+ const pendingRequest = liftRequest?.state === 'pending' ? liftRequest : null
+ const renderedHash = snapshot.current_artifact?.content_hash
+ const story: CleanQuarantinedStory = {
+ snapshot,
+ liftRequest,
+ quarantineReason: quarantine.reason,
+ // Without a linked artifact the rendered hash is unknown, which is not a mismatch.
+ expectsOtherPicture: !!pendingRequest && !!renderedHash && pendingRequest.expected_hash !== renderedHash,
+ }
+ if (pendingRequest) {
+ groups.liftRequested.push(story)
+ } else {
+ groups.notRequested.push(story)
+ }
+ }
+ return groups
+}
diff --git a/products/visual_review/frontend/scenes/VisualReviewRunScene.stories.tsx b/products/visual_review/frontend/scenes/VisualReviewRunScene.stories.tsx
index bdfefa95ec82..a463ed4b3b1c 100644
--- a/products/visual_review/frontend/scenes/VisualReviewRunScene.stories.tsx
+++ b/products/visual_review/frontend/scenes/VisualReviewRunScene.stories.tsx
@@ -349,6 +349,94 @@ export const QuarantinedSnapshotLiftsOnMerge: StoryObj = {
],
}
+const cleanQuarantinedCard = snapshot({
+ ...cleanQuarantinedTooltip,
+ id: 'snapshot-card',
+ identifier: 'Components/Card--hover',
+ baseline_artifact: artifact('base_card'),
+ current_artifact: artifact('base_card'),
+})
+
+const cleanQuarantinedMenu = snapshot({
+ ...cleanQuarantinedTooltip,
+ id: 'snapshot-menu',
+ identifier: 'Components/Menu--open',
+ baseline_artifact: artifact('base_menu'),
+ current_artifact: artifact('base_menu'),
+})
+
+const cardQuarantine: QuarantinedIdentifierEntryApi = {
+ ...tooltipQuarantine,
+ id: 'quarantine-card',
+ identifier: cleanQuarantinedCard.identifier,
+ reason: 'Shadow renders a frame late',
+}
+
+const menuQuarantine: QuarantinedIdentifierEntryApi = {
+ ...tooltipQuarantine,
+ id: 'quarantine-menu',
+ identifier: cleanQuarantinedMenu.identifier,
+ reason: 'Opens at a random scroll position',
+}
+
+// The card request came from an earlier run that rendered another picture, so it would fail after the merge.
+const staleCardLift: QuarantineLiftEntryApi = {
+ ...pendingLift,
+ id: 'lift-card',
+ quarantine_id: cardQuarantine.id,
+ identifier: cardQuarantine.identifier,
+ expected_hash: 'older_card',
+}
+
+const tooltipLift: QuarantineLiftEntryApi = {
+ ...pendingLift,
+ id: 'lift-tooltip',
+ quarantine_id: tooltipQuarantine.id,
+ identifier: tooltipQuarantine.identifier,
+ expected_hash: 'base_tooltip',
+}
+
+// The footer link opens the quarantined stories that rendered clean, grouped by their lift requests.
+export const CleanQuarantinedStories: StoryObj = {
+ parameters: {
+ testOptions: { waitForSelector: '[data-attr="visual-review-clean-quarantined-select"]' },
+ },
+ decorators: [
+ mswDecorator({
+ get: {
+ [`/api/projects/:team_id/visual_review/runs/${RUN_ID}/snapshots/`]: snapshotsMock(snapshots, [
+ cleanQuarantinedTooltip,
+ cleanQuarantinedCard,
+ cleanQuarantinedMenu,
+ ]),
+ [`/api/projects/:team_id/visual_review/repos/${REPO_ID}/quarantine/`]: {
+ ...emptyList,
+ count: 3,
+ results: [tooltipQuarantine, cardQuarantine, menuQuarantine],
+ },
+ [`/api/projects/:team_id/visual_review/runs/${RUN_ID}/quarantine_lifts/`]: [tooltipLift, staleCardLift],
+ },
+ }),
+ ],
+ play: async () => {
+ const toggle = await waitFor(() => {
+ const element = document.querySelector<HTMLButtonElement>(
+ '[data-attr="visual-review-toggle-clean-quarantined"]'
+ )
+ if (!element) {
+ throw new Error('Clean quarantined toggle not yet rendered')
+ }
+ return element
+ })
+ await userEvent.click(toggle)
+ await waitFor(() => {
+ if (!document.querySelector('[data-attr="visual-review-clean-quarantined-select"]')) {
+ throw new Error('Clean quarantined list not yet rendered')
+ }
+ })
+ },
+}
+
// A snapshot tolerated three times this month keeps changing. Clicking Tolerate offers a quarantine first.
// Keep this story last: its dialog opens on its own React root, outlives the story, and covers the next one.
export const TolerateSuggestsQuarantine: StoryObj = {
diff --git a/products/visual_review/frontend/scenes/VisualReviewRunScene.tsx b/products/visual_review/frontend/scenes/VisualReviewRunScene.tsx
index 7f25a58b2343..169a73d527df 100644
--- a/products/visual_review/frontend/scenes/VisualReviewRunScene.tsx
+++ b/products/visual_review/frontend/scenes/VisualReviewRunScene.tsx
@@ -17,6 +17,7 @@ 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'
@@ -229,8 +230,14 @@ export function VisualReviewRunScene(): JSX.Element {
quarantinedIdentifierSet,
showQuarantinedThumbnails,
cleanQuarantinedSnapshots,
+ cleanQuarantinedGroups,
+ showCleanQuarantined,
quarantinedRunSnapshotsLoading,
quarantinedRunSnapshotsLoadFailed,
+ quarantineLiftsLoading,
+ quarantineLiftsLoadFailed,
+ quarantinedIdentifiersLoading,
+ quarantinedIdentifiersLoadFailed,
repoFullName,
isFinalizing,
isApprovingSnapshot,
@@ -258,6 +265,7 @@ export function VisualReviewRunScene(): JSX.Element {
recomputeRun,
markThumbnailFailed,
toggleQuarantinedThumbnails,
+ toggleCleanQuarantined,
setAddImagesToComment,
} = useActions(visualReviewRunSceneLogic)
@@ -271,6 +279,12 @@ export function VisualReviewRunScene(): JSX.Element {
: sortedChangedSnapshots.filter((s: SnapshotApi) => !isHiddenQuarantined(s))
const hiddenQuarantinedCount = sortedChangedSnapshots.length - visibleNavSnapshots.length
const showQuarantinedToggle = quarantinedNavCount > 0 && (hiddenQuarantinedCount > 0 || showQuarantinedThumbnails)
+ // Stays out of view until the quarantined stories load, so the footer never offers an empty list.
+ const showCleanQuarantinedToggle =
+ !isReportingOnly &&
+ !quarantinedRunSnapshotsLoading &&
+ (quarantinedRunSnapshotsLoadFailed || cleanQuarantinedSnapshots.length > 0)
+ const showFooterToggles = showQuarantinedToggle || showCleanQuarantinedToggle
// Navigate over what's actually visible — when quarantined items are hidden, next/previous
// must skip them rather than selecting a hidden quarantined snapshot.
@@ -551,18 +565,31 @@ export function VisualReviewRunScene(): JSX.Element {
)}
{/* Pagination — below thumbnails, right-aligned */}
- {(showQuarantinedToggle || sortedChangedSnapshots.length > 1) && (
+ {(showFooterToggles || sortedChangedSnapshots.length > 1) && (
<div
- className={`flex items-center gap-2 px-3 pb-2 ${
- showQuarantinedToggle ? 'justify-between' : 'justify-end'
+ className={`flex flex-wrap items-center gap-2 px-3 pb-2 ${
+ showFooterToggles ? 'justify-between' : 'justify-end'
}`}
>
- {showQuarantinedToggle && (
- <QuarantinedThumbnailsToggle
- hiddenCount={hiddenQuarantinedCount}
- isExpanded={showQuarantinedThumbnails}
- onClick={toggleQuarantinedThumbnails}
- />
+ {showFooterToggles && (
+ <div className="flex flex-wrap items-center gap-1.5 text-xs text-muted">
+ {showQuarantinedToggle && (
+ <QuarantinedThumbnailsToggle
+ hiddenCount={hiddenQuarantinedCount}
+ isExpanded={showQuarantinedThumbnails}
+ onClick={toggleQuarantinedThumbnails}
+ />
+ )}
+ {showQuarantinedToggle && showCleanQuarantinedToggle && <span>·</span>}
+ {showCleanQuarantinedToggle && (
+ <CleanQuarantinedToggle
+ cleanCount={cleanQuarantinedSnapshots.length}
+ loadFailed={quarantinedRunSnapshotsLoadFailed}
+ isExpanded={showCleanQuarantined}
+ onClick={toggleCleanQuarantined}
+ />
+ )}
+ </div>
)}
{visibleNavSnapshots.length > 1 && (
<div className="flex items-center gap-2">
@@ -596,15 +623,21 @@ export function VisualReviewRunScene(): JSX.Element {
</div>
)}
- {!isReportingOnly && (
- <CleanQuarantinedSnapshots
- snapshots={cleanQuarantinedSnapshots}
- loading={quarantinedRunSnapshotsLoading}
- loadFailed={quarantinedRunSnapshotsLoadFailed}
- selectedSnapshotId={selectedSnapshotId}
- onSelect={setSelectedSnapshotId}
- />
- )}
+ {showCleanQuarantinedToggle &&
+ showCleanQuarantined &&
+ // A failed reload keeps the previous rows, which no longer describe this run.
+ !quarantinedRunSnapshotsLoadFailed &&
+ run.pr_number != null && (
+ <CleanQuarantinedSnapshots
+ groups={cleanQuarantinedGroups}
+ prNumber={run.pr_number}
+ // The groups read both lists, so either one still loading or failed leaves them unknown.
+ liftsLoading={quarantineLiftsLoading || quarantinedIdentifiersLoading}
+ liftsLoadFailed={quarantineLiftsLoadFailed || quarantinedIdentifiersLoadFailed}
+ selectedSnapshotId={selectedSnapshotId}
+ onSelect={setSelectedSnapshotId}
+ />
+ )}
</div>
{/* Body: diff viewer */}
diff --git a/products/visual_review/frontend/scenes/visualReviewRunSceneLogic.ts b/products/visual_review/frontend/scenes/visualReviewRunSceneLogic.ts
index b5b0bb4a2740..0e04df1bac1d 100644
--- a/products/visual_review/frontend/scenes/visualReviewRunSceneLogic.ts
+++ b/products/visual_review/frontend/scenes/visualReviewRunSceneLogic.ts
@@ -33,7 +33,12 @@ import type {
SnapshotApi,
ToleratedHashEntryApi,
} from '../generated/api.schemas'
-import { liftOnMergeDisabledReason, liftRequestsByIdentifier } from '../lib/liftOnMerge'
+import {
+ type CleanQuarantinedGroups,
+ groupCleanQuarantinedStories,
+ liftOnMergeDisabledReason,
+ liftRequestsByIdentifier,
+} from '../lib/liftOnMerge'
import { type RecentTolerations, countRecentTolerations } from '../lib/quarantineNudge'
import { isReportingOnlyRun } from '../lib/runPredicates'
import { visualReviewPreferencesLogic } from './visualReviewPreferencesLogic'
@@ -48,6 +53,7 @@ export interface visualReviewRunSceneLogicValues {
addImagesToComment: boolean // visualReviewPreferencesLogic
breadcrumbs: Breadcrumb[]
changedSnapshots: SnapshotApi[]
+ cleanQuarantinedGroups: CleanQuarantinedGroups
cleanQuarantinedSnapshots: SnapshotApi[]
deepLinkedSnapshot: SnapshotApi | null
deepLinkedSnapshotLoading: boolean
@@ -67,6 +73,7 @@ export interface visualReviewRunSceneLogicValues {
quarantineLiftsLoading: boolean
quarantinedIdentifierSet: Set<string>
quarantinedIdentifiers: QuarantinedIdentifierEntryApi[]
+ quarantinedIdentifiersLoadFailed: boolean
quarantinedIdentifiersLoading: boolean
quarantinedRunSnapshots: SnapshotApi[]
quarantinedRunSnapshotsLoadFailed: boolean
@@ -81,6 +88,7 @@ export interface visualReviewRunSceneLogicValues {
selectedLiftRequest: QuarantineLiftEntryApi | null
selectedSnapshot: SnapshotApi | null
selectedSnapshotId: string | null
+ showCleanQuarantined: boolean
showQuarantinedThumbnails: boolean
snapshots: SnapshotApi[]
snapshotsLoaded: boolean
@@ -284,6 +292,9 @@ export interface visualReviewRunSceneLogicActions {
setSelectedSnapshotId: (snapshotId: string | null) => {
snapshotId: string | null
}
+ toggleCleanQuarantined: () => {
+ value: true
+ }
toggleQuarantinedThumbnails: () => {
value: true
}
@@ -320,6 +331,11 @@ export interface visualReviewRunSceneLogicMeta {
run: RunApi | null
) => Record<string, QuarantineLiftEntryApi>
cleanQuarantinedSnapshots: (quarantinedRunSnapshots: SnapshotApi[]) => SnapshotApi[]
+ cleanQuarantinedGroups: (
+ cleanQuarantinedSnapshots: SnapshotApi[],
+ liftRequestByIdentifier: Record<string, QuarantineLiftEntryApi>,
+ quarantinedIdentifiers: QuarantinedIdentifierEntryApi[]
+ ) => CleanQuarantinedGroups
selectedLiftRequest: (
selectedSnapshot: SnapshotApi | null,
liftRequestByIdentifier: Record<string, QuarantineLiftEntryApi>
@@ -398,6 +414,7 @@ export const visualReviewRunSceneLogic = kea<visualReviewRunSceneLogicType>([
recomputeRunFailure: true,
markThumbnailFailed: (identifier: string) => ({ identifier }),
toggleQuarantinedThumbnails: true,
+ toggleCleanQuarantined: true,
}),
reducers({
// kea-loaders keeps the last success when a load fails, which would let the
@@ -471,6 +488,14 @@ export const visualReviewRunSceneLogic = kea<visualReviewRunSceneLogicType>([
loadQuarantineLiftsFailure: () => true,
},
],
+ quarantinedIdentifiersLoadFailed: [
+ false,
+ {
+ loadQuarantinedIdentifiers: () => false,
+ loadQuarantinedIdentifiersSuccess: () => false,
+ loadQuarantinedIdentifiersFailure: () => true,
+ },
+ ],
quarantinedRunSnapshotsLoadFailed: [
false,
{
@@ -495,6 +520,14 @@ export const visualReviewRunSceneLogic = kea<visualReviewRunSceneLogicType>([
toggleQuarantinedThumbnails: (state) => !state,
},
],
+ // Closed by default: most runs render some quarantined stories clean, and only the author of a
+ // fix for one of them needs the list.
+ showCleanQuarantined: [
+ false,
+ {
+ toggleCleanQuarantined: (state) => !state,
+ },
+ ],
}),
loaders(({ props, values }) => ({
run: [
@@ -572,10 +605,11 @@ export const visualReviewRunSceneLogic = kea<visualReviewRunSceneLogicType>([
if (!run) {
return []
}
+ // The endpoint pages at 100. A quarantine past the first page would drop its lift request.
const response = await visualReviewReposQuarantineList(
String(values.currentProjectId),
run.repo_id,
- { run_type: run.run_type }
+ { run_type: run.run_type, limit: 1000 }
)
return response.results
},
@@ -730,8 +764,26 @@ export const visualReviewRunSceneLogic = kea<visualReviewRunSceneLogicType>([
],
cleanQuarantinedSnapshots: [
(s) => [s.quarantinedRunSnapshots],
+ // `unchanged` also covers tolerated variants, and a lift needs the exact baseline picture.
(quarantinedRunSnapshots: SnapshotApi[]): SnapshotApi[] =>
- quarantinedRunSnapshots.filter((s) => s.result === 'unchanged'),
+ quarantinedRunSnapshots.filter((s) => {
+ const renderedHash = s.current_artifact?.content_hash
+ const baselineHash = s.baseline_artifact?.content_hash
+ return s.result === 'unchanged' && (!renderedHash || !baselineHash || renderedHash === baselineHash)
+ }),
+ ],
+ cleanQuarantinedGroups: [
+ (s) => [s.cleanQuarantinedSnapshots, s.liftRequestByIdentifier, s.quarantinedIdentifiers],
+ (
+ cleanQuarantinedSnapshots: SnapshotApi[],
+ liftRequestByIdentifier: Record<string, QuarantineLiftEntryApi>,
+ quarantinedIdentifiers: QuarantinedIdentifierEntryApi[]
+ ): CleanQuarantinedGroups =>
+ groupCleanQuarantinedStories(
+ cleanQuarantinedSnapshots,
+ liftRequestByIdentifier,
+ quarantinedIdentifiers
+ ),
],
selectedLiftRequest: [
(s) => [s.selectedSnapshot, s.liftRequestByIdentifier],