mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 13:26:04 -06:00
fix: release ClawHub lifecycle state on CLI exit (#114090)
This commit is contained in:
committed by
GitHub
parent
9eae43bd37
commit
53e3f296b1
@@ -5,6 +5,11 @@ import { resolvePluginUninstallId } from "./plugins-uninstall-selection.js";
|
||||
|
||||
describe("resolvePluginUninstallId", () => {
|
||||
it("accepts the recorded ClawHub spec as an uninstall target", () => {
|
||||
const plugin = {
|
||||
id: "linkmind-context",
|
||||
name: "linkmind-context",
|
||||
channelIds: ["linkmind-channel"],
|
||||
};
|
||||
const result = resolvePluginUninstallId({
|
||||
rawId: "clawhub:linkmind-context",
|
||||
config: {
|
||||
@@ -21,13 +26,19 @@ describe("resolvePluginUninstallId", () => {
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig,
|
||||
plugins: [{ id: "linkmind-context", name: "linkmind-context" }],
|
||||
plugins: [plugin],
|
||||
});
|
||||
|
||||
expect(result.pluginId).toBe("linkmind-context");
|
||||
expect(result.plugin).toBe(plugin);
|
||||
});
|
||||
|
||||
it("accepts a versionless ClawHub spec when the install was pinned", () => {
|
||||
const plugin = {
|
||||
id: "linkmind-context",
|
||||
name: "linkmind-context",
|
||||
channelIds: ["linkmind-channel"],
|
||||
};
|
||||
const result = resolvePluginUninstallId({
|
||||
rawId: "clawhub:linkmind-context",
|
||||
config: {
|
||||
@@ -43,9 +54,10 @@ describe("resolvePluginUninstallId", () => {
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig,
|
||||
plugins: [{ id: "linkmind-context", name: "linkmind-context" }],
|
||||
plugins: [plugin],
|
||||
});
|
||||
|
||||
expect(result.pluginId).toBe("linkmind-context");
|
||||
expect(result.plugin).toBe(plugin);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,6 +12,10 @@ export function resolvePluginUninstallId<
|
||||
plugins: TPlugin[];
|
||||
}): { pluginId: string; plugin?: TPlugin } {
|
||||
const rawId = params.rawId.trim();
|
||||
const resolveInstalledPlugin = (pluginId: string) => {
|
||||
const plugin = params.plugins.find((entry) => entry.id === pluginId);
|
||||
return plugin ? { pluginId, plugin } : { pluginId };
|
||||
};
|
||||
const plugin = params.plugins.find((entry) => entry.id === rawId || entry.name === rawId);
|
||||
if (plugin) {
|
||||
return { pluginId: plugin.id, plugin };
|
||||
@@ -24,7 +28,7 @@ export function resolvePluginUninstallId<
|
||||
install.resolvedName === rawId ||
|
||||
install.marketplacePlugin === rawId
|
||||
) {
|
||||
return { pluginId };
|
||||
return resolveInstalledPlugin(pluginId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +40,7 @@ export function resolvePluginUninstallId<
|
||||
parseClawHubPluginSpec(install.spec ?? "")?.name ??
|
||||
parseClawHubPluginSpec(install.resolvedSpec ?? "")?.name;
|
||||
if (installedClawHubName === requestedClawHub.name) {
|
||||
return { pluginId };
|
||||
return resolveInstalledPlugin(pluginId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user