Skip to main content

load_session

Function load_session 

Source
pub fn load_session(
    dirs: &[PathBuf],
    diagnostics: Arc<dyn PluginDiagnostics>,
    action_bridge: Option<Arc<ActionBridge>>,
) -> ExtensionSession
Expand description

Load + register every cdylib in the given dirs (in order, non-recursive), merge their registries first-wins, and return a session with a shared keepalive over the Library handles + the merged snapshot. Dirs that don’t exist are skipped silently; individual plugin load failures are logged via diagnostics and skipped (one bad plugin doesn’t abort the rest).

The order of dirs matters: earlier dirs win on tool/command name collision (pi registration order). Callers pass default dirs first, then --extensions-dir extras, so a same-named tool in a default-dir plugin wins over an extra-dir one.

action_bridge (B5a) is cloned into every loaded plugin’s vtable so post-register runtime_action calls recover the bridge on any thread. rpi-cli builds one master Arc<ActionBridge> per session and passes it here; None keeps the v1 stub (used by tests / --no-extensions no-ops).