Skip to content

[FIX] Wire up HTTP polling fallback for brain TUI status (fixes 'connecting…' forever) #170

Description

@four-bytes-robby

Problem

Brain TUI sidebar shows "connecting…" forever. The useServiceBus subscription never receives status messages because:

  1. Go bus (four-local-bus) is not running (bootstrapped, not yet implemented)
  2. MemoryBus fallback is in-process only (server and TUI have separate JS module scopes due to Bun.build() bundling)
  3. 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:

  1. 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))
  2. Pass { pollEndpoint: "http://127.0.0.1:{port}" } as the 5th argument to useServiceBus

Affected files

  • src/tui.tsx — add port discovery + pollEndpoint option

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions