From 0b9492bca8b25ca38b4517ef64f39c5b6cfe49a4 Mon Sep 17 00:00:00 2001 From: Robby Date: Mon, 15 Jun 2026 13:12:59 +0200 Subject: [PATCH] feat: route BusClient warnings to app.log + toast on fallback #153 --- bun.lock | 8 +++++--- package.json | 4 ++-- src/status.ts | 17 ++++++++++++++--- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/bun.lock b/bun.lock index 649714e..bbe7aee 100644 --- a/bun.lock +++ b/bun.lock @@ -5,7 +5,7 @@ "": { "name": "@four-bytes/four-opencode-brain", "dependencies": { - "@four-bytes/opencode-plugin-lib": "github:four-bytes/four-opencode-plugin-lib#v0.6.1", + "@four-bytes/opencode-plugin-lib": "file:../four-opencode-plugin-lib", "@opencode-ai/plugin": "1.16.2", "@opentui/core": "0.3.2", "@opentui/solid": "0.3.2", @@ -81,7 +81,7 @@ "@babel/types": ["@babel/types@7.29.7", "", { "dependencies": { "@babel/helper-string-parser": "^7.29.7", "@babel/helper-validator-identifier": "^7.29.7" } }, "sha512-4zBIxpPzowiZpusoFkyGVwakdRJUyuH5PxQ/PrqghfdFWWasvnCdPfQXHrenDai+gyLARulZjZowCOj6fjT4pA=="], - "@four-bytes/opencode-plugin-lib": ["@four-bytes/opencode-plugin-lib@github:four-bytes/four-opencode-plugin-lib#6fcf394", { "peerDependencies": { "@opencode-ai/plugin": ">=1.16.0", "@opentui/solid": "^0.4.1", "solid-js": "^1.9.13" } }, "four-bytes-four-opencode-plugin-lib-6fcf394", "sha512-KiGhgfknOS6HfrXbQV95Z7IhMeBvN3pwRPqmXj6+XP5Rfl0cCZyLseA2AVLZ+mqI0Z2NtNvEEoFyR9HenogHTg=="], + "@four-bytes/opencode-plugin-lib": ["@four-bytes/opencode-plugin-lib@file:../four-opencode-plugin-lib", { "devDependencies": { "@opencode-ai/plugin": "^1.16.0", "bun-types": "^1.3.0", "typescript": "^6.0.3" }, "peerDependencies": { "@opencode-ai/plugin": ">=1.16.0", "@opentui/solid": "^0.4.1", "solid-js": "^1.9.13" } }], "@huggingface/jinja": ["@huggingface/jinja@0.5.9", "", {}, "sha512-uWTG+l3VJRsl7EXxYizuL3P+cCPoc3cRqbWWRcQN0FhejRfbdq0RNhCmbY/YDtnTcz9icdLYuLDjsnz4d8JMuw=="], @@ -469,7 +469,7 @@ "tree-sitter-typescript": ["tree-sitter-typescript@0.23.2", "", { "dependencies": { "node-addon-api": "^8.2.2", "node-gyp-build": "^4.8.2", "tree-sitter-javascript": "^0.23.1" }, "peerDependencies": { "tree-sitter": "^0.21.0" }, "optionalPeers": ["tree-sitter"] }, "sha512-e04JUUKxTT53/x3Uq1zIL45DoYKVfHH4CZqwgZhPg5qYROl5nQjV+85ruFzFGZxu+QeFVbRTPDRnqL9UbU4VeA=="], - "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="], + "typescript": ["typescript@6.0.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw=="], "undici-types": ["undici-types@7.24.6", "", {}, "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg=="], @@ -515,6 +515,8 @@ "babel-plugin-jsx-dom-expressions/@babel/helper-module-imports": ["@babel/helper-module-imports@7.18.6", "", { "dependencies": { "@babel/types": "^7.18.6" } }, "sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA=="], + "bun-ffi-structs/typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="], + "cliui/string-width": ["string-width@4.2.3", "", { "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" } }, "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g=="], "cliui/strip-ansi": ["strip-ansi@6.0.1", "", { "dependencies": { "ansi-regex": "^5.0.1" } }, "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A=="], diff --git a/package.json b/package.json index 32fd053..0ccc3bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@four-bytes/four-opencode-brain", - "version": "1.7.7", + "version": "1.7.8", "description": "Unified brain plugin — single SQLite DB for RAG search, memory, and knowledge base", "license": "Apache-2.0", "type": "module", @@ -15,7 +15,7 @@ "four-bytes" ], "dependencies": { - "@four-bytes/opencode-plugin-lib": "github:four-bytes/four-opencode-plugin-lib#v0.6.1", + "@four-bytes/opencode-plugin-lib": "file:../four-opencode-plugin-lib", "@opencode-ai/plugin": "1.16.2", "@opentui/core": "0.3.2", "@opentui/solid": "0.3.2", diff --git a/src/status.ts b/src/status.ts index 946518e..c5e232d 100644 --- a/src/status.ts +++ b/src/status.ts @@ -79,9 +79,20 @@ export function initStatus(client: PluginInput["client"], directory: string): vo function getBus(): Promise { if (!_busPromise) { - _busPromise = BusClient.connect().catch((err) => { - _client?.app?.log({ body: { service: "brain", level: "warn", message: "BusClient connect failed", extra: { error: String(err) } } }).catch(() => {}); - _busPromise = null; // allow retry on next call + _busPromise = BusClient.connect({ + onWarn: (message, ...args) => { + _client?.app?.log({ body: { service: "brain", level: "warn", message, extra: { args: args.map(String) } } }).catch(() => {}); + }, + }).then((bus) => { + // bus.activePort === 0 means MemoryBusClient fallback (Go bus binary not available) + if ((bus as any).activePort === 0) { + _client?.tui?.showToast({ body: { title: "Brain 🧠", message: "Bus unavailable — using in-memory fallback. Install four-local-bus for cross-process communication.", variant: "warning", duration: 8000 } }); + } + return bus; + }).catch((err) => { + _client?.app?.log({ body: { service: "brain", level: "error", message: "BusClient connect failed", extra: { error: String(err) } } }).catch(() => {}); + _client?.tui?.showToast({ body: { title: "Brain 🧠", message: "Bus connection failed: " + String(err).slice(0, 80), variant: "error", duration: 7000 } }); + _busPromise = null; throw err; }); }