File size: 964 Bytes
afa0cbf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//! Adapts existing config loaders for blocking plugin-upgrade workers.
//! Reloads must use the same normal or fallback entry point as the initial load.

use crate::config_manager::ConfigManager;
use codex_core_plugins::ConfigLayerReload;
use codex_utils_absolute_path::AbsolutePathBuf;
use std::sync::Arc;

/// The config-loading path used to select marketplaces for startup tasks.
pub(crate) enum PluginStartupConfig {
    Current,
    Defaults,
}

pub(crate) fn for_cwd(manager: ConfigManager, cwd: AbsolutePathBuf) -> ConfigLayerReload {
    let runtime = tokio::runtime::Handle::current();
    Arc::new(move || runtime.block_on(manager.load_config_layers_for_cwd(cwd.clone())))
}

pub(crate) fn defaults(manager: ConfigManager) -> ConfigLayerReload {
    let runtime = tokio::runtime::Handle::current();
    Arc::new(move || {
        runtime
            .block_on(manager.load_default_config())
            .map(|config| config.config_layer_stack)
    })
}