Skip to content

feat(server): implement WebSocket TTY for interactive terminal sessions#397

Merged
DorianZheng merged 2 commits into
mainfrom
feat/server-websocket-tty
Mar 18, 2026
Merged

feat(server): implement WebSocket TTY for interactive terminal sessions#397
DorianZheng merged 2 commits into
mainfrom
feat/server-websocket-tty

Conversation

@DorianZheng

Copy link
Copy Markdown
Member

Summary

Replace the last remaining 501 stub with a full WebSocket TTY implementation. All 33 OpenAPI endpoints are now fully implemented — zero stubs remaining.

The handler multiplexes four existing gRPC RPCs over a single WebSocket:

  • Client binary frames → SendInput (stdin bytes)
  • Server binary frames ← StreamOutput (PTY output)
  • Client text frames → ResizeTty (JSON resize commands)
  • Server text frames ← exit notification with exit code

Changes:

  • Enable axum ws feature for WebSocketUpgrade extractor
  • Pre-upgrade validation checks box existence before WebSocket handshake
  • Concurrent reader/writer tasks via tokio::select!
  • Add TtyQuery type with defaults (bash, 80x24)
  • Add unit tests for TtyQuery serde + integration tests for upgrade requirement

Test plan

  • cargo test -p boxlite-server — 118 tests pass (68 unit + 44 integration + 6 conformance)
  • cargo clippy -p boxlite-server --tests -- -D warnings — zero warnings
  • cargo fmt -p boxlite-server -- --check — clean
  • Full pre-push test matrix passes
  • Manual test: connect via websocat to verify stdin/stdout/resize

…al sessions (#397)

Replace the last remaining 501 stub with a full WebSocket TTY
implementation. All 33 OpenAPI endpoints are now fully implemented.

The handler multiplexes four existing gRPC RPCs (Exec, StreamOutput,
SendInput, ResizeTty) over a single WebSocket connection:
- Client binary frames → SendInput (stdin bytes)
- Server binary frames ← StreamOutput (PTY output)
- Client text frames → ResizeTty (JSON resize commands)
- Server text frames ← exit notification with exit code

Implementation details:
- Enable axum "ws" feature for WebSocketUpgrade extractor
- Pre-upgrade validation checks box existence before handshake
- Concurrent reader/writer tasks via tokio::select!
- Add TtyQuery type with defaults (bash, 80x24)
- Add unit tests for TtyQuery serde and integration tests for
  WebSocket upgrade requirement and query parameter handling
@DorianZheng DorianZheng merged commit e29e0d3 into main Mar 18, 2026
18 checks passed
@DorianZheng DorianZheng deleted the feat/server-websocket-tty branch March 18, 2026 13:13
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.

1 participant