Add Bubble Tea TUI (cmd/tui) with three-pane layout

- Connects to a running daemon's IPC port on startup
- Sends join_network then get_state; listens for events in real time
- Three-pane layout: room list (left), message history (centre), peers (right)
- Tab/Shift+Tab to switch rooms, Enter to send, PgUp/PgDn to scroll
- DM rooms appear automatically when a DM arrives
- test-tui.sh boots the full stack (anchor + 3 peers) and opens the TUI
  as alice, with bob and charlie sending periodic messages as live noise
- README: layout diagram, key bindings, TUI section; roadmap item marked done

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Fredrik Johansson
2026-06-21 18:30:56 +02:00
parent c4a059431b
commit 714ac15816
6 changed files with 833 additions and 4 deletions

View File

@@ -9,11 +9,12 @@ friend-to-friend encrypted mesh networking with chat and file sharing. Written i
waste-go/
├── cmd/
│ ├── daemon/ The peer process — run one on each friend's machine
── anchor/ WebSocket signaling server — run this on your Hetzner VPS
── anchor/ WebSocket signaling server — run this on your Hetzner VPS
│ └── tui/ Bubble Tea terminal UI (connects to a running daemon)
└── internal/
├── proto/ All wire types (shared by daemon and anchor)
├── crypto/ Ed25519 identity, nacl/box signaling, ChaCha20-Poly1305
<EFBFBD><EFBFBD><EFBFBD>── mesh/ Connected peer state + DataChannel helpers
── mesh/ Connected peer state + DataChannel helpers
├── anchor/ Anchor client — WebRTC signaling via the anchor server
└── ipc/ Local JSON API (UI talks to daemon here, port 17337)
```
@@ -124,6 +125,36 @@ Replaces WASTE's original Blowfish/PCBC (broken cipher mode) + RSA.
> Peer IDs are 64-char lowercase hex (Ed25519 public key). Existing `identity.json` files
> on disk are unaffected — only the over-the-wire representation changed from base64url.
## Terminal UI
Start the daemon first (see Getting started above), then:
```bash
go run ./cmd/tui -network friends
```
Options:
| Flag | Default | Description |
|---|---|---|
| `-network` | *(required)* | Network name to join on startup |
| `-ipc` | `17337` | Daemon IPC port |
**Layout:**
```
╭─ Rooms ──────╮╭─── #general ────────────────╮╭─ Peers ──────╮
│ ▶ #general ││ 15:04 alice hey everyone ││ ◉ alice (me) │
│ @ bob ││ 15:04 bob hi alice! ││ ● bob │
│ ││ 15:05 charlie the mesh works ││ ● charlie │
╰──────────────╯╰─────────────────────────────╯╰──────────────╯
╭─────────────────────────────────────────────────────────────╮
│ Type a message… │
╰─────────────────────────────────────────────────────────────╯
```
**Key bindings:** `Tab` / `Shift+Tab` — switch rooms · `PgUp` / `PgDn` — scroll · `Enter` — send · `Ctrl+C` — quit
## Testing
A self-contained test script boots anchor + three peers, joins them to a named network, exchanges group messages and DMs, and verifies SQLite persistence:
@@ -150,6 +181,6 @@ SELECT peer_id, alias, last_seen FROM peers;
- [x] **Anchor client** (`internal/anchor`) — offer/answer/candidate lifecycle, `nacl/box` sealing
- [x] **IPC updates**`join_network`/`leave_network`; `session_ready` event; DMs via `to` field
- [x] **Message persistence** — SQLite (`internal/store`); messages and peer alias cache
- [ ] **TUI** — Bubble Tea terminal UI consuming the IPC port
- [x] **TUI** — Bubble Tea terminal UI (`cmd/tui`); three-pane layout with room switching and DMs
- [ ] **File transfer** — chunked binary DataChannel (`f:<xid>`)
- [ ] **Native UI** — web frontend with native packaging (Tauri-style)