Problem
Brain TUI sidebar shows "connecting…" forever. The useServiceBus subscription never receives status messages because:
- Go bus (
four-local-bus) is not running (bootstrapped, not yet implemented)
- MemoryBus fallback is in-process only (server and TUI have separate JS module scopes due to
Bun.build() bundling)
- HTTP polling fallback in
useServiceBus is never activated because no pollEndpoint option is passed
Root Cause
tui.tsx calls useServiceBus() without the 5th opts argument containing pollEndpoint. The brain server already runs a Bun.serve HTTP status server on a random port (see status.ts:startStatusServer()), and writes the port to ~/.cache/opencode/brain/status-port-{sha256hash}.json. The plugin-lib's useServiceBus already supports HTTP polling via pollEndpoint — it just needs to be wired up.
Fix
In tui.tsx:
- Discover the status port from
~/.cache/opencode/brain/status-port-{hash}.json (same hash derivation as server: createHash("sha256").update(directory).digest("hex").slice(0, 12))
- Pass
{ pollEndpoint: "http://127.0.0.1:{port}" } as the 5th argument to useServiceBus
Affected files
src/tui.tsx — add port discovery + pollEndpoint option
Problem
Brain TUI sidebar shows "connecting…" forever. The
useServiceBussubscription never receives status messages because:four-local-bus) is not running (bootstrapped, not yet implemented)Bun.build()bundling)useServiceBusis never activated because nopollEndpointoption is passedRoot Cause
tui.tsxcallsuseServiceBus()without the 5thoptsargument containingpollEndpoint. The brain server already runs aBun.serveHTTP status server on a random port (seestatus.ts:startStatusServer()), and writes the port to~/.cache/opencode/brain/status-port-{sha256hash}.json. The plugin-lib'suseServiceBusalready supports HTTP polling viapollEndpoint— it just needs to be wired up.Fix
In
tui.tsx:~/.cache/opencode/brain/status-port-{hash}.json(same hash derivation as server:createHash("sha256").update(directory).digest("hex").slice(0, 12)){ pollEndpoint: "http://127.0.0.1:{port}" }as the 5th argument touseServiceBusAffected files
src/tui.tsx— add port discovery + pollEndpoint option