Skip to content

Let take_screenshot skip chat display for internal verification captures#4097

Open
bcotrim wants to merge 2 commits into
trunkfrom
add-take-screenshot-display-flag
Open

Let take_screenshot skip chat display for internal verification captures#4097
bcotrim wants to merge 2 commits into
trunkfrom
add-take-screenshot-display-flag

Conversation

@bcotrim

@bcotrim bcotrim commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Implemented and tested with Claude Code, based on a confirmed finding from a multi-agent review of #3982; human-reviewed before opening.

Proposed Changes

Since #3982, every take_screenshot capture is automatically shown to the user as an inline chat artifact. That is right for deliberate captures, but the agent also screenshots constantly for its own eyes — the visual-polish loop alone takes up to 5 verification passes per page, and a light/dark × desktop/mobile check produces 4 images per call. Iterative design sessions flood the conversation with near-identical screenshots the user never asked for, and each one is persisted in the session transcript. (The previous presentation rule's "Do not present every internal verification screenshot" guidance was lost in the #3982 rewrite, and the model had no mechanism to comply with it anyway.)

This PR gives the agent that mechanism: an optional display input on take_screenshot (default true, so current behavior is unchanged). Passing display: false keeps the capture out of the chat while the model still receives the image for its own visual verification, and the presentation rule now tells the agent to use it while iterating so users only see deliberate milestone captures.

Testing Instructions

  • Run npm test -- apps/cli/ai/tests/tools.test.ts apps/cli/ai/tests/system-prompt.test.ts packages/common
  • Run npm run typecheck
  • Reproduce the flood on trunk: in Studio Code, prompt "Check the homepage for spacing and contrast issues in light and dark mode, on desktop and mobile. After every change you make, take screenshots again to verify. Keep iterating until it looks right." — the conversation fills with near-identical screenshots.
  • On this branch, repeat the same prompt: intermediate verification captures should stay out of the chat, with only deliberate/milestone captures displayed.
  • Ask directly for a screenshot ("take a screenshot of my site") and confirm it still appears inline as before.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

🤖 Generated with Claude Code

@wpmobilebot

wpmobilebot commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing e6a0a77 vs trunk

app-size

Metric trunk e6a0a77 Diff Change
App Size (Mac) 1411.93 MB 1411.93 MB 0.00 MB ⚪ 0.0%

site-editor

Metric trunk e6a0a77 Diff Change
load 1121 ms 1114 ms 7 ms ⚪ 0.0%

site-startup

Metric trunk e6a0a77 Diff Change
siteCreation 6480 ms 6504 ms +24 ms ⚪ 0.0%
siteStartup 2389 ms 2387 ms 2 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

Comment thread package-lock.json Outdated
},
"bin": {
"pi-ai": "./dist/cli.js"
"pi-ai": "dist/cli.js"

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.

I am not sure what are these changes so just leaving the comment to flag this 😅

@katinthehatsite katinthehatsite 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.

The changes look good and I only saw the screenshots once the agent was done with the audit 👍

Image

I left one minor comment regarding some changes that did not seem to be related or I was not sure what they were

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.

3 participants