Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(plugins): tolerate malformed catalog rows, settle interrupted ins…
…talls and repair CI gates

- Parse drops malformed or conflicting catalog rows instead of rejecting the
  whole index, so one tagged repository cannot hide the unreviewed channel;
  dropped rows stay unresolvable.
- Recovery settles to the installed record when the plugin was toggled or
  removed after an interruption instead of blocking later catalog writes.
- Desktop clears a stale preview when name, replace or link changes, so a
  manual install no longer sends an outdated plan ID.
- Acceptance script asserts the reason for each refusal and covers an index
  re-pointed at another commit.
- Extract install-plan parsing from CapabilitiesPanel, split the catalog apply
  preflight out of Execute, and regenerate the desktop inventory.
  • Loading branch information
zumac zumac
zumac authored and zumac committed Nov 12, 2026
commit 8070286bbcb93b66124d9da1c6f1b50663d5557f
145 changes: 16 additions & 129 deletions desktop/frontend/src/components/CapabilitiesPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import { app } from "../lib/bridge";
import { activeWorkBusyNoticeText, installMCPServer } from "../lib/capabilityMutations";
import { useT } from "../lib/i18n";
import { presentError } from "../lib/errorPresentation";
import { parsePluginInstallPlan, type PluginInstallPlanAction, type PluginInstallPlanView, type PluginRuntimePlan } from "../lib/pluginInstallPlan";
import { mcpServerLifecycleActions, mcpServerRetryableFromAvailableList } from "../lib/mcpServerLifecycle";
import { mcpSessionStateLabel, mcpSettingsSearchText } from "../lib/mcpSessionStatus";
import { canUseNativeMCPOAuth } from "../lib/mcpOAuthEligibility";
import type { CapabilitiesView, MCPMarketplaceEntry, MCPMarketplaceView, MCPServerInput, PluginAgentView, PluginCommandView, PluginCompatibilityIssue, PluginHookView, PluginInstallOptions, PluginMCPServerView, PluginSkillView, PluginView, ServerView, SkillRootSkillView, SkillRootView, SkillsSettingsView, SkillView, TabMeta } from "../lib/types";
import type { CapabilitiesView, MCPMarketplaceEntry, MCPMarketplaceView, MCPServerInput, PluginAgentView, PluginCommandView, PluginHookView, PluginInstallOptions, PluginMCPServerView, PluginSkillView, PluginView, ServerView, SkillRootSkillView, SkillRootView, SkillsSettingsView, SkillView, TabMeta } from "../lib/types";
import { InlineConfirmButton } from "./InlineConfirmButton";
import { ResizableDrawer } from "./ResizableDrawer";
import { Tooltip } from "./Tooltip";
Expand Down Expand Up @@ -1613,47 +1614,6 @@ export function parseMCPQuickDefinition(raw: string): MCPServerInput {
return { name: quickMCPName(definition), transport: "stdio", command: definition, args: [], url: "", env: null, headers: null };
}

type PluginRuntimePlan = {
command?: string;
args?: string[];
intercepts?: string[];
replaces?: string[];
capabilities?: string[];
fullTrust?: boolean;
};

type PluginInstallPlanAction = {
changes?: string[];
action?: string;
kind?: string;
name?: string;
source?: string;
status?: string;
message?: string;
error?: string;
compatibility?: string;
mappedCapabilities?: string[];
skippedCapabilities?: PluginCompatibilityIssue[];
runtime?: PluginRuntimePlan;
agentCount?: number;
skillCount?: number;
commandCount?: number;
hookCount?: number;
toolCount?: number;
};

type PluginInstallPlanView = {
planId?: string;
activationWarning?: string;
raw: string;
ok?: boolean;
status?: string;
name?: string;
actions: PluginInstallPlanAction[];
warnings: string[];
error?: string;
};

type PluginInstallMode = "local" | "git";

