# Terminal silent-socket proof

Two separate checkouts: base 755b73c2ebe9416461a93ad7f19f9fc6c24f22f0 and head 479f56229bcc7d16e62d5859270478f26e451995. Run `vp i` in each.

Both clients were the real Vite web app, Chromium, 1280x800 CSS viewport, light theme. Each side used its own fresh database (`T3CODE_DEV_SEED=0`), local client server and separately started remote server process. All processes ran on one Linux VM, using its Tailscale IPv4 address for the remote BearerConnectionTarget; no cross-machine network was used. No application code was changed.

## Seed and pair (repeat per checkout)

Choose unused WEB_PORT and REMOTE_PORT (head remote 15545, base remote 15546). Start the client with `T3CODE_DEV_SEED=0 T3CODE_ENVIRONMENT_LABEL='Client host' vp run dev --host 0.0.0.0`; read WEB_PORT and the local pairing token from its output. Pair the browser to that client.

Start the remote server in a retained terminal session:

```sh
T3CODE_DEV_SEED=0 T3CODE_ENVIRONMENT_LABEL='Remote host' \
T3CODE_DEV_ALLOWED_ORIGINS="http://localhost:$WEB_PORT" \
node apps/server/src/bin.ts serve --host 0.0.0.0 --port "$REMOTE_PORT" \
  --dev-url "http://localhost:$WEB_PORT" --base-dir "$REMOTE_HOME"
```

Create an empty synthetic workspace, then seed via the real CLI:

```sh
node apps/server/src/bin.ts project add "$WORKSPACE" --title 'Socket stall demo' --base-dir "$REMOTE_HOME"
node apps/server/src/bin.ts thread start "$WORKSPACE" 'Terminal connection proof' \
 --title 'Terminal connection proof' --provider devReplay --model multi-turn \
 --base-dir "$REMOTE_HOME" --json
```

In Settings > Environments > Add environment, enter `http://<Tailscale IPv4>:<REMOTE_PORT>` and the remote pairing code in separate fields. Confirm map says Tailscale. Open the seeded thread directly at `/<environmentId>/<encodedThreadId>`. Open the terminal drawer, hide sidebar and thread details. In the terminal enter `export PS1='remote> '; clear`, followed by a shell comment prefix `# `, without a newline after that prefix. The Replay (dev) model only seeded the conversation; terminal IO is the real PTY and RPC stack.

## Drive and capture

1. Evaluate observe.js in the browser. It transparently observes native WebSocket.send and message events; it does not change frames, network responses, timers, or reconnection logic.
2. Verify terminal writes receive responses. Identify the WebSocket TCP peer port with `ss -tni '( sport = :<REMOTE_PORT> )'`, choosing the sustained-flow connection with the most bytes sent by the server.
3. Start browser recording. Evaluate typing.js, then immediately run `python3 stall.py <Tailscale IPv4> <REMOTE_PORT> <WS_PEER_PORT>` in a retained session. The script waits 3 seconds, REJECTs alternate destination addresses to that test port, then DROPs only server-to-client packets on the existing WebSocket flow for 30 seconds. The finally block removes those rules. New TCP flows to the Tailscale address remain usable.
4. typing.js enters a digit into the real ghostty input every 200 ms for 40 seconds. Its on-page overlay displays observed elapsed time, sent key count, socket count and age of the latest inbound frame. The drop window is approximately elapsed 3-33 seconds.
5. Stop recording after 41 seconds. Export observed frame metadata as base-frames.json / head-frames.json, stripping URLs, credentials and payloads except the synthetic digit of terminal.write. Array columns are `[elapsedMs, socketIndex, direction, frameType, rpcMethod, requestId, syntheticKey]`.
6. analyze.py derives timing-summary.json from those frame metadata and the packet-drop epoch timestamps. Replacement time is the first observed outgoing frame on the replacement WebSocket (subscribeServerConfig), not a fabricated browser connection event. RTT is request-to-Exit, keyed by socket and request ID. Unanswered means no Exit was observed on the old socket before it was discarded.

## Observed

Base: no server.probe while connected; pings continue. Old socket replaced 17.688 seconds after the drop, first new terminal answer at 18.125 seconds, 87 unanswered terminal writes. At elapsed 19.6 seconds the app shows a slow-request toast and the terminal still only displays the first 15 digits although 98 keys were sent.

Head: server.probe starts 1.632 seconds after the drop; replacement's first frame at 4.283 seconds and first new terminal answer at 4.725 seconds, while the old flow is still blocked. 21 old-socket terminal writes unanswered. Typing continues on the replacement throughout the remainder of the 30-second drop. Replacement median RTT is 5.5 ms (base replacement 5.4 ms).

Videos show the same interaction at real time. The head recording was trimmed after 41 seconds to remove idle footage. A paired video scales each to 960x600 and adds commit labels; no terminal content or telemetry was altered.
