Skip to content

feat(scripts): pr-evidence publishes before and after screenshots for a pull request - #559

Merged
Jacksondr5 merged 5 commits into
j5/mainfrom
j5code/live-test-evidence
Oct 12, 2026
Merged

Jacksondr5 merged 5 commits into
j5/mainfrom
j5code/live-test-evidence

Conversation

@Jacksondr5

@Jacksondr5 Jacksondr5 commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Problem

Every PR that changes UI needs before and after screenshots on the PR. Getting them there has several easy mistakes: a JPEG saved under a .png name that GitHub will not render, a commit hook that fails on the evidence branch, a push that collides with another agent's, and a link that returns 404 just after a push. Agents have been redoing these steps by hand. Part of #546 (stage 3, last of five PRs).

What changed

A new script:

node scripts/j5/pr-evidence.ts <pr-number> --pair "<caption>" <before.png> <after.png> --new "<caption>" <after.png>

--pair is a state the change altered. --new is a state the change adds, which has no before; the table says "new" in that column. Both repeat, in row order.

  1. Each file is checked with file and refused unless it really is a PNG.
  2. The j5/evidence branch is cloned shallowly into a temporary directory. A fresh clone has no hooks, which avoids the repository's pre-commit hook failing on a branch with no source tree.
  3. The images are copied to pr-<number>/. Each name carries its order, caption, side and the first eight characters of the file's hash, so a changed image gets a new name and an old link never shows a new picture.
  4. The commit is pushed. If the push is rejected because another agent pushed first, the clone is rebased and the push retried, up to four attempts.
  5. Each image link is requested and must return 200 with an image/ type, in the refs/heads/j5/evidence form, with a short retry.
  6. The before and after markdown table is printed for the PR description.

PNG only; video is out of scope. Nothing is written to the pull request's own branch or to this checkout. --remote and --branch point it somewhere else for testing. The script refuses every branch but j5/evidence and a j5/evidence-selftest-* branch, so it cannot put screenshots on a pull request's own branch or on main, whatever form the remote takes. The one exception is a remote that is an existing local directory which git reports as a bare repository, which is what the tests push to; a local checkout does not qualify, since it could be a clone of the real repository. The link check runs only for a GitHub remote. A caption cannot break the table: its pipes are escaped in the caption cell and in the image alt text, and newlines and brackets are kept out of the alt text.

How the real push path was verified

Nothing was pushed to j5/evidence.

  • The branch refusal, against the real remote. --branch j5/main with the default remote is refused before anything is cloned.
  • Against GitHub, on a throwaway branch. I created j5/evidence-selftest-builder-<timestamp> from the tip of j5/evidence, ran the script with --branch set to it and two rows (one with no before), and it cloned, committed, pushed, got 200 with an image type for all three links, and printed the table. I then deleted the branch and confirmed it was gone. So clone, commit, push, the link form and the link check all ran against the real remote; only the branch name differed.
  • Against a local bare repository, in tests. Including the case the throwaway branch could not show: another agent pushing between the clone and the push.

