Skip to content

Improve built-in terminal reliability and remote replay performance - #1076

Merged
ymichael merged 2 commits into
get-bb:mainfrom
Diffuzmetall:bb/ide-3-4-terminal-reliability
Aug 7, 2026
Merged

Improve built-in terminal reliability and remote replay performance#1076
ymichael merged 2 commits into
get-bb:mainfrom
Diffuzmetall:bb/ide-3-4-terminal-reliability

Conversation

@Diffuzmetall

Copy link
Copy Markdown
Contributor

Closes #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

@ymichael
ymichael force-pushed the bb/ide-3-4-terminal-reliability branch from 9226b7a to beee3ad Compare August 7, 2026 17:40
@ymichael
ymichael merged commit 16c233c into get-bb:main Aug 7, 2026
9 checks passed
ymichael added a commit that referenced this pull request Aug 7, 2026
## Summary

- let GitHub CLI resolve pull requests from the checked-out branch and
its configured upstream
- fix prompt-banner PR detection for branches tracking contributor forks
- apply the same tracking-aware resolution to ready, draft, and merge
actions
- preserve detached-head and lookup-failure behavior

## Reproduction

PR #1076 checked out a branch that tracked Diffuzmetall/bb. Passing its
bare branch name to gh pr view searched the base repository and returned
no pull request. Running gh pr view from the worktree without a
positional target followed the fork upstream and found the PR.

## Validation

- 185 host-workspace tests passed
- host-workspace and host-daemon typechecks passed
- verified the current-branch helper resolves same-repository and
fork-backed pull requests and still reports no PR for main

## Commands

- pnpm exec turbo run test --filter=@bb/host-workspace --force
- pnpm exec turbo run typecheck --filter=@bb/host-workspace
--filter=@bb/host-daemon
amadad pushed a commit to amadad/bb that referenced this pull request Aug 14, 2026
…et-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>
amadad pushed a commit to amadad/bb that referenced this pull request Aug 14, 2026
## Summary

- let GitHub CLI resolve pull requests from the checked-out branch and
its configured upstream
- fix prompt-banner PR detection for branches tracking contributor forks
- apply the same tracking-aware resolution to ready, draft, and merge
actions
- preserve detached-head and lookup-failure behavior

## Reproduction

PR get-bb#1076 checked out a branch that tracked Diffuzmetall/bb. Passing its
bare branch name to gh pr view searched the base repository and returned
no pull request. Running gh pr view from the worktree without a
positional target followed the fork upstream and found the PR.

## Validation

- 185 host-workspace tests passed
- host-workspace and host-daemon typechecks passed
- verified the current-branch helper resolves same-repository and
fork-backed pull requests and still reports no PR for main

## Commands

- pnpm exec turbo run test --filter=@bb/host-workspace --force
- pnpm exec turbo run typecheck --filter=@bb/host-workspace
--filter=@bb/host-daemon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Built-in terminal is slow to reopen and unreliable under sustained output

2 participants