From c4f3479e6db809de50230c8cf55bde2d85ce39eb Mon Sep 17 00:00:00 2001 From: Code_G <12405078+codeg-dev@users.noreply.github.com> Date: Sun, 1 Mar 2026 16:34:13 +0900 Subject: [PATCH] fix(opencode): add 10-min decision timeout and remote share URL notification Add a 10-minute timeout on waitForDecision() with proper clearTimeout cleanup, and use writeRemoteShareLink for remote URL notification instead of os.hostname()/localhost. --- apps/opencode-plugin/index.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/opencode-plugin/index.ts b/apps/opencode-plugin/index.ts index adc557b..dae038b 100644 --- a/apps/opencode-plugin/index.ts +++ b/apps/opencode-plugin/index.ts @@ -26,6 +26,7 @@ import { handleAnnotateServerReady, } from "@plannotator/server/annotate"; import { getGitContext, runGitDiff } from "@plannotator/server/git"; +import { writeRemoteShareLink } from "@plannotator/server/share-url"; // @ts-ignore - Bun import attribute for text import indexHtml from "./plannotator.html" with { type: "text" }; @@ -311,12 +312,25 @@ Do NOT proceed with implementation until your plan is approved. shareBaseUrl: getShareBaseUrl(), htmlContent, opencodeClient: ctx.client, - onReady: (url, isRemote, port) => { + onReady: async (url, isRemote, port) => { handleServerReady(url, isRemote, port); + if (isRemote && await getSharingEnabled()) { + await writeRemoteShareLink(args.plan, getShareBaseUrl(), "review the plan", "plan only").catch(() => {}); + } }, }); - const result = await server.waitForDecision(); + const PLANNOTATOR_TIMEOUT_MS = 10 * 60 * 1000; // 10min timeout + let timeoutId: ReturnType; + const result = await Promise.race([ + server.waitForDecision().then((r) => { clearTimeout(timeoutId); return r; }), + new Promise<{ approved: boolean; feedback?: string }>((resolve) => { + timeoutId = setTimeout( + () => resolve({ approved: false, feedback: "[Plannotator] No response within 10 minutes. Port released automatically. Please call submit_plan again." }), + PLANNOTATOR_TIMEOUT_MS + ); + }), + ]); await Bun.sleep(1500); server.stop(); -- knotmirror 0.0.1