Not exercised: a push to j5/evidence itself, a link that stays 404 past the retry, and a machine with no git identity configured (git's own error is passed through).

Checklist

  • One concern: the description has no "also"
  • Tests cover the changed behavior (backend changes ship with focused tests)
  • UI changes: before/after screenshots above, and a video for motion or interaction (no UI change)
  • Upstream-owned files: each one is recorded in FORK.md (case text and file-table row) in this PR (none edited)
  • Upstream product: any change to what upstream's product does has a human decision linked above and a register entry in docs/j5/product/upstream.md (none)
  • Surfaces: entry points, clients, providers, contracts, reverse states, connection modes (see AGENTS.md). A developer tool with one entry point. There is no removal command; a wrong image is replaced by publishing the right one under its new name.
  • Docs: definitions under docs/j5/product/ and user docs rewritten where this changes them (the skill text is in docs(j5): agents live-test with one setup script, the Browser panel and a testing skill #549)

Tests: vp test run scripts/j5/pr-evidence.test.ts (11 pass): argument parsing and its refusals, the GitHub remote forms, the link form, file naming, the table, PNG checking against JPEG bytes under a .png name, a publish to a bare repository, a repeat publish of the same images, and a rebase onto another agent's push. Typecheck and lint are clean on the touched files.

Built with Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
j5-code Ready Ready Preview Oct 12, 2026 5:45am UTC

Request Review

@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-evidence branch from bea4d89 to d7c0cd7 Compare October 12, 2026 04:00
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-base branch from a8483d3 to b9e4554 Compare October 12, 2026 04:05
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-evidence branch from d7c0cd7 to 447a3e8 Compare October 12, 2026 04:05
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-base branch from b9e4554 to 8d683f2 Compare October 12, 2026 04:06
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-evidence branch from 447a3e8 to 4487017 Compare October 12, 2026 04:06
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-base branch from 8d683f2 to ded7b66 Compare October 12, 2026 04:09
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-evidence branch from 4487017 to 954c6be Compare October 12, 2026 04:09
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-base branch from ded7b66 to d3dde9b Compare October 12, 2026 04:16
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-evidence branch from 954c6be to 70fbd79 Compare October 12, 2026 04:16
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-base branch from d3dde9b to 794867d Compare October 12, 2026 04:24
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-evidence branch from 70fbd79 to fdaeffe Compare October 12, 2026 04:24
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-base branch from 794867d to 2a9db07 Compare October 12, 2026 04:29
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-evidence branch from fdaeffe to 62bb8ad Compare October 12, 2026 04:29
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-evidence branch from 62bb8ad to 12e2526 Compare October 12, 2026 04:37
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-base branch from e6c7a15 to 57ebd01 Compare October 12, 2026 04:43
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-evidence branch from 12e2526 to bd504ea Compare October 12, 2026 04:43
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-base branch from 57ebd01 to 0ee4c5e Compare October 12, 2026 04:46
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-evidence branch from 60cc9ee to eada207 Compare October 12, 2026 05:08
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-evidence branch from eada207 to bf39584 Compare October 12, 2026 05:14
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-base branch from 621ccfb to 58b84d1 Compare October 12, 2026 05:18
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-evidence branch from 2cc1ba3 to c86f194 Compare October 12, 2026 05:18
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-base branch from 58b84d1 to ccc20f2 Compare October 12, 2026 05:20
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-evidence branch from c86f194 to cbf11c3 Compare October 12, 2026 05:20
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-evidence branch from cbf11c3 to 4a7e644 Compare October 12, 2026 05:28
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-evidence branch from 4a7e644 to 5ed77ae Compare October 12, 2026 05:32
@Jacksondr5
Jacksondr5 force-pushed the j5code/live-test-base branch from e0c7c31 to 43b4d78 Compare October 12, 2026 05:33
Jacksondr5 and others added 5 commits October 12, 2026 01:44
… a pull request

Given a pull request number and captioned pairs of PNG files, the script
checks each file really is a PNG, pushes them to pr-<number>/ on the
j5/evidence branch from a fresh shallow clone, rebasing if another agent
pushed first, checks each image link returns an image, and prints the
before and after table for the description.

Part of #546.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…change adds

--new "<caption>" <after.png> publishes one image, and the table says
"new" in its before column.

Part of #546.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review fixes for #559:
- On a GitHub remote the script refuses any branch but j5/evidence and a
  j5/evidence-selftest-* branch, so it cannot put screenshots on a pull
  request's own branch or on main. Any branch is allowed on a local remote.
- A caption's pipes are escaped in the image alt text as well as the caption
  cell, and newlines and brackets are kept out of the alt text, so a caption
  cannot break its row or its images.

Part of #546.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…not a local path

Part of #546.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… a proven local bare repository

The guard allowed any branch on a remote it did not recognise as GitHub, and
its pattern missed valid GitHub URL forms and local checkouts of the real
repository. It now refuses every branch but j5/evidence and a self-test
branch unless the remote is an existing local directory that git reports as
a bare repository.

Part of #546.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 2 billable files and costs up to $0.50.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 37 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 51 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 1b302628-01c7-41ef-8554-48ad98569982

📥 Commits

Reviewing files that changed from the base of the PR and between 7d56979 and 53016b5.


📒 Files selected for processing (2)
  • scripts/j5/pr-evidence.test.ts
  • scripts/j5/pr-evidence.ts

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

This branch was successfully deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant