From 4458a37fa93a7438c1b390eaffb2b361691e29b0 Mon Sep 17 00:00:00 2001 From: prklm10 Date: Thu, 11 Jun 2026 16:15:41 +0530 Subject: [PATCH] feat(core): tip about VRA when a build uses Layout review mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- packages/core/src/snapshot.js | 6 +++ packages/core/test/snapshot.test.js | 68 +++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/packages/core/src/snapshot.js b/packages/core/src/snapshot.js index 8e33750bf..7f797d858 100644 --- a/packages/core/src/snapshot.js +++ b/packages/core/src/snapshot.js @@ -428,6 +428,9 @@ export function createSnapshotsQueue(percy) { await runDoctorOnFailure(percy); } else if (build?.id) { await percy.client.finalizeBuild(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.'); + } percy.log.info(`Finalized build #${build.number}: ${build.url}`, { build }); } else { percy.log.warn('Build not created', { build }); @@ -444,6 +447,9 @@ export function createSnapshotsQueue(percy) { .handle('push', (snapshot, existing) => { let { name, meta } = snapshot; + // track layout usage to tip about VRA when the build is finalized + if (snapshot.enableLayout) build.layoutUsed = true; + // log immediately when not deferred or dry-running if (!percy.deferUploads) percy.log.info(`Snapshot taken: ${snapshotLogName(name, meta)}`, meta); if (percy.dryRun) percy.log.info(`Snapshot found: ${snapshotLogName(name, meta)}`, meta); diff --git a/packages/core/test/snapshot.test.js b/packages/core/test/snapshot.test.js index 93e8e281e..7776db293 100644 --- a/packages/core/test/snapshot.test.js +++ b/packages/core/test/snapshot.test.js @@ -2194,6 +2194,74 @@ describe('Snapshot', () => { }); }); }); + + describe('VRA layout tip', () => { + let tip = '[percy] 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.'; + + it('logs a VRA tip before finalizing when a snapshot has layout enabled', async () => { + await percy.snapshot({ + name: 'test snapshot', + url: 'http://localhost:8000', + domSnapshot: '', + enableLayout: true + }); + + await percy.stop(); + + expect(logger.stderr).toContain(tip); + expect(logger.stdout).toContain( + '[percy] Finalized build #1: https://percy.io/test/test/123' + ); + }); + + it('logs the VRA tip when enableLayout is set globally in config', async () => { + percy.config.snapshot.enableLayout = true; + + await percy.snapshot({ + name: 'test snapshot', + url: 'http://localhost:8000', + domSnapshot: '' + }); + + await percy.stop(); + + expect(logger.stderr).toContain(tip); + }); + + it('logs the VRA tip only once when multiple snapshots have layout enabled', async () => { + await percy.snapshot({ + name: 'snapshot one', + url: 'http://localhost:8000', + domSnapshot: '', + enableLayout: true + }); + await percy.snapshot({ + name: 'snapshot two', + url: 'http://localhost:8000', + domSnapshot: '', + enableLayout: true + }); + + await percy.stop(); + + expect(logger.stderr.filter(l => l === tip).length).toEqual(1); + }); + + it('does not log the VRA tip when no snapshot has layout enabled', async () => { + await percy.snapshot({ + name: 'test snapshot', + url: 'http://localhost:8000', + domSnapshot: '' + }); + + await percy.stop(); + + expect(logger.stderr).not.toContain(tip); + expect(logger.stdout).toContain( + '[percy] Finalized build #1: https://percy.io/test/test/123' + ); + }); + }); }); // ── runDoctorOnFailure ────────────────────────────────────────────────────────