Skip to content

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

fix(web): 插件页读不出来时,原因留在页面上

lmlihenge6a996181b18
diff --git a/changelog/unreleased/2026-11-02-plugins-read-refusal.md b/changelog/unreleased/2026-11-02-plugins-read-refusal.md
new file mode 100644
index 00000000..2d3d96bb
--- /dev/null
+++ b/changelog/unreleased/2026-11-02-plugins-read-refusal.md
@@ -0,0 +1,44 @@
+# A plugins page that fails to load says why, instead of standing empty
+
+- **Date:** 2026-11-02
+- **Type:** fix
+- **Scope:** `web`
+- **Breaking:** no
+
+[中文](2026-11-02-plugins-read-refusal.zh.md)
+
+Settings → Plugins draws one card per configuration entry, and draws nothing at all until
+`GET /api/admin/plugin-config` answers. On this server that read failing left a blank page and the
+reason in a toast, which was gone six seconds later — after that, nothing on screen said the page
+was empty because it could not be read. A picked machine already said so on the page itself; this
+server did not.
+
+Both cases now draw the reason where the cards would be, and no longer as a toast: a strip with
+`role="alert"`, the machine's name when a machine is the one that could not answer, this server's
+own words when it is this server. It stays until another machine is picked or the page is left and
+opened again — a remount re-reads, and that is the retry. The page has no retry button of its own.
+
+## Details
+
+- `packages/web/src/features/settings/plugin-config-read.ts` (new): `pluginConfigUnreadable(name,
+ reason)` — the sentence a failed read becomes, naming a picked machine and speaking of this
+ server without printing the picker's bare "This server" as if it were a machine's name.
+- `packages/web/src/features/settings/plugins-section.tsx`: a failed hydration adopts an empty
+ list and keeps the sentence, for this server as well as for a machine; the strip is drawn
+ whenever there is one, with `role="alert"`, and the read path no longer uses `toastError`. What
+ a machine's failure says is unchanged.
+- `packages/web/src/lib/strings{,-en}.ts`: `plugins.thisServerUnreadable`, beside the existing
+ `machineUnreadable`.
+
+## Tests
+
+- `packages/web/test/plugin-config-read.test.ts` (new, 4 cases): a machine is named, this server
+ is not, the reason travels through as given, and the sentence follows the interface's language.
+- `packages/web/e2e/plugins-read-refusal.spec.mjs` (new, one case on a real server): with the read
+ refused — one sentence on the page, no cards, no toast at all, still there after seven seconds;
+ leaving the page and coming back (a remount is the retry) clears it and draws the cards.
+
+## Compatibility
+
+- No interface, request or storage change: the same `GET /api/admin/plugin-config`. Only where the
+ reason is drawn on failure has moved.
diff --git a/changelog/unreleased/2026-11-02-plugins-read-refusal.zh.md b/changelog/unreleased/2026-11-02-plugins-read-refusal.zh.md
new file mode 100644
index 00000000..5d35f5d2
--- /dev/null
+++ b/changelog/unreleased/2026-11-02-plugins-read-refusal.zh.md
@@ -0,0 +1,39 @@
+# 插件页读不出来时,原因留在页面上,不再只剩一个空页与一条六秒的通知
+
+- **日期:** 2026-11-02
+- **类型:** fix
+- **范围:** `web`
+- **破坏性:** 无
+
+[English](2026-11-02-plugins-read-refusal.md)
+
+设置 →「插件」按配置项一张卡片地画,而 `GET /api/admin/plugin-config` 回来之前它什么都不画。
+在本机这条读失败时,留下的是一个空页,理由只进了一条六秒的通知 —— 六秒后屏上再没有任何东西说明
+这页为什么是空的。选中的远程机器本来就在页面上说明原因,本机没有。
+
+现在两种都把那句话画在卡片本该出现的地方,也不再是通知:一条 `role="alert"` 的提示条,远端机器
+报出机器名,本机用本机自己的措辞。它一直留到换了机器或离开这一页再回来 —— 重新挂载即重新拉取,
+那就是重试。这一页没有自己的重试按钮。
+
+## 细节
+
+- `packages/web/src/features/settings/plugin-config-read.ts`(新):`pluginConfigUnreadable(name,
+ reason)` —— 一次读失败变成的那句话:选中的机器点名,本机则用自己的说法,不把选择器上那个光秃秃的
+ 「本机」当成机器名塞进机器的句式里。
+- `packages/web/src/features/settings/plugins-section.tsx`:水合失败时收成空列表并把那句话留下,
+ 本机与远程机器同一套;有那句话就画提示条(`role="alert"`),读这条路上不再 `toastError`。
+ 远程机器失败时说的是什么一个字没动。
+- `packages/web/src/lib/strings{,-en}.ts`:新增 `plugins.thisServerUnreadable`,就在既有的
+ `machineUnreadable` 旁边。
+
+## 测试
+
+- `packages/web/test/plugin-config-read.test.ts`(新,4 条):机器点名、本机不点名、原因原样带过去、
+ 那句话跟着界面语言走。
+- `packages/web/e2e/plugins-read-refusal.spec.mjs`(新,真服务端一条):读被拒时 —— 页面上一条句子、
+ 一张卡片都没有、完全没有 toast、七秒后仍在;离开这一页再回来(重新挂载即重试)后句子消失,
+ 卡片画出来。
+
+## 兼容
+
+- 接口、请求与存储都没变:还是同一个 `GET /api/admin/plugin-config`。改变的只有失败时那句话画在哪里。
diff --git a/packages/web/e2e/plugins-read-refusal.spec.mjs b/packages/web/e2e/plugins-read-refusal.spec.mjs
new file mode 100644
index 00000000..b3780909
--- /dev/null
+++ b/packages/web/e2e/plugins-read-refusal.spec.mjs
@@ -0,0 +1,118 @@
+/**
+ * Regression: Settings → 插件 says why the page is empty when `GET /api/admin/plugin-config`
+ * fails, on the page itself, and that sentence outlives the six seconds a toast lives.
+ *
+ * The page draws nothing until the configuration arrives, so a failed read left a blank page and
+ * the reason in a notification that dismissed itself — six seconds later there was nothing on
+ * screen about it at all. A picked machine already said why; this server did not.
+ *
+ * The read is stubbed at `page.route` rather than provoked from the server: what is under test is
+ * what the page does with an answer, and the sentence asserted is the app's own for the code the
+ * server would send (`internal`), which the caller localizes before it reaches the line. Leaving
+ * the page and coming back is the retry — the section is mounted only while it is the open page.
+ */
+import { test, expect } from "@playwright/test";
+import { ADMIN_ID, ADMIN_PASSWORD, login } from "./auth.mjs";
+
+const BASE = process.env.BASE_URL;
+const MOCK = process.env.MOCK_URL;
+
+/** The line the page draws for this server: its own sentence, then the app's text for `internal`. */
+const REFUSED = "无法读取本机的插件:服务器内部错误,请稍后重试。";
+
+/**
+ * Sign in as the seeded administrator (the page is admin-only) and give the Project a model —
+ * the onboarding overlay covers the page without one.
+ */
+async function ready(page) {
+ await login(page.request, ADMIN_ID, ADMIN_PASSWORD);
+ const projectId = (await (await page.request.get(`${BASE}/api/projects`)).json()).projects[0]
+ .projectId;
+ const put = await page.request.put(`${BASE}/api/projects/${projectId}/models`, {
+ data: {
+ defaultModel: { provider: "custom", modelId: "claude-4-8" },
+ models: [
+ {
+ provider: "custom",
+ modelId: "claude-4-8",
+ apiKey: "sk-mock",
+ baseUrl: MOCK,
+ contextWindow: 200000,
+ },
+ ],
+ },
+ });
+ expect(put.ok(), "put models").toBeTruthy();
+}
+
+/** The settings dialog, opened the way a person opens it: the user menu, then a page. */
+async function openSettings(page, section) {
+ // The user menu shares its name with the Project switcher, so take the last match (as chat.spec).
+ await page.getByRole("button", { name: ADMIN_ID }).last().click();
+ await page.getByRole("menuitem", { name: "设置", exact: true }).click();
+ const settings = page.getByRole("dialog", { name: "设置" });
+ await expect(settings).toBeVisible();
+ await settings.getByRole("button", { name: section, exact: true }).click();
+ return settings;
+}
+
+/**
+ * The toast stack by its own hook rather than by role: the modal marks the rest of the page
+ * aria-hidden, and a toast is exactly the surface this spec is about — read the DOM, so a toast
+ * that is on screen still counts.
+ */
+function toasts(page) {
+ return page.locator('section[aria-label="通知"] button');
+}
+
+/**
+ * Answer `GET /api/admin/plugin-config` with a refusal (500 `internal`) until `letThrough()`.
+ * Counted, so the spec can tell whether a request was really sent at all.
+ */
+async function stubRead(page, seen) {
+ let refuse = true;
+ await page.route("**/api/admin/plugin-config", async (route) => {
+ if (route.request().method() !== "GET") return route.fallback();
+ seen.push(route.request().url());
+ if (!refuse) return route.fallback();
+ await route.fulfill({
+ status: 500,
+ contentType: "application/json",
+ body: JSON.stringify({ error: { code: "internal", message: "Internal server error" } }),
+ });
+ });
+ return () => {
+ refuse = false;
+ };
+}
+
+test("the plugins page says why it is empty, past the toast it used to be", async ({ page }) => {
+ await ready(page);
+ const reads = [];
+ const letThrough = await stubRead(page, reads);
+
+ await page.goto("/");
+ const settings = await openSettings(page, "插件");
+ const section = settings.locator("section").first();
+ // Empty, with the reason — the cards that would be here never arrived.
+ await expect(section.getByRole("alert")).toHaveText(REFUSED);
+ await expect(section.getByRole("alert")).toHaveCount(1);
+ await expect(section.locator("[data-plugin-config]")).toHaveCount(0);
+ expect(reads.length).toBeGreaterThanOrEqual(1);
+ await expect(toasts(page)).toHaveCount(0);
+
+ // Six seconds is how long a toast lives; this sentence has to still be there after it.
+ await page.waitForTimeout(7_000);
+ await expect(section.getByRole("alert")).toHaveText(REFUSED);
+
+ // Leaving the page and coming back is the retry: the read lands, the sentence goes, and the
+ // cards it was standing in for are drawn.
+ letThrough();
+ const remountAt = reads.length;
+ await settings.getByRole("button", { name: "通用", exact: true }).click();
+ await settings.getByRole("button", { name: "插件", exact: true }).click();
+ const again = settings.locator("section").first();
+ await expect(again.getByRole("alert")).toHaveCount(0);
+ await expect(again.locator("[data-plugin-config]").first()).toBeVisible();
+ expect(reads.length).toBeGreaterThan(remountAt);
+});
diff --git a/packages/web/src/features/settings/plugin-config-read.ts b/packages/web/src/features/settings/plugin-config-read.ts
new file mode 100644
index 00000000..7ad5a430
--- /dev/null
+++ b/packages/web/src/features/settings/plugin-config-read.ts
@@ -0,0 +1,23 @@
+/**
+ * What the Plugins page says when it could not read the configuration it draws — this server's,
+ * or the picked machine's.
+ *
+ * The page draws nothing until that read lands, so a failure leaves it empty; the reason used to
+ * go to a toast, which dismisses itself after six seconds while the page stays empty and offers
+ * nothing at all about it (7.19's rule, app-wide: a refusal lives where the thing it is about
+ * lives). The failure is therefore a sentence for the page to draw where the cards would be;
+ * leaving and re-entering the page is the retry, since the page has nothing of its own to retry
+ * with.
+ *
+ * Which sentence: a picked machine is named, because it is the one that could not answer, while
+ * this server has no name to print — the picker's "This server" is a bare label that would read
+ * as a machine's name inside the machine phrasing, so this server gets its own words.
+ */
+import { S } from "../../lib/strings";
+
+/** The line drawn where the cards would be — `machineName` is null for this server. */
+export function pluginConfigUnreadable(machineName: string | null, reason: string): string {
+ return machineName === null
+ ? S.plugins.thisServerUnreadable(reason)
+ : S.plugins.machineUnreadable(machineName, reason);
+}
diff --git a/packages/web/src/features/settings/plugins-section.tsx b/packages/web/src/features/settings/plugins-section.tsx
index 4c0aa080..e487fd08 100644
--- a/packages/web/src/features/settings/plugins-section.tsx
+++ b/packages/web/src/features/settings/plugins-section.tsx
@@ -54,6 +54,7 @@ import type { Draft } from "./plugin-config-draft";
import { ConfigField } from "./plugin-config-field";
import { ConfigHeading } from "./plugin-config-heading";
import { withLiveParts } from "./plugin-config-live";
+import { pluginConfigUnreadable } from "./plugin-config-read";
import { SandboxBackendPrompt } from "./sandbox-backend-prompt";
import {
Button,
@@ -115,7 +116,11 @@ export function PluginsSection({ focus }: { focus?: string } = {}) {
const { machineIds, machineLabels } = useSessions();
/** The machine whose settings the page shows and saves: null for this server. */
const [machine, setMachine] = useState<string | null>(null);
- /** Why the picked machine's settings could not be read, when they could not. */
+ /**
+ * Why the settings on screen could not be read — the sentence drawn where the cards would be,
+ * null when the read landed. It is about this server or the picked machine (`nameOf`), and it
+ * stays until another machine is picked or the page is opened again.
+ */
const [loadError, setLoadError] = useState<string | null>(null);
const nameOf = (id: string) => machineLabels.get(id) ?? id;
const projectId = useProject().currentProject?.projectId ?? null;
@@ -151,14 +156,14 @@ export function PluginsSection({ focus }: { focus?: string } = {}) {
},
(e: unknown) => {
if (cancelled) return;
- if (machine === null) {
- toastError(apiErrorText(e));
- return;
- }
- // A machine that cannot answer — no connection, or a build without these routes —
- // shows an empty page with the reason, not this server's settings under its name.
+ // A read that failed leaves no settings to draw: an empty page that says why, rather
+ // than this server's settings under a machine's name. The reason stays on screen —
+ // the page is blank in this state, so a toast would be the only account of it there
+ // ever was, and it is gone six seconds later.
adopt([]);
- setLoadError(apiErrorText(e));
+ setLoadError(
+ pluginConfigUnreadable(machine === null ? null : nameOf(machine), apiErrorText(e)),
+ );
},
);
return () => {
@@ -478,9 +483,15 @@ export function PluginsSection({ focus }: { focus?: string } = {}) {
return (
<SettingsSection>
{picker}
- {machine !== null && loadError !== null && (
- <NoticeStrip tone="attention" as="p" className="rounded-md px-3 py-2 text-xs">
- {S.plugins.machineUnreadable(nameOf(machine), loadError)}
+ {loadError !== null && (
+ <NoticeStrip
+ tone="attention"
+ as="p"
+ // The page is empty under it, so this line is the whole account of the state.
+ role="alert"
+ className="rounded-md px-3 py-2 text-xs"
+ >
+ {loadError}
</NoticeStrip>
)}
<FocusCard focus={focus} ready={entries.length > 0} />
diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.ts
index 181cb83f..71194eb4 100644
--- a/packages/web/src/lib/strings-en.ts
+++ b/packages/web/src/lib/strings-en.ts
@@ -2767,6 +2767,8 @@ export const en: Strings = {
sharedCannotRemove: "Enabled on all machines: remove it in the All machines view.",
machineUnreadable: (name: string, reason: string) =>
`Could not read what ${name} runs: ${reason}`,
+ /** The same line about this server: the picker's bare label does not fit the machine phrasing. */
+ thisServerUnreadable: (reason: string) => `Could not read this server's plugins: ${reason}`,
/** Header icon button opening the Settings dialog on its Plugins page (admin only). */
openSettings: "Plugin settings",
pageDesc:
diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.ts
index a564b1c6..673b62fb 100644
--- a/packages/web/src/lib/strings.ts
+++ b/packages/web/src/lib/strings.ts
@@ -2812,6 +2812,12 @@ export const zh = {
/** Remove is unavailable in a machine's view for a plugin the shared table lists. */
sharedCannotRemove: "已对所有机器启用:请在「所有机器」视图中移除。",
machineUnreadable: (name: string, reason: string) => `无法读取 ${name} 运行的插件:${reason}`,
+ /**
+ * The same line about this server, whose plugins the page draws when no machine is picked:
+ * the picker's label cannot be glued into the machine phrasing — it is a bare
+ * "This server" and would read as if it were a machine's name.
+ */
+ thisServerUnreadable: (reason: string) => `无法读取本机的插件:${reason}`,
/** Header icon button opening the Settings dialog on its Plugins page (admin only). */
openSettings: "插件设置",
pageDesc:
diff --git a/packages/web/test/plugin-config-read.test.ts b/packages/web/test/plugin-config-read.test.ts
new file mode 100644
index 00000000..44b065d5
--- /dev/null
+++ b/packages/web/test/plugin-config-read.test.ts
@@ -0,0 +1,53 @@
+/**
+ * What the Plugins page says when it could not read the configuration it draws
+ * (`pluginConfigUnreadable`): the page draws nothing until that read lands, so a failed one has
+ * to hand it a sentence for the empty page rather than a toast that dismisses itself.
+ *
+ * - A picked machine is named: it is the one that could not answer.
+ * - This server is not: the picker's bare "This server" would read as a machine's name inside
+ * the machine phrasing, so this server has words of its own.
+ * - The reason travels through as given — the caller's `apiErrorText` has already turned the
+ * server's code into the app's own sentence.
+ * - The sentence speaks the interface's language.
+ */
+import { afterEach, describe, expect, it } from "vitest";
+import { S, setActiveStrings, zh as ZH } from "../src/lib/strings";
+import { en as EN } from "../src/lib/strings-en";
+import { pluginConfigUnreadable } from "../src/features/settings/plugin-config-read";
+
+const MACHINE = "gpu-box";
+const REASON = S.errors.byCode.internal;
+
+afterEach(() => {
+ setActiveStrings(ZH);
+});
+
+describe("pluginConfigUnreadable", () => {
+ it("names the machine that could not answer", () => {
+ expect(pluginConfigUnreadable(MACHINE, REASON)).toBe(
+ S.plugins.machineUnreadable(MACHINE, REASON),
+ );
+ expect(pluginConfigUnreadable(MACHINE, REASON)).toContain(MACHINE);
+ });
+
+ it("speaks of this server without printing a machine name", () => {
+ const line = pluginConfigUnreadable(null, REASON);
+ expect(line).toBe(S.plugins.thisServerUnreadable(REASON));
+ // The picker's label is not glued into the machine phrasing ("无法读取 本机 运行的插件") —
+ // this server gets its own sentence.
+ expect(line).not.toBe(S.plugins.machineUnreadable(S.plugins.thisServer, REASON));
+ });
+
+ it("carries the reason through as given", () => {
+ expect(pluginConfigUnreadable(null, REASON)).toContain(S.errors.byCode.internal);
+ expect(pluginConfigUnreadable(MACHINE, REASON)).toContain(S.errors.byCode.internal);
+ });
+
+ it("speaks English when the interface does", () => {
+ setActiveStrings(EN);
+ expect(pluginConfigUnreadable(null, EN.errors.byCode.internal)).toBe(
+ EN.plugins.thisServerUnreadable(EN.errors.byCode.internal),
+ );
+ expect(pluginConfigUnreadable(MACHINE, EN.errors.byCode.internal)).toContain(MACHINE);
+ });
+});