One Keypress, Fully Traced
The client’s input handler receives a parsed terminal event and sends a
ClientToServerMsg::Key over IPC. Keybindings are interpreted on the server,
so live configuration and shared-session state determine the action.
The route thread turns that action into a typed subsystem instruction. For
ordinary text it sends ScreenInstruction::WriteCharacter, carrying raw bytes,
client identity, keyboard-protocol information, and a NotificationEnd.
Screen is the serial owner of tabs, focus, modes, and panes. It decides whether the bytes rename UI state, update search, go to one focused terminal, go to all synchronized panes, or become an intercepted plugin event.
For terminal input, the selected pane ultimately sends
PtyWriteInstruction::Write. A dedicated writer thread owns a FIFO queue per
terminal and performs nonblocking writes. It moves on when one kernel buffer
returns EAGAIN, so a slow program cannot stall input to every pane.
NotificationEnd connects logical completion back to the route action. Its
Drop implementation sends the result through a Tokio oneshot when the
instruction reaches the end of its ownership path. The route thread normally
waits no more than one second before allowing the next potentially racing
action.
This is not request/response RPC between every thread. It is mostly one-way ownership transfer, with a small completion token attached only when ordering matters.