From f069790d7d8d081208d326a3bb3b7dcae5199ccb Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Thu, 19 Mar 2026 18:54:14 -0400 Subject: [PATCH] fix: inject network_idle warning into hook prompts (#1345) (#1401) Post-unit hooks that use browser tools can hang indefinitely when the LLM calls browser_wait_for with condition 'network_idle' against a dev server with persistent connections (Vite HMR, WebSocket). The networkidle event never fires because at least one connection stays open. Fix: Inject a browser safety instruction into every hook prompt warning against network_idle and recommending selector_visible, text_visible, or delay as alternatives. Fixes #1345 --- src/resources/extensions/gsd/post-unit-hooks.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/resources/extensions/gsd/post-unit-hooks.ts b/src/resources/extensions/gsd/post-unit-hooks.ts index 649566259..c4e598980 100644 --- a/src/resources/extensions/gsd/post-unit-hooks.ts +++ b/src/resources/extensions/gsd/post-unit-hooks.ts @@ -149,11 +149,15 @@ function dequeueNextHook(basePath: string): HookDispatchResult | null { // Build the prompt with variable substitution const [mid, sid, tid] = triggerUnitId.split("/"); - const prompt = config.prompt + let prompt = config.prompt .replace(/\{milestoneId\}/g, mid ?? "") .replace(/\{sliceId\}/g, sid ?? "") .replace(/\{taskId\}/g, tid ?? ""); + // Inject browser safety instruction for hooks that may use browser tools (#1345). + // Vite HMR and other persistent connections prevent networkidle from resolving. + prompt += "\n\n**Browser tool safety:** Do NOT use `browser_wait_for` with `condition: \"network_idle\"` — it hangs indefinitely when dev servers keep persistent connections (Vite HMR, WebSocket). Use `selector_visible`, `text_visible`, or `delay` instead."; + return { hookName: config.name, prompt,