Skip to content

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

fix(plugins): a refused module plugin install keeps its confirmation and the reason (7.22)

lmlihengba0ac3838280
diff --git a/changelog/unreleased/2026-10-21-plugin-install-refusal.md b/changelog/unreleased/2026-10-21-plugin-install-refusal.md
new file mode 100644
index 00000000..fa48fb76
--- /dev/null
+++ b/changelog/unreleased/2026-10-21-plugin-install-refusal.md
@@ -0,0 +1,35 @@
+# A refused module plugin install keeps its confirmation and the reason in it
+
+- **Date:** 2026-10-21
+- **Type:** fix
+- **Scope:** `web`
+- **Breaking:** no
+
+[中文版](2026-10-21-plugin-install-refusal.zh.md)
+
+Installing (or removing) a module plugin for a Project on the Plugins page asks first, and that card used to
+close from a `finally`: success or refusal alike. A refused install therefore left the plugin exactly where it
+was (the row still read "not installed") but took the reason with it, and that reason arrived as a toast that
+dismissed itself after six seconds and floated over the page instead of in the card.
+
+The card now closes only once the write landed. When the server refuses one, the card stays with its sentence
+and the server's own words drawn under it, so the retry is the same button — a failed plugin install is the
+most common refusal there is.
+
+## Details
+
+- The rule follows the model library, scheduled tasks and evaluation center rounds (`ConfirmModal`'s `refusal`
+ slot): the reason is drawn inside the card that asked for the write, and opening the card clears the previous
+ attempt's reason first — that sentence was about the previous attempt.
+- `features/plugins/plugins-page.tsx`: `setPendingApply(null)` moved into the success path, the `catch` hands
+ the server's words to a new `applyRefusal` state instead of a toast; the two ways of opening the card
+ (install / remove) became `askApply`, which does open-first-then-clear.
+- New browser spec `e2e/plugins-install-refusal.spec.mjs` (two tests): a refused install keeps the card, its
+ sentence and the row, raises no toast and changes nothing; the retry writes it and only a written one closes
+ the card.
+
+## Compatibility
+
+- No API, wire-format or dependency change: this is only when the card closes and where its refusal is drawn.
+- The same page's "bulk update" and per-Agent "uninstall / update" cards still close on the request; the ledger
+ records them under "what is left".
diff --git a/changelog/unreleased/2026-10-21-plugin-install-refusal.zh.md b/changelog/unreleased/2026-10-21-plugin-install-refusal.zh.md
new file mode 100644
index 00000000..5c58f279
--- /dev/null
+++ b/changelog/unreleased/2026-10-21-plugin-install-refusal.zh.md
@@ -0,0 +1,30 @@
+# 安装模块插件被拒时,确认框留着,原因也留在框里
+
+- **Date:** 2026-10-21
+- **Type:** fix
+- **Scope:** `web`
+- **Breaking:** no
+
+[English](2026-10-21-plugin-install-refusal.md)
+
+插件市场里给项目安装(或移除)一个模块插件要先确认,而那张卡片过去在 `finally` 里关掉:成功与失败一样关。
+于是被拒的安装虽然什么都没装(那一行仍在「未安装」),原因却跟着框一起没了;那句话只出现在一条六秒后自己
+消失、且浮在框上方的 toast 里。
+
+现在只有写入真的落地,卡片才关。服务端拒绝时,卡片留着它那句话,服务端的原话画在下面,于是重试就是同一个
+按钮 —— 装插件失败本来就是最常见的那种拒绝。
+
+## 细节
+
+- 规则沿用模型库、定时任务与评估中心那几轮(`ConfirmModal` 的 `refusal` 槽):原因画在发起写入的那张卡片
+ 里,而打开这张卡片时先撤掉上一次的原因 —— 那句话说的事是上一次。
+- `features/plugins/plugins-page.tsx`:`setPendingApply(null)` 搬进成功那一条,`catch` 把服务端的原话交给
+ 新的 `applyRefusal` 状态,不再弹 toast;两个打开卡片的入口(安装 / 移除)合并成 `askApply`,落「先开框、
+ 再清旧原因」的写法。
+- 新增浏览器用例 `e2e/plugins-install-refusal.spec.mjs`(两条):被拒的安装留着卡片、句子与那一行,不弹
+ toast、不改变任何状态;重试真的写进去,而只有写成功的那一次才关框。
+
+## 兼容性
+
+- 没有接口、传输格式或依赖变化;只改了卡片什么时候关、拒绝提示画在哪。
+- 同一页里「批量更新」与「单 Agent 的卸载 / 更新」那几张卡片仍是旧的「发出即关」,见台账的「还差什么」。
diff --git a/packages/web/e2e/plugins-install-refusal.spec.mjs b/packages/web/e2e/plugins-install-refusal.spec.mjs
new file mode 100644
index 00000000..73346291
--- /dev/null
+++ b/packages/web/e2e/plugins-install-refusal.spec.mjs
@@ -0,0 +1,140 @@
+/**
+ * Regression: installing a module plugin asks first, and a refused install keeps that question —
+ * with the server's words inside it — instead of closing on the way out of the request.
+ *
+ * The page used to close the confirmation from a `finally`: the plugin was still exactly as it
+ * was (the server refused, so nothing was listed) but the reason arrived as a toast that
+ * dismissed itself after six seconds and sat above the page rather than in the card. The card now
+ * closes only once the write landed, and a refusal leaves it open with the reason drawn under its
+ * sentence (`ConfirmModal`'s `refusal` slot), so the retry is the same button.
+ *
+ * The list read is stubbed: a development data root ships no module plugin, so without a fixture
+ * the page has no install row at all. Both halves the tests need are the page's own contract with
+ * the server — the list it reads and the write it sends — and the write is what is measured.
+ */
+import { test, expect } from "@playwright/test";
+import { ADMIN_ID, ADMIN_PASSWORD, login } from "./auth.mjs";
+
+/** A module plugin the registry already describes, so the row carries real metadata. */
+const SPEC = "@adelie/sandbox-bwrap";
+
+/** The install call the page makes; a 500 with its own words proves the reason came back. */
+const REFUSAL = { code: "plugin_store_closed", message: "plugin store is closed" };
+
+/** The list as the page reads it: `listed` are the specifiers this Project already runs. */
+function deployment(listed) {
+ return {
+ plugins: listed.map((specifier) => ({
+ specifier,
+ active: true,
+ builtin: true,
+ modules: [],
+ replaces: [],
+ everywhere: true,
+ machines: [],
+ here: true,
+ })),
+ shipped: [SPEC],
+ file: ".project_config.toml",
+ machineId: "probe-machine",
+ restartPending: false,
+ };
+}
+
+/**
+ * Serve the deployment read from a fixture and take over the install write. `state.refuse` is
+ * flipped by the retry test; `state.posts` keeps every write so the tests can tell how many were
+ * sent.
+ */
+async function stubDeployment(page, state) {
+ const answer = (route, body) =>
+ route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify(body) });
+ await page.route("**/api/projects/*/plugins/installed*", async (route) => {
+ const req = route.request();
+ if (req.method() === "GET") return answer(route, deployment(state.listed));
+ if (req.method() !== "POST") return route.fallback();
+ state.posts.push(req.postDataJSON());
+ if (state.refuse) {
+ return route.fulfill({
+ status: 500,
+ contentType: "application/json",
+ body: JSON.stringify({ error: REFUSAL }),
+ });
+ }
+ state.listed = [SPEC];
+ return answer(route, deployment(state.listed));
+ });
+}
+
+/** The module row's own install button, then the shared confirmation. */
+async function openInstallDialog(page) {
+ await page.getByRole("button", { name: `安装 ${SPEC}`, exact: true }).click();
+ const dialog = page.getByRole("dialog");
+ await expect(dialog).toBeVisible();
+ return dialog;
+}
+
+/** The card's own text with the refusal line dropped — the only thing a refusal may change. */
+async function cardText(dialog) {
+ return (await dialog.innerText()).replace(/\n操作被拒绝:[^\n]*/, "");
+}
+
+const installButton = (page) => page.getByRole("button", { name: `安装 ${SPEC}`, exact: true });
+const removeButton = (page) => page.getByRole("button", { name: `移除 ${SPEC}`, exact: true });
+
+test("a refused install keeps the question, the reason and the row", async ({ page }) => {
+ await login(page.request, ADMIN_ID, ADMIN_PASSWORD);
+ const state = { listed: [], posts: [], refuse: true };
+ await stubDeployment(page, state);
+
+ await page.goto("/plugins");
+ await expect(installButton(page)).toBeVisible();
+ const dialog = await openInstallDialog(page);
+ const sentence = await cardText(dialog);
+
+ await dialog.getByRole("button", { name: "安装", exact: true }).click();
+
+ // The reason is in the card that asked, and it is not a toast: the notification region holds no
+ // dismissible button, and the card reads exactly as it did before the attempt plus one line.
+ await expect(dialog.getByText(REFUSAL.message)).toBeVisible();
+ await expect(page.getByRole("region", { name: "通知" }).getByRole("button")).toHaveCount(0);
+ expect(state.posts).toEqual([{ specifier: SPEC }]);
+ await expect(dialog).toBeVisible();
+ expect(await cardText(dialog)).toBe(sentence);
+
+ // Nothing was installed anywhere: the row still offers Install and no Remove.
+ await expect(installButton(page)).toBeVisible();
+ await expect(removeButton(page)).toHaveCount(0);
+
+ // Closing the card decides nothing, and opening it again does not carry the old reason over.
+ await dialog.getByRole("button", { name: "取消" }).click();
+ await expect(dialog).toHaveCount(0);
+ await expect(installButton(page)).toBeVisible();
+ const reopened = await openInstallDialog(page);
+ await expect(reopened.getByText(REFUSAL.message)).toHaveCount(0);
+});
+
+test("the retry after a refused install writes it, and only a written one closes the card", async ({
+ page,
+}) => {
+ await login(page.request, ADMIN_ID, ADMIN_PASSWORD);
+ const state = { listed: [], posts: [], refuse: true };
+ await stubDeployment(page, state);
+
+ await page.goto("/plugins");
+ await expect(installButton(page)).toBeVisible();
+ const dialog = await openInstallDialog(page);
+ await dialog.getByRole("button", { name: "安装", exact: true }).click();
+ await expect(dialog.getByText(REFUSAL.message)).toBeVisible();
+ await expect(dialog).toBeVisible();
+ expect(state.posts).toHaveLength(1);
+
+ // The retry is the same card, and this time the write lands: the card closes and the row is
+ // the installed one (Remove, no Install).
+ state.refuse = false;
+ await dialog.getByRole("button", { name: "安装", exact: true }).click();
+ await expect(dialog).toHaveCount(0);
+ expect(state.posts).toHaveLength(2);
+ await expect(removeButton(page)).toBeVisible();
+ await expect(installButton(page)).toHaveCount(0);
+});
diff --git a/packages/web/src/features/plugins/plugins-page.tsx b/packages/web/src/features/plugins/plugins-page.tsx
index 5ee0e603..75b87f01 100644
--- a/packages/web/src/features/plugins/plugins-page.tsx
+++ b/packages/web/src/features/plugins/plugins-page.tsx
@@ -361,10 +361,32 @@ export function PluginsPage() {
null,
);
+ /**
+ * The server's words for the last module plugin change it refused, drawn inside the
+ * confirmation that asked for it. It has to outlive a toast: when the write is refused the
+ * plugin is still exactly as it was, so retrying is the next thing the user does — and the
+ * button that retries it is in this card.
+ */
+ const [applyRefusal, setApplyRefusal] = useState<string | null>(null);
+
+ /**
+ * Open the confirmation for one module plugin change, without the previous refusal: that
+ * sentence belonged to the attempt before (one attempt, one reason).
+ */
+ const askApply = (specifier: string, install: boolean) => {
+ setPendingApply({ specifier, install });
+ setApplyRefusal(null);
+ };
+
/**
* Asks this Project for a module plugin (or drops it); the server lists it and re-assembles
* the App, so the row's state afterwards is what the running process has — including a
* load that failed, which is reported as such rather than toasted as installed.
+ *
+ * The confirmation closes on the answer, not on the request: a refusal leaves the plugin
+ * where it was, so the card stays open with the server's words in it and the same button
+ * retries. Closing it in a `finally` used to take the reason away with it — the toast that
+ * carried it dismisses itself after six seconds and sits above the card, not in it.
*/
const runDeploymentInstall = async (specifier: string, install: boolean) => {
if (pendingSpecifier !== null || projectId === null) return;
@@ -374,6 +396,7 @@ export function PluginsPage() {
? await api.installPlugin(projectId, specifier, viewMachine)
: await api.uninstallPlugin(projectId, specifier, viewMachine);
setDeployment(next);
+ setPendingApply(null);
const row = next.plugins.find((p) => p.specifier === specifier);
if (install && row?.error !== undefined) {
toastError(S.plugins.deploymentFailedToast(specifier, row.error));
@@ -381,10 +404,9 @@ export function PluginsPage() {
toastSuccess(install ? S.plugins.deploymentInstalledToast(specifier) : S.common.saved);
}
} catch (e) {
- toastError(apiErrorText(e));
+ setApplyRefusal(apiErrorText(e));
} finally {
setPendingSpecifier(null);
- setPendingApply(null);
}
};
@@ -866,11 +888,7 @@ export function PluginsPage() {
busy={pendingSpecifier === row.specifier}
blocked={pendingSpecifier !== null && pendingSpecifier !== row.specifier}
onInstall={null}
- onRemove={
- isAdmin
- ? () => setPendingApply({ specifier: row.specifier, install: false })
- : null
- }
+ onRemove={isAdmin ? () => askApply(row.specifier, false) : null}
/>
),
)}
@@ -893,11 +911,7 @@ export function PluginsPage() {
shipped={row.shipped}
busy={pendingSpecifier === row.specifier}
blocked={pendingSpecifier !== null && pendingSpecifier !== row.specifier}
- onInstall={
- isAdmin
- ? () => setPendingApply({ specifier: row.specifier, install: true })
- : null
- }
+ onInstall={isAdmin ? () => askApply(row.specifier, true) : null}
onRemove={null}
/>
),
@@ -943,6 +957,7 @@ export function PluginsPage() {
busy={pendingSpecifier !== null}
onClose={() => setPendingApply(null)}
onConfirm={() => void runDeploymentInstall(pendingApply.specifier, pendingApply.install)}
+ refusal={applyRefusal === null ? undefined : S.common.refused(applyRefusal)}
>
<p>{S.plugins.applyConfirmBody}</p>
</ConfirmModal>