Terminals: one active client per terminal; keystrokes skip the request queue
Several clients drawing one terminal (machine terminal or chat terminal command) no longer interfere. The server tracks, per terminal, the connections drawing it, most recently active first: the active client (the opener, then whoever last typed or focused it) owns the PTY size and is the only one whose emulator's automatic query answers reach the process; other clients' answers are acknowledged and dropped, and their sizes recorded but not applied. When the active connection closes the next most recent client's size is applied. Protocol (backwards compatible; all new fields optional): - terminal_input / chat_shell_input: reply (emulator answer), cols/rows (the typist's size, applied before the input). - terminal_resize / chat_shell_resize: activate (the client focused it). Latency: PipelinesClient sends terminal_input, terminal_resize, chat_shell_input and chat_shell_resize at once rather than behind the previous request's reply. The server reads those onto a per-connection terminal lane handled in order beside the ordinary request loop, and terminal_open (up to 5 s waiting for su) now runs off the read loop. Client: ChatShellTerminalSession routes what the emulator emits while drawing output to onReply and reports focus through activate(); ChatShellInputPipe keeps answers and typing in separate requests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -107,8 +107,28 @@ data?, after?}`.
|
||||
when the login cannot ask for a password (below).
|
||||
- `terminal_list` → `terminals` (running and ended, oldest first; live
|
||||
records carry their current title, size and `stream`).
|
||||
- `terminal_input {terminal_id, data}` (UTF-8, ≤ 16 KiB, 64-request queue),
|
||||
`terminal_resize {terminal_id, cols, rows}` (clamped 20–500 × 4–200).
|
||||
- `terminal_input {terminal_id, data, reply?, cols?, rows?}` (UTF-8,
|
||||
≤ 16 KiB, 64-request queue), `terminal_resize {terminal_id, cols, rows,
|
||||
activate?}` (clamped 20–500 × 4–200).
|
||||
- **Several clients on one terminal** (`terminal_viewers.go`,
|
||||
`terminal_active.go`; chat terminal commands too): one *active* client
|
||||
owns the PTY size and is the only one whose emulator's automatic answers
|
||||
(`reply: true`: cursor position, device attributes) reach the shell, so
|
||||
a query gets one answer, not one per client. The opener starts active;
|
||||
typing (carrying the typist's `cols`/`rows`, applied before the input)
|
||||
or focusing a terminal view (`terminal_resize` with `activate`) makes a
|
||||
client active. Others' sizes are kept, not applied; when the active
|
||||
connection closes the next most recent client's size is applied. The
|
||||
client marks answers by what the emulator emits while drawing output
|
||||
(`ChatShellTerminalSession.onReply`).
|
||||
- **Input latency**: `PipelinesClient.call` sends `terminal_input`,
|
||||
`terminal_resize`, `chat_shell_input` and `chat_shell_resize` at once
|
||||
instead of behind the previous request's reply; the server reads them
|
||||
onto a per-connection terminal lane (`terminal_lane.go`) handled in
|
||||
order beside the ordinary loop, and `terminal_open` runs off the read
|
||||
loop. `ChatShellInputPipe` still keeps one request in flight per
|
||||
terminal (typing during it is coalesced; answers go in their own
|
||||
requests).
|
||||
- `terminal_output {terminal_id, after}` → `terminal` with `output`,
|
||||
`output_start`, `output_end`, `stream`; subscribes the connection.
|
||||
- `terminal_close {terminal_id}` → the closed record (runs off the read
|
||||
|
||||
Reference in New Issue
Block a user