A local-first multi-agent app development platform, built on PenguinHarness
fix(web): 插件装不到某个 Agent 上时,原因留在那张卡片里,不再只活六秒
lmliheng6e0a3d93f41b
diff --git a/changelog/unreleased/2026-11-07-plugin-install-refusal.md b/changelog/unreleased/2026-11-07-plugin-install-refusal.mdnew file mode 100644index 00000000..bb71345e--- /dev/null+++ b/changelog/unreleased/2026-11-07-plugin-install-refusal.md@@ -0,0 +1,65 @@+# A plugin that could not be installed to an Agent says why in its card, not in a six-second toast++- **Date:** 2026-11-07+- **Type:** fix+- **Scope:** `web`+- **Breaking:** no++[中文](2026-11-07-plugin-install-refusal.zh.md)++A plugin card has two ways to put a plugin on an Agent: the card's own "Install to <agent>" button,+and the "Install" on each row of its "manage installs" dialog. Neither asks first, and when the+install did not land (the server refused, the plugin was not in the library, the request never+arrived) nothing changed: the files were still not installed, the card and that row were still+there with the same button, and the reason went to a notification that dismissed itself after six+seconds. Afterwards the screen read exactly as it had before the press, with nothing said about why.++That sentence now renders in the plugin's card (`role="alert"`, danger colour, two lines, the whole+sentence on hover) and names the Agent it could not reach — the dialog lists one row per Agent and+the card's button follows the page's selection, so without the name there is no telling which Agent+stayed empty. It stays until the next attempt starts, or until an install that lands replaces it.++## Why the page keeps the sentence, not the card++An install is optimistic: as the request leaves, the page marks the plugin present on that Agent,+which files the card into the installed section; when the server refuses, the mark rolls back and+the card returns. The card instance that sent the request is therefore unmounted once before the+answer arrives — a sentence kept inside it goes with that instance (which is what the first version+did; measured, and the page showed nothing at all). So the page keeps it, keyed by plugin, and hands+it to the card that comes back. The "manage installs" dialog closes with the same move, which is why+its rows carry no slot of their own.++## Details++- `packages/web/src/features/plugins/install-refusal.ts` (new): `installRefused(plugin, agent,+ reason)` builds the sentence and `installRefusalFor(refusal, plugin)` decides which card gets it —+ the pure part, testable without the page. The reason is the one `toggleInstall` already produced+ (`apiErrorText`, with `refusalText`' rule for a value no server answered), so it speaks with the+ same voice as the three confirmations' refusal slots.+- `packages/web/src/features/plugins/plugins-page.tsx`: the page keeps `installRefusal` (plugin ++ sentence); `toggleInstall` clears it when an install starts and writes it when the install fails+ (the uninstall path is untouched and still hands its outcome back to the confirmation that asked),+ and the card reads it through a new `installRefusal` prop. The card's outer element becomes a+ column — the existing row plus the sentence underneath.+- `packages/web/src/lib/strings{,-en}.ts`: one new sentence,+ `plugins.installRefused(plugin, agent, reason)`.++## Tests++- `packages/web/test/install-refusal.test.ts` (new, 5 cases): the sentence names the plugin and the+ Agent and carries the reason through; it uses the active language; it is handed to its own+ plugin's card and to no other; nothing is drawn when the last install was not refused.+- `packages/web/e2e/plugin-install-refusal.spec.mjs` (new, real server + real browser, 2 cases): the+ install is stubbed to a 500 (a code the interface has its own copy for, plus an English wire+ message). A refused one-click install puts the sentence in the card, names the Agent, uses the+ interface's words rather than the English message, leaves the notification region out of it, and+ keeps the retry enabled — **seven seconds later** (past the six an error notification lives) it is+ still there, and a retry that lands clears it with both request bodies identical. The second case:+ an install refused from a "manage installs" row closes that dialog with the card's optimistic+ move, the card returns to the available list with the same sentence underneath (past seven seconds+ too), and a retry through the dialog clears it once it lands.++## Compatibility++No interface change, no new dependency, no Project config change. The success path, the three+confirmations (update, uninstall, delete) and the rest of "manage installs" are untouched.diff --git a/changelog/unreleased/2026-11-07-plugin-install-refusal.zh.md b/changelog/unreleased/2026-11-07-plugin-install-refusal.zh.mdnew file mode 100644index 00000000..5256625c--- /dev/null+++ b/changelog/unreleased/2026-11-07-plugin-install-refusal.zh.md@@ -0,0 +1,54 @@+# 插件装不到某个 Agent 上时,原因留在那张卡片里,不再只活六秒++- **日期:** 2026-11-07+- **类型:** fix+- **范围:** `web`+- **破坏性:** 否++[English](2026-11-07-plugin-install-refusal.md)++插件卡片上有两个往 Agent 上装东西的入口:卡片自己的「安装到 X」,以及「管理安装」对话框里每一行+的「安装」。两个都不问一句就发请求,装不上时(服务端拒、插件不在库中、请求根本没到)什么都没变:+文件仍没装上去,卡片与那一行仍在原地、按钮仍是那个按钮,而原因只落进一条通知,六秒后自己消失。+此后屏幕读起来与按下之前一模一样,没说为什么。++那句话现在画在那张插件卡片里(`role="alert"`、危险色、限两行、整句挂悬停),并且点名装上不去的那+个 Agent —— 「管理安装」里每个 Agent 一行,卡片上的按钮又跟着当前选中的 Agent 走,不点名就分不清+是哪一个没装上。它一直留到下一次尝试开始,或被一次装成功的安装取代。++## 为什么这句话归页面记,而不归卡片++安装是**乐观**的:请求发出时页面先把插件在该 Agent 上标记为已安装,卡片因此被归进「已安装」那一+段;服务端拒绝后标记回滚,卡片回到「可安装」。也就是说,发请求的那个卡片实例在答复回来之前就已经+卸载过一次 —— 把句子存在卡片里,它会跟着那个实例一起消失(第一版就是这么写的,实测页面上一句话+都没有)。于是句子由页面按插件名记着,交回重新出现的那张卡片;「管理安装」对话框同样随卡片的移动+关掉,所以它自己的那几行不再留槽位。++## 明细++- `packages/web/src/features/plugins/install-refusal.ts`(新):`installRefused(plugin, agent,+ reason)` 造那句话、`installRefusalFor(refusal, plugin)` 决定交给哪张卡片 —— 纯判断,不依赖+ 页面就能测。原因沿用 `toggleInstall` 已经算好的那份(`apiErrorText`,本仓自己抛的值走+ `refusalText`,7.19 的规则),所以它与三个确认框里的拒绝句说的是同一套话。+- `packages/web/src/features/plugins/plugins-page.tsx`:页面多一个 `installRefusal`(插件名 ++ 句子);`toggleInstall` 在安装开始前清掉它、失败时写上它(卸载那条路不变,仍把结论交回问话的+ 确认框),卡片经新增的 `installRefusal` 属性读到。卡片外层从单行 flex 改成列 —— 原来那一行+ 加下面的句子。+- `packages/web/src/lib/strings{,-en}.ts`:一条新文案 `plugins.installRefused(plugin, agent,+ reason)`。++## 测试++- `packages/web/test/install-refusal.test.ts`(新,5 条):句子点名插件与 Agent、原因原话带过;+ 用的是当前语言;句子只交给它自己那张卡片,别的插件的卡片拿不到;没有拒绝时什么也不画。+- `packages/web/e2e/plugin-install-refusal.spec.mjs`(新,真服务端 + 真浏览器,2 条):把安装桩成+ 500(一个界面自己有文案的错误码 + 一句英文原文)—— 卡片一键安装被拒时,句子出现在卡片里、点名+ Agent、念的是界面自己的话而不是那串英文,通知区里没有它,重试按钮仍可用,**七秒后**(超过错误+ 通知活着的 6 秒)它仍在,重试成功后它消失、两次请求体相同;第二条:从「管理安装」那一行安装被+ 拒时,对话框随卡片的乐观移动关掉、卡片回到「可安装」并在下面留着同一句话(同样活过七秒),+ 再打开对话框重试成功后它消失。++## 兼容性++不碰接口、不引入新依赖、不改 Project 配置。成功路径、三个确认框(更新 / 卸载 / 删除)与整段+「管理安装」的动作都没动。diff --git a/packages/web/e2e/plugin-install-refusal.spec.mjs b/packages/web/e2e/plugin-install-refusal.spec.mjsnew file mode 100644index 00000000..2fe6e26a--- /dev/null+++ b/packages/web/e2e/plugin-install-refusal.spec.mjs@@ -0,0 +1,177 @@+/**+ * Regression: the two controls that install a library plugin onto one Agent — the card's+ * one-click "Install to <Agent>" button and a row's toggle in the "manage installs" Modal — keep+ * a refused install's reason under the control that sent it, instead of in a toast that dismisses+ * itself after six seconds.+ *+ * An install moves the page's snapshot optimistically and moves it back when the server refuses,+ * so both controls return to the very button that retries. What used to vanish was the reason: it+ * arrived as a notification over the list, and afterwards the card read exactly as it had before+ * the press, with the files still not installed and nothing saying why. The sentence is drawn+ * under that button or that row now (`role="alert"`, danger colour, two lines, the whole sentence+ * on hover) and names the Agent, which matters in the Modal — one row per Agent.+ *+ * The library listing is stubbed: a development data root ships no user plugin, so without a+ * fixture there is no card to install from. The write itself is what the tests measure (the+ * page's own POST /api/projects/:p/agents/:a/plugins); everything else stays real.+ */+import { test, expect } from "@playwright/test";+import { ADMIN_ID, ADMIN_PASSWORD, login } from "./auth.mjs";++const AGENT = "default_agent";++/** The plugin under test: a user plugin this Project holds on no Agent, so its card offers the install. */+const PLUGIN = {+ source: "user",+ name: "probe-plugin",+ description: "A probe plugin.",+ descriptionZh: "一个探针插件。",+ version: "2026.10.22.1",+ skills: [+ {+ name: "probe-skill",+ description: "A probe skill.",+ descriptionZh: "一个探针技能。",+ version: "2026.10.22.1",+ },+ ],+ hooks: [],+};++/**+ * What the refused install answers with: a code the interface has its own copy for, plus an+ * English message that must not reach the page — that is how the test tells the localized+ * sentence from the server's raw words.+ */+const REFUSAL = { code: "unknown_plugin", message: "RAW ENGLISH SERVER MESSAGE" };+/** The line the page draws for that code (S.errors.byCode), after the plugin and the Agent. */+const REASON = "该插件不在插件库中。";++const notifications = (page) => page.getByRole("region", { name: "通知" });++/** The library as the page reads it: one user plugin, and no Agent holds it. */+async function stubLibrary(page) {+ await page.route("**/api/plugins", async (route) => {+ if (new URL(route.request().url()).pathname !== "/api/plugins") return route.fallback();+ if (route.request().method() !== "GET") return route.fallback();+ await route.fulfill({+ status: 200,+ contentType: "application/json",+ body: JSON.stringify({+ groups: [{ id: "probe", title: "Probe", titleZh: "探针", plugins: [PLUGIN] }],+ }),+ });+ });+}++/**+ * Take over the install; `state.refuse` is flipped by the retry half and `state.writes` keeps+ * every request body, so the tests can tell what was really sent. A written one answers with the+ * Agent's refreshed lists, which is what the real route returns.+ */+async function stubInstall(page, state) {+ await page.route("**/api/projects/*/agents/*/plugins", async (route) => {+ if (route.request().method() !== "POST") return route.fallback();+ state.writes.push(route.request().postDataJSON());+ if (state.refuse) {+ return route.fulfill({+ status: 500,+ contentType: "application/json",+ body: JSON.stringify({ error: REFUSAL }),+ });+ }+ await route.fulfill({+ status: 201,+ contentType: "application/json",+ body: JSON.stringify({ skills: PLUGIN.skills, hooks: [] }),+ });+ });+}++/** The sentence one refused install leaves: the plugin, the Agent it was going to, and the reason. */+const refusalLine = (page) =>+ page.getByRole("alert").filter({ hasText: `未能将 ${PLUGIN.name} 安装到` });++/** Open the page and unfold both lists: a typed query opens them and leaves this single card. */+async function openPage(page) {+ await page.goto("/plugins");+ const search = page.getByRole("searchbox", { name: "搜索插件" });+ await expect(search).toBeVisible();+ await search.fill(PLUGIN.name);+}++/** The card's own install button, by the accessible name it carries for this plugin. */+const cardInstall = (page) =>+ page.getByRole("button", { name: new RegExp(`^安装到 .+ ${PLUGIN.name}$`) });++test("a refused one-click install keeps the reason under the card's button, past six seconds", async ({+ page,+}) => {+ await login(page.request, ADMIN_ID, ADMIN_PASSWORD);+ const state = { writes: [], refuse: true };+ await stubLibrary(page);+ await stubInstall(page, state);+ await openPage(page);++ await cardInstall(page).click();++ const line = refusalLine(page);+ await expect(line).toBeVisible();+ await expect(line).toHaveText(new RegExp(`^未能将 ${PLUGIN.name} 安装到 .+:${REASON}$`));+ // The interface's own words for that code, never the server's English message.+ await expect(line).not.toContainText("RAW ENGLISH");+ // The reason is the card's, not a notification's.+ await expect(notifications(page)).not.toContainText("RAW ENGLISH");+ // Nothing was installed, so the button that retries is still there.+ await expect(cardInstall(page)).toBeEnabled();++ // Past the six seconds an error notification lived: the sentence is still under the card.+ await page.waitForTimeout(7000);+ await expect(line).toBeVisible();+ await expect(line).toHaveText(new RegExp(`^未能将 ${PLUGIN.name} 安装到 .+:${REASON}$`));++ // The retry is the same button, and it clears the sentence of the attempt before it.+ state.refuse = false;+ await cardInstall(page).click();+ await expect(refusalLine(page)).toHaveCount(0);+ expect(state.writes).toEqual([{ names: [PLUGIN.name] }, { names: [PLUGIN.name] }]);+});++test("a refused install from a manage-installs row leaves the reason on the card that comes back", async ({+ page,+}) => {+ await login(page.request, ADMIN_ID, ADMIN_PASSWORD);+ const state = { writes: [], refuse: true };+ await stubLibrary(page);+ await stubInstall(page, state);+ await openPage(page);++ await page.getByRole("button", { name: `管理安装 ${PLUGIN.name}`, exact: true }).click();+ const modal = page.getByRole("dialog", { name: `管理安装:${PLUGIN.name}` });+ await expect(modal).toBeVisible();+ await modal.getByRole("button", { name: `安装 ${AGENT}`, exact: true }).click();++ // The install marks the plugin present as the request leaves, which files the card into the+ // installed section and closes the Modal with it. The refusal rolls that back, so the card is+ // back in the available list — and the sentence the page kept is drawn under it, naming the+ // Agent the refused row was about.+ const line = refusalLine(page);+ await expect(line).toBeVisible();+ await expect(line).toHaveText(new RegExp(`^未能将 ${PLUGIN.name} 安装到 .+:${REASON}$`));+ await expect(notifications(page)).not.toContainText("RAW ENGLISH");+ await expect(modal).toHaveCount(0);++ // Past the six seconds an error notification lived: the sentence is still under the card.+ await page.waitForTimeout(7000);+ await expect(line).toBeVisible();+ await expect(line).toHaveText(new RegExp(`^未能将 ${PLUGIN.name} 安装到 .+:${REASON}$`));++ // The retry is the same row, one Modal away; it clears the sentence of the attempt before it.+ state.refuse = false;+ await page.getByRole("button", { name: `管理安装 ${PLUGIN.name}`, exact: true }).click();+ const again = page.getByRole("dialog", { name: `管理安装:${PLUGIN.name}` });+ await expect(again).toBeVisible();+ await again.getByRole("button", { name: `安装 ${AGENT}`, exact: true }).click();+ await expect(refusalLine(page)).toHaveCount(0);+ expect(state.writes).toEqual([{ names: [PLUGIN.name] }, { names: [PLUGIN.name] }]);+});diff --git a/packages/web/src/features/plugins/install-refusal.ts b/packages/web/src/features/plugins/install-refusal.tsnew file mode 100644index 00000000..01f3aa88--- /dev/null+++ b/packages/web/src/features/plugins/install-refusal.ts@@ -0,0 +1,50 @@+/**+ * The two controls that install one library plugin onto one Agent — the card's one-click+ * "Install to <Agent>" button and a row's toggle in the card's "manage installs" Modal — and the+ * sentence one refused install leaves behind, and where it goes.+ *+ * An install goes out optimistically: the page marks the plugin present on that Agent as the+ * request leaves, which files the card into the other section, so the card is unmounted and the+ * Modal with it; a refusal rolls the mark back and the card returns. What the reader was left with+ * was a notification over the list that dismissed itself after six seconds, and a card that read+ * exactly as it had before the press — the files still not installed, nothing saying why.+ *+ * The sentence is therefore kept by the page, keyed by plugin, and drawn under that plugin's card+ * (the same `role="alert"` slot, danger colour, two lines and hover rule as 7.89–7.92): that card+ * is what the rollback brings back on screen, and its install button is the retry. It names the+ * Agent because the card's own button follows the page's Agent selection while a refused row of+ * the Modal may have been aimed at another Agent — which is also what keeps the sentence readable+ * once the Modal is gone.+ *+ * Whose words: the reason is the one `toggleInstall` already produced (`apiErrorText`, with+ * `refusalText`' rule for a value no server answered), so this sentence and the confirmation+ * dialogs' refusal slots keep speaking with one voice.+ */+import { S } from "../../lib/strings";++/** The sentence one refused install left, and the plugin it was for. */+export interface InstallRefusal {+ readonly plugin: string;+ readonly text: string;+}++/** The sentence: what could not be installed, which Agent it was going to, and why. */+export function installRefused(plugin: string, agent: string, reason: string): string {+ return S.plugins.installRefused(plugin, agent, reason);+}++/**+ * What this card draws for a refusal, if anything.+ *+ * A refusal belongs to the card of the plugin it was about — the plugin is what the page keys it+ * by, and cards for other plugins on the same page must not read it. Nothing else is matched: the+ * Agent is named inside the sentence, and the card's button follows whichever Agent the page+ * works with at the time (the refusal did not change that, only that Agent's empty install).+ */+export function installRefusalFor(+ refusal: InstallRefusal | null,+ plugin: string,+): string | undefined {+ if (refusal === null || refusal.plugin !== plugin) return undefined;+ return refusal.text;+}diff --git a/packages/web/src/features/plugins/plugins-page.tsx b/packages/web/src/features/plugins/plugins-page.tsxindex 1c43012f..b12ba742 100644--- a/packages/web/src/features/plugins/plugins-page.tsx+++ b/packages/web/src/features/plugins/plugins-page.tsx@@ -38,9 +38,11 @@* - Download "manage installs": a Modal listing every Agent in the current Project —* not-installed shows "Install", installed shows "Installed" (hover switches to* "Uninstall", click to uninstall); any member can operate it; optimistic update, a- * top-level toast on success for install/uninstall, rollback plus a toast on failure.- * A refusal is not always a toast: the two writes the card asks about first (uninstall,- * update) keep their confirmation open with the server's words inside it — see the+ * top-level toast on success for install/uninstall, rollback on failure.+ * A refusal is not a toast: an install's — from this row's toggle or the card's one-click+ * button — is drawn under that plugin's card, naming the Agent it could not reach+ * (install-refusal.ts), while the three writes the card asks about first (update, uninstall,+ * delete) keep their confirmation open with the server's words inside it — see the* PluginCard's three confirmations. Installed means the whole plugin is: every one of its* skills is in the Agent's installed skills and, when it ships a hook package, that package is* in the Agent's installed hooks —@@ -114,6 +116,8 @@ import { PluginDetailModal } from "./plugin-detail";import { PluginImportActions } from "./plugin-import-dialog";import { pluginImportErrorText, pluginNameFromError } from "./plugin-import";import { libraryAddRefused } from "./library-add-refusal";+import { installRefusalFor, installRefused } from "./install-refusal";+import type { InstallRefusal } from "./install-refusal";import { SettingsDialog } from "../settings/settings-dialog";import { formatRelativeDate } from "../../lib/format";import { SkillTile } from "../skills/skill-icon-view";@@ -392,6 +396,17 @@ export function PluginsPage() {specifier: string;name: string;} | null>(null);+ /**+ * The sentence for the last install onto an Agent this page did not get, and the plugin it was+ * for: it is drawn under that plugin's card (install-refusal.ts). It lives here rather than in+ * the card because an install moves the card into the other section before the answer arrives,+ * so the instance that sent the request no longer exists by the time a refusal comes back.+ */+ const [installRefusal, setInstallRefusal] = useState<{+ plugin: string;+ text: string;+ } | null>(null);+/*** The server's words for the last "add to the library" it refused, and the row they belong to.* It has to outlive a toast: the write changed nothing, so that row is still on the shelf with@@ -557,15 +572,21 @@ export function PluginsPage() {* and its `pluginUpdates` moved, and both are read off that list.** The answer is a {@link WriteOutcome} rather than a toast: uninstall is asked about first, so- * a refusal belongs in the card that asked (its retry button is there). The install paths have- * no card to keep — the card's one-click button and a manage-installs row's toggle — and they- * add the toast themselves; nothing is toasted here.+ * a refusal belongs in the card that asked (its retry button is there). An install is not asked+ * about, so its refusal is kept here instead — the page outlives the cards — and drawn under+ * the card of that plugin (install-refusal.ts); nothing is toasted either way.** Only an install moves the snapshot before the answer. An uninstall waits for it: removing the* current Agent's copy on the way out flips the card to "not installed" and carries it into the* other section, which unmounts the very confirmation that asked — and with it a refusal's* reason. The row reads "Installed" until the answer arrives, which is also what a refused one* leaves it at.+ *+ * The optimistic move is also why the install's refusal cannot live in the card: it files the+ * card into the other section on the way out and back on a refusal, so the instance that sent+ * the request is unmounted either way. The sentence names the Agent for the same reason the+ * Modal needs it to: the card's own button installs to the Agent the page is working with, while+ * a refused row may have been aimed at another one.*/const toggleInstall = async (agentId: string,@@ -576,7 +597,11 @@ export function PluginsPage() {// behind that gate). The generic sentence is what a write that never left would report.if (!projectId) return { ok: false, reason: S.common.unknownError };const prev = installed.get(agentId) ?? NO_INSTALLS;- if (on) setAgentInstalls(agentId, withPlugin(prev, plugin, on));+ if (on) {+ // One attempt, one reason: the sentence of the attempt before belonged to it.+ setInstallRefusal(null);+ setAgentInstalls(agentId, withPlugin(prev, plugin, on));+ }const target = agents.find((a) => a.agentId === agentId);const agentName = target ? agentDisplayName(target) : agentId;try {@@ -609,7 +634,16 @@ export function PluginsPage() {}} catch (e) {setAgentInstalls(agentId, prev);- return { ok: false, reason: apiErrorText(e) };+ const reason = apiErrorText(e);+ // An install has no confirmation to keep the reason in and no card instance that survives+ // its own optimistic move: the page holds it, keyed by plugin, for the card that comes back.+ if (on) {+ setInstallRefusal({+ plugin: plugin.name,+ text: installRefused(plugin.name, agentName, reason),+ });+ }+ return { ok: false, reason };}void reloadAgents();return { ok: true };@@ -873,6 +907,7 @@ export function PluginsPage() {installed={installed}marketSpecifier={marketEntryFor(row.plugin, index ?? [])?.name ?? null}canDelete={isAdmin}+ installRefusal={installRefusalFor(installRefusal, row.plugin.name)}onQuickInvoke={quickInvoke}onToggleInstall={toggleInstall}onUpdateOutdated={updateOutdated}@@ -1725,6 +1760,7 @@ function PluginCard({installed,marketSpecifier,canDelete,+ installRefusal,onQuickInvoke,onToggleInstall,onUpdateOutdated,@@ -1739,6 +1775,13 @@ function PluginCard({marketSpecifier: string | null;/** Whether this account may delete, which is the account's admin right and not a Project role (see the page header). */canDelete: boolean;+ /**+ * Why the last install of this plugin onto an Agent did not land, naming that Agent+ * (install-refusal.ts). The page keeps it rather than this card: an install moves the snapshot+ * optimistically, so the card is filed into the other section and remounts on the way — and a+ * sentence held here would go with the instance that sent it. Undefined when there is none.+ */+ installRefusal?: string;onQuickInvoke: (skillName: string) => void;onToggleInstall: (agentId: string, plugin: PluginItem, on: boolean) => Promise<WriteOutcome>;onUpdateOutdated: (name: string, agentIds: string[]) => Promise<WriteOutcome>;@@ -1784,15 +1827,6 @@ function PluginCard({setDeleteRefusal(null);};- /**- * The card's install paths — no confirmation, so no card to keep a refusal in: the reason- * takes the toast here (the same sentence a refused confirm would draw inside its dialog).- */- const installNow = async (agentId: string) => {- const outcome = await onToggleInstall(agentId, plugin, true);- if (!outcome.ok) toastError(outcome.reason);- };-/*** The three confirmations close on the answer, not on the request: a refused write changes* nothing on either side (the same files are still installed, the same plugin is still on@@ -1882,184 +1916,202 @@ function PluginCard({.filter((v): v is string => v !== null).join(" · ");return (- <div className="flex items-center gap-3 rounded-md p-4 transition-colors hover:bg-gray-100/70 dark:hover:bg-gray-800/60">- <button- type="button"- onClick={() => setDetailOpen(true)}- className="min-w-0 flex-1 text-left"- >- {/* Header: the plugin icon centered across the two text rows (rounded tile in the plugin's- own palette color — see SkillTile; deliberately a bit smaller than the two rows),- with the name and short description on one line each to the right. */}- <div className="flex items-center gap-3">- <SkillTile- icon={plugin.icon}- name={plugin.name}- fallback={ICONS.puzzle}- size={36}- glyph={20}+ <div className="rounded-md p-4 transition-colors hover:bg-gray-100/70 dark:hover:bg-gray-800/60">+ <div className="flex items-center gap-3">+ <button+ type="button"+ onClick={() => setDetailOpen(true)}+ className="min-w-0 flex-1 text-left"+ >+ {/* Header: the plugin icon centered across the two text rows (rounded tile in the plugin's+ own palette color — see SkillTile; deliberately a bit smaller than the two rows),+ with the name and short description on one line each to the right. */}+ <div className="flex items-center gap-3">+ <SkillTile+ icon={plugin.icon}+ name={plugin.name}+ fallback={ICONS.puzzle}+ size={36}+ glyph={20}+ />+ <div className="min-w-0 flex-1">+ <span+ className="block truncate font-mono text-[length:var(--ui-text-code-size)] font-semibold"+ data-tooltip={plugin.name}+ data-tooltip-content="code"+ >+ {plugin.name}+ </span>+ {/* Short description truncates to one line (full description goes into title for hover reading). */}+ <p+ className="mt-0.5 truncate text-xs leading-5 text-gray-500 dark:text-gray-400"+ data-tooltip={fullDescription}+ data-tooltip-content="text"+ >+ {description}+ </p>+ </div>+ </div>+ {/* Metadata line under the header (e.g. `v2026.08.29.1 · updated 3 days ago · used by+ 2 agents`); what the plugin contains lives in the detail Modal this card opens. */}+ <p+ className="mt-2.5 truncate text-xs text-gray-400 dark:text-gray-500"+ data-tooltip={meta}+ data-tooltip-content="text"+ >+ {meta}+ </p>+ {/* Tag line: the category, where the plugin came from (the build, or the server's plugin+ directory — the two kinds carry different actions, so this is what says which a card+ is), and what it carries. */}+ <div className="mt-2 flex flex-wrap items-center gap-1.5 text-xs">+ <Tag>{category}</Tag>+ {isUser ? (+ <Tag title={S.plugins.userBadgeHint}>{S.plugins.userBadge}</Tag>+ ) : (+ <Tag title={S.plugins.libraryBuiltinHint}>{S.plugins.builtin}</Tag>+ )}+ {plugin.skills.length > 0 && (+ <Tag mono>{S.skills.skillCount(plugin.skills.length)}</Tag>+ )}+ {plugin.hooks.length > 0 && <Tag mono>{S.hooks.hookCount(plugin.hooks.length)}</Tag>}+ {/* The shelf's state, relative to the Agent the page is working with: the same value+ the one-click button acts on, named so the reader knows which Agent it is about. */}+ {market !== undefined && (+ <Tag title={S.plugins.marketStateHint(marketAgentName ?? "")}>+ {S.plugins.marketState[market]}+ </Tag>+ )}+ </div>+ </button>+ {detailOpen && (+ <PluginDetailModal+ plugin={plugin}+ meta={meta}+ marketSpecifier={marketSpecifier}+ onClose={() => setDetailOpen(false)}/>- <div className="min-w-0 flex-1">- <span- className="block truncate font-mono text-[length:var(--ui-text-code-size)] font-semibold"- data-tooltip={plugin.name}- data-tooltip-content="code"+ )}+ {/* Actions: equal-square light icon buttons in a single row, vertically centered at the+ card's right edge (copy goes into aria-label and title). */}+ <div className="flex shrink-0 items-center justify-center gap-1.5">+ {/* The shelf's one-click action, on the Agent the page is working with: install when that+ Agent holds nothing of this plugin, or the update an outdated copy gets elsewhere on+ the card (that one confirms first, because it overwrites installed files). The card's+ primary action, so it carries a label rather than a glyph; with no Agent selected+ there is nothing to install to and the shelf's state is not shown either. */}+ {market === "available" && marketAgent !== null && (+ <Button+ size="sm"+ className="h-8 shrink-0"+ aria-label={`${S.plugins.marketInstall(marketAgentName ?? "")} ${plugin.name}`}+ title={S.plugins.marketInstall(marketAgentName ?? "")}+ onClick={() => void onToggleInstall(marketAgent.agentId, plugin, true)}>- {plugin.name}- </span>- {/* Short description truncates to one line (full description goes into title for hover reading). */}- <p- className="mt-0.5 truncate text-xs leading-5 text-gray-500 dark:text-gray-400"- data-tooltip={fullDescription}- data-tooltip-content="text"+ {S.plugins.install}+ </Button>+ )}+ {market === "updatable" && marketAgent !== null && (+ <Button+ size="sm"+ variant="secondary"+ className="h-8 shrink-0"+ aria-label={`${S.plugins.marketUpdate(marketAgentName ?? "")} ${plugin.name}`}+ title={S.plugins.marketUpdate(marketAgentName ?? "")}+ onClick={() => askUpdate([marketAgent.agentId])}>- {description}- </p>- </div>- </div>- {/* Metadata line under the header (e.g. `v2026.08.29.1 · updated 3 days ago · used by- 2 agents`); what the plugin contains lives in the detail Modal this card opens. */}- <p- className="mt-2.5 truncate text-xs text-gray-400 dark:text-gray-500"- data-tooltip={meta}- data-tooltip-content="text"- >- {meta}- </p>- {/* Tag line: the category, where the plugin came from (the build, or the server's plugin- directory — the two kinds carry different actions, so this is what says which a card- is), and what it carries. */}- <div className="mt-2 flex flex-wrap items-center gap-1.5 text-xs">- <Tag>{category}</Tag>- {isUser ? (- <Tag title={S.plugins.userBadgeHint}>{S.plugins.userBadge}</Tag>- ) : (- <Tag title={S.plugins.libraryBuiltinHint}>{S.plugins.builtin}</Tag>+ {S.skills.updateAction}+ </Button>)}- {plugin.skills.length > 0 && <Tag mono>{S.skills.skillCount(plugin.skills.length)}</Tag>}- {plugin.hooks.length > 0 && <Tag mono>{S.hooks.hookCount(plugin.hooks.length)}</Tag>}- {/* The shelf's state, relative to the Agent the page is working with: the same value- the one-click button acts on, named so the reader knows which Agent it is about. */}- {market !== undefined && (- <Tag title={S.plugins.marketStateHint(marketAgentName ?? "")}>- {S.plugins.marketState[market]}- </Tag>+ {/* Light (secondary): an update nudge, not the card's primary action. The last stop on+ the plugins trail, so it carries the dot itself — straddling the top-right corner of+ the button's border, the anchoring rule update-dot.tsx states for a button. The mark+ is decorative; what is waiting is already in this button's own title and accessible+ name, which is why no sr-only sentence is added beside it. */}+ {outdated.length > 0 && (+ <Button+ size="sm"+ variant="secondary"+ className="relative h-8 w-8 shrink-0 justify-center p-0"+ aria-label={`${S.plugins.updateOutdated(outdated.length)} ${plugin.name}`}+ title={S.plugins.updateOutdated(outdated.length)}+ onClick={() => askUpdate(outdated)}+ >+ <GlyphIcon d={ICONS.rotateCw} size={ICON_SIZE.iconButton} />+ <UpdateDot+ size="inline"+ position="right-0.5 top-0.5 -translate-y-1/2 translate-x-1/2"+ />+ </Button>+ )}+ {plugin.skills.length > 0 && (+ <Button+ size="sm"+ className="h-8 w-8 shrink-0 justify-center p-0"+ aria-label={`${S.skills.quickInvoke} ${plugin.name}`}+ title={quickStartSkill ? S.skills.quickInvoke : S.plugins.quickInvokeNeedsInstall}+ disabled={quickStartSkill === undefined}+ onClick={() => {+ if (quickStartSkill) onQuickInvoke(quickStartSkill.name);+ }}+ >+ <GlyphIcon d={ICONS.paperPlane} size={ICON_SIZE.iconButton} />+ </Button>)}- </div>- </button>- {detailOpen && (- <PluginDetailModal- plugin={plugin}- meta={meta}- marketSpecifier={marketSpecifier}- onClose={() => setDetailOpen(false)}- />- )}- {/* Actions: equal-square light icon buttons in a single row, vertically centered at the- card's right edge (copy goes into aria-label and title). */}- <div className="flex shrink-0 items-center justify-center gap-1.5">- {/* The shelf's one-click action, on the Agent the page is working with: install when that- Agent holds nothing of this plugin, or the update an outdated copy gets elsewhere on- the card (that one confirms first, because it overwrites installed files). The card's- primary action, so it carries a label rather than a glyph; with no Agent selected- there is nothing to install to and the shelf's state is not shown either. */}- {market === "available" && marketAgent !== null && (- <Button- size="sm"- className="h-8 shrink-0"- aria-label={`${S.plugins.marketInstall(marketAgentName ?? "")} ${plugin.name}`}- title={S.plugins.marketInstall(marketAgentName ?? "")}- onClick={() => void installNow(marketAgent.agentId)}- >- {S.plugins.install}- </Button>- )}- {market === "updatable" && marketAgent !== null && (- <Button- size="sm"- variant="secondary"- className="h-8 shrink-0"- aria-label={`${S.plugins.marketUpdate(marketAgentName ?? "")} ${plugin.name}`}- title={S.plugins.marketUpdate(marketAgentName ?? "")}- onClick={() => askUpdate([marketAgent.agentId])}- >- {S.skills.updateAction}- </Button>- )}- {/* Light (secondary): an update nudge, not the card's primary action. The last stop on- the plugins trail, so it carries the dot itself — straddling the top-right corner of- the button's border, the anchoring rule update-dot.tsx states for a button. The mark- is decorative; what is waiting is already in this button's own title and accessible- name, which is why no sr-only sentence is added beside it. */}- {outdated.length > 0 && (- <Button- size="sm"- variant="secondary"- className="relative h-8 w-8 shrink-0 justify-center p-0"- aria-label={`${S.plugins.updateOutdated(outdated.length)} ${plugin.name}`}- title={S.plugins.updateOutdated(outdated.length)}- onClick={() => askUpdate(outdated)}- >- <GlyphIcon d={ICONS.rotateCw} size={ICON_SIZE.iconButton} />- <UpdateDot- size="inline"- position="right-0.5 top-0.5 -translate-y-1/2 translate-x-1/2"- />- </Button>- )}- {plugin.skills.length > 0 && (- <Button- size="sm"- className="h-8 w-8 shrink-0 justify-center p-0"- aria-label={`${S.skills.quickInvoke} ${plugin.name}`}- title={quickStartSkill ? S.skills.quickInvoke : S.plugins.quickInvokeNeedsInstall}- disabled={quickStartSkill === undefined}- onClick={() => {- if (quickStartSkill) onQuickInvoke(quickStartSkill.name);- }}- >- <GlyphIcon d={ICONS.paperPlane} size={ICON_SIZE.iconButton} />- </Button>- )}- <Button- size="sm"- className="h-8 w-8 shrink-0 justify-center p-0"- aria-label={`${S.skills.manageInstall} ${plugin.name}`}- title={S.skills.manageInstall}- onClick={() => setInstallOpen(true)}- >- <GlyphIcon d={INSTALL_ICON} size={ICON_SIZE.iconButton} />- </Button>- {/* Export, for a user plugin only (a built-in is in the build, so there is nothing to take- a copy of): the archive download the Skills and Hooks rows export with, open to every- member — the route is a read. */}- {isUser && (- <Button- size="sm"- variant="secondary"- 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)}- >- <DownloadIcon size={ICON_SIZE.iconButton} />- </Button>- )}- {/* Delete, for a user plugin and an admin: the one action that removes files from the- machine, so it takes the danger variant and confirms first. */}- {isUser && canDelete && (<Buttonsize="sm"- variant="danger"className="h-8 w-8 shrink-0 justify-center p-0"- aria-label={`${S.plugins.deletePluginAction} ${plugin.name}`}- title={S.plugins.deletePluginAction}- onClick={askDelete}+ aria-label={`${S.skills.manageInstall} ${plugin.name}`}+ title={S.skills.manageInstall}+ onClick={() => setInstallOpen(true)}>- <GlyphIcon d={ICONS.trash} size={ICON_SIZE.iconButton} />+ <GlyphIcon d={INSTALL_ICON} size={ICON_SIZE.iconButton} /></Button>- )}+ {/* Export, for a user plugin only (a built-in is in the build, so there is nothing to take+ a copy of): the archive download the Skills and Hooks rows export with, open to every+ member — the route is a read. */}+ {isUser && (+ <Button+ size="sm"+ variant="secondary"+ 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)}+ >+ <DownloadIcon size={ICON_SIZE.iconButton} />+ </Button>+ )}+ {/* Delete, for a user plugin and an admin: the one action that removes files from the+ machine, so it takes the danger variant and confirms first. */}+ {isUser && canDelete && (+ <Button+ size="sm"+ variant="danger"+ className="h-8 w-8 shrink-0 justify-center p-0"+ aria-label={`${S.plugins.deletePluginAction} ${plugin.name}`}+ title={S.plugins.deletePluginAction}+ onClick={askDelete}+ >+ <GlyphIcon d={ICONS.trash} size={ICON_SIZE.iconButton} />+ </Button>+ )}+ </div></div>+ {/* An install this card offered that did not land: the card is back with the button that+ retries it, so the reason sits under the row rather than in a notification that+ dismisses itself (install-refusal.ts). */}+ {installRefusal !== undefined && (+ <p+ role="alert"+ data-testid="install-refusal"+ data-tooltip={installRefusal}+ data-tooltip-content="text"+ className={`mt-1 line-clamp-2 break-words text-xs ${toneInk.danger}`}+ >+ {installRefusal}+ </p>+ )}{installOpen && (<Modalopen@@ -2079,7 +2131,7 @@ function PluginCard({outdated={outdated.includes(a.agentId)}onToggle={(on) => {// Install runs directly; uninstall deletes the installed files, so it confirms first.- if (on) void installNow(a.agentId);+ if (on) void onToggleInstall(a.agentId, plugin, true);else askUninstall(a.agentId);}}onUpdate={() => askUpdate([a.agentId])}diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.tsindex cf18af5b..b4222738 100644--- a/packages/web/src/lib/strings-en.ts+++ b/packages/web/src/lib/strings-en.ts@@ -2918,6 +2918,14 @@ export const en: Strings = {n === 0 ? "not used yet" : n === 1 ? "used by 1 agent" : `used by ${n} agents`,/** Title on a disabled quick-start button: it pre-selects one of the plugin's skills on the currently selected agent, so the plugin has to be installed there first. */quickInvokeNeedsInstall: "Install this plugin on the current agent first to quick-start",+ /**+ * Why an install onto one Agent did not land, drawn under the button or the row that sent it+ * (install-refusal.ts): a refusal leaves the plugin where it was, so that control and its+ * button are the retry — and the Agent is named because the manage-installs Modal has one row+ * per Agent while the card follows the page's selection.+ */+ installRefused: (plugin: string, agent: string, reason: string) =>+ `Could not install ${plugin} to ${agent}: ${reason}`,installedToast: (plugin: string, agent: string): string => `Installed ${plugin} to ${agent}`,uninstalledToast: (plugin: string, agent: string): string =>`Uninstalled ${plugin} from ${agent}`,diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.tsindex 9d69a45f..f2b3cf35 100644--- a/packages/web/src/lib/strings.ts+++ b/packages/web/src/lib/strings.ts@@ -2967,6 +2967,14 @@ export const zh = {usedByAgents: (n: number): string => (n === 0 ? "未被使用" : `${n} 个 Agent 在用`),/** Title on a disabled quick-start button: it pre-selects one of the plugin's skills on the currently selected Agent, so the plugin has to be installed there first. */quickInvokeNeedsInstall: "先在当前 Agent 安装该插件后才能快捷调用",+ /**+ * Why an install onto one Agent did not land, drawn under the button or the row that sent it+ * (install-refusal.ts): a refusal leaves the plugin where it was, so that control and its+ * button are the retry — and the Agent is named because the manage-installs Modal has one row+ * per Agent while the card follows the page's selection.+ */+ installRefused: (plugin: string, agent: string, reason: string) =>+ `未能将 ${plugin} 安装到 ${agent}:${reason}`,/** Top toast shown on successful install / uninstall. */installedToast: (plugin: string, agent: string): string => `已将 ${plugin} 安装到 ${agent}`,uninstalledToast: (plugin: string, agent: string): string => `已从 ${agent} 卸载 ${plugin}`,diff --git a/packages/web/test/install-refusal.test.ts b/packages/web/test/install-refusal.test.tsnew file mode 100644index 00000000..907508b2--- /dev/null+++ b/packages/web/test/install-refusal.test.ts@@ -0,0 +1,63 @@+/**+ * A refused install of a library plugin onto an Agent (src/features/plugins/install-refusal.ts):+ * which words are drawn, and on which card.+ *+ * The install is the one write these controls make with no question in front of it, and it moves+ * the page's snapshot optimistically — so on a refusal the card that sent the request has already+ * been unmounted once and comes back to be redrawn by the page's sentence. That is what this test+ * pins: the reason names the Agent it could not reach (the Modal has one row per Agent, and the+ * card's button follows the page's selection), and it is handed to the card of its own plugin and+ * to no other — a toast would be gone after six seconds while the retry stayed on screen.+ */+import { afterEach, describe, expect, it } from "vitest";+import { en as EN } from "../src/lib/strings-en";+import { S, setActiveStrings, zh as ZH } from "../src/lib/strings";+import {+ installRefusalFor,+ installRefused,+ type InstallRefusal,+} from "../src/features/plugins/install-refusal";++afterEach(() => {+ setActiveStrings(ZH);+});++const refusal: InstallRefusal = { plugin: "probe-plugin", text: "x" };++describe("installRefused", () => {+ it("names the plugin and the Agent it could not go to, then the reason", () => {+ // The reason arrives already localized (toggleInstall reads it through apiErrorText, whose+ // rule is refusalText for a value no server answered): it is carried through verbatim.+ const line = installRefused("probe-plugin", "General Agent", "没有访问该目录的权限。");+ expect(line).toBe(+ S.plugins.installRefused("probe-plugin", "General Agent", "没有访问该目录的权限。"),+ );+ expect(line).toContain("probe-plugin");+ expect(line).toContain("General Agent");+ expect(line).toContain("没有访问该目录的权限。");+ });++ it("speaks the interface language", () => {+ setActiveStrings(EN);+ expect(installRefused("probe-plugin", "General Agent", "denied")).toBe(+ S.plugins.installRefused("probe-plugin", "General Agent", "denied"),+ );+ expect(installRefused("probe-plugin", "General Agent", "denied")).toContain(+ "Could not install probe-plugin to General Agent: denied",+ );+ });+});++describe("installRefusalFor", () => {+ it("hands the sentence to the card of the plugin it was about", () => {+ expect(installRefusalFor(refusal, "probe-plugin")).toBe("x");+ });++ it("hands it to no other plugin's card", () => {+ expect(installRefusalFor(refusal, "another-plugin")).toBeUndefined();+ });++ it("draws nothing when the last install was not refused", () => {+ expect(installRefusalFor(null, "probe-plugin")).toBeUndefined();+ });+});