// PluginsSettingsPage is the desktop plugin package manager embedded inside
Expand Down Expand Up @@ -1806,12 +1766,15 @@ export function PluginsSettingsPage() {
{loadError && <SettingsFeedback kind="error" onRetry={() => { setLoadError(null); void reload(); }}><ErrorMessage error={loadError} /></SettingsFeedback>}
{notice && !err && <SettingsFeedback kind="success">{notice}</SettingsFeedback>}
<div className="settings-toolbar">
<div className="cap-tabs"><button className={"cap-tab"+(!discover?" cap-tab--active":"")} aria-pressed={!discover} onClick={()=>setDiscover(false)}>{t("caps.installedPlugins")}</button>
<button className={"cap-tab"+(discover?" cap-tab--active":"")} aria-pressed={discover} onClick={()=>requestLeave(()=>{setInstallOpen(false);setDiscover(true)})}>{t("market.discover")}</button>{!discover && summary && <span className="drawer__summary">{summary}</span>}</div>
<div className="cap-tabs">
<button className={"cap-tab" + (!discover ? " cap-tab--active" : "")} aria-pressed={!discover} onClick={() => setDiscover(false)}>{t("caps.installedPlugins")}</button>
<button className={"cap-tab" + (discover ? " cap-tab--active" : "")} aria-pressed={discover} onClick={() => requestLeave(() => { setInstallOpen(false); setDiscover(true); })}>{t("market.discover")}</button>
{!discover && summary && <span className="drawer__summary">{summary}</span>}
</div>
<div className="settings-toolbar__actions"><button className="btn btn--small" disabled={actionBusy} onClick={() => void reload()}>{t("caps.pluginRefresh")}</button>
<button className="btn btn--primary" aria-expanded={installOpen} aria-controls="settings-plugin-install" disabled={actionBusy} onClick={() => installOpen ? requestLeave(() => setInstallOpen(false)) : setInstallOpen(true)}>{installOpen ? t("common.cancel") : t("caps.pluginInstall")}</button></div>
</div>
{discover && <PluginMarket installed={plugins||[]} choose={chooseMarket}/>}
{discover && <PluginMarket installed={plugins || []} choose={chooseMarket} />}
<div id="settings-plugin-install" hidden={!installOpen}>
<div className="cap-plugin-installer">
<div className="cap-plugin-installer__head">
Expand Down Expand Up @@ -1869,23 +1832,23 @@ export function PluginsSettingsPage() {
aria-label={t("caps.pluginInstallName")}
placeholder={t("caps.pluginInstallNamePlaceholder")}
value={name}
onChange={(e) => setName(e.target.value)}
onChange={(e) => { setName(e.target.value); setPlan(null); }}
/>
</div>
</div>
)}
<div className="cap-plugin-installer__options">
<div className="cap-plugin-option-block">
<label className="cap-plugin-option">
<input type="checkbox" checked={replace} disabled={actionBusy} onChange={(e) => setReplace(e.target.checked)} />
<input type="checkbox" checked={replace} disabled={actionBusy} onChange={(e) => { setReplace(e.target.checked); setPlan(null); }} />
<span>{t("caps.pluginReplace")}</span>
</label>
<div className="cap-plugin-option-hint">{t("caps.pluginReplaceHint")}</div>
</div>
{installMode === "local" && (
<div className="cap-plugin-option-block">
<label className="cap-plugin-option">
<input type="checkbox" checked={link} disabled={actionBusy} onChange={(e) => setLink(e.target.checked)} />
<input type="checkbox" checked={link} disabled={actionBusy} onChange={(e) => { setLink(e.target.checked); setPlan(null); }} />
<span>{t("caps.pluginLink")}</span>
</label>
<div className="cap-plugin-option-hint">{t("caps.pluginLinkHint")}</div>
Expand All @@ -1896,15 +1859,15 @@ export function PluginsSettingsPage() {
<button className="btn btn--small" type="button" disabled={!canPlan} onClick={previewInstall}>
{t("caps.pluginPreview")}
</button>
<button className="btn btn--primary btn--small" type="button" disabled={!canPlan || (isMarket && (!plan?.planId || !plan.ok))} onClick={install}>
<button className="btn btn--primary btn--small" type="button" disabled={!canPlan || (isMarket && (!plan?.planId || !plan.ok))} onClick={install}>
{t("caps.pluginInstall")}
</button>
</div>
</div>
</div>
{plan && <PluginPlanPreview plan={plan} />}
</div>
<div className="cap-server-section cap-plugin-section" hidden={discover}>
<div className="cap-server-section cap-plugin-section" hidden={discover}>

{!plugins ? (
!loadError && <SettingsFeedback kind="loading" />
Expand Down Expand Up @@ -1961,8 +1924,8 @@ function PluginPlanPreview({ plan }: { plan: PluginInstallPlanView }) {
{asArray(action.skippedCapabilities).map((issue, issueIndex) => <span className="cap-plugin-plan__warning" key={`${issue.capability}-${issue.path || ""}-${issueIndex}`}>{issue.capability}: {issue.reason}</span>)}
{action.message && <span className="cap-plugin-action__source">{action.message}</span>}
{action.error && <span className="cap-plugin-plan__warning"><ErrorMessage error={action.error} /></span>}
{action.changes?.map((change,i)=><span key={i} className="cap-plugin-plan__warning">{change}</span>)}
{action.runtime ? <PluginRuntimeTrustBlock runtime={action.runtime} /> : null}
{action.changes?.map((change, i) => <span key={i} className="cap-plugin-plan__warning">{change}</span>)}
{action.runtime ? <PluginRuntimeTrustBlock runtime={action.runtime} /> : null}
</div>
))}
</div>
Expand Down Expand Up @@ -2336,89 +2299,13 @@ function pluginWarnings(plugin: PluginView, diagnostic?: PluginView): string[] {
return Array.from(new Set(warnings.filter((warning) => warning.trim().length > 0)));
}

function parsePluginInstallPlan(raw: string): PluginInstallPlanView {
try {
const value = JSON.parse(raw) as Record<string, unknown>;
const actions = (Array.isArray(value.actions) ? value.actions : []).flatMap((action) => {
if (!action || typeof action !== "object") return [];
const item = action as Record<string, unknown>;
return [{
action: stringValue(item.action),
kind: stringValue(item.kind),
name: stringValue(item.name),
source: stringValue(item.source),
status: stringValue(item.status),
message: stringValue(item.message),
error: stringValue(item.error),
compatibility: stringValue(item.compatibility),
mappedCapabilities: (Array.isArray(item.mappedCapabilities) ? item.mappedCapabilities : []).filter((value): value is string => typeof value === "string"),
skippedCapabilities: (Array.isArray(item.skippedCapabilities) ? item.skippedCapabilities : []) as PluginCompatibilityIssue[],
runtime: parsePluginRuntimePlan(item.runtime),
changes: marketPlanChanges(item),
agentCount: numericValue(item.agentCount), skillCount: numericValue(item.skillCount), commandCount: numericValue(item.commandCount), hookCount: numericValue(item.hookCount), toolCount: numericValue(item.toolCount),
}];
});
return {
raw,
ok: typeof value.ok === "boolean" ? value.ok : undefined,
planId: stringValue(value.planId),
activationWarning: stringValue(value.activationWarning),
status: stringValue(value.status),
name: stringValue(value.name),
actions,
warnings: (Array.isArray(value.warnings) ? value.warnings : []).flatMap((warning) => typeof warning === "string" ? [warning] : []),
error: stringValue(value.error),
};
} catch {
return { raw, actions: [], warnings: [] };
}
}

function marketPlanChanges(item:Record<string,unknown>):string[] {
const c=item.catalog as {execution?:string[];previousExecution?:string[];requirements?:{namespace:string;kind:string;id:string}[];previous?:{version:string};previousCapabilities?:Record<string,number|boolean>;capabilities?:Record<string,number|boolean>}|undefined;
if(!c)return [];
const lines=(Array.isArray(item.riskReasons)?item.riskReasons:[]).filter((x):x is string=>typeof x==="string");
for(const s of c.execution||[])lines.push((c.previous && !c.previousExecution?.includes(s)?"+ ":"")+s);
for(const s of c.previousExecution||[])if(!c.execution?.includes(s))lines.push("− "+s);
for(const r of c.requirements||[])lines.push("requires: "+[r.namespace,r.kind,r.id].join("/"));
if(c.previous){lines.unshift(c.previous.version+" → "+item.version);
for(const [k,v] of Object.entries(c.capabilities||{}))if(c.previousCapabilities?.[k]!==v)lines.push(k+": "+(c.previousCapabilities?.[k]??0)+" → "+v)}
return lines;
}
function numericValue(value: unknown): number | undefined {
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
}

function stringValue(value: unknown): string | undefined {
return typeof value === "string" && value.trim() ? value.trim() : undefined;
}

// parsePluginRuntimePlan extracts the FULL TRUST runtime block a plugin
// install plan carries (installsource.RuntimePlanInfo). Anything malformed
// simply drops out — the risk UI is additive and must never break planning.
function parsePluginRuntimePlan(value: unknown): PluginRuntimePlan | undefined {
if (!value || typeof value !== "object") return undefined;
const item = value as Record<string, unknown>;
const command = stringValue(item.command);
if (!command) return undefined;
const list = (v: unknown): string[] => (Array.isArray(v) ? v : []).filter((entry): entry is string => typeof entry === "string" && entry.trim().length > 0);
return {
command,
args: list(item.args),
intercepts: list(item.intercepts),
replaces: list(item.replaces),
capabilities: list(item.capabilities),
fullTrust: item.fullTrust === true,
};
}

function pluginPlanActionLabel(action: PluginInstallPlanAction, t: ReturnType<typeof useT>): string {
const verb = action.action || action.kind || t("caps.pluginAction");
return [verb, action.name].filter(Boolean).join(" · ");
}

function pluginPlanNotice(plan: PluginInstallPlanView, t: ReturnType<typeof useT>): string {
if(plan.activationWarning)return plan.activationWarning;
if (plan.activationWarning) return plan.activationWarning;
if (plan.error) return plan.error;
if (plan.status === "done" || plan.status === "applied" || plan.status === "complete") return t("caps.pluginPlanInstalled");
return plan.status ? t("caps.pluginPlanStatus", { status: plan.status }) : t("caps.pluginPlanComplete");
Expand Down
2 changes: 1 addition & 1 deletion desktop/frontend/src/lib/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3259,7 +3259,7 @@ function makeMockApp(): MockAppBindings {
return JSON.stringify({
ok: true,
status: "planned",
kind: "plugin",
kind: "plugin",
planId: "mock-market-plan",
actions: [{ kind: "plugin", action: "install_plugin_package", name, source, status: "planned" }],
});
Expand Down
120 changes: 120 additions & 0 deletions desktop/frontend/src/lib/pluginInstallPlan.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// Parsing of install_source plan JSON for the plugin settings page.
import type { PluginCompatibilityIssue } from "./types";

export type PluginRuntimePlan = {
command?: string;
args?: string[];
intercepts?: string[];
replaces?: string[];
capabilities?: string[];
fullTrust?: boolean;
};

export type PluginInstallPlanAction = {
changes?: string[];
action?: string;
kind?: string;
name?: string;
source?: string;
status?: string;
message?: string;
error?: string;
compatibility?: string;
mappedCapabilities?: string[];
skippedCapabilities?: PluginCompatibilityIssue[];
runtime?: PluginRuntimePlan;
agentCount?: number;
skillCount?: number;
commandCount?: number;
hookCount?: number;
toolCount?: number;
};

export type PluginInstallPlanView = {
planId?: string;
activationWarning?: string;
raw: string;
ok?: boolean;
status?: string;
name?: string;
actions: PluginInstallPlanAction[];
warnings: string[];
error?: string;
};


export function parsePluginInstallPlan(raw: string): PluginInstallPlanView {
try {
const value = JSON.parse(raw) as Record<string, unknown>;
const actions = (Array.isArray(value.actions) ? value.actions : []).flatMap((action) => {
if (!action || typeof action !== "object") return [];
const item = action as Record<string, unknown>;
return [{
action: stringValue(item.action),
kind: stringValue(item.kind),
name: stringValue(item.name),
source: stringValue(item.source),
status: stringValue(item.status),
message: stringValue(item.message),
error: stringValue(item.error),
compatibility: stringValue(item.compatibility),
mappedCapabilities: (Array.isArray(item.mappedCapabilities) ? item.mappedCapabilities : []).filter((value): value is string => typeof value === "string"),
skippedCapabilities: (Array.isArray(item.skippedCapabilities) ? item.skippedCapabilities : []) as PluginCompatibilityIssue[],
runtime: parsePluginRuntimePlan(item.runtime),
changes: marketPlanChanges(item),
agentCount: numericValue(item.agentCount), skillCount: numericValue(item.skillCount), commandCount: numericValue(item.commandCount), hookCount: numericValue(item.hookCount), toolCount: numericValue(item.toolCount),
}];
});
return {
raw,
ok: typeof value.ok === "boolean" ? value.ok : undefined,
planId: stringValue(value.planId),
activationWarning: stringValue(value.activationWarning),
status: stringValue(value.status),
name: stringValue(value.name),
actions,
warnings: (Array.isArray(value.warnings) ? value.warnings : []).flatMap((warning) => typeof warning === "string" ? [warning] : []),
error: stringValue(value.error),
};
} catch {
return { raw, actions: [], warnings: [] };
}
}

export function marketPlanChanges(item:Record<string,unknown>):string[] {
const c=item.catalog as {execution?:string[];previousExecution?:string[];requirements?:{namespace:string;kind:string;id:string}[];previous?:{version:string};previousCapabilities?:Record<string,number|boolean>;capabilities?:Record<string,number|boolean>}|undefined;
if(!c)return [];
const lines=(Array.isArray(item.riskReasons)?item.riskReasons:[]).filter((x):x is string=>typeof x==="string");
for(const s of c.execution||[])lines.push((c.previous && !c.previousExecution?.includes(s)?"+ ":"")+s);
for(const s of c.previousExecution||[])if(!c.execution?.includes(s))lines.push("− "+s);
for(const r of c.requirements||[])lines.push("requires: "+[r.namespace,r.kind,r.id].join("/"));
if(c.previous){lines.unshift(c.previous.version+" → "+item.version);
for(const [k,v] of Object.entries(c.capabilities||{}))if(c.previousCapabilities?.[k]!==v)lines.push(k+": "+(c.previousCapabilities?.[k]??0)+" → "+v)}
return lines;
}
export function numericValue(value: unknown): number | undefined {
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
}

export function stringValue(value: unknown): string | undefined {
return typeof value === "string" && value.trim() ? value.trim() : undefined;
}

// parsePluginRuntimePlan extracts the FULL TRUST runtime block a plugin
// install plan carries (installsource.RuntimePlanInfo). Anything malformed
// simply drops out — the risk UI is additive and must never break planning.
export function parsePluginRuntimePlan(value: unknown): PluginRuntimePlan | undefined {
if (!value || typeof value !== "object") return undefined;
const item = value as Record<string, unknown>;
const command = stringValue(item.command);
if (!command) return undefined;
const list = (v: unknown): string[] => (Array.isArray(v) ? v : []).filter((entry): entry is string => typeof entry === "string" && entry.trim().length > 0);
return {
command,
args: list(item.args),
intercepts: list(item.intercepts),
replaces: list(item.replaces),
capabilities: list(item.capabilities),
fullTrust: item.fullTrust === true,
};
}
Loading
Loading