feat(core): tip about VRA when a build uses Layout review mode (PER-9502)#2276
Conversation
Emit a single warn-level tip just before the "Finalized build" log whenever any snapshot in the build had enableLayout set (via global config or per-snapshot). Detection flips a per-build flag in the queue push handler; emission is gated in the end handler, so it logs at most once per process. Parallel builds surface the tip per shard via core — cli-build finalize needs no change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Emit a percy_cli_vra_recommendation_emitted build event (category percy:cli) when the VRA tip is shown, so the recommendation can be instrumented. Extends the client's sendBuildEvents to optionally send the newer top-level event_name and category params; existing callers are unaffected (params default and the API applies its own defaults). The event is sent before finalizing the build and is wrapped so telemetry can never fail a build. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a spec that makes sendBuildEvents reject and asserts the build still finalizes, exercising the previously-uncovered catch block in the snapshot queue end handler (restores 100% coverage). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
prklm10
left a comment
There was a problem hiding this comment.
Claude Code Review (automated) — 2 inline finding(s). Full report in the PR comment below. Verdict: Passed.
| await runDoctorOnFailure(percy); | ||
| } else if (build?.id) { | ||
| if (build.layoutUsed) { | ||
| percy.log.warn('Tip: VRA is Percy\'s recommended visual review mode — more accurate and adaptable than Layout. Learn more: https://www.browserstack.com/docs/percy/ai-agents/visual-review-agent/overview.'); |
There was a problem hiding this comment.
[Low] Tip emitted at WARN level
This is a promotional/informational tip, but it's logged via percy.log.warn. WARN normally signals something went wrong, and CI log processors or --fail-on-warning-style tooling may surface a benign mode-recommendation as a warning.
Suggestion: Use percy.log.info (or a dedicated tip level) unless WARN-level visibility is an explicit product requirement — in which case a one-line comment noting that intent would prevent future churn.
Reviewer: stack:code-reviewer
There was a problem hiding this comment.
Not applicable, it should be warning,
|
|
||
| // instrument the recommendation; telemetry must never fail a build | ||
| try { | ||
| await percy.client.sendBuildEvents(build.id, { |
There was a problem hiding this comment.
[Medium] Telemetry duplicates centralized pattern and omits cliVersion/clientInfo
This swallow-and-debug-log telemetry call reimplements the pattern already centralized in percy.sendCacheTelemetry (packages/core/src/percy.js:484). Unlike that path, the event body here omits cliVersion and clientInfo, which existing build events carry for attribution.
Suggestion: Route through a shared telemetry helper, or add cliVersion: percy.client.cliVersion and clientInfo: percy.clientInfo to the body to match the established event shape. At minimum, confirm with the events consumer that the slimmer payload is acceptable.
Reviewer: stack:code-reviewer
There was a problem hiding this comment.
Not applicable here
Claude Code PR ReviewPR: #2276 • Head: e08ba27 • Reviewers: stack:code-reviewer (came to rest mid-investigation — no final report) + orchestrator source analysis SummaryAdds a one-time "use VRA instead of Layout" tip, logged when a build that used Layout review mode is finalized, and instruments that recommendation via the Review Table
Findings
Verdict: PASS — Backward-compatible, well-tested change with no Critical/High issues. The Medium quality finding (telemetry pattern/field consistency) is worth addressing but is non-blocking. |
Summary
warn-level tip immediately before theFinalized buildlog whenever any snapshot in a build had Layout review mode enabled (enableLayout, set via global config or per-snapshot).build.layoutUsed) in the queuepushhandler; emission is gated in theendhandler, so it logs at most once per process.endhandler, socli-buildfinalize needs no change.[percy]prefix at normal log level):Changes
packages/core/src/snapshot.js— detection inpushhandler + guardedwarninendhandler.packages/core/test/snapshot.test.js— 4 new specs.Testing
snapshot.test.js, all passing:enableLayoutis set globally in configeslintfrom repo root).install.test.js(global.__MOCK_IMPORTS__undefined; ESM loader hook) and oneapi.test.jsserver-disabled spec (AggregateErrorvsECONNREFUSED, a Node networking quirk). No snapshot/finalize/layout specs fail.Post-Deploy Monitoring & Validation
Tip: VRA is Percy's recommended visual review mode.npx percy snapshotwithenableLayout: true(global or per-snapshot) → tip appears once just beforeFinalized build.Finalized buildordering → revert this commit (log-only change, safe to revert).Update: instrumentation of the recommendation
The VRA tip is now also instrumented via a build event so we can measure how often the recommendation is shown:
PercyClient#sendBuildEventsto optionally accept the newer top-level paramsevent_nameandcategory(backward compatible — existing callers unchanged; when omitted the API applies its defaults).event_name:percy_cli_vra_recommendation_emittedcategory:percy:clidata:{ message: "VRA recommendation shown for a build using Layout review mode" }Note:
categorywas set topercy:cli(the CLI-side sibling of thepercy:appexample) since it wasn't specified — easy to change if a different taxonomy is preferred.Added tests: client
sendBuildEventswithevent_name/category, and core specs asserting the event is sent (filtered byevent_name) only when Layout is used.