Skip to content

Commit 01a4a05

Browse files
DeRaowlclaude
andcommitted
fix(percy): clone always creates build — falls back to screenshot copy
When snapshot names aren't URLs (most builds), the clone was stopping and asking the user to provide URLs. Now it automatically falls through to screenshot copy mode which always works. Logic: URL names → Percy CLI replay. No URLs → screenshot copy. Never stops without creating a build. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e745965 commit 01a4a05

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

src/tools/percy-mcp/v2/clone-build.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,25 @@ export async function percyCloneBuildV2(
235235
}
236236
}
237237

238-
// ── Step 4: Check if Percy CLI is available for URL replay ────────────
238+
// ── Step 4: Determine clone mode ────────────────────────────────────────
239+
240+
// Check if snapshots have URL names (web builds where name IS the URL)
241+
const hasUrlNames = snapshots.some(
242+
(s) => s.name.startsWith("http://") || s.name.startsWith("https://"),
243+
);
239244

240245
let hasCli = false;
241-
try {
242-
await execFileAsync("npx", ["@percy/cli", "--version"]);
243-
hasCli = true;
244-
} catch {
245-
hasCli = false;
246+
if (hasUrlNames) {
247+
try {
248+
await execFileAsync("npx", ["@percy/cli", "--version"]);
249+
hasCli = true;
250+
} catch {
251+
hasCli = false;
252+
}
246253
}
247254

248-
if (hasCli && buildType === "web") {
249-
// ── URL Replay mode: use Percy CLI to re-snapshot ─────────────────
255+
if (hasCli && hasUrlNames && buildType === "web") {
256+
// URL Replay: Percy CLI re-snapshots with full resources
250257
return await replayWithPercyCli(
251258
output,
252259
snapshots,
@@ -255,7 +262,7 @@ export async function percyCloneBuildV2(
255262
args.target_project_name,
256263
);
257264
} else {
258-
// ── Screenshot copy mode: download and re-upload images ───────────
265+
// Screenshot copy: always works — downloads and re-uploads images
259266
return await copyScreenshots(output, snapshots, targetToken, branch);
260267
}
261268
}

0 commit comments

Comments
 (0)