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:
+12
-2
@@ -1315,8 +1315,18 @@ app's terminal panel). Every request carries `terminal_request`
|
||||
pipelines`), never the operator's tmux. At most 8 running terminals per
|
||||
machine.
|
||||
- `terminal_list` replies with `terminals` (running and ended, oldest first).
|
||||
- `terminal_input {terminal_id, data}` writes UTF-8 input (at most 16 KiB);
|
||||
`terminal_resize {terminal_id, cols, rows}` resizes. Neither is logged.
|
||||
- `terminal_input {terminal_id, data, reply?, cols?, rows?}` writes UTF-8
|
||||
input (at most 16 KiB); `terminal_resize {terminal_id, cols, rows,
|
||||
activate?}` reports the size a client draws at. Neither is logged. With
|
||||
several clients on one terminal, the *active* client (the opener, then
|
||||
whichever most recently typed or sent `activate`, i.e. focused it) owns
|
||||
the terminal's size, and only its emulator's automatic query answers
|
||||
(`reply: true`) reach the shell; others' are acknowledged and dropped.
|
||||
Typed input may carry the sender's `cols`/`rows`, applied first. When the
|
||||
active connection closes, the next most recent client's size is applied.
|
||||
`chat_shell_input`/`chat_shell_resize` follow the same rules. Input and
|
||||
resize requests are handled on a lane of their own per connection, in
|
||||
order, never behind a slow request read before them.
|
||||
- `terminal_output {terminal_id, after}` replies with the retained output (1
|
||||
MiB tail) from byte `after` of the stream named `stream`. Opening or reading subscribes the connection to
|
||||
the terminal's output frames.
|
||||
|
||||
Reference in New Issue
Block a user