OpenCode in the Console

How the OpenCode Lite TUI is built on Text.js and how to run it locally.

OpenCode is an open source coding agent. OpenCode Lite is a console client for it, built with Text.js.

Try it

  • On this site: visit OpenCode and open DevTools.
  • Locally: bunx create-text-app my-app --template opencode.

The site runs a sandbox with a scripted agent. Type any prompt.

Anatomy

RegionComponents
Transcript<ScrollBox stickyScroll> + <Markdown>
Tool cards<Code> and <Diff>
Prompt<Textarea>
Palette<Modal> + <Select searchable>
app/session/[id]/page.tsxtsx
export default function SessionPage({ params }: PageProps<{ id: string }>) {  const { messages, send } = useSession(params.id);  return (    <Box className="flex-col grow">      <ScrollBox stickyScroll className="grow">        {messages.map((m) => <MessageView key={m.id} message={m} />)}      </ScrollBox>      <Textarea placeholder="Ask anything…" onSubmit={send} autoFocus />    </Box>  );}

Keys

KeyAction
EnterSend
Shift+TabSwitch agent (build / plan)
Ctrl+PCommands
Ctrl+X then LSessions
Ctrl+X then NNew session
Esc twiceInterrupt the running session

Connect a local server

# From any directory:opencode service status  # If stopped: opencode service startbunx @textjs/opencode@latest proxy

Leave the bridge running. On the OpenCode page, enter http://127.0.0.1:4096, press Connect, and allow local network access if Chrome asks. Then enter the pairing code the bridge printed. The page stays paired until the bridge restarts or you press Disconnect. Use the bridge URL, not the service port: the bridge supplies the service credential and CORS headers. Stop it with Ctrl+C when done.

For a foreground server already on port 4096, run bunx @textjs/opencode@latest proxy --port 4097 --target http://127.0.0.1:4096 and connect the page to port 4097. For a password-protected foreground server, export its OPENCODE_PASSWORD in the bridge shell; don't put a password in a browser URL.

The bridge is the @textjs/opencode package. It has no dependencies and also runs with npx on Node 22 or later. Inside a Text.js project, text proxy starts the same bridge.

Edit this page on GitHub