mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-03 23:11:42 +00:00
fix(cli): prevent blocked plugin enable side effects (#114490)
This commit is contained in:
committed by
GitHub
parent
d92a8f5812
commit
d16c2dedd2
@@ -203,9 +203,6 @@ async function runPluginsEnableCommandUnlocked(idInput: string): Promise<void> {
|
||||
const { enableExplicitlySelectedPluginInConfig } = await import("../plugins/enable.js");
|
||||
const { normalizePluginId } = await loadPluginsConfigState();
|
||||
const { buildPluginRegistrySnapshotReport } = await loadPluginsStatus();
|
||||
const { applySlotSelectionForPlugin } = await loadPluginSlotSelection();
|
||||
const { logSlotWarnings } = await loadPluginsCommandHelpers();
|
||||
const { refreshPluginRegistryAfterConfigMutation } = await loadPluginsRegistryRefresh();
|
||||
const snapshot = await readConfigFileSnapshot();
|
||||
const cfg = (snapshot.sourceConfig ?? snapshot.config) as OpenClawConfig;
|
||||
const report = buildPluginRegistrySnapshotReport({ config: cfg });
|
||||
@@ -216,6 +213,19 @@ async function runPluginsEnableCommandUnlocked(idInput: string): Promise<void> {
|
||||
const enableResult = enableExplicitlySelectedPluginInConfig(cfg, id, {
|
||||
updateChannelConfig: false,
|
||||
});
|
||||
// A blocked request must not displace the active slot or rewrite persisted state.
|
||||
if (!enableResult.enabled) {
|
||||
defaultRuntime.log(
|
||||
theme.warn(
|
||||
`Plugin "${id}" could not be enabled (${enableResult.reason ?? "unknown reason"}).`,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const { applySlotSelectionForPlugin } = await loadPluginSlotSelection();
|
||||
const { logSlotWarnings } = await loadPluginsCommandHelpers();
|
||||
const { refreshPluginRegistryAfterConfigMutation } = await loadPluginsRegistryRefresh();
|
||||
let next: OpenClawConfig = enableResult.config;
|
||||
const slotResult = applySlotSelectionForPlugin(next, id);
|
||||
next = slotResult.config;
|
||||
@@ -233,13 +243,7 @@ async function runPluginsEnableCommandUnlocked(idInput: string): Promise<void> {
|
||||
},
|
||||
});
|
||||
logSlotWarnings(slotResult.warnings);
|
||||
if (enableResult.enabled) {
|
||||
defaultRuntime.log(`Enabled plugin "${id}". Restart the gateway to apply.`);
|
||||
return;
|
||||
}
|
||||
defaultRuntime.log(
|
||||
theme.warn(`Plugin "${id}" could not be enabled (${enableResult.reason ?? "unknown reason"}).`),
|
||||
);
|
||||
defaultRuntime.log(`Enabled plugin "${id}". Restart the gateway to apply.`);
|
||||
}
|
||||
|
||||
/** Disable a plugin in config and refresh the registry snapshot for the changed policy. */
|
||||
|
||||
Reference in New Issue
Block a user