feat: WebSocket terminal I/O with server-side DEC 2026 sync#40
Open
Spirotot wants to merge 1 commit intoArk0N:masterfrom
Open
feat: WebSocket terminal I/O with server-side DEC 2026 sync#40Spirotot wants to merge 1 commit intoArk0N:masterfrom
Spirotot wants to merge 1 commit intoArk0N:masterfrom
Conversation
Replace per-keystroke HTTP POST + SSE terminal output with a single bidirectional WebSocket connection for dramatically lower input latency. The existing SSE+POST paths remain fully functional as fallback. Server-side: ws-routes.ts provides /ws/sessions/:id/terminal with 8ms micro-batching and 16KB flush threshold. Each batch is wrapped in DEC 2026 synchronized update markers so xterm.js renders atomically — Ink's DA capability negotiation fails through the PTY→server→WS proxy chain, so without server-injected markers, cursor-up redraws flicker. Frontend: _connectWs/_disconnectWs manage per-session WS lifecycle. Input and resize use WS fast path with HTTP POST fallback. SSE terminal events are suppressed when WS is active to prevent double rendering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/ws/sessions/:id/terminal) as a low-latency bidirectional channel for terminal I/O, replacing per-keystroke HTTP POST + SSE output with a single persistent connection\x1b[?2026h/\x1b[?2026l) so xterm.js renders atomically — eliminates flicker from Ink's cursor-up redraws (Ink's DA capability negotiation for DEC 2026 fails through the PTY→server→WS proxy chain, so server-injected markers are required)Protocol
All JSON text frames:
{"t":"o","d":"..."}{"t":"c"}{"t":"r"}{"t":"i","d":"..."}{"t":"z","c":N,"r":N}Files changed
src/web/routes/ws-routes.ts(new) — WebSocket route handler with micro-batching and DEC 2026 wrappingsrc/web/routes/index.ts— Barrel exportsrc/web/server.ts—@fastify/websocketregistrationsrc/web/public/app.js— WS client lifecycle, SSE suppression guards, input/resize fast pathspackage.json—@fastify/websocketdependencyTest plan
🤖 Generated with Claude Code