Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

fix(web): a refused plugin export leaves its reason on the card

lmliheng5ebaf9a923cc
diff --git a/changelog/unreleased/2026-11-11-plugin-export-refusal.md b/changelog/unreleased/2026-11-11-plugin-export-refusal.md
new file mode 100644
index 00000000..61447964
--- /dev/null
+++ b/changelog/unreleased/2026-11-11-plugin-export-refusal.md
@@ -0,0 +1,50 @@
+# A refused plugin export leaves its reason on the card that asked
+
+- **Date:** 2026-11-11
+- **Type:** Fix
+- **Scope:** `web`
+- **Breaking:** no
+
+[中文](2026-11-11-plugin-export-refusal.zh.md)
+
+"Export plugin" on a library card fetches one zip of that plugin's directory and hands it to the
+browser through a temporary object URL. When the server refuses the download, the plugin is still
+there, the card is still there, and even the button that was pressed is still there — but the only
+words explaining why were a notification that dismisses itself after six seconds, floating above
+the list while the reader's eyes were on a card below.
+
+That is the shape 7.19 forbids, and it is the same one the Skills tab (7.101) and the Hooks tab
+(7.103) already fixed: all three export through the shared download
+(`agents/archive-download.ts`), so all three fail the same way — the plugin card was the one left
+raising a toast.
+
+The reason is now drawn inside the card that asked (`role="alert"`, danger ink, at most two lines,
+the whole sentence on hover) and stays until the next attempt starts; the same button is the retry.
+The sentence says the export only reads, so nothing in the plugin was changed, rather than that the
+plugin is still in the directory: an export really is a read, and "still there" would be false in
+the very refusal that means it is gone (`unknown_plugin`).
+
+## Details
+
+- New `packages/web/src/features/plugins/plugin-export-refusal.ts`: `pluginExportRefused(plugin,
+ error)` writes the sentence (the reason goes through `refusalText`, the rule every refusal in the
+ app follows).
+- `packages/web/src/features/plugins/plugins-page.tsx`: the card's `onExport` went from "returns
+ void, toasts on failure" to returning a `WriteOutcome` — the same channel this card's update,
+ uninstall and delete refusals already use — and the sentence lives on the **card** rather than on
+ the page. Unlike the install refusal (`installRefusal`), an export moves the card to no other
+ section and remounts nothing, so the instance that asked is the one that draws it.
+- `packages/web/src/lib/strings{,-en}.ts`: one new `plugins.exportRefused(plugin, reason)`.
+
+## Tests
+
+- `packages/web/test/plugin-export-refusal.test.ts` (new, 6 cases): an answer the server gave is
+ read through its code's own sentence (never the wire message), a failure this codebase raised
+ keeps its own words, a value with nothing to say falls back to the generic text, the plugin that
+ was not exported is named, the sentence says the export only read, and the English sentence.
+
+## Compatibility
+
+No interface change, no new dependency, no Project config change. The rest of the plugins library
+— both import dialogs, install / update / uninstall onto an Agent, the admin's delete with its
+confirmation and refusal line, the detail modal — is unchanged.
diff --git a/changelog/unreleased/2026-11-11-plugin-export-refusal.zh.md b/changelog/unreleased/2026-11-11-plugin-export-refusal.zh.md
new file mode 100644
index 00000000..11aa35a6
--- /dev/null
+++ b/changelog/unreleased/2026-11-11-plugin-export-refusal.zh.md
@@ -0,0 +1,39 @@
+# 插件没有导出成时,原因留在那张卡片上
+
+- **日期:** 2026-11-11
+- **类型:** 修复
+- **范围:** `web`
+- **破坏性变更:** 否
+
+[English](2026-11-11-plugin-export-refusal.md)
+
+插件库卡片上「导出插件」拉一次那棵插件目录的 zip,再用一个临时的对象地址交给浏览器。服务端拒了这次下载时,
+插件还在、那张卡片还在、连按下去的那颗按钮都还在原地,可唯一解释原因的那句话是一条六秒后自己消失的通知 ——
+它浮在列表上方,而读者的视线落在下面某张卡片上。
+
+这正是 7.19 禁止的形状,也是技能页(7.101)与钩子页(7.103)各自已经改过一次的同一处:三处导出调的是同一个
+共享下载(`agents/archive-download.ts`),所以三处失败得一模一样,只剩插件卡片这一处还在弹通知。
+
+原因现在画在发问的那张卡片里(`role="alert"`、危险色、最多两行、整句挂悬停),留到下一次尝试开始为止;再按
+一次那颗导出按钮就是重试。句子说「导出只是读取,它的文件没有被改动」而不是「插件仍在目录里」:导出确实只读,
+而当这次拒绝正是「这个插件已经不在库里」(`unknown_plugin`)时,「仍在目录里」会是假的。
+
+## 细节
+
+- 新增 `packages/web/src/features/plugins/plugin-export-refusal.ts`:`pluginExportRefused(plugin, error)` 造句
+ (原因走 `refusalText`,与全应用每一个拒绝同一个规则)。
+- `packages/web/src/features/plugins/plugins-page.tsx`:卡片的 `onExport` 从「返回 void、失败弹通知」改成返回
+ `WriteOutcome`(与这张卡片已有的更新 / 卸载 / 删除三条拒绝同一个渠道);拒绝句存在**卡片自己**身上而不是页面上
+ —— 与装到某个 Agent 上的那次拒绝(`installRefusal`)不同,导出不会把卡片挪到另一个分区、不会让它重挂,因此
+ 发问的那一份实例就是留下句子的那一份。
+- `packages/web/src/lib/strings{,-en}.ts`:新增一句 `plugins.exportRefused(plugin, reason)`。
+
+## 测试
+
+- `packages/web/test/plugin-export-refusal.test.ts`(新增,6 条):服务端的原因按错误码念(绝不念线上原文)、
+ 界面自己抛出的句子原样保留、什么都没说时落到通用文案、念出插件名、点明导出只是读取没有改动文件、英文那一句。
+
+## 兼容性
+
+不改接口、不引入新依赖、不改 Project 配置。插件库的其它行为 —— 两个导入对话框、装到 Agent 上的更新 / 卸载、
+管理员删除及其确认框与拒绝行、详情弹窗 —— 原样不变。
diff --git a/packages/web/src/features/plugins/plugin-export-refusal.ts b/packages/web/src/features/plugins/plugin-export-refusal.ts
new file mode 100644
index 00000000..cd816d9b
--- /dev/null
+++ b/packages/web/src/features/plugins/plugin-export-refusal.ts
@@ -0,0 +1,30 @@
+/**
+ * A user plugin's "Export plugin" button on the library card (`plugins-page.tsx`), and the
+ * sentence one refused export leaves behind — the third of this family, after the Skills tab's
+ * rows (7.101, `agent/skill-export-refusal.ts`) and the Hooks tab's (7.103,
+ * `agents/hook-export-refusal.ts`): all three export through the same shared archive download
+ * (`agents/archive-download.ts`), so all three fail the same way.
+ *
+ * The export is a plain fetch of the plugin through `/api/plugins/:plugin/archive`: nothing is
+ * written on the server, the directory stays where it is, and no client state moves while the
+ * request is out — so when the request is refused the card that sent it is still on screen,
+ * right under the button that retries it. The reason used to arrive only as a notification: it
+ * dismissed itself after six seconds, sat above the list, and a reader who had looked away was
+ * left with no zip file and nothing saying why (7.19's rule, app-wide — the sentence belongs
+ * where the attempt was made).
+ *
+ * The card holds the sentence rather than the page (`installRefusal` above it has to live on the
+ * page because an install moves the card between sections and remounts it), because nothing about
+ * an export moves anything: the same card instance that asked is the one that has to show it.
+ *
+ * Which words: `refusalText`, the rule every refusal in the app follows — an answer the server
+ * gave is read through its code's own localized sentence, and a value this codebase raised
+ * itself is shown as it wrote it.
+ */
+import { refusalText } from "../../lib/api-error";
+import { S } from "../../lib/strings";
+
+/** The sentence: which plugin was not exported, and why. */
+export function pluginExportRefused(plugin: string, error: unknown): string {
+ return S.plugins.exportRefused(plugin, refusalText(error));
+}
diff --git a/packages/web/src/features/plugins/plugins-page.tsx b/packages/web/src/features/plugins/plugins-page.tsx
index b12ba742..9bf378e7 100644
--- a/packages/web/src/features/plugins/plugins-page.tsx
+++ b/packages/web/src/features/plugins/plugins-page.tsx
@@ -111,9 +111,11 @@ import { draftKey, loadDraft, saveDraft } from "../chat/draft-cache";
import { prepareNewChatDraft } from "../chat/new-chat";
import { localizedShortText, localizedText } from "../chat/skill-use";
import { downloadArchive } from "../agents/archive-download";
+import { refusalOf } from "../models/write-outcome";
import type { WriteOutcome } from "../models/write-outcome";
import { PluginDetailModal } from "./plugin-detail";
import { PluginImportActions } from "./plugin-import-dialog";
+import { pluginExportRefused } from "./plugin-export-refusal";
import { pluginImportErrorText, pluginNameFromError } from "./plugin-import";
import { libraryAddRefused } from "./library-add-refusal";
import { installRefusalFor, installRefused } from "./install-refusal";
@@ -773,12 +775,17 @@ export function PluginsPage() {
* one the Skills and Hooks tabs export with). Open to any member — GET
* /api/plugins/:plugin/archive is a plain read of a directory everyone can already browse —
* and the way to keep a copy of a plugin an admin may delete off the machine.
+ *
+ * The refusal comes back as a {@link WriteOutcome} rather than a toast: the card that asked is
+ * still on screen with the button that retries it, and a toast dismisses itself after six
+ * seconds over the list (7.19's rule; plugin-export-refusal.ts draws the sentence).
*/
- const exportPlugin = async (name: string) => {
+ const exportPlugin = async (name: string): Promise<WriteOutcome> => {
try {
await downloadArchive(api.pluginArchiveUrl(name), name);
+ return { ok: true };
} catch (e) {
- toastError(apiErrorText(e));
+ return { ok: false, reason: pluginExportRefused(name, e) };
}
};
@@ -1785,7 +1792,7 @@ function PluginCard({
onQuickInvoke: (skillName: string) => void;
onToggleInstall: (agentId: string, plugin: PluginItem, on: boolean) => Promise<WriteOutcome>;
onUpdateOutdated: (name: string, agentIds: string[]) => Promise<WriteOutcome>;
- onExport: (name: string) => Promise<void>;
+ onExport: (name: string) => Promise<WriteOutcome>;
onDelete: (plugin: PluginItem) => Promise<WriteOutcome>;
}) {
const { locale } = useLocale();
@@ -1810,6 +1817,12 @@ function PluginCard({
const [updateRefusal, setUpdateRefusal] = useState<string | null>(null);
const [uninstallRefusal, setUninstallRefusal] = useState<string | null>(null);
const [deleteRefusal, setDeleteRefusal] = useState<string | null>(null);
+ /**
+ * The reason an "Export plugin" that did not land left under the row
+ * (plugin-export-refusal.ts). Held here rather than on the page (unlike the install refusal
+ * above): an export moves nothing, so the card instance that asked is still the one on screen.
+ */
+ const [exportRefusal, setExportRefusal] = useState<string | null>(null);
/** A user plugin, i.e. one from the server's plugin directory: the only kind the library can delete, and the only kind that carries a "user" mark. */
const isUser = plugin.source === "user";
@@ -1860,6 +1873,16 @@ function PluginCard({
else setDeleteRefusal(outcome.reason);
};
+ /**
+ * "Export plugin": one attempt, one reason — starting attempt clears the sentence the one
+ * before it left (so it is not read as this attempt's), and only a refusal leaves one behind.
+ * A written one clears it: the zip is on disk and the line no longer has anything to say.
+ */
+ const exportThis = async () => {
+ setExportRefusal(null);
+ setExportRefusal(refusalOf(await onExport(plugin.name)));
+ };
+
/** Display name of the Agent pending uninstall (falls back to the raw id below). */
const uninstallAgent =
pendingUninstall !== null ? agents.find((a) => a.agentId === pendingUninstall) : undefined;
@@ -2077,7 +2100,7 @@ function PluginCard({
className="h-8 w-8 shrink-0 justify-center p-0"
aria-label={`${S.plugins.exportPlugin} ${plugin.name}`}
title={S.plugins.exportPlugin}
- onClick={() => void onExport(plugin.name)}
+ onClick={() => void exportThis()}
>
<DownloadIcon size={ICON_SIZE.iconButton} />
</Button>
@@ -2112,6 +2135,20 @@ function PluginCard({
{installRefusal}
</p>
)}
+ {/* An export this card offered that did not land: the card is still here with the button
+ that retries it, so the reason sits under the row rather than in a notification that
+ dismisses itself (plugin-export-refusal.ts). */}
+ {exportRefusal !== null && (
+ <p
+ role="alert"
+ data-testid="export-refusal"
+ data-tooltip={exportRefusal}
+ data-tooltip-content="text"
+ className={`mt-1 line-clamp-2 break-words text-xs ${toneInk.danger}`}
+ >
+ {exportRefusal}
+ </p>
+ )}
{installOpen && (
<Modal
open
diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.ts
index 340b83fb..b0a85ca2 100644
--- a/packages/web/src/lib/strings-en.ts
+++ b/packages/web/src/lib/strings-en.ts
@@ -3022,6 +3022,9 @@ export const en: Strings = {
"From the user plugin directory: exportable as a backup, imported and deleted by an admin",
/** Card actions of a user plugin (a built-in plugin keeps today's actions only). */
exportPlugin: "Export plugin",
+ /** An export the download refused (plugin-export-refusal.ts), drawn under the row that asked. */
+ exportRefused: (plugin: string, reason: string): string =>
+ `The plugin ${plugin} was not exported as a zip — an export only reads, so nothing in it was changed: ${reason}`,
deletePluginAction: "Delete plugin",
deleteConfirmTitle: (name: string): string => `Delete ${name}`,
deleteConfirmBody: (name: string): string =>
diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.ts
index e2244092..dae2e5d4 100644
--- a/packages/web/src/lib/strings.ts
+++ b/packages/web/src/lib/strings.ts
@@ -3068,6 +3068,13 @@ export const zh = {
userBadgeHint: "来自用户插件目录:可导出备份,由管理员导入或删除",
/** Card actions of a user plugin (a built-in plugin keeps today's actions only). */
exportPlugin: "导出插件",
+ /**
+ * An export the download refused (plugin-export-refusal.ts), drawn under the row that asked.
+ * Says the export only reads, because that is the one moment a reader wonders whether the
+ * attempt touched the plugin; the reason goes last, as in every other refusal sentence.
+ */
+ exportRefused: (plugin: string, reason: string): string =>
+ `插件 ${plugin} 没有导出成 zip,导出只是读取,它的文件没有被改动:${reason}`,
deletePluginAction: "删除插件",
deleteConfirmTitle: (name: string): string => `删除 ${name}`,
deleteConfirmBody: (name: string): string =>
diff --git a/packages/web/test/plugin-export-refusal.test.ts b/packages/web/test/plugin-export-refusal.test.ts
new file mode 100644
index 00000000..db5224ce
--- /dev/null
+++ b/packages/web/test/plugin-export-refusal.test.ts
@@ -0,0 +1,64 @@
+/**
+ * A user plugin's export that did not land (src/features/plugins/plugin-export-refusal.ts): the
+ * sentence the card that asked draws.
+ *
+ * The export writes nothing on the server and moves no client state, so a refusal leaves the card,
+ * the plugin and the same button on screen — the sentence is the only thing saying the zip was not
+ * saved. Three things it has to get right: an answer the server gave speaks the interface's own
+ * language rather than the wire message (7.19's rule), a failure this codebase raised itself keeps
+ * what it knows, and it names the plugin it is about (the card is one of a list).
+ */
+import { afterEach, describe, expect, it } from "vitest";
+import { ApiError } from "../src/api/client";
+import { S, setActiveStrings, zh as ZH } from "../src/lib/strings";
+import { en as EN } from "../src/lib/strings-en";
+import { pluginExportRefused } from "../src/features/plugins/plugin-export-refusal";
+
+afterEach(() => {
+ setActiveStrings(ZH);
+});
+
+describe("pluginExportRefused", () => {
+ it("reads a refusal through the code's own sentence, not the wire message", () => {
+ const line = pluginExportRefused(
+ "my-plugin",
+ new ApiError(404, "unknown_plugin", "RAW ENGLISH"),
+ );
+ expect(line).not.toContain("RAW ENGLISH");
+ expect(line).toBe(
+ S.plugins.exportRefused("my-plugin", S.errors.byCode.unknown_plugin as string),
+ );
+ });
+
+ it("keeps what a failure that never reached the route has to say", () => {
+ expect(pluginExportRefused("my-plugin", new Error("Failed to fetch"))).toBe(
+ S.plugins.exportRefused("my-plugin", "Failed to fetch"),
+ );
+ });
+
+ it("falls back to the generic text when the value has nothing to say", () => {
+ expect(pluginExportRefused("my-plugin", undefined)).toBe(
+ S.plugins.exportRefused("my-plugin", S.common.unknownError),
+ );
+ });
+
+ it("names the plugin that was not exported", () => {
+ expect(pluginExportRefused("my-plugin", new Error("boom"))).toContain("my-plugin");
+ });
+
+ it("says the export only read, so nothing in the plugin changed", () => {
+ // A failed export is the one moment a reader wonders whether the attempt touched the files;
+ // the sentence answers that without claiming the plugin is still there (a 404 means it is not).
+ expect(pluginExportRefused("my-plugin", new Error("boom"))).toContain("它的文件没有被改动");
+ });
+
+ it("speaks the active language", () => {
+ setActiveStrings(EN);
+ expect(pluginExportRefused("my-plugin", new ApiError(404, "unknown_plugin", "RAW"))).toBe(
+ EN.plugins.exportRefused("my-plugin", EN.errors.byCode.unknown_plugin as string),
+ );
+ expect(pluginExportRefused("my-plugin", new Error("boom"))).toContain(
+ "nothing in it was changed",
+ );
+ });
+});