Skip to content

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

fix(web): a memory that did not open keeps its reason in its own row

lmliheng49a8ea09802c
diff --git a/changelog/unreleased/2026-11-12-memory-view-refusal.md b/changelog/unreleased/2026-11-12-memory-view-refusal.md
new file mode 100644
index 00000000..49bfc42f
--- /dev/null
+++ b/changelog/unreleased/2026-11-12-memory-view-refusal.md
@@ -0,0 +1,57 @@
+# A memory that did not open says so in its own row
+
+- **Date:** 2026-11-12
+- **Type:** fix
+- **Scope:** `web`, `ui`
+- **Breaking:** no
+
+[中文版](2026-11-12-memory-view-refusal.zh.md)
+
+The Agent settings page's Memory tab answers a refused read where it was asked. Pressing a memory's
+eye button fetches one file and opens the view panel; when that read fails the panel simply never
+appears, nothing is written, and the row keeps its eye button as the retry — but the only account of
+why was a notification above the page that dismissed itself after six seconds. A reader who asked
+for a memory and got no panel was left with the memory still listed and nothing saying whether the
+attempt had touched it.
+
+Now the reason is drawn inside that row, under the memory it is about and above the rule that closes
+the row: `记忆「<title>」没有打开,打开只是读取,记忆一条都没有被改动:<reason>`. It stays until the next
+attempt (whichever memory that attempt is for), and the row's eye button is the retry. Nothing is
+toasted for it any more.
+
+This closes the family the previous rounds worked through: a refusal with a surface of its own stays
+there, and only writes that landed (and reads with no surface at all) still raise a notification.
+
+## Details
+
+- `packages/web/src/features/agents/memory-file-refusal.ts` (new): `memoryViewRefused(title, error)`
+ builds the sentence through `refusalText` — the same rule as every other refusal — and
+ `memoryFileRefusalFor(refusal, scopeKey, fileName)` says which row draws it. It claims by the
+ scope's key and the memory's file name, never their titles: a memory's title is a label it may
+ share with a memory in another group.
+- `packages/web/src/features/agents/memory-tab.tsx`: `openView` fills that slot instead of calling
+ `toastError` (the tab no longer imports it), and `fileRow` hands the sentence to the row's new
+ `notice` line.
+- `packages/ui/src/components/data/list-row/list-row.tsx`: `ListRow` takes an optional `notice`, a
+ full-width line drawn inside the row above its rule — so the reason belongs to the row that holds
+ the action to retry, and the column beside it keeps its width.
+- `packages/web/src/lib/strings{,-en}.ts`: one sentence per language.
+
+## Tests
+
+- `packages/web/test/memory-file-refusal.test.ts`: the sentence follows `refusalText` rather than the
+ wire message, keeps a failure that never reached the route, falls back when there is nothing to
+ say, names the memory, says the read changed nothing, and speaks the active language; the row
+ lookup hands the sentence to one row only.
+- `packages/ui/test/list-row.test.ts`: the notice is a child of the row tag (inside its rule), after
+ the actions, and absent when nothing was refused.
+- `packages/web/e2e/memory-view-refusal.spec.mjs`: against a real server and a real browser — a
+ refused read leaves the sentence in that row, no notification, no panel, and both sides unchanged
+ seven seconds later; the same button then opens the panel. A second case shows a later attempt on
+ another memory clearing the reason.
+
+## Compatibility
+
+No interface change on the wire, no new dependency, no Project config change. The sentences of every
+other refusal, the success notifications, the delete / import / export surfaces and the tab's
+initial-load error are unchanged.
diff --git a/changelog/unreleased/2026-11-12-memory-view-refusal.zh.md b/changelog/unreleased/2026-11-12-memory-view-refusal.zh.md
new file mode 100644
index 00000000..84087d96
--- /dev/null
+++ b/changelog/unreleased/2026-11-12-memory-view-refusal.zh.md
@@ -0,0 +1,44 @@
+# 没打开的那条记忆,原因留在它自己那一行
+
+- **日期:** 2026-11-12
+- **类型:** 修复
+- **范围:** `web`、`ui`
+- **破坏性变更:** 否
+
+[English](2026-11-12-memory-view-refusal.md)
+
+Agent 设置页的记忆分区把被拒的读取讲在它被问的地方。按下一行记忆的「查看」会取一个文件并打开查看面板;这次读取
+失败时面板根本没出现、什么都没写、那一行连按钮都留在原地 —— 而原因只有页面顶部一条六秒后自己消失的通知。人要的
+是那条记忆,拿到的是没打开,而屏幕上再没有一句话说这次尝试有没有动过它。
+
+现在那句话画在**那一行里**,就在它说的那条记忆下面、收住这一行的横线之上:
+`记忆「<标题>」没有打开,打开只是读取,记忆一条都没有被改动:<原因>`。它留到下一次尝试为止(不论那次尝试是
+哪条记忆),那一行的「查看」就是重试。这件事不再另弹通知。
+
+这也收掉了前面几轮一路做下来的那一族:已经有地方可留的拒绝就留在那里,只有**写到位的**写操作(以及根本没有面可留的
+读取)仍然发通知。
+
+## 细节
+
+- `packages/web/src/features/agents/memory-file-refusal.ts`(新增):`memoryViewRefused(title, error)`
+ 按 `refusalText`(全应用统一的拒绝口径)造句;`memoryFileRefusalFor(refusal, scopeKey, fileName)`
+ 决定这句话归哪一行。认的是分组的 **key** 与文件的**名字**,不是它们的标题 —— 标题是标签,两条记忆可能同名。
+- `packages/web/src/features/agents/memory-tab.tsx`:`openView` 写进这个槽,不再 `toastError`
+ (这一页也不再引用它);`fileRow` 把句子交给行的 `notice`。
+- `packages/ui/src/components/data/list-row/list-row.tsx`:`ListRow` 多一个可选的 `notice` —— 一条整行的
+ 说明,画在行内、行的横线之上,于是原因属于那一行,而旁边的文字列宽度一寸未动。
+- `packages/web/src/lib/strings{,-en}.ts`:两种语言各一句。
+
+## 测试
+
+- `packages/web/test/memory-file-refusal.test.ts`:句子走 `refusalText` 而不是线上原话、保留没到路由的失败、
+ 没话说时回落到通用文案、点名是哪条记忆、说明这次读取什么都没改、跟随当前语言;归属只落在一条行上。
+- `packages/ui/test/list-row.test.ts`:`notice` 是行标签的子节点(在它的横线之内)、排在动作之后、没有拒绝时不出现。
+- `packages/web/e2e/memory-view-refusal.spec.mjs`:真服务端 + 真浏览器 —— 被拒的读取把句子留在那一行、通知区
+ 没有东西、面板没开、七秒后两侧都与开始时一模一样;同一颗按钮再按一次面板就打开。第二条用例说明后一次尝试
+ (哪怕是另一条记忆)会清掉前一句。
+
+## 兼容性
+
+线上接口没变、没有新依赖、Project 配置没变。其余拒绝的句子、成功的通知、删除 / 导入 / 导出那几处、以及这一页
+初次加载失败的错误都一字未改。
diff --git a/packages/ui/src/components/data/list-row/list-row.tsx b/packages/ui/src/components/data/list-row/list-row.tsx
index 74809d89..619d0f0b 100644
--- a/packages/ui/src/components/data/list-row/list-row.tsx
+++ b/packages/ui/src/components/data/list-row/list-row.tsx
@@ -6,6 +6,11 @@
* A row that opens what it names takes `onClick`: the mark and the text become one button, and
* the trailing actions stay outside it, since a button cannot hold another.
*
+ * A row whose own action was refused takes `notice`: the sentence is drawn full width under the
+ * row's line, inside the row and above its rule, so the reason belongs to the row that holds the
+ * action to retry. Anything the caller puts there must not stretch the row: it is the row's own
+ * line, so it wraps rather than widening the text column beside it.
+ *
* The text gives way and the actions never do. Title and description truncate to one line each,
* whatever their length, and a cut-off line shows whole on hover through the app's tooltip layer,
* which reads the line's own text, so it needs no attribute. The meta and the actions keep their
@@ -62,6 +67,11 @@ export interface ListRowProps {
meta?: ReactNode;
/** The row's own actions. */
trailing?: ReactNode;
+ /**
+ * A whole line the row keeps under its text: the reason one of its own actions was refused,
+ * where the action that retries it still is.
+ */
+ notice?: ReactNode;
/** Opens what the row names: the mark and the text become one button. */
onClick?: () => void;
/** `li` inside a `ul` or `ol`; a `div` otherwise (the default). */
@@ -75,6 +85,7 @@ export function ListRow({
description,
meta,
trailing,
+ notice,
onClick,
as: Tag = "div",
className = "",
@@ -117,6 +128,10 @@ export function ListRow({
)}
</div>
)}
+ {/* The row's own line, under the text and inside the row's rule: `w-full` is what makes it
+ wrap there instead of widening the text column, and it stays inside the row's hover
+ surface so the reason reads as this row's. */}
+ {notice !== undefined && <div className="w-full">{notice}</div>}
</Tag>
);
}
diff --git a/packages/ui/test/list-row.test.ts b/packages/ui/test/list-row.test.ts
index c65869e0..853f8da6 100644
--- a/packages/ui/test/list-row.test.ts
+++ b/packages/ui/test/list-row.test.ts
@@ -9,6 +9,8 @@
* ending in an ellipsis, and the line's hover hint carries all of it — never half a character.
* - Given a description a row can show, it is rendered whole with no hint of its own (the
* tooltip layer shows a cut-off line's own text).
+ * - Given an action of the row's own that was refused, the reason is a line of its own inside the
+ * row and above the row's rule, after the action that retries it.
*
* How rows fit their card at every width is measured in a browser: ui-gallery's
* e2e/list-row-width.spec.mjs.
@@ -99,4 +101,26 @@ describe("ListRow", () => {
/<button type="button" class="[^"]*"><span[^>]*><img[^>]*\/><\/span>(?:(?!<\/button>).)*case-01(?:(?!<\/button>).)*<\/button><div class="ml-auto[^"]*"><div[^>]*><button type="button" aria-label="Export">/,
);
});
+
+ it("keeps a refused action's reason inside the row, on its own line above the row's rule", () => {
+ const html = renderStatic(
+ createElement(ListRow, {
+ as: "li",
+ title: "probe-memory.md",
+ onClick: () => {},
+ trailing,
+ notice: createElement("p", { role: "alert" }, "It did not open"),
+ }),
+ );
+ // The rule is the row tag's own border, so the reason has to be a child of that tag — and the
+ // last child, so nothing sits between it and the line it belongs under.
+ expect(html).toMatch(/<div class="w-full"><p role="alert">It did not open<\/p><\/div><\/li>$/);
+ // Under the action that retries it, which keeps the width it had.
+ expect(html.indexOf("It did not open")).toBeGreaterThan(html.indexOf('aria-label="Export"'));
+ });
+
+ it("draws no notice line when nothing was refused", () => {
+ const html = renderStatic(createElement(ListRow, { title: "pdf", trailing }));
+ expect(html).not.toContain('class="w-full"');
+ });
});
diff --git a/packages/web/e2e/memory-view-refusal.spec.mjs b/packages/web/e2e/memory-view-refusal.spec.mjs
new file mode 100644
index 00000000..9b03e186
--- /dev/null
+++ b/packages/web/e2e/memory-view-refusal.spec.mjs
@@ -0,0 +1,209 @@
+/**
+ * Regression: a memory that did not open leaves its reason in the row that asked, instead of only
+ * in a notification that dismisses itself after six seconds.
+ *
+ * Opening a memory is a plain read of one file — the view panel simply never comes up when it
+ * fails, nothing is written, and the row keeps its eye button as the retry. Before this, that read
+ * answered with `toastError`: the person asked for a panel, got none, and the only account of why
+ * left the screen after six seconds. The Skills (7.101), Hooks (7.103) and memory-group (7.109 /
+ * 7.110) twins are the same family; this one hangs off a list row, so its reason sits inside that
+ * row (`ListRow`'s `notice`) — under the memory it is about, above the rule that closes the row.
+ *
+ * The memory is seeded through the export document the import route accepts (the tab has no "new
+ * file" form by design: a memory's text is the model's document). The refused read is the page's
+ * own request as seen by `page.route`; both halves are the page's contract with the server.
+ */
+import { test, expect } from "@playwright/test";
+import { provisionAndLogin } from "./auth.mjs";
+
+const BASE = process.env.BASE_URL;
+const MOCK = process.env.MOCK_URL;
+const P = "password123";
+const AGENT = "default_agent";
+const FILE = "probe-view-memory.md";
+const TITLE = "Probe view memory";
+const OTHER_FILE = "probe-other-memory.md";
+const OTHER_TITLE = "Probe other memory";
+
+/** The refused read: its code's own localized sentence is what the row has to draw. */
+const REFUSAL = { code: "internal", message: "the memory could not be read" };
+/** S.errors.byCode.internal — the copy that code stands for in a zh-CN interface. */
+const REASON = "服务器内部错误,请稍后重试。";
+
+/** Two memory documents as the export route writes them (the import route's own shape). */
+function documentWith(content, otherContent) {
+ return {
+ format: "penguin-memory-scope",
+ version: 1,
+ scopeKey: "user",
+ kind: "user",
+ exportedAt: new Date().toISOString(),
+ index: `- [${TITLE}](${FILE}) — seeded by the e2e run\n- [${OTHER_TITLE}](${OTHER_FILE}) — seeded by the e2e run\n`,
+ files: [
+ {
+ name: FILE,
+ content: `---\nname: ${TITLE}\ndescription: A memory the view refusal test opens.\n---\n\n${content}\n`,
+ },
+ {
+ name: OTHER_FILE,
+ content: `---\nname: ${OTHER_TITLE}\ndescription: The other row, which no attempt was made for.\n---\n\n${otherContent}\n`,
+ },
+ ],
+ };
+}
+
+/**
+ * Provision the user, give the Project a model (the onboarding overlay covers the page without
+ * one), and seed two user-scope memories so the group has more than one row. Rerunning this file
+ * shares one data root with earlier runs, so the seed overwrites what a previous run left.
+ */
+async function projectWithMemories(page, user, content, otherContent) {
+ await provisionAndLogin(page.request, user, P);
+ const projectId = (await (await page.request.get(`${BASE}/api/projects`)).json()).projects[0]
+ .projectId;
+ const models = 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(models.ok(), "put models").toBeTruthy();
+
+ const scopeBase = `${BASE}/api/projects/${projectId}/agents/${AGENT}/memory/scopes/user`;
+ const seeded = await page.request.post(`${scopeBase}/import`, {
+ data: { mode: "overwrite", confirm: true, payload: documentWith(content, otherContent) },
+ });
+ expect(seeded.ok(), "seed the memories").toBeTruthy();
+
+ /** The scope's topic files as the server holds them: what the page reads. */
+ const files = async () => (await (await page.request.get(`${scopeBase}/files`)).json()).files;
+
+ return { projectId, files };
+}
+
+/** A memory row's own eye button (accessible name: the verb plus that memory's title). */
+const eyeButton = (page, title) => page.getByRole("button", { name: `查看 ${title}`, exact: true });
+
+/** That memory's row: the list item holding the eye button. */
+const rowOf = (page, title) => page.getByRole("listitem").filter({ has: eyeButton(page, title) });
+
+/** The reason line inside that row (one slot, the row that asked). */
+const refusalLine = (page, title) => rowOf(page, title).getByTestId("memory-file-refusal");
+
+/**
+ * The view panel's own action row: the drawer's "Edit" is the one button whose whole accessible
+ * name is the verb (the row's icons are named "<verb> <title>"). Present only when a panel opened.
+ */
+const panelEdit = (page) => page.getByRole("button", { name: "编辑", exact: true });
+
+/** The notification region: a refusal must not be announced there (that is the old toast). */
+const notifications = (page) => page.getByRole("region", { name: "通知" });
+
+/**
+ * Nothing was raised in the notification region for this refusal, read at once.
+ *
+ * `toHaveCount(0)` retries for the whole expect timeout, so it also passes against a toast that
+ * simply expired after six seconds — the very behaviour this file is about.
+ */
+async function expectNoToast(page) {
+ await page.waitForTimeout(400);
+ expect(await notifications(page).getByRole("button").count()).toBe(0);
+}
+
+/** Take over one memory's read: every GET is kept in `seen`, refused while `state.refuse` is set. */
+async function interceptFile(page, state) {
+ await page.route("**/api/projects/*/agents/*/memory/scopes/*/files/*", async (route) => {
+ const pathname = new URL(route.request().url()).pathname;
+ if (!pathname.endsWith(`/${FILE}`)) return route.fallback();
+ state.seen.push(pathname);
+ if (!state.refuse) return route.fallback();
+ await route.fulfill({
+ status: 500,
+ contentType: "application/json",
+ body: JSON.stringify({ error: REFUSAL }),
+ });
+ });
+}
+
+test("a memory that did not open keeps its reason in its own row, and nothing else changes", async ({
+ page,
+}) => {
+ const { files } = await projectWithMemories(
+ page,
+ "r225memviewrefuse",
+ "What the memory held.",
+ "The other row's text.",
+ );
+ const before = await files();
+
+ const state = { seen: [], refuse: true };
+ await interceptFile(page, state);
+
+ await page.goto(`/agents/${AGENT}?tab=memory`);
+ await expect(rowOf(page, TITLE)).toHaveCount(1);
+ await expect(rowOf(page, OTHER_TITLE)).toHaveCount(1);
+ await expect(page.getByTestId("memory-file-refusal")).toHaveCount(0);
+
+ await eyeButton(page, TITLE).click();
+
+ // The reason is in the row that asked, and it is not a toast: the notification region holds no
+ // dismissible button, and the row still has the eye button that retries it.
+ await expect(refusalLine(page, TITLE)).toHaveCount(1);
+ await expect(refusalLine(page, TITLE)).toHaveText(
+ `记忆「${TITLE}」没有打开,打开只是读取,记忆一条都没有被改动:${REASON}`,
+ );
+ await expect(eyeButton(page, TITLE)).toBeVisible();
+ await expect(notifications(page).getByRole("button")).toHaveCount(0);
+ expect(state.seen).toHaveLength(1);
+ expect(state.seen[0]).toMatch(/\/memory\/scopes\/user\/files\/probe-view-memory\.md$/);
+
+ // One row, one sentence: no other row grew one, and no panel opened.
+ await expect(page.getByTestId("memory-file-refusal")).toHaveCount(1);
+ await expect(panelEdit(page)).toHaveCount(0);
+
+ // Six seconds is where the old toast gave up; the sentence is still there.
+ await page.waitForTimeout(7000);
+ await expect(refusalLine(page, TITLE)).toHaveCount(1);
+
+ // The read changed neither side: the memories are listed and on disk exactly as before.
+ await expect(rowOf(page, TITLE)).toHaveCount(1);
+ expect(await files()).toEqual(before);
+
+ // The retry is the same eye button; this time the memory really comes back: the sentence goes and
+ // the panel opens with that memory in it.
+ state.refuse = false;
+ await eyeButton(page, TITLE).click();
+ await expect(page.getByTestId("memory-file-refusal")).toHaveCount(0);
+ await expect(panelEdit(page)).toHaveCount(1);
+ expect(state.seen).toHaveLength(2);
+ expect(await files()).toEqual(before);
+});
+
+test("a later attempt clears the reason, even when it is another memory that opened", async ({
+ page,
+}) => {
+ await projectWithMemories(page, "r225memviewretry", "The refused one.", "The one that opens.");
+
+ const state = { seen: [], refuse: true };
+ await interceptFile(page, state);
+
+ await page.goto(`/agents/${AGENT}?tab=memory`);
+ await expect(rowOf(page, TITLE)).toHaveCount(1);
+ await eyeButton(page, TITLE).click();
+ await expect(refusalLine(page, TITLE)).toHaveCount(1);
+ await expectNoToast(page);
+
+ // Only `FILE` is refused, so the other row's eye opens its panel — and that attempt supersedes
+ // the reason the first one left: one refusal, the last one.
+ await eyeButton(page, OTHER_TITLE).click();
+ await expect(panelEdit(page)).toHaveCount(1);
+ await expect(page.getByTestId("memory-file-refusal")).toHaveCount(0);
+});
diff --git a/packages/web/src/features/agents/memory-file-refusal.ts b/packages/web/src/features/agents/memory-file-refusal.ts
new file mode 100644
index 00000000..e92662a3
--- /dev/null
+++ b/packages/web/src/features/agents/memory-file-refusal.ts
@@ -0,0 +1,53 @@
+/**
+ * A memory row on the Agent's Memory tab (`memory-tab.tsx`) and the sentence one refused **read**
+ * leaves behind: the view panel a memory's eye button asks for never opened (7.112).
+ *
+ * The host is the row, not the group: the eye is that row's own action, the row is still there with
+ * the same button, and the panel simply never came up — so the group's slot (7.109 / 7.110, the
+ * whole-group transfers) has nothing to do with this one. The row draws the sentence inside itself,
+ * under its text and above its rule (`ListRow`'s `notice`), which is why the tab needs no new
+ * surface for it.
+ *
+ * It writes nothing, which is what the sentence says: opening a memory fetches one file. A reader
+ * who sees a panel fail to appear can wonder whether the memory is still intact, and this answer is
+ * the whole account of it.
+ *
+ * The sentence hangs off the scope's **key** and the memory's **file name**, never their titles: a
+ * title is a label (two Workspaces whose folders share a last segment read the same, and a memory's
+ * title may repeat across groups), while the key and the name are what the request was for and what
+ * the server's route took.
+ *
+ * Which words: an answer the server gave is read through `refusalText`, the rule every refusal in
+ * the app follows, so the same failure reads the same here as beside any other write.
+ */
+import { refusalText } from "../../lib/api-error";
+import { S } from "../../lib/strings";
+
+/** The sentence one refused read left, and which memory it was for. */
+export interface MemoryFileRefusal {
+ readonly scopeKey: string;
+ readonly fileName: string;
+ readonly text: string;
+}
+
+/** The sentence: which memory did not open, and why. */
+export function memoryViewRefused(title: string, error: unknown): string {
+ return S.memory.viewRefused(title, refusalText(error));
+}
+
+/**
+ * What this row draws for a refusal, if anything.
+ *
+ * The tab keeps one refusal at a time — an attempt supersedes the reason of the attempt before it —
+ * so the sentence belongs to the one memory it was made for: every other row in the list, in this
+ * group or another, must stay exactly as it was.
+ */
+export function memoryFileRefusalFor(
+ refusal: MemoryFileRefusal | null,
+ scopeKey: string,
+ fileName: string,
+): string | undefined {
+ if (refusal === null) return undefined;
+ if (refusal.scopeKey !== scopeKey || refusal.fileName !== fileName) return undefined;
+ return refusal.text;
+}
diff --git a/packages/web/src/features/agents/memory-tab.tsx b/packages/web/src/features/agents/memory-tab.tsx
index 252e3bb8..d0f1c9e4 100644
--- a/packages/web/src/features/agents/memory-tab.tsx
+++ b/packages/web/src/features/agents/memory-tab.tsx
@@ -56,7 +56,6 @@ import {
UploadIcon,
bodyWithoutFrontmatter,
buttonClass,
- toastError,
toastSuccess,
useCopied,
} from "@adelie/ui";
@@ -74,6 +73,8 @@ import { placeholderInsertRefused } from "./placeholder-insert-refusal";
import { useSaveConfirm } from "./save-confirm";
import { useAiBridge } from "../ai-create";
import { buildMemoryAddPrompt, buildMemoryEditPrompt } from "./memory-chat-prompts";
+import { memoryFileRefusalFor, memoryViewRefused } from "./memory-file-refusal";
+import type { MemoryFileRefusal } from "./memory-file-refusal";
import {
memoryExportRefused,
memoryGroupRefusalFor,
@@ -168,9 +169,9 @@ export function MemoryTab({
const [templateHasMemory, setTemplateHasMemory] = useState(true);
const [memoryDir, setMemoryDir] = useState("");
const [groups, setGroups] = useState<ScopeGroup[] | null>(null);
- // Tab-level error is the initial load failure only; an action that has nowhere to keep its
- // refusal — opening a memory, whose panel never got as far as opening — reports via toast, while
- // the ones below that draw the sentence where they asked do not toast as well.
+ // Tab-level error is the initial load failure only: every action below keeps its refusal where it
+ // asked (the slots under this one), so nothing that fails once the page is up becomes a
+ // notification that dismisses itself.
const [error, setError] = useState<string | null>(null);
const [switchBusy, setSwitchBusy] = useState(false);
// The server's words for a flip of the memory switch it refused, drawn under that card: the
@@ -184,6 +185,10 @@ export function MemoryTab({
// still there, so a notification that dismisses itself after six seconds is the one thing that
// would carry that reason away. One slot for both directions — a later attempt supersedes it.
const [groupRefusal, setGroupRefusal] = useState<MemoryGroupRefusal | null>(null);
+ // The reason one memory did not open, kept in the row whose eye button asked
+ // (memory-file-refusal.ts): the panel never came up, so that row is the only thing left holding
+ // the read's retry — and a notification would carry the reason away after six seconds.
+ const [viewRefusal, setViewRefusal] = useState<MemoryFileRefusal | null>(null);
const collapseKey = userId && projectId ? collapsedStoreKey(userId, projectId, agentId) : null;
const [collapsed, setCollapsed] = useState<Set<string>>(() => readCollapsedScopes(collapseKey));
const [memoryPrompt, setMemoryPrompt] = useState("");
@@ -378,13 +383,21 @@ export function MemoryTab({
const openView = async (scope: MemoryScopeInfo, file: MemoryFileInfo) => {
if (!projectId) return;
+ // A fresh attempt starts without the previous one's reason, whichever memory it was for.
+ setViewRefusal(null);
try {
const res = await api.getMemoryFile(projectId, agentId, scope.scopeKey, file.name);
setSheetSnap("half"); // Every mobile open starts at the browsing height, like the chat panels.
setViewing({ scope, file: res.file, content: res.content });
setViewOpen(true);
} catch (e) {
- toastError(apiErrorText(e));
+ // Handed to this row, which keeps the reason under its eye button — and nothing is toasted
+ // for it: the panel is what the person asked for, and it is not there to say anything.
+ setViewRefusal({
+ scopeKey: scope.scopeKey,
+ fileName: file.name,
+ text: memoryViewRefused(file.title, e),
+ });
}
};
@@ -607,20 +620,41 @@ export function MemoryTab({
);
// A memory's title is its file's identifier, so it keeps the data face on the code rung.
- const fileRow = (scope: MemoryScopeInfo, file: MemoryFileInfo) => (
- <ListRow
- key={file.name}
- as="li"
- title={<span className="font-mono text-[length:var(--ui-text-code-size)]">{file.title}</span>}
- description={file.description ? file.description : undefined}
- meta={
- <span className="tabular-nums">
- {file.updatedAt ?? formatRelativeDate(file.modifiedAt, locale)}
- </span>
- }
- trailing={rowActions(scope, file)}
- />
- );
+ const fileRow = (scope: MemoryScopeInfo, file: MemoryFileInfo) => {
+ const refusal = memoryFileRefusalFor(viewRefusal, scope.scopeKey, file.name);
+ return (
+ <ListRow
+ key={file.name}
+ as="li"
+ title={
+ <span className="font-mono text-[length:var(--ui-text-code-size)]">{file.title}</span>
+ }
+ description={file.description ? file.description : undefined}
+ meta={
+ <span className="tabular-nums">
+ {file.updatedAt ?? formatRelativeDate(file.modifiedAt, locale)}
+ </span>
+ }
+ trailing={rowActions(scope, file)}
+ /* A memory that did not open: this row still holds the eye button that retries it, so the
+ reason sits under the row rather than in a notification that dismisses itself
+ (memory-file-refusal.ts). */
+ notice={
+ refusal !== undefined ? (
+ <p
+ role="alert"
+ data-testid="memory-file-refusal"
+ data-tooltip={refusal}
+ data-tooltip-content="text"
+ className={`line-clamp-2 break-words text-xs ${toneInk.danger}`}
+ >
+ {refusal}
+ </p>
+ ) : undefined
+ }
+ />
+ );
+ };
/** Metadata + rendered body of the memory in view, shared by the Drawer and the Sheet. */
const viewMeta = viewing && (
diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.ts
index f1f541f9..29a8fed6 100644
--- a/packages/web/src/lib/strings-en.ts
+++ b/packages/web/src/lib/strings-en.ts
@@ -2500,6 +2500,9 @@ export const en: Strings = {
*/
importRefused: (scope: string, reason: string): string =>
`The memory group "${scope}" was not imported — this file could not be read, so no memory was changed: ${reason}`,
+ /** A memory that did not open (memory-file-refusal.ts), drawn in the row whose eye asked. */
+ viewRefused: (title: string, reason: string): string =>
+ `The memory "${title}" did not open — opening only reads, so no memory was changed: ${reason}`,
importScope: "Import",
importScopeHint: "Restore memories into this group from an exported JSON document",
importScopeLabel: (scope: string): string => `Import into ${scope}`,
diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.ts
index b1ca6e2d..094c269c 100644
--- a/packages/web/src/lib/strings.ts
+++ b/packages/web/src/lib/strings.ts
@@ -2559,6 +2559,13 @@ export const zh = {
*/
importRefused: (scope: string, reason: string): string =>
`记忆组「${scope}」没有导入,这个文件没有读成,记忆一条都没有被改动:${reason}`,
+ /**
+ * A memory that did not open (memory-file-refusal.ts), drawn in the row whose eye button asked.
+ * Says the attempt only read, because a panel that fails to appear is exactly the moment a
+ * reader wonders whether the memory survived it; the reason goes last, as in every refusal.
+ */
+ viewRefused: (title: string, reason: string): string =>
+ `记忆「${title}」没有打开,打开只是读取,记忆一条都没有被改动:${reason}`,
importScope: "导入",
importScopeHint: "从导出的 JSON 文档恢复记忆到该组",
importScopeLabel: (scope: string): string => `导入到${scope}`,
diff --git a/packages/web/test/memory-file-refusal.test.ts b/packages/web/test/memory-file-refusal.test.ts
new file mode 100644
index 00000000..ada794b6
--- /dev/null
+++ b/packages/web/test/memory-file-refusal.test.ts
@@ -0,0 +1,83 @@
+/**
+ * A memory that did not open (src/features/agents/memory-file-refusal.ts): the sentence the row
+ * that asked draws — and the one thing it must not do, speak for another memory.
+ *
+ * Opening a memory only reads one file: the panel never comes up when the read fails, so nothing is
+ * written and the row keeps its eye button as the retry. A reader who asked for a panel and did not
+ * get one wonders whether the memory survived it, which is what the sentence answers. What it has to
+ * get right: an answer the server gave speaks the interface's own language rather than the wire
+ * message (7.19's rule), a value with nothing to say falls back rather than showing an empty colon,
+ * and it names the memory it is about.
+ */
+import { afterEach, describe, expect, it } from "vitest";
+import { ApiError } from "../src/api/client";
+import { S, setActiveStrings, zh as ZH } from "../src/lib/strings";
+import { en as EN } from "../src/lib/strings-en";
+import {
+ memoryFileRefusalFor,
+ memoryViewRefused,
+} from "../src/features/agents/memory-file-refusal";
+
+afterEach(() => {
+ setActiveStrings(ZH);
+});
+
+describe("memoryViewRefused", () => {
+ it("reads a refusal through the code's own sentence, not the wire message", () => {
+ const line = memoryViewRefused("probe.md", new ApiError(500, "internal", "RAW ENGLISH"));
+ expect(line).not.toContain("RAW ENGLISH");
+ expect(line).toBe(S.memory.viewRefused("probe.md", S.errors.byCode.internal as string));
+ });
+
+ it("keeps what a failure that never reached the route has to say", () => {
+ expect(memoryViewRefused("probe.md", new Error("Failed to fetch"))).toBe(
+ S.memory.viewRefused("probe.md", "Failed to fetch"),
+ );
+ });
+
+ it("falls back to the generic text when the value has nothing to say", () => {
+ expect(memoryViewRefused("probe.md", undefined)).toBe(
+ S.memory.viewRefused("probe.md", S.common.unknownError),
+ );
+ });
+
+ it("names the memory that did not open", () => {
+ expect(memoryViewRefused("probe-memory.md", new Error("boom"))).toContain("probe-memory.md");
+ });
+
+ it("says opening only read, so no memory changed", () => {
+ // A panel that fails to appear is the one moment a reader wonders whether the attempt touched
+ // the file; the sentence answers that without claiming anything about its content.
+ expect(memoryViewRefused("probe.md", new Error("boom"))).toContain("记忆一条都没有被改动");
+ });
+
+ it("speaks the active language", () => {
+ setActiveStrings(EN);
+ expect(memoryViewRefused("probe.md", new ApiError(500, "internal", "RAW"))).toBe(
+ EN.memory.viewRefused("probe.md", EN.errors.byCode.internal as string),
+ );
+ expect(memoryViewRefused("probe.md", new Error("boom"))).toContain("no memory was changed");
+ });
+});
+
+describe("memoryFileRefusalFor", () => {
+ it("draws nothing when no read was refused", () => {
+ expect(memoryFileRefusalFor(null, "user", "probe.md")).toBeUndefined();
+ });
+
+ it("draws the reason in the row that asked, and only there", () => {
+ const refusal = { scopeKey: "user", fileName: "probe.md", text: "did not open" };
+ expect(memoryFileRefusalFor(refusal, "user", "probe.md")).toBe("did not open");
+ // Every other row must read exactly as it did before the attempt.
+ expect(memoryFileRefusalFor(refusal, "user", "other.md")).toBeUndefined();
+ expect(memoryFileRefusalFor(refusal, "ws:/root/adelie", "probe.md")).toBeUndefined();
+ });
+
+ it("claims by scope key and file name, so two memories that read alike stay apart", () => {
+ // A memory's title is a label it may share with a memory in another group; the key and the
+ // file name are what the request was for.
+ const refusal = { scopeKey: "ws:/root/a/adelie", fileName: "notes.md", text: "did not open" };
+ expect(memoryFileRefusalFor(refusal, "ws:/root/b/adelie", "notes.md")).toBeUndefined();
+ expect(memoryFileRefusalFor(refusal, "ws:/root/a/adelie", "notes.md")).toBe("did not open");
+ });
+});