Skip to content

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

fix(web): 安装插件之后那次重读失败时,原因留在页面上

lmlihengb66a1aaa05f7
diff --git a/changelog/unreleased/2026-11-03-plugins-refresh-refusal.md b/changelog/unreleased/2026-11-03-plugins-refresh-refusal.md
new file mode 100644
index 00000000..21afcdc9
--- /dev/null
+++ b/changelog/unreleased/2026-11-03-plugins-refresh-refusal.md
@@ -0,0 +1,52 @@
+# A read that fails right after an install says so on the page, past the toast it used to be
+
+- **Date:** 2026-11-03
+- **Type:** fix
+- **Scope:** `web`
+- **Breaking:** no
+
+[中文](2026-11-03-plugins-refresh-refusal.zh.md)
+
+Settings → Plugins' Sandbox card asks whether to install this OS's backends when its switch is
+turned on and the machine reports none — the install itself is the Plugins page's own, and once it
+lands the cards' **live parts** (notices, actions, the backend report) are read again so what
+installed shows. Each package reports itself in a notification, but that read failing used to add
+one more six-second notification: the card still read "no backend for this OS", and six seconds
+later nothing on screen explained why it never changed.
+
+That failure now stays on the page, above the cards: `role="alert"` (it is the only account of the
+state there, so it is read out), the words naming this server or the machine and the reason the
+read failed, ending in what is on screen — **the state on the cards may still be from before the
+install**. It stays until another machine is picked, the page is opened again (a fresh read), or
+another read lands — the install already landed, so reopening the page is the retry.
+
+## Details
+
+- `packages/web/src/features/settings/plugin-config-read.ts`: a new `pluginConfigStale(machineName,
+ reason)` beside the existing `pluginConfigUnreadable` — the latter says nothing could be read and
+ the page is empty under it, the former says the cards are still there with what the machine said
+ before the install. The two are not interchangeable.
+- `packages/web/src/lib/strings{,-en}.ts`: `plugins.machineStale` / `plugins.thisServerStale`, next
+ to the "could not read" pair; this server keeps its own phrasing (the picker's bare "This server"
+ does not fit the machine phrasing).
+- `packages/web/src/features/settings/plugins-section.tsx`: `loadError` became `readError` (two
+ sources: the read on mount, and the read after an install), drawn in the same place;
+ `installOffered`'s `catch` writes that sentence instead of `toastError`, and a landing read clears
+ it. The per-package install notifications are unchanged.
+
+## Tests
+
+- `packages/web/test/plugin-config-read.test.ts` (+5 cases): the machine is named; this server
+ keeps its own phrasing; the reason travels as given; not the same sentence as "nothing could be
+ read"; the active language.
+- `packages/web/e2e/plugins-backend-refresh-refusal.spec.mjs` (new, one case on a real server):
+ both the configuration read and the install write are stubbed at `page.route` — turn the Sandbox
+ switch on, confirm the install, watch it land (with its own notification) and watch the read
+ right after it fail with a 500 `internal`: one sentence on the page, no notification carrying that
+ reason, and still there seven seconds later; with the refusal lifted and the page reopened, the
+ sentence is gone and the cards are read again.
+
+## Compatibility
+
+- No interface, request or storage change: the same `GET /api/admin/plugin-config`. Only where a
+ read that fails after an install is drawn has moved — from a notification to above the cards.
diff --git a/changelog/unreleased/2026-11-03-plugins-refresh-refusal.zh.md b/changelog/unreleased/2026-11-03-plugins-refresh-refusal.zh.md
new file mode 100644
index 00000000..a3018279
--- /dev/null
+++ b/changelog/unreleased/2026-11-03-plugins-refresh-refusal.zh.md
@@ -0,0 +1,42 @@
+# 安装插件之后那次重读失败时,原因留在页面上,不再只活六秒
+
+- **日期:** 2026-11-03
+- **类型:** fix
+- **范围:** `web`
+- **破坏性:** 无
+
+[English](2026-11-03-plugins-refresh-refusal.md)
+
+设置 →「插件」的沙盒卡片在开关打开、而机器报告没有适用于其操作系统的后端时会问是否安装 ——
+安装走的是插件页那条路,装完之后卡片上的**实况**(提示、按钮、后端报告)要重读一次才跟得上。安装
+本身会按包各报一条通知,但那次重读要是失败,此前只多一条六秒的通知:卡片上仍写着「这个系统没有沙盒
+后端」,六秒之后屏上再没有任何东西解释它为什么没变。
+
+现在这类失败那句话留在页面上、卡片的上方:`role="alert"`(页面上只有这句在说状态,所以会被读出),
+内容是本机或那台机器的名字加上这次读失败的原因,末尾说明**卡片上的状态可能仍是安装前的**。它留到换
+机器、重新打开这一页(一次新的读)或另一次读成功为止 —— 安装已经落地,重读就是靠重新打开这一页。
+
+## 细节
+
+- `packages/web/src/features/settings/plugin-config-read.ts`:新增 `pluginConfigStale(machineName,
+ reason)`,与已有的 `pluginConfigUnreadable` 并排 —— 后者说的是「什么都没读到、页面底下是空的」,
+ 前者说的是「卡片还在,但内容是安装前的」,两句话不能互换。
+- `packages/web/src/lib/strings{,-en}.ts`:新增 `plugins.machineStale` / `plugins.thisServerStale`,
+ 与「无法读取插件」那两句挨着;本机仍然用自己的句式(选择器上那个「本机」塞进机器句式里读不通)。
+- `packages/web/src/features/settings/plugins-section.tsx`:`loadError` 收成 `readError`(两种来源:
+ 挂载时那次读、安装之后那次重读),画的位置不变;`installOffered` 的 `catch` 从 `toastError` 改成
+ 写这句;读成功时清掉。安装的逐包通知一条没动。
+
+## 测试
+
+- `packages/web/test/plugin-config-read.test.ts`(扩 5 条):点机器的名字 / 本机用自己的句式 / 原因原样
+ 带过去 / 与「什么都没读到」那句不是同一句 / 跟着界面语言走。
+- `packages/web/e2e/plugins-backend-refresh-refusal.spec.mjs`(新,真服务端一条):配置读与安装写都桩在
+ `page.route` 上 —— 打开沙盒开关、确认安装、安装落地(有它自己的通知)、紧接着的重读以 500 `internal`
+ 失败:页面上一条句子、通知区没有这条原因,七秒后句子还在;把拒绝放开、离开这一页再回来,句子消失、
+ 卡片重新读出来。
+
+## 兼容
+
+- 接口、请求与存储都没变:还是同一次 `GET /api/admin/plugin-config`。改变的只有「安装之后那次读失败」
+ 画在哪里 —— 从一条通知挪到卡片上方。
diff --git a/packages/web/e2e/plugins-backend-refresh-refusal.spec.mjs b/packages/web/e2e/plugins-backend-refresh-refusal.spec.mjs
new file mode 100644
index 00000000..51191b61
--- /dev/null
+++ b/packages/web/e2e/plugins-backend-refresh-refusal.spec.mjs
@@ -0,0 +1,185 @@
+/**
+ * Regression: when the read that follows an install (the one that brings the cards' notices, the
+ * actions and the backend report up to date) fails, the page says so where the cards are — past
+ * the six seconds a toast lives, over a card that keeps claiming the backend is missing.
+ *
+ * The Sandbox card offers to install this OS's default backends the moment its switch is turned
+ * on and the machine reports none. Installing does land — each package reports itself in a toast —
+ * but the cards' live parts are re-read afterwards, and a failure there used to be one more toast:
+ * a card still reading "no backend for this OS" stayed that way with nothing left on screen to
+ * explain it, six seconds later.
+ *
+ * Both halves the spec needs are the page's own contract with the server and are stubbed at
+ * `page.route`: the configuration it reads (a group with a switch and a backend report, then a
+ * refusal on the read after the install) and the install it sends (the deployment list read for
+ * the machine id, then the install itself). 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 package the card offers on this machine, and the one the install is expected to send. */
+const SPEC = "@adelie/sandbox-bwrap";
+
+/** The line the page draws after a failed read that follows an install; `internal`'s own text. */
+const STALE =
+ "安装之后没能重新读取本机的插件状态(卡片上的状态可能仍是安装前的):服务器内部错误,请稍后重试。";
+
+/** One group with a switch, a field behind it and the backend report that offers an install. */
+const ENTRY = {
+ name: "sandbox",
+ configuration: {
+ title: "Sandbox",
+ titleZh: "沙盒",
+ switch: "enabled",
+ properties: {
+ enabled: { type: "boolean", title: "Enable sandbox", titleZh: "启用沙盒" },
+ maskPaths: { type: "string", title: "Mask paths", titleZh: "掩码路径" },
+ },
+ },
+ values: {},
+ backend: { installed: false, recommended: [SPEC] },
+};
+
+/** Sign in as the seeded administrator and give the Project a model (the onboarding overlay). */
+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 one of the two surfaces this spec tells apart.
+ */
+function toasts(page) {
+ return page.locator('section[aria-label="通知"] button');
+}
+
+/** The deployment list the install path reads for the machine id, and the install it sends. */
+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 configuration from the fixture, answer the install, and refuse the read that follows
+ * it. `state.reads` counts the configuration reads, `state.posts` the install writes; `repair()`
+ * makes later reads land again, so the spec can show what the retry does.
+ */
+async function stub(page, state) {
+ const answer = (route, body) =>
+ route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify(body) });
+ await page.route("**/api/admin/plugin-config", async (route) => {
+ if (route.request().method() !== "GET") return route.fallback();
+ state.reads.push(route.request().url());
+ // The first read hydrates the page; every read after an install is the one under test.
+ if (state.reads.length === 1 || !state.refuse) {
+ return answer(route, { plugins: [state.entry] });
+ }
+ await route.fulfill({
+ status: 500,
+ contentType: "application/json",
+ body: JSON.stringify({ error: { code: "internal", message: "Internal server error" } }),
+ });
+ });
+ await page.route("**/api/projects/*/plugins/installed*", async (route) => {
+ if (route.request().method() === "GET") return answer(route, deployment(state.listed));
+ if (route.request().method() !== "POST") return route.fallback();
+ state.posts.push(route.request().postDataJSON());
+ state.listed = [SPEC];
+ state.entry = { ...state.entry, backend: { installed: true } };
+ return answer(route, deployment(state.listed));
+ });
+}
+
+test("a failed read after an install says so on the cards, past the toast it used to be", async ({
+ page,
+}) => {
+ await ready(page);
+ const state = { entry: ENTRY, reads: [], posts: [], listed: [], refuse: true };
+ await stub(page, state);
+
+ await page.goto("/");
+ const settings = await openSettings(page, "插件");
+ const section = settings.locator("section").first();
+ const card = settings.locator('[data-plugin-config="sandbox"]');
+ await expect(card).toBeVisible();
+ await expect(section.getByRole("alert")).toHaveCount(0);
+
+ // Turning the switch on asks whether to install this OS's backends — the install path under test.
+ await card.getByRole("switch", { name: "启用沙盒" }).click();
+ const prompt = page.getByRole("dialog", { name: "安装沙盒后端" });
+ await expect(prompt).toBeVisible();
+ await prompt.getByRole("button", { name: "安装", exact: true }).click();
+
+ // The install landed (its own toast says so, that half is unchanged) …
+ await expect(prompt).toHaveCount(0);
+ expect(state.posts).toEqual([{ specifier: SPEC, machineId: "probe-machine" }]);
+ // … and the read that was to follow it failed: the reason is on the page, above the cards, not
+ // in a notification that dismisses itself.
+ await expect(section.getByRole("alert")).toHaveText(STALE);
+ await expect(section.getByRole("alert")).toHaveCount(1);
+ expect(state.reads).toHaveLength(2);
+ await expect(toasts(page).filter({ hasText: "服务器内部错误" })).toHaveCount(0);
+
+ // Six seconds is how long a toast lives; this sentence has to still be there after it, and so
+ // does the card it is about — untouched, because nothing changed the drafts.
+ await page.waitForTimeout(7_000);
+ await expect(section.getByRole("alert")).toHaveText(STALE);
+ await expect(card).toBeVisible();
+ await expect(toasts(page)).toHaveCount(0);
+
+ // Leaving the page and coming back is the retry: the read lands, the sentence goes, and the
+ // cards show what the machine answers now (the backend the install put there).
+ state.refuse = false;
+ 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(settings.locator('[data-plugin-config="sandbox"]')).toBeVisible();
+ expect(state.reads.length).toBeGreaterThan(2);
+});
diff --git a/packages/web/src/features/settings/plugin-config-read.ts b/packages/web/src/features/settings/plugin-config-read.ts
index 7ad5a430..faa1d195 100644
--- a/packages/web/src/features/settings/plugin-config-read.ts
+++ b/packages/web/src/features/settings/plugin-config-read.ts
@@ -21,3 +21,21 @@ export function pluginConfigUnreadable(machineName: string | null, reason: strin
? S.plugins.thisServerUnreadable(reason)
: S.plugins.machineUnreadable(machineName, reason);
}
+
+/**
+ * What the page says when the read it makes *after* an install fails — the one that brings the
+ * cards' live parts (notices, actions, the backend report) up to date with what the install did.
+ *
+ * The cards stay on screen here, with the values and the live status the machine answered with
+ * before the install, so this is not the sentence above: that one says nothing could be read and
+ * the page is empty under it. This one says what is being shown — the install's own toasts said
+ * what installed, and a card that still reads "no backend for this OS" is what it said before it.
+ * It used to be a toast, whose six seconds were the only account of why the card never changed
+ * (7.19's rule, app-wide: a refusal lives where the thing it is about lives). Reading the page
+ * again is the retry, since the install itself already landed.
+ */
+export function pluginConfigStale(machineName: string | null, reason: string): string {
+ return machineName === null
+ ? S.plugins.thisServerStale(reason)
+ : S.plugins.machineStale(machineName, reason);
+}
diff --git a/packages/web/src/features/settings/plugins-section.tsx b/packages/web/src/features/settings/plugins-section.tsx
index 3be2791c..a7c0f552 100644
--- a/packages/web/src/features/settings/plugins-section.tsx
+++ b/packages/web/src/features/settings/plugins-section.tsx
@@ -24,7 +24,9 @@
*
* Values hydrate when the section mounts and the saved response is adopted as the new
* baseline, the proxy page's rule; the plugin picks the change up through its watch, so
- * nothing here says "restart".
+ * nothing here says "restart". Either read failing — that first one, or the one an install makes
+ * afterwards to bring the cards' live parts up to date — keeps its reason on the page rather than
+ * in a toast that would be gone before the person looked (plugin-config-read.ts).
*/
import { useEffect, useRef, useState } from "react";
import type { PluginConfigEntry, PluginConfigField } from "@adelie/server/api";
@@ -57,7 +59,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 { pluginConfigStale, pluginConfigUnreadable } from "./plugin-config-read";
import { pluginSaveRefusal } from "./plugin-config-save";
import { SandboxBackendPrompt } from "./sandbox-backend-prompt";
import {
@@ -128,11 +130,14 @@ export function PluginsSection({ focus }: { focus?: string } = {}) {
/** The machine whose settings the page shows and saves: null for this server. */
const [machine, setMachine] = useState<string | null>(null);
/**
- * 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.
+ * Why the settings on screen could not be read, null when the read landed. Two reads can fail:
+ * the one on mount leaves the page empty under this sentence (nothing to draw), and the one
+ * after an install leaves the cards as the machine answered before it (`pluginConfigStale`).
+ * Either way it is about this server or the picked machine (`nameOf`), it is drawn where the
+ * cards are, and it stays until another machine is picked, a read lands, or the page is opened
+ * again.
*/
- const [loadError, setLoadError] = useState<string | null>(null);
+ const [readError, setReadError] = useState<string | null>(null);
const nameOf = (id: string) => machineLabels.get(id) ?? id;
const projectId = useProject().currentProject?.projectId ?? null;
/** The backend package the install prompt offers, while it is open. */
@@ -159,7 +164,7 @@ export function PluginsSection({ focus }: { focus?: string } = {}) {
useEffect(() => {
let cancelled = false;
setEntries(null);
- setLoadError(null);
+ setReadError(null);
setFieldErrors({});
// A sentence about a save describes the values another machine (or another mount) held.
setSaveRefusals({});
@@ -174,7 +179,7 @@ export function PluginsSection({ focus }: { focus?: string } = {}) {
// 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(
+ setReadError(
pluginConfigUnreadable(machine === null ? null : nameOf(machine), apiErrorText(e)),
);
},
@@ -401,8 +406,14 @@ export function PluginsSection({ focus }: { focus?: string } = {}) {
try {
const config = await api.adminGetPluginConfig(machine);
setEntries((prev) => withLiveParts(prev ?? [], config.plugins));
+ // The cards say what the machine answered: nothing is stale any more.
+ setReadError(null);
} catch (e) {
- toastError(apiErrorText(e));
+ // The package toasts said what installed, but the cards' notices, actions and backend
+ // report are what the machine said before the install — a card that still reads "no
+ // backend for this OS" is the worst answer, and a six-second toast over it was all that
+ // said why (7.72). Say it where the cards are; opening the page again is the retry.
+ setReadError(pluginConfigStale(machine === null ? null : nameOf(machine), apiErrorText(e)));
} finally {
setInstalling(false);
}
@@ -502,15 +513,17 @@ export function PluginsSection({ focus }: { focus?: string } = {}) {
return (
<SettingsSection>
{picker}
- {loadError !== null && (
+ {readError !== null && (
<NoticeStrip
tone="attention"
as="p"
- // The page is empty under it, so this line is the whole account of the state.
+ // Under a failed first read the page is empty, and under a failed read after an install
+ // the cards keep what the machine said before it: either way this line is the account
+ // of the state, so it is read out rather than glanced at.
role="alert"
className="rounded-md px-3 py-2 text-xs"
>
- {loadError}
+ {readError}
</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 71194eb4..17a51834 100644
--- a/packages/web/src/lib/strings-en.ts
+++ b/packages/web/src/lib/strings-en.ts
@@ -2769,6 +2769,16 @@ export const en: Strings = {
`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}`,
+ /**
+ * The read again after an install (pluginConfigStale): the cards stay on screen with what the
+ * machine answered before it, so the line says what is being shown rather than that nothing
+ * could be read — "may still be" because a later read of the notices can land on its own.
+ */
+ machineStale: (name: string, reason: string) =>
+ `Could not read what ${name} runs again after the install (the state on the cards may still be from before it): ${reason}`,
+ /** The same line about this server: the picker's bare label does not fit the machine phrasing. */
+ thisServerStale: (reason: string) =>
+ `Could not read this server's plugin state again after the install (the state on the cards may still be from before it): ${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 673b62fb..8ccce97f 100644
--- a/packages/web/src/lib/strings.ts
+++ b/packages/web/src/lib/strings.ts
@@ -2818,6 +2818,16 @@ export const zh = {
* "This server" and would read as if it were a machine's name.
*/
thisServerUnreadable: (reason: string) => `无法读取本机的插件:${reason}`,
+ /**
+ * The read again after an install (pluginConfigStale): the cards stay on screen with what the
+ * machine answered before it, so the line says what is being shown rather than that nothing
+ * could be read — "may still be" because a later read of the notices can land on its own.
+ */
+ machineStale: (name: string, reason: string) =>
+ `安装之后没能重新读取 ${name} 上的插件状态(卡片上的状态可能仍是安装前的):${reason}`,
+ /** The same line about this server, whose label would read as a machine's name (see above). */
+ thisServerStale: (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
index 44b065d5..9ee9fe11 100644
--- a/packages/web/test/plugin-config-read.test.ts
+++ b/packages/web/test/plugin-config-read.test.ts
@@ -1,7 +1,8 @@
/**
- * 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.
+ * What the Plugins page says when it could not read the configuration it draws — the first read
+ * on mount (`pluginConfigUnreadable`) and the one an install makes afterwards
+ * (`pluginConfigStale`). Neither may go to a toast: the first leaves the page empty under it, and
+ * the second leaves the cards saying what the machine answered before the install.
*
* - 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
@@ -9,11 +10,17 @@
* - 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.
+ * - The two are not the same sentence: one says the page is empty, the other says the cards kept
+ * what the machine said before the install, and confusing them would claim a full page is
+ * blank.
*/
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";
+import {
+ pluginConfigStale,
+ pluginConfigUnreadable,
+} from "../src/features/settings/plugin-config-read";
const MACHINE = "gpu-box";
const REASON = S.errors.byCode.internal;
@@ -51,3 +58,36 @@ describe("pluginConfigUnreadable", () => {
expect(pluginConfigUnreadable(MACHINE, EN.errors.byCode.internal)).toContain(MACHINE);
});
});
+
+describe("pluginConfigStale", () => {
+ it("names the machine whose state could not be read again", () => {
+ expect(pluginConfigStale(MACHINE, REASON)).toBe(S.plugins.machineStale(MACHINE, REASON));
+ expect(pluginConfigStale(MACHINE, REASON)).toContain(MACHINE);
+ });
+
+ it("speaks of this server without printing a machine name", () => {
+ const line = pluginConfigStale(null, REASON);
+ expect(line).toBe(S.plugins.thisServerStale(REASON));
+ // Not the machine phrasing with the picker's bare label in it (as above).
+ expect(line).not.toBe(S.plugins.machineStale(S.plugins.thisServer, REASON));
+ });
+
+ it("carries the reason through as given", () => {
+ expect(pluginConfigStale(null, REASON)).toContain(S.errors.byCode.internal);
+ expect(pluginConfigStale(MACHINE, REASON)).toContain(S.errors.byCode.internal);
+ });
+
+ it("says the cards may be out of date rather than that nothing was read", () => {
+ // The blank-page sentence over cards that are on screen would misdescribe the page.
+ expect(pluginConfigStale(null, REASON)).not.toBe(pluginConfigUnreadable(null, REASON));
+ expect(pluginConfigStale(null, REASON)).not.toBe(pluginConfigStale(MACHINE, REASON));
+ });
+
+ it("speaks English when the interface does", () => {
+ setActiveStrings(EN);
+ expect(pluginConfigStale(null, EN.errors.byCode.internal)).toBe(
+ EN.plugins.thisServerStale(EN.errors.byCode.internal),
+ );
+ expect(pluginConfigStale(MACHINE, EN.errors.byCode.internal)).toContain(MACHINE);
+ });
+});