Skip to main content

Module websocket

Module websocket 

Source

Structs§

WSIncoming 🔒
Incoming WebSocket message envelope. Supports both ping/pong messages and wscommand-based RPC.

Constants§

FLEET_ENDED_WINDOW_MS 🔒
How far back the fleet list (COMMAND_LIST_BACKGROUND_TASKS with an empty blockid) reaches for tasks that already ended. Comfortably longer than the longest finished-row retention the renderer applies (15 s for an error), so a finished row is still in the list for as long as it is shown.
NON_PANE_EVENT_KEY 🔒
Sentinel key for every priority-lane event that is NOT a blockfile (terminal/PTY output) event. Not a valid block:<id> scope string, so it can never collide with a real pane key.

Functions§

background_event_key 🔒
Extract a coalescing key from a background-lane event. Background events are RPC-wrapped MPS events: { “eventtype”: “rpc”, “data”: { “command”: “eventrecv”, “data”: { “event”: “sysinfo”, “scopes”: [“local”] } } } Key = “:”, e.g. “sysinfo:local” or “blockstats:block:abc123”. Falls back to “:” for events that don’t match the expected shape (safe: they coalesce to one slot, which is acceptable because non-sysinfo/blockstats never reach this lane).
coalesce_background 🔒
Drain all immediately-available events from rx (including first) and coalesce them to the latest reading per (event-name:scope) key. Iteration order in the returned Vec is first-seen (stable across coalescing rounds).
dispatch_blockinput 🔒
Route a decoded blockinput payload — the actual human-keystroke path (termViewModel.ts’s blockinput WS command, used by both the standalone Terminal widget and an agent pane’s composer-drawer shell) — to its block’s controller.
enqueue_priority_event 🔒
fair_drain_priority 🔒
Drain all immediately-available events from rx (including first) and interleave them round-robin by pane (priority_pane_key), instead of forwarding in raw arrival order. Without this, a pane producing output faster than the socket can flush it fills this same lane with its own frames, and a different pane’s keystroke-echo frame — queued in the same FIFO — waits behind the entire backlog. Round-robining bounds that wait to one slot per OTHER distinct pane with events currently queued, regardless of how deep any single pane’s backlog is.
forward_event 🔒
Forward a queued event-bus value to the WebSocket. Returns true if the send failed (the caller should break the loop).
handle_incoming_text 🔒
Handle an incoming text message. Returns Err(true) if the socket send failed. Returns Ok(Some((rx, agent_id))) if a bus:register was processed.
handle_ws 🔒
handle_ws_connection 🔒
parse_block_input 🔒
Parse a CommandBlockInputData into a BlockInputUnion.
priority_pane_key 🔒
Extract a fairness key so a flood of PTY output from one pane can’t queue an unbounded number of frames ahead of a different pane’s own keystroke echo sitting in the same lane.
register_handlers 🔒
srv_info_event 🔒
The srvinfo event sent once on every WebSocket connect, right after config: srv’s version, which the UI compares with its own, and the machine srv runs on (crate::srv_info).
with_question_controller 🔒
Run f on block_id’s persistent controller for agent.answer / agent.cancel. The error strings are matched by the frontend’s SAFE_TO_RETRY_VIA_FOLLOWUP allowlist (useAgentQuestions.ts).