Skip to content

feat: HTTP status endpoint (Bun.serve) replaces file-based status - #108

Merged
four-bytes-robby merged 1 commit into
mainfrom
feat/107-http-status-endpoint
Jun 8, 2026
Merged

four-bytes-robby merged 1 commit into
mainfrom
feat/107-http-status-endpoint

Conversation

@four-bytes-robby

@four-bytes-robby four-bytes-robby commented Jun 8, 2026 •

Copy link
Copy Markdown
Member

Closes #107

Pattern

Same as limits-sidebar: TUI polls a local HTTP endpoint for status data.

Architecture

  • Bun.serve({ port: 0 }) — dynamic port, no collision risk
  • Port written to ~/.cache/opencode/brain/status-port-<hash>.json (session-scoped)
  • TUI reads port file once, then polls http://127.0.0.1:<port>/status every 200ms
  • Status JSON served from memory — no file I/O for status updates
  • stopStatusServer() called on plugin dispose

Files

  • src/status.ts — startStatusServer/stopStatusServer + Bun.serve
  • src/tui.tsx — HTTP fetch polling
  • src/four-opencode-brain.ts — dispose hook
  • src/shared.ts — emptied (getBrainStatusFile removed)

Summary by cubic

Replaces file-based brain status with a local HTTP endpoint via Bun.serve on a dynamic port. Implements #107 by having the TUI resolve the port once and poll /status for in-memory JSON; removes status file I/O and shuts down the server on dispose.

  • Refactors
    • Serve status at http://127.0.0.1:<port>/status via Bun.serve({ port: 0 }) (OS-assigned free port).
    • Write discovery file at ~/.cache/opencode/brain/status-port-<hash>.json (session-scoped).
    • TUI reads the port file once and polls the endpoint every 200ms.
    • Removed status file writes and getBrainStatusFile; added stopStatusServer() and a dispose hook.

Written for commit 837ecd0. Summary will update on new commits.

Review in cubic

…tus #107

- Server: Bun.serve on dynamic port, writes port to discovery file
- TUI: reads port file once, polls http://127.0.0.1:<port>/status every 200ms
- Removed getBrainStatusFile + all status file I/O
- stopStatusServer on dispose hook
- port:0 guarantees OS-assigned free port (no collision risk)
@four-bytes-robby four-bytes-robby self-assigned this Jun 8, 2026
@four-bytes-robby
four-bytes-robby merged commit a698b6d into main Jun 8, 2026
4 checks passed
@four-bytes-robby
four-bytes-robby deleted the feat/107-http-status-endpoint branch June 8, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP status endpoint: replace file-based status with Bun.serve

1 participant