Commit 0fc6a85
Improve built-in terminal reliability and remote replay performance (get-bb#1076)
Closes get-bb#1075.
## Summary
- batch raw PTY output into ordered chunks and preserve arbitrary
UTF-8/binary bytes end to end
- add bounded browser and daemon websocket backpressure, bad-socket
isolation, heartbeat/reconnect, input queuing, and sequence
deduplication
- reconnect from the last received sequence and bound initial browser
replay to the latest 512 KiB instead of replaying the full 4 MiB
scrollback on every open
- serialize terminal restart, open the replacement before closing the
old PTY, and wait for daemon exit acknowledgement so final output
precedes exit
- keep threadless terminal caches current, make latest-attached clients
own resize, and restore ownership on failed attach/detach
- enable xterm Unicode 11 width rules and Nerd Font fallbacks
- bump the host-daemon protocol from 75 to 76 for byte-preserving input
and required bounded-replay fields
## Measurements
### Sustained output
A local 16 MiB output probe improved from about 6.5 MiB/s to 53–63
MiB/s. Websocket output messages dropped from 16,386 to 258–480
depending on PTY chunking.
Input remained responsive during a 16 MiB remote flood. Over the
Tailscale path used for QA, the full burst completed without disconnect
while a concurrent input echo returned in 101 ms.
### Reopening a populated remote terminal
Measured through an SSH tunnel to a patched VPS:
| | Before | After |
|---|---:|---:|
| Time to final replayed line | 2,210 ms | 556 ms |
| Replay bytes | 4,192,407 | 461,853 |
| Websocket output messages | 1,025 | 15 |
A subsequent reconnect requested the previous `nextSeq` and replayed
only 319 bytes rather than the retained history.
### Input integrity
A 200,009-byte payload containing emoji and combining characters crossed
multiple 64 KiB request boundaries on the VPS with an exact SHA-256
match. CLI `--stdin` also has coverage for invalid UTF-8 bytes.
## Validation
On current `main`:
- `pnpm exec turbo run typecheck` for app, CLI, host daemon, host-daemon
contract, server, SDK, server contract, and templates
- 191 focused tests across app terminal UI/transport/controller, CLI
terminal commands, daemon connection/PTY manager, server hub/routes, and
both contracts
- production builds for app, CLI, server, and host daemon
- patched local and VPS live stacks, including latency,
flood/backpressure, atomic restart, large paste, replay truncation,
reconnect, and multi-client resize ownership
---------
Co-authored-by: Michael Yong <wrong92@gmail.com>1 parent 799b250 commit 0fc6a85
36 files changed
Lines changed: 2583 additions & 352 deletions
File tree
- apps
- app
- src/components/thread/terminal
- cli/src
- __tests__/command-output
- commands
- host-daemon/src
- terminals
- server
- src
- routes
- services/terminals
- ws
- test
- app
- public
- packages
- host-daemon-contract
- src
- test
- plugin-sdk/bundled-types
- sdk
- src/areas
- test
- server-contract
- src
- api
- test
- templates/src
- generated
- templates
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| |||
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
132 | | - | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
| |||
Lines changed: 8 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| |||
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| 103 | + | |
101 | 104 | | |
102 | 105 | | |
103 | 106 | | |
| |||
237 | 240 | | |
238 | 241 | | |
239 | 242 | | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
| 243 | + | |
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
256 | 259 | | |
257 | 260 | | |
258 | 261 | | |
| |||
Lines changed: 100 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
4 | 9 | | |
5 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
6 | 15 | | |
7 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
8 | 108 | | |
9 | 109 | | |
10 | 110 | | |
| |||
0 commit comments