Skip to main content

Module notifications

Module notifications 

Source
Expand description

IDE-protocol I6: server-initiated notifications (server → agent).

A task subscribes to the generic event bus (SelectionsChanged), coalesces bursts (cursor moves fire at ~30 Hz under a held key), and broadcasts selection_changed — plus a didChangeActiveEditor when the active buffer changes — to every connected agent through the server’s broadcast sender (crate::mcp::server::ClaudeCodeServerHandle::notify_sender). Each connection’s forwarder relays the frame to its WS writer; a lagged connection skips dropped frames (coalescing — latest wins).

Crate-owned per feedback_mode_owns_its_surface: the host only publishes the generic events. The editor thread pays nothing new — it already publishes SelectionsChanged; the coalescing + framing run off-thread.

The frame SHAPE is PROVISIONAL until validated against a live claude CLI — server→agent notification formats are less documented than the tool replies. In particular selection.start/end.character carries the editor’s byte offset within the line (lattice’s Position.byte); the VS Code contract is a UTF-16 character offset. Carrying it verbatim mirrors the I3 selection-encoding caveat; the conversion lands once a live CLI pins it.

Functions§

at_mentioned_frame
Build the at_mentioned notification frame (PROVISIONAL shape) — the user pushing the current file + selected line range into the agent’s context via :claude-send / @.
did_change_active_editor_frame
Build the didChangeActiveEditor notification frame (PROVISIONAL shape).
selection_changed_frame
Build the selection_changed notification frame (PROVISIONAL shape).
spawn_notifier
Subscribe to SelectionsChanged and spawn the notification task. The task coalesces bursts and broadcasts notification frames through notify_tx.