From 7d8c2c258072717041f651955633aed9fe1294b0 Mon Sep 17 00:00:00 2001 From: Simon Alman Date: Mon, 2 Nov 2026 10:47:32 +0000 Subject: [PATCH] fix(v2): avoid blocking TUI setup on RPC and prevent inotify watcher loop - Defer client.status() check in lib/v2/tui.tsx from setup() to open(). In OpenCode v2, plugins initialize concurrently while the server defers handling RPC requests until activation completes (awaitActivation). Invoking RPC during setup() causes a circular startup wait that triggers watchdog stalls. - Make default prompt file initialization idempotent in lib/prompts/store.ts by checking directory existence before writing defaults, preventing recursive inotify events when watching configuration paths. --- lib/prompts/store.ts | 8 +++++++- lib/v2/tui.tsx | 13 ++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/prompts/store.ts b/lib/prompts/store.ts index a9213a7e..0d6e3032 100644 --- a/lib/prompts/store.ts +++ b/lib/prompts/store.ts @@ -420,9 +420,15 @@ export class PromptStore { } private ensureDefaultFiles(): void { + if (existsSync(this.paths.defaultsDir)) { + return + } + try { mkdirSync(this.paths.defaultsDir, { recursive: true }) - mkdirSync(this.paths.globalOverridesDir, { recursive: true }) + if (!existsSync(this.paths.globalOverridesDir)) { + mkdirSync(this.paths.globalOverridesDir, { recursive: true }) + } } catch { this.logger.warn("Failed to initialize prompt directories", { defaultsDir: this.paths.defaultsDir, diff --git a/lib/v2/tui.tsx b/lib/v2/tui.tsx index 29843135..c048e7ea 100644 --- a/lib/v2/tui.tsx +++ b/lib/v2/tui.tsx @@ -8,7 +8,6 @@ import { panelTheme } from "./theme" export async function setup(ctx: Plugin.Context) { const client = ctx.client.rpc(rpc) const options = () => ({ location: ctx.location ?? ctx.data.location.default() }) - if (!(await client.status({}, options())).enabled) return const api: ViewApi = { renderer: ctx.renderer, theme: { @@ -37,6 +36,18 @@ export async function setup(ctx: Plugin.Context) { } const sessionID = route.sessionID try { + const status = await client.status({}, options()) + if (!status.enabled) { + show(() => ( + + )) + return + } const data = await client.snapshot({ sessionID }, options()) const back = () => { void open()