opencode icon indicating copy to clipboard operation
opencode copied to clipboard

wip: add /client to expose the TUI via HTTP

Open CefBoud opened this issue 4 months ago • 1 comments

This PR adds a /client and /ws endpoints to expose the TUI via HTTP, making it accessible from the browser and remotely using [Xterm](https://xtermjs.org/). The endpoint spawns a new TUI for each request via a PTY.

The implementation relies on bun-pty, but there was a small issue with environment variables, so I am using a slightly modified fork (https://github.com/CefBoud/bun-pty#feat-use-env) for now.

# Very much temporary workaround
cd path/to/opencode
cd ./node_modules/bun-pty/rust-pty && cargo build --release && cd -
# bun-pty might need an architecture-specific binary name; in my case, I am running:
cp ./node_modules/bun-pty/rust-pty/target/release/librust_pty.dylib ./node_modules/bun-pty/rust-pty/target/release/librust_pty_arm64.dylib

Then, run:

bun run dev --port 8080 --hostname 0.0.0.0

Head over to your browser at localhost:8080 or <IP>:8080, and the TUI will now be accessible remotely.

CefBoud avatar Sep 21 '25 14:09 CefBoud

super cool, +1

heavenly avatar Sep 21 '25 16:09 heavenly