Skip to content

pr-visual: show before, after, and diff in the PR comment - #5572

Merged
cixzhang merged 4 commits into
mainfrom
pr-visual-report
Aug 27, 2026
Merged

cixzhang merged 4 commits into
mainfrom
pr-visual-report

Conversation

@cixzhang

@cixzhang cixzhang commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

pr-visual already produces the evidence a reviewer needs, then hides it in an Actions artifact ZIP. A link to a ZIP is not a visual review: download, unzip, find three matching filenames, and only then decide whether the after is correct.

That is why Cindy has not been seeing the screens even when the gate detects real deltas.

What

  • deploy-preview.yml downloads visual-pr-report best-effort and copies its static report to https://facebook.github.io/astryx/pr/<number>/visual/
  • the PR analysis comment links that full wipe report
  • the first three changed shots render directly in the comment as Before / After / Diff tables
  • additional changes stay in the full report so a broad PR does not make the comment unreadable

The privileged workflow_run job only copies files; it never executes PR-controlled report code.

Evidence

Verified against #5567's real visual-pr-report artifact (run 33001426427): its two Collapsible deltas generate six inline image URLs and the full-report URL.

Collapsible — Single Mode — neutral dark
[ Before ] [ After ] [ Diff ]

Collapsible — Single Mode — neutral light
[ Before ] [ After ] [ Diff ]

Testing

  • 17 focused formatter/comment tests
  • real artifact download and render from #5567
  • pnpm check:repo
  • git diff --check

Security hardening after review

The first cut copied PR-generated HTML into a privileged workflow_run publisher and used the PR number claimed by a PR-produced artifact. The reviewer correctly rejected that shape.

The publisher now:

  • resolves the PR from the GitHub API and requires the run head to equal the current PR head
  • cross-checks the artifact's PR/head/run claims
  • validates the verdict schema, count and key grammar; rejects symlinks/oversized files
  • decodes and re-encodes every PNG, stripping metadata
  • generates the report HTML from default-branch code; PR-produced HTML/JS is never executed or published
  • publishes to immutable pr/<number>/visual/<head_sha>/<run_id>/ paths and refuses different bytes at an existing path
  • uses immutable raw-image URLs inline, independent of Pages deployment health

The separate demo comment uses a durable cixzhang/astryx asset branch so it survives preview cleanup. Production evidence remains under the PR's gh-pages lifecycle and is deleted when that PR closes.

@vercel

vercel Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 26, 2026 10:28pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 26, 2026
@cixzhang

cixzhang commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Live demo using real PR #5567 data

This is the exact Visual Regression section the PR Analysis Report will contain. Demo images live on Cindy’s durable fork asset branch; production evidence will use immutable head/run paths.

Visual Regression

2 of 20 shot(s) changed.

component story theme mode pixels
Collapsible Single Mode (default) neutral dark 8,182
Collapsible Single Mode (default) neutral light 7,689
Collapsible — Single Mode (default) — neutral dark
BeforeAfterDiff
Collapsible — Single Mode (default) — neutral light
BeforeAfterDiff

@github-actions

github-actions Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

cixzhang pushed a commit that referenced this pull request Aug 26, 2026
github-actions Bot added a commit that referenced this pull request Aug 26, 2026
pr-visual already generated a static report with before/after/diff PNGs, then
hid it in an Actions artifact ZIP. A link to a ZIP is not a visual review: the
reviewer has to download, unzip, and match filenames before they can answer the
one question the gate asks — is the after correct?

The privileged workflow_run deployer now copies the static report beside the
PR preview at /pr/<n>/visual/ without executing PR-controlled code. The PR
analysis comment links the full wipe report and embeds the first three changed
shots as a Before / After / Diff table, directly where the decision is made.
The rest stay in the full report so a broad change does not make the comment
unreadable.

Verified against #5567's real visual-pr-report artifact: its two Collapsible
deltas produce six inline image URLs plus the full-report URL.
The first #5572 cut copied PR-generated HTML/JS into a privileged gh-pages
publisher and trusted the PR number inside a PR-produced artifact. A fork could
redirect that publisher at another PR; an older out-of-order run could also
overwrite evidence under the same mutable URL.

The workflow now resolves PR identity from the GitHub API and cross-checks the
artifact's PR/head/run. Default-branch code validates the verdict schema and
safe key grammar, rejects symlinks and oversized files, decodes/re-encodes every
PNG, and generates the report wrapper itself. PR-produced HTML/JS is neither
executed nor published.

Evidence paths are immutable by head SHA + run ID. An existing path with
anything but byte-identical content is a hard failure. Inline image URLs point
at the immutable raw branch path, independent of Pages deployment health; the
full wipe UI uses Pages.

Validated against #5567's real artifact plus negative controls for wrong run,
path traversal/shell-shaped keys, and invalid PNG bytes.
…sted code

Review found three trust-boundary defects in the initial publisher: it trusted a
PR number supplied by a PR-controlled artifact, copied PR-generated HTML/JS to
the shared Pages origin, and used a mutable per-PR URL that an old run could
overwrite.

The workflow_run now resolves PR identity through the GitHub API and requires
repo/head/run metadata to agree. Default-branch code validates verdict schema,
counts and key grammar, rejects symlinks/oversized files, decodes and re-encodes
all PNGs, and generates the HTML wrapper itself. Evidence publishes under an
immutable head-SHA/run-ID path; different bytes at an existing path are a hard
failure. Inline images use the immutable raw branch URL so Pages deployment
health cannot break the PR evidence.

No pull_request_target or workflow_run step checks out or executes PR code.
github-actions Bot added a commit that referenced this pull request Aug 26, 2026
@cixzhang
cixzhang merged commit 0ac4e83 into main Aug 27, 2026
21 checks passed
@github-actions
github-actions Bot deleted the pr-visual-report branch August 27, 2026 09:11

This branch was successfully deployed

1 active deployment
Preview — c30de639 Deployed Aug 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant