From 3c2f520c93e1353d41cf4538be793e72ebdd8ed7 Mon Sep 17 00:00:00 2001 From: Xiangzhe <32761048+xz-dev@users.noreply.github.com> Date: Wed, 3 Jun 2026 23:45:37 +0800 Subject: [PATCH] fix(pi-extension): avoid visible approval follow-up queue (#843) --- apps/pi-extension/index.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/pi-extension/index.ts b/apps/pi-extension/index.ts index efb9655f..d5f2ff44 100644 --- a/apps/pi-extension/index.ts +++ b/apps/pi-extension/index.ts @@ -1165,9 +1165,16 @@ Execute each step in order. After completing a step, include [DONE:n] in your re pi.on("agent_end", async (_event, ctx) => { if (phase === "executing" && justApprovedPlan) { justApprovedPlan = false; - pi.sendUserMessage("Continue with the approved plan.", { - deliverAs: "followUp", - }); + let attempts = 0; + const continueWhenIdle = (): void => { + if (!ctx.isIdle()) { + attempts += 1; + if (attempts <= 200) setTimeout(continueWhenIdle, 50); + return; + } + pi.sendUserMessage("Continue with the approved plan."); + }; + setTimeout(continueWhenIdle, 0); return; }