A local-first multi-agent app development platform, built on PenguinHarness
fix(web): 文件面板的新建 / 重命名 / 删除被拒时,框留着、原因也留在框里
lmlihengeb9dd76ac05d
diff --git a/changelog/unreleased/2026-10-23-files-action-refusal.md b/changelog/unreleased/2026-10-23-files-action-refusal.mdnew file mode 100644index 00000000..363961c5--- /dev/null+++ b/changelog/unreleased/2026-10-23-files-action-refusal.md@@ -0,0 +1,49 @@+# Files panel: a refused New, rename or delete keeps its question — and the reason — instead of toasting++- **Date:** 2026-10-23+- **Type:** fix+- **Scope:** `web`+- **Breaking:** no++[中文](2026-10-23-files-action-refusal.zh.md)++The Files panel's three entry actions — New (file or folder), rename/move, and delete — all ask+first. A refusal used to arrive as a toast only: the card did stay open (nothing had been written),+but the reason landed in a notification that dismissed itself after six seconds and sat above the+card, while the entry it was about was still on the page and on disk. Rename and delete were a step+worse — the sentence still said "Refresh and try again", while the card's confirm button carried the+version marker the refused attempt had just proved stale, so pressing it again could only earn the+same refusal.++Now all three draw the reason inside the card that asked (`ConfirmModal`'s `refusal` slot, same+"Refused:" lead-in), and a `file_changed` refusal re-reads that entry's version: the confirm button+is disabled while it lands and then retries against the file as it is now. A New that lands on a+taken name behaves the same — the name stays in the field to be changed.++## Details++- `features/chat/workspace-browser.tsx`: `reportFileActionError` (a toast and nothing else) becomes+ two things — `fileActionReason` turns the failure into the one sentence the card shows, and+ `readActionVersion` reads the marker, with a re-read path. A re-read clears the version and sets+ `reading` first (the confirm goes grey and the card says the version is being read), then settles+ on the new marker. `beginFileAction` drops the previous reason as it opens the card — that+ sentence belonged to the entry the last attempt named.+- The New path judged `target_exists` itself; it now reports through `createRefusal`, which+ `beginCreate` clears when it opens.+- `S.files.changedBeforeAction` ends with "its version has been read again — retrying works right+ away" instead of "Refresh and try again": the behaviour changed, so the sentence follows (Chinese+ alongside).+- New browser test `e2e/files-action-refusal.spec.mjs` (three): a taken name keeps the card, the+ name and the reason (nothing to dismiss in the notification region), and the same button creates+ once the name is free — reopening without the old reason; a refused rename (`page.route` 500)+ keeps the card, its sentence and the file where it was, and the same button moves it once+ permitted; a delete refused with `file_changed` (`page.route` 409) shows the sentence naming that+ file, re-enables its confirm after the re-read, and the retry removes it.+- The existing "a taken name changes nothing" assertion in `e2e/files-folders.spec.mjs` narrows from+ "the page has this sentence" to "the dialog has this line", which is where it is drawn now.++## Compatibility++- No interface, wire-format, stored-data or dependency change: only *when* the card closes, *where*+ the reason is drawn, and *which* marker the confirm carries after a `file_changed`. No new copy+ beyond the existing `S.common.refused` lead-in.diff --git a/changelog/unreleased/2026-10-23-files-action-refusal.zh.md b/changelog/unreleased/2026-10-23-files-action-refusal.zh.mdnew file mode 100644index 00000000..9f2083a0--- /dev/null+++ b/changelog/unreleased/2026-10-23-files-action-refusal.zh.md@@ -0,0 +1,38 @@+# 文件面板:新建 / 重命名 / 删除被拒时,框留着、原因也留在框里++- **Date:** 2026-10-23+- **Type:** fix+- **Scope:** `web`+- **Breaking:** no++[English](2026-10-23-files-action-refusal.md)++右侧文件面板的三处入口动作 —— 新建文件 / 文件夹、重命名(也就是移动)、删除 —— 都先问一句。过去这句问法被拒时+只弹一条 toast:框确实还开着(什么都没写下去),但原因落在一条六秒后自己消失、还浮在框上方的通知里,而它说的那+一条文件在页面上、在磁盘上都还在。重命名与删除更糟一层:被拒时那句话还写着「刷新后可重试」,而框里的确认按钮带的+是被拒的那次已经作废的版本标记 —— 同一颗按钮再点一次只会换回同一句拒绝。++现在:三处的原因都画在发起它的那张卡片里(`ConfirmModal` 的 `refusal` 槽,前缀仍是「操作被拒绝:」);因+`file_changed` 被拒时还会重新读一次那一条的版本,确认按钮在读回来之前是灰的,回来后直接重试就落在文件此刻的样子+上。新建撞上已存在的名字也一样,名字留在输入框里等着改。++## 细节++- `features/chat/workspace-browser.tsx`:`reportFileActionError`(只管弹 toast)换成两个东西 ——+ `fileActionReason` 把失败翻成一句话交给框,`readActionVersion` 负责读版本,多一个「重读」的走法。重读时先把+ 版本清空、`reading` 置真(确认按钮因此灰着、框里写着「正在读取该文件的当前版本…」),再按新标记落回去。+ `beginFileAction` 打开框时顺手清掉上一次的原因(那句话属于上次点名的那一条)。+- 新建那条路原本自己判 `target_exists`,现在同样落在 `createRefusal` 里;`beginCreate` 打开时清空。+- 文案 `S.files.changedBeforeAction` 的尾巴从「刷新后可重试」改成「已按它现在的版本重新读取,可以直接重试」——+ 行为变了,句子跟着变(英文同步)。+- 新浏览器用例 `e2e/files-action-refusal.spec.mjs`(三条):新建撞名时框、名字与原因都在,通知区没有可点的按钮,+ 改个名字同一个按钮就建出来,重开不带上一次的原因;重命名被拒(`page.route` 500)时框留着、原因在里面、磁盘上+ 原封不动,放行后同一个按钮把它移过去;删除因 `file_changed` 被拒(`page.route` 409)时框里是点名那一条的句子,+ 确认按钮在重读之后恢复可点,重试即删掉。+- 既有用例 `e2e/files-folders.spec.mjs` 里那句「撞名被拒」的断言从「页面上有这句话」收窄到「对话框里有这一行」,+ 因为它现在画在框里。++## 兼容性++- 没有接口、传输格式、已存数据或依赖变化:只改了「框什么时候收、原因画在哪」,以及 `file_changed` 之后确认按钮+ 带的是哪个版本标记。除既有的 `S.common.refused` 前缀外没有新文案。diff --git a/docs/FORK-PROGRESS.md b/docs/FORK-PROGRESS.mdindex a561bab5..b59b0a95 100644--- a/docs/FORK-PROGRESS.md+++ b/docs/FORK-PROGRESS.md@@ -1411,6 +1411,17 @@ mock 路由导入序、`chat-page.tsx` 的旧探针体),自带 4 份用例反证与探针见「第一百一十四轮」一节。**还差什么**:同一次扫描里还有同形的写入没改(`agents` 的记忆文件删除与 `memory-tab` 的导入、`company` 的组织 / 员工 / 频道 / 手册各处、工程 / 工作区文件编辑器),按「一轮一处」留给后面的轮次。+- [x] **7.33 文件面板的新建 / 重命名 / 删除被拒时,框留着、原因也留在框里**(**2026-10-23 第一百一十八轮**+ 落地,提交见该节;1 处源码 `features/chat/workspace-browser.tsx` + 1 个新文件+ `packages/web/e2e/files-action-refusal.spec.mjs`(3 条用例)+ 既有用例一处断言收窄 + 两句文案+ (`changedBeforeAction` 的中英)+ changelog 一对,**无新依赖、不碰接口**):三处入口动作过去把失败弹成+ toast(框确实还开着,但原因六秒后自己消失、还浮在框上方),重命名 / 删除被拒时框里的确认按钮带的还是那次+ 已经作废的版本标记 —— 同一颗按钮只会换回同一句拒绝。**现在**:原因画在 `ConfirmModal` 的 `refusal` 槽里+ (既有的 `S.common.refused` 前缀),`file_changed` 被拒时重新读一次版本(读的过程中确认按钮灰着),重试+ 就落在文件此刻的样子上。细节、两态读数、反证与探针见「第一百一十八轮」一节。**还差什么**:同一条扫描线上+ 还剩 `components/layout/project-dialogs.tsx` 的删除项目、`features/agents/api-tab.tsx` 与+ `features/settings/agent-api-section.tsx` 的密钥保存,以及 `features/company/` 的日历 / 员工 / 组织 /+ 手册 / 频道各处;文件面板自己的**保存**(`save()`)仍是「先关框再写」,要不要同一套口径留给后面的轮次定。## 发布 v0.2.0(2026-10-05)diff --git a/packages/web/e2e/files-action-refusal.spec.mjs b/packages/web/e2e/files-action-refusal.spec.mjsnew file mode 100644index 00000000..24b9bdc1--- /dev/null+++ b/packages/web/e2e/files-action-refusal.spec.mjs@@ -0,0 +1,198 @@+/**+ * Regression: the Files panel's three entry actions — New, rename/move, delete — ask in a+ * `ConfirmModal`, and a refused write keeps that question, with the server's words inside it.+ *+ * All three used to report a failure as a toast: the card stayed open (nothing was written), but+ * the reason arrived as a notification that dismissed itself after six seconds and sat above the+ * card the user was still looking at — while the entry it was about was still there. A rename+ * whose version had gone stale made that worse: the retry carried the same stale marker, so the+ * button beside the vanished reason could only fail again.+ *+ * Now the reason renders in the dialog's `refusal` slot, and a `file_changed` refusal re-reads+ * the entry's version, so the same button retries against the file as it is now.+ *+ * Every refusal here that the server cannot be asked to produce on demand (a read-only+ * Workspace, a file rewritten mid-decision) is a `page.route` answer; the taken name is the+ * server's own.+ */+import fs from "node:fs";+import os from "node:os";+import path from "node:path";+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";++/** The mock model the Project needs before the page is usable (the onboarding overlay). */+async function setUp(page, user, files) {+ const dir = path.join(fs.mkdtempSync(path.join(os.tmpdir(), "e2e-files-refusal-")), "files");+ for (const [rel, text] of Object.entries(files)) {+ fs.mkdirSync(path.dirname(path.join(dir, rel)), { recursive: true });+ fs.writeFileSync(path.join(dir, rel), text);+ }+ fs.mkdirSync(dir, { recursive: true });+ await provisionAndLogin(page.request, user, P);+ 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();+ const res = await page.request.post(+ `${BASE}/api/projects/${projectId}/agents/default_agent/sessions`,+ { data: { workspace: dir } },+ );+ expect(res.ok(), "create session").toBeTruthy();+ return { dir, sessionId: (await res.json()).session.sessionId };+}++async function openFiles(page, sessionId) {+ await page.goto(`${BASE}/chat/${sessionId}`);+ await page.getByPlaceholder(/输入消息/).waitFor();+ await page.getByTestId("dock-toggle-right").click();+ await page.getByTestId("dock-pick-workspace").click();+ const dock = page.getByTestId("dock");+ await dock.locator('[role="tree"]').waitFor();+ return dock;+}++/** The row's context menu → one of its two entry actions. */+async function askFromRow(page, dock, treePath, item) {+ await dock.locator(`[data-tree-path="${treePath}"]`).click({ button: "right" });+ await page.getByRole("menuitem", { name: item }).click();+ const dialog = page.getByRole("dialog");+ await expect(dialog).toBeVisible();+ return dialog;+}++test("a taken name keeps the New dialog with its reason, and a name that is free still creates", async ({+ page,+}) => {+ const { dir, sessionId } = await setUp(page, "filesrefusal1", { "README.md": "# hi\n" });+ const dock = await openFiles(page, sessionId);+ await dock.locator('[data-tree-path="README.md"]').waitFor();++ await dock.getByRole("button", { name: "新建", exact: true }).click();+ await page.getByRole("menuitem", { name: "新建文本文件" }).click();+ const dialog = page.getByRole("dialog");+ await dialog.getByRole("textbox").fill("README.md");+ await dialog.getByRole("button", { name: "创建" }).click();++ // The server's own refusal, in the card that asked: the name is still in the field to be+ // changed, and the notification region holds nothing to dismiss.+ await expect(dialog.getByText("操作被拒绝:README.md 已存在,未做改动。")).toBeVisible();+ await expect(page.getByRole("region", { name: "通知" }).getByRole("button")).toHaveCount(0);+ await expect(dialog.getByRole("textbox")).toHaveValue("README.md");+ expect(fs.readFileSync(path.join(dir, "README.md"), "utf8")).toBe("# hi\n");++ // The same card creates once the name is free, and reopens without the old reason.+ await dialog.getByRole("textbox").fill("notes.md");+ await dialog.getByRole("button", { name: "创建" }).click();+ await expect(dialog).toHaveCount(0);+ await expect(dock.locator('[data-tree-path="notes.md"]')).toBeVisible();+ expect(fs.readFileSync(path.join(dir, "notes.md"), "utf8")).toBe("");++ await dock.getByRole("button", { name: "新建", exact: true }).click();+ await page.getByRole("menuitem", { name: "新建文本文件" }).click();+ await expect(page.getByRole("dialog")).not.toContainText("操作被拒绝");+ await page.getByRole("dialog").getByRole("button", { name: "取消" }).click();+});++test("a refused move keeps the dialog, its reason and the file where it was", async ({ page }) => {+ const { dir, sessionId } = await setUp(page, "filesrefusal2", { "docs/notes.md": "notes\n" });+ const dock = await openFiles(page, sessionId);+ await dock.locator('[data-tree-path="docs"]').click();+ await dock.locator('[data-tree-path="docs/notes.md"]').waitFor();++ const REFUSAL = { code: "workspace_read_only", message: "workspace is read-only" };+ const moves = [];+ let refuse = true;+ await page.route("**/api/sessions/*/files/move", async (route) => {+ if (route.request().method() !== "POST") return route.fallback();+ moves.push(route.request().postDataJSON());+ if (!refuse) return route.fallback();+ await route.fulfill({+ status: 500,+ contentType: "application/json",+ body: JSON.stringify({ error: REFUSAL }),+ });+ });++ const dialog = await askFromRow(page, dock, "docs/notes.md", "重命名 / 移动");+ const sentence = await dialog.innerText();+ await dialog.getByRole("textbox").fill("archive/notes.md");+ await dialog.getByRole("button", { name: "移动" }).click();++ await expect(dialog.getByText(`操作被拒绝:${REFUSAL.message}`)).toBeVisible();+ await expect(page.getByRole("region", { name: "通知" }).getByRole("button")).toHaveCount(0);+ expect(moves).toHaveLength(1);+ // The card reads as it did before the attempt, plus the one refusal line.+ expect((await dialog.innerText()).replace(/\n操作被拒绝:[^\n]*/, "")).toBe(sentence);+ expect(moves[0].to).toBe("archive/notes.md");+ expect(fs.readFileSync(path.join(dir, "docs", "notes.md"), "utf8")).toBe("notes\n");+ expect(fs.existsSync(path.join(dir, "archive"))).toBe(false);++ // The retry is the same button, and this time the move lands.+ refuse = false;+ await dialog.getByRole("button", { name: "移动" }).click();+ await expect(dialog).toHaveCount(0);+ await expect(dock.locator('[data-tree-path="docs/notes.md"]')).toHaveCount(0);+ expect(fs.readFileSync(path.join(dir, "archive", "notes.md"), "utf8")).toBe("notes\n");+});++test("a delete refused because the file moved reads its version again, so the retry lands", async ({+ page,+}) => {+ const { dir, sessionId } = await setUp(page, "filesrefusal3", { "docs/notes.md": "notes\n" });+ const dock = await openFiles(page, sessionId);+ await dock.locator('[data-tree-path="docs"]').click();+ await dock.locator('[data-tree-path="docs/notes.md"]').waitFor();++ const deletes = [];+ let refuse = true;+ await page.route("**/api/sessions/*/files/content*", async (route) => {+ if (route.request().method() !== "DELETE") return route.fallback();+ deletes.push(route.request().url());+ if (!refuse) return route.fallback();+ await route.fulfill({+ status: 409,+ contentType: "application/json",+ body: JSON.stringify({+ error: { code: "file_changed", message: "the file is not the one that was read" },+ }),+ });+ });++ const dialog = await askFromRow(page, dock, "docs/notes.md", "删除");+ await expect(dialog.getByRole("button", { name: "删除", exact: true })).toBeEnabled();+ await dialog.getByRole("button", { name: "删除", exact: true }).click();++ // The precondition refused it: the sentence names the file and says what happened, in the card+ // itself. The confirm is disabled only while the fresh version is being read.+ await expect(dialog.getByText(/操作被拒绝:notes\.md 在你决定期间被改写/)).toBeVisible();+ await expect(page.getByRole("region", { name: "通知" }).getByRole("button")).toHaveCount(0);+ expect(deletes).toHaveLength(1);+ await expect(dialog.getByRole("button", { name: "删除", exact: true })).toBeEnabled();+ expect(fs.readFileSync(path.join(dir, "docs", "notes.md"), "utf8")).toBe("notes\n");++ // Retrying is the same button and now sends the marker of the file as it is: the delete lands.+ refuse = false;+ await dialog.getByRole("button", { name: "删除", exact: true }).click();+ await expect(dialog).toHaveCount(0);+ expect(deletes).toHaveLength(2);+ expect(fs.existsSync(path.join(dir, "docs", "notes.md"))).toBe(false);+ await expect(dock.locator('[data-tree-path="docs/notes.md"]')).toHaveCount(0);+});diff --git a/packages/web/e2e/files-folders.spec.mjs b/packages/web/e2e/files-folders.spec.mjsindex 22045670..56317fd6 100644--- a/packages/web/e2e/files-folders.spec.mjs+++ b/packages/web/e2e/files-folders.spec.mjs@@ -108,7 +108,10 @@ test("new folders and text files are made where asked, and a taken name changesawait page.getByRole("menuitem", { name: "新建文本文件" }).click();await page.getByRole("dialog").getByRole("textbox").fill("README.md");await page.getByRole("dialog").getByRole("button", { name: "创建" }).click();- await expect(page.getByText("README.md 已存在,未做改动。").first()).toBeVisible();+ // The refusal is the dialog's own: the name stays in the field and the reason sits under it.+ await expect(+ page.getByRole("dialog").getByText("操作被拒绝:README.md 已存在,未做改动。"),+ ).toBeVisible();await expect(page.getByRole("dialog")).toBeVisible();expect(fs.readFileSync(path.join(dir, "README.md"), "utf8")).toBe("# hi\n");});diff --git a/packages/web/src/features/chat/workspace-browser.tsx b/packages/web/src/features/chat/workspace-browser.tsxindex adfbffd3..2f23a8a6 100644--- a/packages/web/src/features/chat/workspace-browser.tsx+++ b/packages/web/src/features/chat/workspace-browser.tsx@@ -574,6 +574,14 @@ export function WorkspaceBrowser({const [renameTarget, setRenameTarget] = useState<FileActionTarget | null>(null);const [renameDraft, setRenameDraft] = useState("");const [removeTarget, setRemoveTarget] = useState<FileActionTarget | null>(null);+ /**+ * The server's own words for an entry action that was refused, rendered inside the dialog+ * that asked. A refusal leaves the question standing — the entry is still there, or still+ * where it was — so the reason belongs beside the button that retries it rather than in a+ * toast that dismisses itself over the card the user is still looking at.+ */+ const [renameRefusal, setRenameRefusal] = useState<string | null>(null);+ const [removeRefusal, setRemoveRefusal] = useState<string | null>(null);const [fileActionBusy, setFileActionBusy] = useState(false);/** The open "discard unsaved changes?" question, resolving with the answer. */const [discardPrompt, setDiscardPrompt] = useState<{ resolve: (ok: boolean) => void } | null>(@@ -618,6 +626,8 @@ export function WorkspaceBrowser({const [createTarget, setCreateTarget] = useState<{ kind: "file" | "dir"; dir: string } | null>(null,);+ /** The refusal of a New the server did not write, shown in the New dialog (see renameRefusal). */+ const [createRefusal, setCreateRefusal] = useState<string | null>(null);const [createName, setCreateName] = useState("");const [creating, setCreating] = useState(false);const previewMenu = useRowContextMenu();@@ -952,6 +962,29 @@ export function WorkspaceBrowser({[promptDiscard, discardEditor],);+ /**+ * Reads the version marker an entry action is preconditioned on.+ *+ * A dialog that stays open on a `file_changed` refusal reads it again (`again`): the retry must+ * act on the file as it is now, or it would earn the very same refusal, so the marker is+ * dropped and re-read with the confirm disabled in between.+ */+ const readActionVersion = useCallback(+ (path: string, action: "rename" | "delete", again = false): void => {+ const settle = (version: string | null, reading: boolean) => {+ const next = (t: FileActionTarget | null): FileActionTarget | null =>+ t !== null && t.path === path ? { ...t, version, reading } : t;+ if (action === "rename") setRenameTarget(next);+ else setRemoveTarget(next);+ };+ if (again) settle(null, true);+ void fetchFileVersion(filesRef.current.fileUrl(path))+ .then((version) => settle(version, false))+ .catch(() => settle(null, false));+ },+ [],+ );+/*** Puts one of the two entry actions on screen and, for a file, starts reading its current* version.@@ -968,40 +1001,34 @@ export function WorkspaceBrowser({if (action === "rename") {setRenameDraft(path);setRenameTarget(opened);+ setRenameRefusal(null);} else {setRemoveTarget(opened);+ setRemoveRefusal(null);}if (kind === "dir") return;- const settle = (version: string | null) => {- const next = (t: FileActionTarget | null): FileActionTarget | null =>- t !== null && t.path === path ? { path, kind, version, reading: false } : t;- if (action === "rename") setRenameTarget(next);- else setRemoveTarget(next);- };- void fetchFileVersion(filesRef.current.fileUrl(path))- .then(settle)- .catch(() => settle(null));+ readActionVersion(path, action);};const editing = editorRef.current;if (kind === "dir" && (editing === null || !isWithin(editing.path, path))) open();else void navigateGuarded(null, open);},- [navigateGuarded],+ [navigateGuarded, readActionVersion],);/**- * Reports the failures the entry actions share. Nothing was changed, so this is a toast and- * not a dialog: there is no decision left to take, only the same action again on the entry as- * it now is.+ * The server's sentence for an entry action that did not land, in the words its dialog shows+ * (see renameRefusal). Nothing was changed, so there is no second decision to take — only the+ * same action again, which is why this text belongs beside the button that retries it.*/- const reportFileActionError = (err: unknown, path: string, to?: string): void => {+ const fileActionReason = (err: unknown, path: string, to?: string): string => {if (err instanceof ApiError && err.code === "file_changed") {- toastError(S.files.changedBeforeAction(baseName(path)));- } else if (err instanceof ApiError && err.code === "target_exists" && to !== undefined) {- toastError(S.files.targetExists(to));- } else {- toastError(apiErrorText(err));+ return S.files.changedBeforeAction(baseName(path));+ }+ if (err instanceof ApiError && err.code === "target_exists" && to !== undefined) {+ return S.files.targetExists(to);}+ return apiErrorText(err);};/**@@ -1059,7 +1086,12 @@ export function WorkspaceBrowser({followMove(target.path, to);toastSuccess(S.files.renamed(baseName(to)));} catch (err) {- reportFileActionError(err, target.path, to);+ // A marker that was already stale is not something to retry with: read the entry again,+ // then leave the reason beside the button (the dialog itself stays open).+ if (err instanceof ApiError && err.code === "file_changed") {+ readActionVersion(target.path, "rename", true);+ }+ setRenameRefusal(fileActionReason(err, target.path, to));} finally {setFileActionBusy(false);}@@ -1076,7 +1108,10 @@ export function WorkspaceBrowser({refreshAll();toastSuccess(S.files.deleted(baseName(target.path)));} catch (err) {- reportFileActionError(err, target.path);+ if (err instanceof ApiError && err.code === "file_changed") {+ readActionVersion(target.path, "delete", true);+ }+ setRemoveRefusal(fileActionReason(err, target.path));} finally {setFileActionBusy(false);}@@ -1570,6 +1605,7 @@ export function WorkspaceBrowser({*/const beginCreate = (kind: "file" | "dir", dir: string): void => {setCreateName(kind === "file" ? DEFAULT_TEXT_FILE_NAME : "");+ setCreateRefusal(null);setCreateTarget({ kind, dir });};@@ -1606,11 +1642,12 @@ export function WorkspaceBrowser({editOnOpen.current = path;openFile(path, { locate: true });} catch (err) {- if (err instanceof ApiError && err.code === "target_exists") {- toastError(S.files.targetExists(path));- } else {- toastError(apiErrorText(err));- }+ if (scopeKeyRef.current !== key) return;+ setCreateRefusal(+ err instanceof ApiError && err.code === "target_exists"+ ? S.files.targetExists(path)+ : apiErrorText(err),+ );} finally {if (scopeKeyRef.current === key) setCreating(false);}@@ -2709,6 +2746,7 @@ export function WorkspaceBrowser({confirmDisabled={!actionReady(renameTarget) || renameDraft.trim() === ""}busy={fileActionBusy}tone="primary"+ refusal={renameRefusal === null ? undefined : S.common.refused(renameRefusal)}onClose={() => setRenameTarget(null)}onConfirm={() => void applyRename()}>@@ -2733,6 +2771,7 @@ export function WorkspaceBrowser({cancelLabel={S.common.cancel}confirmDisabled={newEntryName(createName) === ""}busy={creating}+ refusal={createRefusal === null ? undefined : S.common.refused(createRefusal)}onClose={() => setCreateTarget(null)}onConfirm={() => void applyCreate()}>@@ -2764,6 +2803,7 @@ export function WorkspaceBrowser({cancelLabel={S.common.cancel}confirmDisabled={removeTarget?.version == null}busy={fileActionBusy}+ refusal={removeRefusal === null ? undefined : S.common.refused(removeRefusal)}onClose={() => setRemoveTarget(null)}onConfirm={() => void applyDelete()}>diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.tsindex 960f8aa8..b8b01a80 100644--- a/packages/web/src/lib/strings-en.ts+++ b/packages/web/src/lib/strings-en.ts@@ -4134,7 +4134,7 @@ export const en: Strings = {"This file's current version could not be read, so the action is not offered.",/** The version precondition refused it: the Agent wrote the file while the question was on screen. */changedBeforeAction: (name: string): string =>- `${name} was rewritten while you were deciding, most likely by the Agent during its turn, so nothing was changed. Refresh and try again.`,+ `${name} was rewritten while you were deciding, most likely by the Agent during its turn, so nothing was changed. Its version has been read again — retrying works right away.`,conflictTitle: "File changed on disk",conflictBody: (name: string): string =>`${name} was rewritten after you opened it, most likely by the Agent during its turn, so nothing was saved. Overwrite it with your version, or keep editing and copy what you need out first — either way your text is kept.`,diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.tsindex 4e5cdd54..70e70fd3 100644--- a/packages/web/src/lib/strings.ts+++ b/packages/web/src/lib/strings.ts@@ -4171,7 +4171,7 @@ export const zh = {actionVersionFailed: "读不到该文件的当前版本,因此不执行此操作。",/** The version precondition refused it: the Agent wrote the file while the question was on screen. */changedBeforeAction: (name: string): string =>- `${name} 在你决定期间被改写(多半是 Agent 在本轮写入的),因此未做任何改动。刷新后可重试。`,+ `${name} 在你决定期间被改写(多半是 Agent 在本轮写入的),因此未做任何改动。已按它现在的版本重新读取,可以直接重试。`,conflictTitle: "文件在磁盘上已变更",conflictBody: (name: string): string =>`${name} 在你打开之后被重写(多半是 Agent 本轮写的),本次没有保存任何内容。可以用你的版本覆盖它,也可以继续编辑、先把需要的内容取出来——两种选择都会保留你的文本。`,