Skip to content

chore: add a method and checks for retaking screenshots - #2843

Open
claudiacodacy wants to merge 3 commits into
masterfrom
docs-screenshot-checks
Open

claudiacodacy wants to merge 3 commits into
masterfrom
docs-screenshot-checks

Conversation

@claudiacodacy

Copy link
Copy Markdown
Contributor

Agents retaking product screenshots with Claude in Chrome have committed images that looked right in the transcript but weren't: one was a blank white PNG. This adds a standard, the steps, and checks that must pass before an image is committed. Replaces #2841.

The standard

  • A 1280×720 viewport captured whole, saved as a 1456×819 PNG.
  • Always at Chrome page zoom 100% on a Retina screen (device pixel ratio exactly 2). Every screenshot renders at the same density and is reduced by the same factor, 2560 to 1456 wide. Nothing is scaled up.
  • No pointer, no hover state, and only UI a customer sees.

Changes

  • .claude/reference/screenshots.md: the standard, the Claude in Chrome steps, and the methods that don't work and why.
  • .claude/scripts/finish-screenshot.py: takes the page check (innerWidth, innerHeight, devicePixelRatio) and two captures. Refuses any other zoom, viewport or capture size, removes the pointer Claude in Chrome draws (refusing if anything else changed between captures), and writes a capture record into the PNG.
  • .claude/scripts/validate-screenshot.py: fails if the file isn't a real PNG, has no capture record or the wrong one, isn't 1456×819 (or, with --crop, is under 400×150), is blank or nearly one colour, is partly transparent, is blurry or scaled up, is pixelated, went through JPEG, shows text from the local hide list, or doesn't contain the --expect text. Text is read with macOS Vision (ocr.swift).
  • .claude/scripts/hide-ui.py: prints a page script that hides the elements in the local hide list and reports any that are still visible.
  • .gitignore: ignores .claude/screenshots.local.json, the local hide list.
  • CLAUDE.md: links the new reference.

How it was tested

  • Quality checks: real captures pass; scaled-up (smooth and blocky), JPEG, blank, near-blank, renamed-JPEG and loading-spinner images fail.
  • finish-screenshot.py refuses a window at 80% zoom, a wrong viewport and captures of the wrong size. On a matching pair it removes both pointers and changes no other pixel.
  • The two screenshots in docs: rewrite Ignoring files around ignore rules [OD-1217] #2837 pass, with and without the local hide list. A hide-list entry that matches their text makes them fail.

🚧 To do

  • Perform a self-review of the changes
  • Fix any issues reported by the CI/CD

🤖 Generated with Claude Code

Agents taking screenshots with Claude in Chrome have committed blank
images before. screenshots.md sets the standard (a 1280x720 viewport at
100% zoom, saved as a 1456x819 PNG, no pointer) and the steps.
finish-screenshot.py checks zoom and viewport, removes the pointer and
records how the image was made. validate-screenshot.py rejects blank,
JPEG, blurry, pixelated and wrong-size images and checks expected text
with macOS Vision. hide-ui.py and the validator read a git-ignored local
list of UI that customers don't see.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claudiacodacy
claudiacodacy requested a review from a team as a code owner November 30, 2026 15:44
@codacy-production

codacy-production Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 73 complexity · 0 duplication

Metric Results
Complexity 73
Duplication 0

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@github-actions
github-actions Bot temporarily deployed to Netlify November 30, 2026 15:45 Inactive

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

⚠️ Resolve issues before merging

Two blocking risks remain: fixed-position account-specific elements can be missed by the hiding check, and the finishing algorithm can mistake unrelated small changes for pointer differences. These leave acceptance criteria around UI removal and pointer-only merging only partially implemented.

The screenshot validator also does not reliably reject partially transparent images. The affected image-processing scripts are complex and lack automated coverage for their failure paths.

Codacy also found:

  • 45 complexity points in .claude/scripts/validate-screenshot.py and 28 in .claude/scripts/finish-screenshot.py.
  • Shebang/executable-bit consistency findings in .claude/scripts/hide-ui.py and .claude/scripts/validate-screenshot.py.

Test suggestions

  • Finish two valid full-page captures with pointers in different locations and verify the output removes both pointers without changing other pixels.
  • Reject finishing when the page has the wrong device pixel ratio, viewport, capture dimensions, or capture count.
  • Reject capture pairs that differ in content beyond pointer-sized regions.
  • Validate rejection of blank, near-blank, blurry, pixelated, JPEG-derived, incorrectly sized, and incorrectly stamped images.
  • Validate OCR expectations and hidden-list text or line rejection, including allowed lines.
  • Generate the hide script from a local configuration and report hidden and still-visible selectors.
  • Exercise malformed-image and OCR-failure paths in the validator.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Finish two valid full-page captures with pointers in different locations and verify the output removes both pointers without changing other pixels.
2. Reject finishing when the page has the wrong device pixel ratio, viewport, capture dimensions, or capture count.
3. Reject capture pairs that differ in content beyond pointer-sized regions.
4. Validate rejection of blank, near-blank, blurry, pixelated, JPEG-derived, incorrectly sized, and incorrectly stamped images.
5. Validate OCR expectations and hidden-list text or line rejection, including allowed lines.
6. Generate the hide script from a local configuration and report hidden and still-visible selectors.
7. Exercise malformed-image and OCR-failure paths in the validator.

TIP Add a Jira or Linear ticket key to the branch or title so the reviewer can check the PR against it. Using another tracker? Tell us.
TIP How was this review? Give us feedback

}
const stillVisible = (config.check || []).flatMap((selector) =>
[...document.querySelectorAll(selector)]
.filter((element) => element.offsetParent)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 HIGH RISK

Visible fixed-position elements are omitted from stillVisible because their offsetParent is null. This can allow account-only UI into screenshots when hiding it fails. Consider checking computed visibility and rendered bounds instead.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

Comment on lines +163 to +165
alpha_mean = ImageStat.Stat(image.getchannel("A")).mean[0]
if alpha_mean < 250:
failures.append(f"partly transparent: mean alpha {alpha_mean:.0f} of 255")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

The validator does not reliably reject partly transparent PNGs because it checks only mean alpha; inspect whether any alpha value is below 255 (or apply an explicitly documented tolerance) so transparent pixels cannot pass unnoticed.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

Comment on lines +81 to +83
boxes = regions(differs)
too_big = [b for b in boxes if b[2] - b[0] > MAX_POINTER_SIZE or b[3] - b[1] > MAX_POINTER_SIZE]
if len(boxes) != 2 or too_big:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

If the pointer fails to move but two small UI regions change between captures, this accepts those changes as pointers and leaves the actual pointer in the output. Consider requiring the pointer positions and rejecting differences outside those regions.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

probe.verify()
image = Image.open(path)
image.load()
except Exception as error: # a truncated or corrupt file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Suggestion: Unexpected programming errors during image validation can be swallowed and reported as corrupt-image failures because this catches every Exception. Catch the specific Pillow exceptions expected from verify(), load(), and decoding instead.

See Issue in Codacy

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions
github-actions Bot temporarily deployed to Netlify November 30, 2026 15:47 Inactive
Return to Previous Size is greyed out when a window is tiled to a corner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions
github-actions Bot temporarily deployed to Netlify November 30, 2026 15:50 Inactive

This branch was previously deployed

1 inactive deployment
Netlify — 2b994e8f Deployed Nov 30, 2026 by github-actions[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