Skip to main content

spawn_discover_and_load

Function spawn_discover_and_load 

Source
pub fn spawn_discover_and_load(
    manager: Arc<RwLock<ExtensionManager>>,
    tx: UnboundedSender<ExtensionLoaderEvent>,
    session_id: Option<String>,
) -> JoinHandle<()> ⓘ
Expand description

Discover and load extensions in the background, then fire on_session_start.

Process-level and IDEMPOTENT (daemon-mode C2): the manager records its discovery result, so a second call on the same manager (second host in one process, or a second session in a daemon) replays Finished from that record and spawns nothing. on_session_start still fires for session_id on every call — that part is per session.

The hook is emitted HERE, not at engine boot, and that placement is the whole point. engine::setup::boot() used to emit it while constructing an empty ExtensionManager — before any host had called this function — so the event reached zero subscribers in every host (TUI, server, rpc). No extension had ever received on_session_start. A comment in cmd/server.rs recorded the symptom (“no subscribers until extensions loaded”) without it being recognised as a defect.

session_id is the session the hook reports. None skips the emit, for callers that have no session (or extensions disabled).