Files
codex/codex-rs/app-server/src/plugin_config_reload.rs
Eric Trautandcopyberry f73a478c87 Keep global app-server config independent of the launch directory (#51872)
## Why

Global requests can inherit project settings from the app-server's launch directory. This can prevent marketplace removal or expose project-only feature settings, and config reloads can fail if that directory is deleted.

## What changed

- Load configuration without project context when no working directory is supplied, using `CODEX_HOME` to materialize `Config.cwd`.
- Use global configuration for marketplace mutations, marketplace upgrade reloads, and MCP requests without thread context.
- Pass the launch directory explicitly during startup to preserve project-aware startup configuration.

## Testing

Update regression tests to verify that marketplace removal ignores launch-project configuration and leaves the project config intact. Extend feature-list coverage to verify that global requests ignore project features, thread requests retain them, and global requests work after the launch directory is deleted on Unix.

GitOrigin-RevId: b77063a7ea0b09fd0a79cfc4040db9f1d02606b3
2026-10-07 23:19:26 +00:00

38 lines
1.3 KiB
Rust

//! 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())))
}
/// Reloads config without deriving project context from a process cwd.
pub(crate) fn global(manager: ConfigManager) -> ConfigLayerReload {
let runtime = tokio::runtime::Handle::current();
Arc::new(move || {
runtime
.block_on(manager.load_non_project_config())
.map(|config| config.config_layer_stack)
})
}
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)
})
}