Both Go peer and browser now broadcast {type:"presence", from, role}
every 10s on the bus. When either side sees a presence from someone
they don't yet have a RTCPeerConnection to, they initiate a new one
targeted at that specific peerID via the new "to" field on signal
messages. Each side keeps a map<peerID, RTCPeerConnection> instead of
the v0.3 single-connection model.
This means:
- N browsers can pair with M peers (true mesh)
- New tabs auto-discover existing peers via their next 10s chirp
- Restarts and network blips recover within 10s instead of needing
a manual browser refresh
- 45s lastSeen timeout sweeps disconnected peers and tears down their
PeerConnection
The browser UI now shows a row of peer chips that flip green when their
DataChannel opens. The pill shows "rtc" if *any* peer is open, else
"negotiating" if any are in progress, else "sse".
Go side regenerates a random peerID per process start (was static).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Browser was JSON.stringify-ing the inner payload before putting it
in the outer message envelope. Go side then saw a JSON string where
it expected a JSON object, and SignalPayload Unmarshal silently
failed — which is why answers never made it back through the
peer connection.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Old filter hid all source=web messages — meant multiple browsers
couldn't see each other's sends. Now each browser only filters out
its OWN peerID, so iphone↔mbp↔desktop all see each other's clipboard.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Server: unchanged shape, just added a "signal" message type to the
existing /api/send + /api/stream bus. Now carries both "clipboard"
(payload) and "signal" (offer/answer/ICE) over the same envelope.
Client: -rtc flag turns the Go listener into a Pion peer. Posts an SDP
offer at startup, accepts the browser's answer through the signaling
bus, exchanges ICE, then receives clipboard text over a DataChannel
named "tether". On message: writes to OS clipboard same as SSE path.
Web UI: acts as the answerer. Listens for "signal" SSE events, replies
to offers, exchanges ICE. When DataChannel opens, the send button uses
RTCDataChannel.send() instead of POST /api/send — data no longer
traverses the server after pairing. Pill in the header flips
sse → negotiating → rtc to make this visible.
Toolchain: bumped go.mod to go 1.26, switched to pion/webrtc v4 and
prometheus/client_golang v1.23.x.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Single Go module with two binaries (server, client) and an embedded
phone UI. MVP transport is HTTP POST → SSE fanout; the roadmap calls
for upgrading to WebRTC P2P with Sign in with Apple for identity, mDNS
for discovery, and OS clipboard hooks.
- server/: Go HTTP server, embedded index.html, broadcast bus with
short replay history, SSE stream endpoint, single-binary deploy.
- client/: subscribes to SSE feed and prints messages; -send for
one-shot publish from CLI. No OS clipboard touched yet (v0.5).
- web/index.html: dark phone-first UI, paste-clipboard button (uses
navigator.clipboard.readText), live feed of incoming messages via
EventSource.
This commit is intentionally tiny — it proves the end-to-end shape so
the WebRTC/SiwA/mDNS pieces can be added incrementally without
restructuring.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>