Foray
A full terminal you can drive from your phone
- 24,500lines of code
- 120commits
- 1line to install
About
Foray is a terminal in your browser, built so I could keep working with Claude Code from my phone. Your sessions live on your own server, so closing the tab, losing signal or redeploying doesn't end them.
It installs with one line on a Linux server or a Mac, you reach it privately over Tailscale, and it sits on your home screen like an app.
Stack
- Client
- ReactVitexterm.js with WebGLCodeMirror
- Server
- NodeExpressWebSocketsnode-ptytmux
- Ops
- systemdpm2TailscaleCloudflare Workers for the site
- Testing
- Playwrightnode:test
Technical challenges
Scrollback without holes
tmux only repaints what's on screen, so history rebuilt from the byte stream has gaps. The server reads tmux's own history and lines it up with what the browser already has, by content. A bug that spliced lines mid-word was fixed by requiring the overlap to be a whole number of pane widths, then checked against 4,000 lines of real scrollback.
Typing on a phone
Phone keyboards leave ghost characters in a terminal. A separate composer sends finished text as one paste, and a sticky bar adds the Ctrl and Alt keys phones don't have.
The keyboard as a curtain
Opening the keyboard doesn't resize the terminal. The layout follows the visible part of the screen instead, so output doesn't reflow every time you start typing.
Phones drop connections
The socket reconnects with backoff and a heartbeat, and probes as soon as the tab wakes up, so a phone coming out of a pocket is live again almost at once.
Sessions that outlive the server
tmux runs in its own system service, so a deploy, a crash or an out-of-memory kill leaves every session running.
A shell in a browser, safely
Token login with a timing-safe compare, strict cookies, an origin check on the socket and size-capped messages. The app only listens locally and is reached over Tailscale, and the install script is served only if it matches the repo.

