Skip to content

Commit a23ce15

Browse files
docs: restructure README, split getting-started, add troubleshooting and usage guide, fix 15 inaccuracies (#112)
Restructured README and docs after auditing every page against the source code. README is now more scannable with a proper Features section, improved How It Works diagram, and a trimmed CLI table that links to full docs instead of duplicating them. Split the bloated getting-started page into a focused setup guide and a new usage guide for UI features. Added a troubleshooting page. Fixed 15 verified inaccuracies including wrong terminal size defaults, references to removed toolbar buttons, stale version numbers, and missing architecture modules. Added See Also cross-links across all docs pages. Closes #111. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c08f23b commit a23ce15

17 files changed

Lines changed: 2815 additions & 154 deletions

README.md

Lines changed: 55 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414

1515
</div>
1616

17-
TermBeam lets you access your terminal from a phone, tablet, or any browser — no SSH, no port forwarding, no config files. Run one command and scan the QR code.
18-
19-
I built this because I kept needing to run quick commands on my dev machine while away from my desk, and SSH on a phone is painful. TermBeam gives you a real terminal with a touch-optimized UI — key bar, swipe scroll, pinch zoom — that actually works on small screens. You get multi-session tabs with split view, terminal search, a command palette, 12 themes, and secure remote access out of the box.
17+
TermBeam lets you access your terminal from a phone, tablet, or any browser — no SSH, no port forwarding, no configuration needed. Run one command and scan the QR code.
2018

2119
[Full documentation](https://dorlugasigal.github.io/TermBeam/) · [Website](https://termbeam.pages.dev)
2220

@@ -47,95 +45,79 @@ termbeam
4745

4846
Scan the QR code printed in your terminal, or open the URL on any device.
4947

50-
> **First time?** Run `termbeam -i` for a guided setup wizard that walks you through password, port, and access mode.
51-
52-
### Secure by default
53-
54-
TermBeam starts with a tunnel and auto-generated password out of the box — just run `termbeam` and scan the QR code.
55-
5648
```bash
5749
termbeam # tunnel + auto-password (default)
58-
termbeam --password mysecret # use a specific password
59-
termbeam --no-tunnel # LAN-only (no tunnel)
60-
termbeam --no-password # disable password protection
50+
termbeam --password mysecret # custom password
51+
termbeam --no-tunnel # LAN only
6152
termbeam -i # interactive setup wizard
6253
```
6354

64-
## Remote Access
55+
## Features
6556

66-
```bash
67-
# Tunnel is on by default
68-
termbeam
57+
### Mobile-First
6958

70-
# Persisted tunnel (stable URL you can bookmark, reused across restarts, 30-day expiry)
71-
termbeam --persisted-tunnel
59+
- **No SSH client needed** — just open a browser on any device
60+
- **Touch-optimized key bar** with arrows, Tab, Ctrl, Esc, copy, paste, and more
61+
- **Swipe scrolling**, pinch zoom, and text selection overlay for copy-paste
62+
- **iPhone PWA safe-area support** for a native-app feel
7263

73-
# LAN-only (no tunnel)
74-
termbeam --no-tunnel
75-
```
64+
### Multi-Session
7665

77-
If the [Dev Tunnels CLI](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/get-started) is not installed, TermBeam will offer to install it for you automatically. You can also install it manually:
66+
- **Tabbed terminals** with drag-to-reorder and live tab previews on hover/long-press
67+
- **Split view** — two sessions side-by-side (auto-rotates horizontal/vertical)
68+
- **Session colors and activity indicators** for at-a-glance status
69+
- **Folder browser** for picking working directory, optional initial command per session
7870

79-
- **Windows:** `winget install Microsoft.devtunnel`
80-
- **macOS:** `brew install --cask devtunnel`
81-
- **Linux:** `curl -sL https://aka.ms/DevTunnelCliInstall | bash`
71+
### Productivity
8272

83-
Persisted tunnels save a tunnel ID to `~/.termbeam/tunnel.json` so the URL stays the same between sessions.
73+
- **Terminal search** with regex, match count, and prev/next navigation
74+
- **Command palette** (Ctrl+K / Cmd+K) for quick access to all actions
75+
- **Completion notifications** — browser alerts when background commands finish
76+
- **12 color themes** with adjustable font size
77+
- **Port preview** — reverse-proxy a local web server through TermBeam
78+
- **Image paste** from clipboard
8479

85-
## CLI Reference
80+
### Secure by Default
8681

87-
```bash
88-
termbeam [shell] [args...] # start with a specific shell (default: auto-detect)
89-
termbeam --port 8080 # custom port (default: 3456)
90-
termbeam --host 0.0.0.0 # allow LAN access (default: 127.0.0.1)
91-
termbeam --lan # shortcut for --host 0.0.0.0
92-
termbeam -i # interactive setup wizard
93-
termbeam resume [name] # reconnect to a running session from another terminal
94-
termbeam list # list active sessions on the running server
95-
termbeam service install # interactive PM2 service setup wizard
96-
termbeam service uninstall # stop & remove PM2 service
97-
termbeam service status # show PM2 service status
98-
termbeam service logs # tail PM2 service logs
99-
termbeam service restart # restart PM2 service
82+
- **Auto-generated password** with rate limiting and httpOnly cookies
83+
- **QR code auto-login** with single-use share tokens (5-min expiry)
84+
- **DevTunnel integration** for secure remote access — ephemeral or persisted URLs
85+
- **Security headers** (X-Frame-Options, CSP, nosniff) on all responses; only detected shells allowed
86+
87+
## How It Works
88+
89+
TermBeam starts a lightweight web server that spawns a PTY (pseudo-terminal) with your shell, serves a mobile-optimized [xterm.js](https://xtermjs.org/) UI via Express, and bridges the two over WebSocket. Multiple clients can view the same session simultaneously, and sessions persist when all clients disconnect.
90+
91+
```mermaid
92+
flowchart LR
93+
A["Phone / Browser"] <-->|WebSocket| B["TermBeam Server"]
94+
B <-->|PTY| C["Shell (zsh/bash)"]
95+
B -->|Express| D["Web UI (xterm.js)"]
96+
B -.->|Optional| E["DevTunnel"]
10097
```
10198

102-
| Flag | Description | Default |
103-
| --------------------- | ---------------------------------------------------- | -------------- |
104-
| `--password <pw>` | Set access password (also accepts `--password=<pw>`) | Auto-generated |
105-
| `--no-password` | Disable password (cannot combine with `--public`) ||
106-
| `--generate-password` | Auto-generate a secure password | On |
107-
| `--tunnel` | Create an ephemeral devtunnel URL (private) | On |
108-
| `--no-tunnel` | Disable tunnel (LAN-only) ||
109-
| `--persisted-tunnel` | Create a reusable devtunnel URL | Off |
110-
| `--public` | Allow public tunnel access | Off |
111-
| `--port <port>` | Server port | `3456` |
112-
| `--host <addr>` | Bind address | `127.0.0.1` |
113-
| `--lan` | Bind to all interfaces (LAN access) | Off |
114-
| `--log-level <level>` | Log verbosity (error/warn/info/debug) | `info` |
115-
| `-i, --interactive` | Interactive setup wizard (guided configuration) | Off |
116-
| `--force` | Stop existing server before starting a new one | Off |
117-
| `-h, --help` | Show help ||
118-
| `-v, --version` | Show version ||
119-
120-
| Subcommand | Description |
121-
| ------------------- | ------------------------------------------------- |
122-
| `resume [name]` | Attach to a running session from another terminal |
123-
| `list` | List active sessions on the running server |
124-
| `service install` | Interactive PM2 service setup |
125-
| `service uninstall` | Stop & remove from PM2 |
126-
| `service status` | Show PM2 service status |
127-
| `service logs` | Tail PM2 service logs |
128-
| `service restart` | Restart PM2 service |
129-
130-
Environment variables: `PORT`, `TERMBEAM_PASSWORD`, `TERMBEAM_CWD`, `TERMBEAM_LOG_LEVEL`, `SHELL` (Unix fallback), `COMSPEC` (Windows fallback). See [Configuration docs](https://dorlugasigal.github.io/TermBeam/configuration/).
99+
## CLI Highlights
131100

132-
## Security
101+
| Flag | Description | Default |
102+
| --------------------- | ----------------------------------------------- | -------------- |
103+
| `--password <pw>` | Set access password | Auto-generated |
104+
| `--no-password` | Disable password protection ||
105+
| `--tunnel` | Create an ephemeral devtunnel URL | On |
106+
| `--no-tunnel` | Disable tunnel (LAN-only) ||
107+
| `--persisted-tunnel` | Reusable devtunnel URL (stable across restarts) | Off |
108+
| `--port <port>` | Server port | `3456` |
109+
| `--host <addr>` | Bind address | `127.0.0.1` |
110+
| `--lan` | Bind to all interfaces (LAN access) | Off |
111+
| `-i, --interactive` | Interactive setup wizard | Off |
112+
| `--log-level <level>` | Log verbosity (error/warn/info/debug) | `info` |
113+
114+
For all flags, subcommands, and environment variables, see the [Configuration docs](https://dorlugasigal.github.io/TermBeam/configuration/).
133115

134-
TermBeam auto-generates a password and creates a tunnel by default, so your terminal is protected out of the box. By default, the server binds to `127.0.0.1` (localhost only). Use `--lan` or `--host 0.0.0.0` to allow LAN access, or `--no-tunnel` to disable the tunnel.
116+
## Security
135117

136-
Auth uses secure httpOnly cookies with 24-hour expiry, login is rate-limited to 5 attempts per minute, and security headers (X-Frame-Options, X-Content-Type-Options, etc.) are set on all responses. Each QR code contains a single-use share token (5-minute expiry) for password-free login. API clients that can't use cookies can authenticate with an `Authorization: Bearer <password>` header.
118+
TermBeam auto-generates a password and creates a secure tunnel by default, binding to `127.0.0.1` (localhost only). Auth uses httpOnly cookies with 24-hour expiry, login is rate-limited to 5 attempts per minute, QR codes contain single-use share tokens (5-min expiry), and security headers (X-Frame-Options, CSP, nosniff) are set on all responses.
137119

138-
For the full threat model, safe usage guidance, and a quick safety checklist, see [SECURITY.md](SECURITY.md). For detailed security feature documentation, see the [Security Guide](https://dorlugasigal.github.io/TermBeam/security/).
120+
For the full threat model and safety checklist, see [SECURITY.md](SECURITY.md). For detailed security documentation, see the [Security Guide](https://dorlugasigal.github.io/TermBeam/security/).
139121

140122
## Contributing
141123

docs/api.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Create a new session.
112112
}
113113
```
114114

115-
All fields are optional. If `initialCommand` is provided, it will be sent to the shell after startup. If `color` is omitted, a color is assigned automatically from a built-in palette. The optional `cols` and `rows` fields set the initial terminal size (defaults to 80×24 if omitted).
115+
All fields are optional. If `initialCommand` is provided, it will be sent to the shell after startup. If `color` is omitted, a color is assigned automatically from a built-in palette. The optional `cols` and `rows` fields set the initial terminal size (defaults to 120×30 if omitted).
116116

117117
The `shell` field is validated against the list of detected shells (see `GET /api/shells`). The `cwd` field must be an absolute path to an existing directory.
118118

@@ -468,3 +468,10 @@ The server validates resize dimensions: `cols` must be between 1–500 and `rows
468468
```json
469469
{ "type": "error", "message": "Session not found" }
470470
```
471+
472+
---
473+
474+
## See Also
475+
476+
- **[Architecture](architecture.md)** — system design, module responsibilities, and data flow
477+
- **[Security](security.md)** — threat model, safe usage, and security features

docs/architecture.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ termbeam/
1111
│ ├── cli.js # Argument parsing & help
1212
│ ├── devtunnel-install.js # DevTunnel CLI auto-installer
1313
│ ├── auth.js # Authentication & rate limiting
14+
│ ├── client.js # WebSocket terminal client (resume)
1415
│ ├── sessions.js # PTY session management
1516
│ ├── routes.js # Express HTTP routes
1617
│ ├── websocket.js # WebSocket connection handling
1718
│ ├── git.js # Git repo detection & status
1819
│ ├── tunnel.js # DevTunnel integration
1920
│ ├── preview.js # Port preview reverse proxy
21+
│ ├── resume.js # Resume/list subcommands
2022
│ ├── service.js # PM2 service management
2123
│ ├── interactive.js # Interactive setup wizard
2224
│ ├── prompts.js # Terminal prompt primitives (color, ask, choose, confirm)
@@ -26,22 +28,32 @@ termbeam/
2628
├── public/
2729
│ ├── index.html # Session manager (mobile UI)
2830
│ ├── terminal.html # Terminal view (xterm.js, search, notifications, command palette)
31+
│ ├── css/ # Stylesheets
32+
│ ├── js/ # Client-side JavaScript modules
2933
│ ├── sw.js # Service worker (PWA caching)
3034
│ ├── manifest.json # Web app manifest
3135
│ └── icons/ # PWA icons
3236
├── test/
3337
│ ├── auth.test.js
3438
│ ├── cli.test.js
39+
│ ├── client.test.js
3540
│ ├── interactive.test.js
3641
│ ├── prompts.test.js
3742
│ ├── devtunnel-install.test.js
3843
│ ├── e2e-keybar.test.js
44+
│ ├── git.test.js
3945
│ ├── integration.test.js
4046
│ ├── logger.test.js
4147
│ ├── preview.test.js
48+
│ ├── resume.test.js
4249
│ ├── routes.test.js
50+
│ ├── server.test.js
51+
│ ├── service-interactive.test.js
52+
│ ├── service.test.js
4353
│ ├── sessions.test.js
4454
│ ├── shells.test.js
55+
│ ├── snapshot.test.js
56+
│ ├── terminal-ui.test.js
4557
│ ├── version.test.js
4658
│ └── websocket.test.js
4759
├── docs/ # MkDocs documentation
@@ -142,3 +154,18 @@ Client (Phone Browser)
142154
├─ resize ├─ resize terminal
143155
└─ output ◄────── └─ read stdout
144156
```
157+
158+
### `client.js` — WebSocket Terminal Client
159+
160+
WebSocket terminal client used by the `resume` command. Handles raw-mode stdin/stdout piping, Ctrl+B detach, terminal resize synchronization via SIGWINCH, and scrollback replay on attach.
161+
162+
### `resume.js` — Resume & List Subcommands
163+
164+
Implements the `termbeam resume [name]` and `termbeam list` CLI subcommands. Auto-discovers running servers via `~/.termbeam/connection.json`, lists sessions, provides an interactive arrow-key chooser when multiple sessions exist, and delegates terminal attachment to `client.js`.
165+
166+
---
167+
168+
## See Also
169+
170+
- **[API Reference](api.md)** — REST and WebSocket endpoint documentation
171+
- **[Contributing](contributing.md)** — development setup, testing, and pull request guidelines

docs/configuration.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ description: All TermBeam CLI flags and options — ports, passwords, tunnels, s
5252

5353
The browser UI stores the following preferences in `localStorage`:
5454

55-
| Key | Description | Default |
56-
| ------------------------ | --------------------------------------------------------- | ------- |
57-
| `termbeam-notifications` | Command completion notifications enabled (`true`/`false`) | `true` |
58-
| `termbeam-fontsize` | Terminal font size | `14` |
59-
| `termbeam-theme` | Light/dark theme preference | `dark` |
55+
| Key | Description | Default |
56+
| ------------------------ | --------------------------------------------------------- | -------------------- |
57+
| `termbeam-notifications` | Command completion notifications enabled (`true`/`false`) | `true` |
58+
| `termbeam-fontsize` | Terminal font size | `responsive (12–15)` |
59+
| `termbeam-theme` | Light/dark theme preference | `dark` |
6060

6161
These settings are per-browser and persist across sessions. They can be cleared by the user via the browser's developer tools or the Refresh button in the toolbar.
6262

@@ -171,3 +171,12 @@ Requirements:
171171

172172
- `devtunnel` CLI — TermBeam will offer to install it automatically if not found
173173
- Login is handled automatically — if not already logged in, TermBeam will launch `devtunnel user login` for you
174+
175+
---
176+
177+
## See Also
178+
179+
- **[Usage Guide](usage-guide.md)** — tabs, split view, search, touch controls, and more
180+
- **[Getting Started](getting-started.md)** — install and run TermBeam in under a minute
181+
- **[Security](security.md)** — threat model, safe usage, and security features
182+
- **[Running in Background](running-in-background.md)** — keep TermBeam always available with PM2, systemd, or launchd

docs/contributing.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,24 @@ TermBeam also has end-to-end UI tests using [Playwright](https://playwright.dev/
4040
- [ ] Commits follow conventional format
4141
- [ ] Documentation updated if needed
4242
- [ ] Manually tested on mobile (if UI changes)
43+
44+
### Architecture Overview
45+
46+
TermBeam follows a one-responsibility-per-file pattern. Key modules:
47+
48+
- **`bin/termbeam.js`** — CLI entry point, dispatches subcommands
49+
- **`src/server.js`** — orchestrator that wires Express + WebSocket + PTY
50+
- **`src/sessions.js`** — PTY session lifecycle (create/list/delete)
51+
- **`src/auth.js`** — password auth, tokens, rate limiting
52+
- **`src/routes.js`** — Express routes for API and pages
53+
- **`src/websocket.js`** — WebSocket message handling
54+
- **`public/`** — vanilla HTML/JS frontend using xterm.js
55+
56+
For the full architecture, see [Architecture](architecture.md).
57+
58+
### Documentation
59+
60+
- **README.md** — user-facing quick reference
61+
- **`docs/`** — full MkDocs Material site (deployed to GitHub Pages)
62+
- Preview docs locally: `pip install mkdocs-material && mkdocs serve`
63+
- Changes to `docs/` pushed to `main` auto-deploy

0 commit comments

Comments
 (0)