Fix: skip recoverEmptyCycling in injectVariantsFromSource when GENERATING

Server-side preflight writes the scaffold to source before variants are
ready, triggering a full Astro page reload via HMR. After reload the
browser calls injectVariantsFromSource, finds the empty scaffold wrapper
(no variants yet), and calls recoverEmptyCycling which destroys the
session. When the agent then writes real variants and posts done, there
is no active session to receive it, so the browser never enters CYCLING.

Fix: in GENERATING state, an empty wrapper is expected (the agent is
still writing variants). Return early without touching the session so the
next HMR or done SSE can deliver the full variant set.

Fixes the intermittent astro-vite7 CYCLING timeout in live-e2e smoke.
This commit is contained in:
copilot-swe-agent[bot]
2026-07-18 21:50:14 +00:00
committed by GitHub
parent a3d7009e33
commit 1098879103
+7
View File
@@ -5687,6 +5687,13 @@
arrivedVariants = variants.length;
expectedVariants = parseInt(wrapper.dataset.impeccableVariantCount || arrivedVariants);
if (arrivedVariants <= 0) {
// Scaffold wrapper exists but variants haven't been written yet.
// This happens when server-side preflight triggers a full page reload
// (e.g. Astro's HMR) before the agent finishes writing variants. In
// GENERATING state the agent will write the variants shortly — don't
// destroy the session. The next HMR or done SSE will call this again
// with the full variant set.
if (state === 'GENERATING') return;
recoverEmptyCycling('source-fallback-empty');
return;
}