fn buffer_prompt_until_connected(
workspace: &Arc<Workspace>,
sender: &SessionSlot,
target_key: &SessionSlot,
wrapped: WrappedPrompt,
) -> Option<WrappedPrompt>Expand description
Handle a Command::DeliverWorkerPrompt: route a wrapped peer-style
envelope to the worker matching target_label in the caller’s
project. Latest-spawned-wins on duplicate labels. The typed
PeerEnvelopeAppended echo follows the same pattern as
handle_deliver_peer_prompt - workers reuse the peer envelope
verbatim so a view’s chat render is identical between the two
paths.
Unlike handle_deliver_peer_prompt, this handler never buffers +
auto-spawns: workers are only addressable while live. If the
target label vanished between the dispatch and the handler firing
(worker closed, lead cascade fired), the prompt is dropped with a
warn log.
Buffer wrapped on target_key’s DomainSession when the target
hasn’t finished its Connected handshake (no session_id yet). Returns
Some(wrapped) when the target IS connected (caller delivers now), or
None when it parked (the target’s Connected handler drains the
bucket, doing the render + dispatch). Mirrors the sleeping-peer
buffering in handle_deliver_peer_prompt, sender included so an
expired bucket can still acknowledge the message.