Skip to content

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

fix(web): 智能体设置里还原配置、更新内核被拒时,原因留在框里(7.48)

lmliheng6b324138339b
diff --git a/changelog/unreleased/2026-10-26-agent-config-refusal.md b/changelog/unreleased/2026-10-26-agent-config-refusal.md
new file mode 100644
index 00000000..7469dd28
--- /dev/null
+++ b/changelog/unreleased/2026-10-26-agent-config-refusal.md
@@ -0,0 +1,38 @@
+# Agent settings: a refused config reset or kernel update keeps the reason in the card
+
+- **Date:** 2026-10-26
+- **Type:** fix
+- **Scope:** `web`
+- **Breaking:** no
+
+[中文](2026-10-26-agent-config-refusal.zh.md)
+
+The Agent settings overview asks two questions that rewrite the config file: restore the defaults,
+and advance the kernel. Both cards already stayed open on a refusal and changed nothing — the only
+thing lost was the sentence. Why the server refused went into a toast alone, gone six seconds
+later, while the card that asked was still on screen and its retry button sat at the bottom.
+
+Both cards now hold their own answer: a refusal draws the server's words under the sentence the
+card asked with (the app's existing "Refused:" lead-in), right beside the button that retries it.
+Closing or reopening the card drops the previous reason. The Agents list's batch kernel update and
+this page's API tab have worked this way for a while; these two were the last on the page that had
+not caught up.
+
+## Details
+
+- `features/agents/agent-settings-page.tsx`: the overview gains `resetRefusal` / `kernelRefusal`,
+ handed to `ConfirmModal`'s `refusal` slot the way the API tab does it (the server's own words in
+ state, wrapped in `S.common.refused` when drawn); both the open and the close paths clear it, and
+ a failure no longer toasts. The overview's name/description save still reports through a toast —
+ it has no card, and the fields keep what was typed.
+- New browser spec `e2e/agent-config-refusal.spec.mjs`, two cases: with `…/config/reset` and
+ `…/config/kernel-update` refused at `page.route` 500, the reason is inside the card, the
+ notification region never carries it, the card's own sentence is byte-for-byte what it was, and
+ the server's config is unwritten; cancelling and reopening shows no stale reason, and the retry
+ lands and closes the card. The kernel case edits `kernelOutdated` into the config read so its
+ update button is live (a development data root ships the default Agent up to date).
+
+## Compatibility
+
+- No interface, wire-format, stored-data or dependency change: only *where* a refusal is reported.
+ No new copy beyond the existing `S.common.refused` lead-in.
diff --git a/changelog/unreleased/2026-10-26-agent-config-refusal.zh.md b/changelog/unreleased/2026-10-26-agent-config-refusal.zh.md
new file mode 100644
index 00000000..00d06e6d
--- /dev/null
+++ b/changelog/unreleased/2026-10-26-agent-config-refusal.zh.md
@@ -0,0 +1,32 @@
+# 智能体设置:还原配置与更新内核被拒时,原因留在框里
+
+- **Date:** 2026-10-26
+- **Type:** fix
+- **Scope:** `web`
+- **Breaking:** no
+
+[English](2026-10-26-agent-config-refusal.md)
+
+智能体设置的概览页有两个改写配置文件的确认框:还原为默认配置、更新内核。它们被拒时框本来就开着、
+没改动任何东西,丢的只有那句话 —— 服务端为什么拒绝只落进一条通知,几秒后自己消失,而框还留在眼前,
+重试按钮就在最下面。
+
+现在两个框都自己留着回答:被拒时服务端原话画在框里那一句话的下面(应用既有的「操作被拒绝:」前缀),
+就在重试按钮旁边。关掉框或重新打开都不会带上一次的原因。智能体列表页的同一次批量内核更新、以及本页 API
+标签页的三张卡早就这么做了,这一处是同一套口径没有跟上的最后两处。
+
+## 细节
+
+- `features/agents/agent-settings-page.tsx`:概览页新增 `resetRefusal` / `kernelRefusal` 两份状态,
+ 两个确认框把它们交给 `ConfirmModal` 的 `refusal` 槽(与 API 标签页一致,状态里存服务端原话、
+ 画的时候套 `S.common.refused` 前缀);打开与关闭两条路径都清空它,失败不再弹通知。
+ 概览页的「保存名称 / 描述」那条路径仍用通知 —— 它没有确认框,字段里的输入本来就留着。
+- 新增浏览器用例 `e2e/agent-config-refusal.spec.mjs`,两条:用 `page.route` 把 `…/config/reset` 与
+ `…/config/kernel-update` 拒成 500 之后,原因在框里、通知区里没有、框与它原来那句话一个字节没变、
+ 服务端的配置也没被改写;取消后重开不带旧原因,重试才落地并关框。内核那一条把配置读取里的
+ `kernelOutdated` 改成 true,才有可点的更新按钮(开发数据根里默认智能体本来就是最新的)。
+
+## 兼容性
+
+- 没有接口、传输格式、已存数据或依赖变化:只改了「被拒时原因画在哪」。除既有的 `S.common.refused`
+ 前缀外没有新文案。
diff --git a/docs/FORK-PROGRESS.md b/docs/FORK-PROGRESS.md
index b09ad748..039d27d3 100644
--- a/docs/FORK-PROGRESS.md
+++ b/docs/FORK-PROGRESS.md
@@ -1585,6 +1585,16 @@ mock 路由导入序、`chat-page.tsx` 的旧探针体),自带 4 份用例
**顺手修掉一处真 bug**:一次「保存预算」过去会写两次 —— 写入在途时输入框被置灰、焦点随之离开,
而「焦点离开也保存」又把同一次写入发一遍;编辑器现在用一个在途标记把第二发挡掉(两态读数里
`writes` 从 2 变 1)。细节、两态读数与反证见「第一百三十三轮」一节。
+- [x] **7.48 智能体设置里还原配置 / 更新内核被拒时,原因留在框里**(**2026-10-26 第一百三十五轮**落地,
+ 提交见该节;1 处源码 `features/agents/agent-settings-page.tsx`(+18 −4:概览页新增 `resetRefusal` /
+ `kernelRefusal` 两份状态,两个 `ConfirmModal` 接上 `refusal` 槽,开框 / 关框都清空,失败不再弹通知)
+ + 1 个新文件 `packages/web/e2e/agent-config-refusal.spec.mjs`(2 条用例)+ changelog 一对,
+ **无新依赖、不碰接口、无新文案**):台账点名的下一站「插件市场 / 智能体设置 / 定时任务面板里那些带
+ 确认的写入」里,插件市场(批量更新、删插件)与定时任务面板(删除)早已接好 `refusal` 槽,只剩智能体
+ 设置概览页这两张;而同一操作在智能体列表页(批量内核更新,`agents-page.tsx` 的 `kernelRefusal`)与本页
+ API 标签页都已经是「原因留在框里」,这两张是最后一处没跟上的。**现在**:被拒时服务端原话经
+ `S.common.refused` 画进框里那一句话下面,重试就是同一个按钮;重新打开不带上一次的原因。
+ 细节、两态读数与反证见「第一百三十五轮」一节。
## 发布 v0.2.0(2026-10-05)
@@ -2234,6 +2244,8 @@ v0.2.2」——它只加台账里 v0.2.2 那一节与两行表格,**跟本轮
| 2026-10-26 | 7.46 | **新建工单被拒时,表单留着、填过的每个字段也留着**(不是移植:1 处源码 `packages/web/src/features/company/tickets-page.tsx` —— `CreateTicketDialog` 加一份 `refusal` 状态、写入失败的原话改由 `NoticeStrip` 画在字段上方、每次开表单先清空它、`Modal` 的 `onClose` 在写入在途时不再响应(`toastError` 也从这份文件的 import 里去掉了)+ 1 个新文件 `packages/web/e2e/ticket-create-refusal.spec.mjs`(1 条用例)+ changelog 一对,**无新依赖、不碰接口、无新文案**):那条「点击即关、失败只弹 toast」扫描线在 `features/company/` 上的第十处,也是其中唯一一处**写入不关框、只是原因会消失**的写点 —— 被拒之后几秒,通知没了,面板一点没变、按钮又亮着,没有任何东西说明为什么。现在原因留在表单里、字段原样留着,重试就是再按一次 | 六包 `typecheck` `EXIT=0`;`npx oxlint` 两个改动文件 0 警告 0 错误;`prettier --check` 与 `git diff --check` 干净 · 逐包 test `EXIT=0`:core **1420 通过 / 6 跳过**(69 文件)· ui **1053**(130)· cli **561**(38)· web **3249 通过 / 2 跳过**(265 文件)· server **2970 通过 / 4 跳过**(203 文件)· **真服务**(8950)+ mock(8951)+ 当天新构建的 `packages/{core,server,web}/dist`:新 spec **1 / 1 通过(3.3s)**,回归 `ticket-refusal.spec.mjs` **5 / 5 通过**;**反证**:把那一处源码 `git stash push --`(只带这一个路径)、重建 web → 同一条命令 **1 failed**(`element(s) not found`:改前表单里没有那句原话)· **两态探针**(`r132/probe.mjs`,各跑一次,同一个 `page.route` 500,读数取被拒后 1.5 s 与 6.5 s 两次):**改前** `reasonInForm:0`、`reasonInNotice:1 → 0`(通知几秒后自己消失,截图 `r132/before/shots/3-six-seconds-later.png` 里表单还在、一句原因都没有);**改后** `reasonInForm:1`、`reasonInNotice:0`,6.5 s 后原样还在(截图 `r132/after/shots/2-refused.png` 里红色提示条在标题上方);两态服务端上的工单数都是 0、两态 console 的 error 只有既有的 `/machines` 403 与刻意造的 500,无 `pageerror` · 端口只用 8950 / 8951(跑完都已停),3003 / 3004 / 4000 / 7364 / 7369 一个没碰 | `df07b72d` |
| 2026-10-26 | 7.47 | **财务页改预算被拒时,框留着、填过的金额与原因都留着**(不是移植:1 处源码 `packages/web/src/features/company/finance-page.tsx`(+46 −5:`BudgetEditor` 多一份 `refusal` 与一句「读不懂」的自有提示(复用既有 `budgetHint` 文案)、画在框下方那一行(`role="alert"`);`FinancePage` 把拒绝文案按员工存在 `budgetRefusal` 里,开框 / 取消 / 落地都清掉;`saveBudget` 的 `catch` 不再 `toastError`,`toastError` 也从这份文件的 import 里去掉了。**顺手修一处真 bug**:写入在途时输入框被置灰、焦点随之离开,而「焦点离开也保存」又把同一次写入发了一遍 —— 一次保存过去写两次;编辑器现在用一个在途标记(`asking`,`busy` 落下时重置)挡掉第二发)+ 1 个新文件 `packages/web/e2e/finance-budget-refusal.spec.mjs`(2 条用例:被拒 → 取消重开 → 重试落地;读不懂的金额一次都不写)+ changelog 一对,**无新依赖、不碰接口、无新文案**):7.46 末尾点名的下一处里最靠前的「财务」那一处,也是那条「原因只进 toast」扫描线在这一页上的第十一处 | 六包 `typecheck` **`EXIT=0`**(六个 `Done`;`gen:ifaces` 报 **`src/ifaces.json unchanged`**,195 接口 / 589 类型 —— 本笔不动服务契约)· `npx oxlint` 两个改动文件 **0 警告 0 错误** · 四个改动文件`prettier --check` 干净 · `git diff --check` 干净 · 逐包 test **`EXIT=0`、0 失败**:core **69 通过文件 + 1 跳过 / 1420 通过 / 6 跳过** · ui **130 文件 / 1053 通过** · cli **38 文件 / 561 通过** · web **265 文件 / 3249 通过 / 2 跳过** · server **203 文件 / 2970 通过 / 4 跳过** · hmr 无测试文件 · **真服务 + 真浏览器单 spec**(`/root/adelie-fork-data/r133-e2e`,服务 8950、mock 8951,`packages/{core,server,web}/dist` 都是本轮新构建):新 spec **2 passed(4.7s)**;相邻回归 `company.spec.mjs` **1 passed(22.0s)** · **整套浏览器 e2e**(`SKIP_BUILD=1 bash e2e/run.sh`,自带 mock 与 `mktemp` 数据根):**164 passed(10.3m)、0 failed** · **反证(同一份 spec,两种产物)**:把这一处源码 `git stash push -- packages/web/src/features/company/finance-page.tsx`(只带这一个路径)、重建 web → 同一条命令 **2 failed**(第一条死在框里没有那句原话,第二条死在 `每月上限` 那条提示从 `role=alert` 里找不到);`git stash pop` 后重建即回到 2 / 2 · **两态实测真看一眼**(探针 `r133/probe.mjs`,改后产物起在 8950、改前产物(`r133/before-dist`)另起一台 8960,各一次、同一个 `page.route` 500,1440×900,读数取被拒后 1.5 s 与 6.5 s 两次):**改前** `{boxVisible:true, reasonInBox:0, reasonInNotice:2, value:"42"}` → 6.5 s 后 `reasonInNotice:0`(屏幕上一点解释都没有了),`writes:2`(**一次保存写了两次**);**改后** `{boxVisible:true, reasonInBox:1, reasonInNotice:0, value:"42"}`,6.5 s 后原样还在,`writes:1`;两态服务端上的预算都是原来的 100,截图 `r133/{before,after}/shots/{3-refused,4-six-seconds-later}.png` 里正好是「改前框里 42、上方两条红 toast、框下一句都没有」对「改后框下那行『操作被拒绝:the org chart is mid-rewrite』」;console 里的 error 只有既有的 `/machines` 403 与刻意造的 500,无 `pageerror` · 端口只用 8950 / 8951 / 8960(跑完都已停),3003 / 3004 / 4000 / 7364 / 7369 一个没碰;数据只落在 `/root/adelie-fork-data/r133-{e2e,before}` 与 scratchpad 的 `r133/` 下(`packages/*/dist`、`packages/web/test-results/` 都是产物,未 `git add`)· 没有切版本号、没发 npm、没发安装包、没发发布汇总 | `467c076d` |
| 2026-10-26 | 用户点单(火山方舟分组 + 视频输入输出) | **模型库多一个 Volcengine Ark 分组(11 条模型行),对话里能发视频、能看视频,另加一个 Seedance 出视频的插件**(不是移植:`packages/core/src/state/model-catalog.ts` 加 `volcengine` 分组、`supportsVideo` 与 `catalogSupportsVideo`;`pnpm patch` 给 agenthub 加 `video_url` 内容项(`patches/@prismshadow__agenthub.patch` + `patchedDependencies`);core / server / cli / web 四层把视频当一等输入(预算、按引用、轨迹播放器、窗口化历史);`packages/server/src/services/trace-images.ts` 改名合并为 `trace-media.ts` 并新增 `GET /:sessionId/trace-video`;新插件 `plugins/use-seedance`(`@adelie/use-seedance`,走方舟异步出片接口);新增 6 个测试文件与 3 对 changelog;两家品牌图标各一枚):用户 2026-10-25 点单,2026-10-26 补明用 `pnpm patch` 打 agenthub、要「Adelie 应用能产出视频」 | 六包 `typecheck` **`EXIT=0`**(六个 `Done`;`gen:ifaces` 报 **`src/ifaces.json unchanged`**,195 接口 / 590 类型)· `npx oxlint` **0 警告 0 错误**(2297 文件)· `npx prettier --check .` 干净 · `pnpm -r test` **`EXIT=0`、0 失败**:core **1421 通过 / 6 跳过**(69 文件 + 1 跳过)· ui **1053**(130)· cli **561**(38)· web **3273 通过 / 2 跳过**(268)· server **2988 通过 / 4 跳过**(204)· docs **62**(8)· amsp **68**(2)· desktop **304**(26)· ui-gallery **140**(20)· `plugins/use-seedance` **8**(桩服务端到端)· `pnpm -r build` `EXIT=0` · 方舟真端点:假 key 实测 401 `AuthenticationError`(视频部件与文本部件走同一句鉴权错)· **没做**:没在真浏览器里目视播放一次视频、Seedance 没拿真 key 出过一次片、Trace 详情页的 `events` 仍会整份返回那条记录的 base64 | 见本行提交 |
+| 2026-10-26 | 7.48 | **智能体设置里「还原为默认配置」「更新内核」被拒时,原因留在框里**(不是移植:1 处源码 `packages/web/src/features/agents/agent-settings-page.tsx`(`OverviewTab` 新增 `resetRefusal` / `kernelRefusal`,两个 `ConfirmModal` 接上 `refusal` 槽并按 `S.common.refused` 加前缀,两个 `catch` 不再 `toastError`,开框 / 关框都清旧原因) + 1 个新文件 `packages/web/e2e/agent-config-refusal.spec.mjs`(2 条用例)+ changelog 一对,**无新依赖、不碰接口、无新文案**):台账点名的下一站是「插件市场 / 智能体设置 / 定时任务面板里带确认的写入」,实摸之后插件市场与定时任务面板早已接好 `refusal` 槽,只剩智能体设置概览页这两张;同一操作在智能体列表页(批量内核更新)与本页 API 标签页早就会把原因留在框里,这两张是最后一处没跟上的 | 六包 `typecheck` **`EXIT=0`**(六个 `Done`;`gen:ifaces` 报 **`src/ifaces.json unchanged`**,195 接口 / 590 类型)· `npx oxlint` 两个改动文件 **0 警告 0 错误** · 四个改动文件 `prettier --check` 干净 · `git diff --check` 干净 · 逐包 test **`EXIT=0`、0 失败**(两条扫全仓的 5 s 用例在本机与另一条线的发布测试并行时超时、单独复跑通过,见该节):core **69 通过文件 + 1 跳过 / 1421 通过 / 6 跳过** · ui **130 / 1053** · cli **38 / 561** · server **204 / 2990 通过 / 4 跳过** · web **267 文件 / 3272 通过 / 2 跳过** · **真服务 + 真浏览器单 spec**(`/root/adelie-fork-data/r135-e2e`,服务 8950、mock 8951,`packages/{core,server,web}/dist` 本轮新构建):新 spec **2 passed(9.1s)** · **反证(同一份 spec,两种产物)**:把这一处源码 `git stash push -- packages/web/src/features/agents/agent-settings-page.tsx`(只带这一个路径)、重建 web 成 `r135/before-dist`、另起一台服务端(8960,`/root/adelie-fork-data/r135-before`)→ **2 failed**(`element(s) not found`:改前框里没有那句原话);`git stash pop` 后重建即回到 2 / 2 · **两态实测真看一眼**(探针 `r135/probe.mjs`,两态各跑一次、两张框各测一遍,同一个 `page.route` 500,1440×900,读数取被拒后 1.5 s 与 6.5 s 两次):**改前** 两张框都是 `{cardVisible:true, alertInCard:0, noticeHasReason:true}` → 6.5 s 后 `noticeHasReason:false`(屏幕上一点解释都没有了);**改后** 两张框都是 `{cardVisible:true, alertInCard:1, noticeHasReason:false}`,6.5 s 后原样还在——截图 `r135/{before,after}/shots/{reset,kernel}-2-six-seconds-later.png` 里正好是「改前框里空着」对「改后框里那行『操作被拒绝:agent state is read-only』」;两态 console 的 error 只有既有的 `/machines` 403(普通成员读机器列表)与刻意造的 500,无 `pageerror` · **整套浏览器 e2e**(`SKIP_BUILD=1 bash e2e/run.sh`,自带 mock 与 `mktemp` 数据根):**167 passed(11.9m)、0 failed、`EXIT=0`**(第一百三十三轮整套是 164,+ 本笔 2 + 另一条线视频那 1) · 端口只用 8950 / 8951 / 8960 与整套的 8930 / 8931(跑完都已停),3003 / 3004 / 4000 / 7364 / 7369 一个没碰;数据只落在 `/root/adelie-fork-data/r135-{e2e,before}` 与 scratchpad 的 `r135/` 下(`packages/*/dist`、`packages/web/test-results/` 都是产物,未 `git add`)· 没有切版本号、没发 npm、没发安装包、没发发布汇总(0.5.7 的版本号与发布正文是另一条线推上来的 `d80630ec` / `63fa1064`,本线只 `merge --ff-only` 跟上) | 见本行提交 |
+
> **2026-10-11 与另一条线的交汇(第三十七轮)**:定时任务触发时(07:00)`git status --short` **不干净**
> —— 另一条线(会话 `session-2026-10-05-20-32-50-2ee69aba`)正在做**用户点单**的「回复能复制成纯文本」
@@ -16308,3 +16320,93 @@ adelie 应用可以产出视频」。
- 校园邮箱这一轮只试一次(`cd …/csu-mail/scripts && timeout 60 python3 mail.py check` **超时**、
`RC=124`、无输出)—— 还是 `202.197.0.0/16` 那个网段的问题,不是凭据,不重试。照前几轮改由飞书送达,
正文留底在 scratchpad 的 `r117/report.txt`;下一轮开工再探一次。
+
+## 第一百三十五轮:智能体设置里还原配置 / 更新内核被拒时,原因留在框里(2026-10-26,条目 7.48)
+
+### 开工自检与选活理由
+
+- 第 0 步先撞上「工作区不干净」:`git status --short` 里有 6 个 `video-input` 相关文件,判据指向**另一条
+ 会话在跑**而不是半成品 —— 它 18:55 起的 `pnpm -r test` 到 19:00 仍在跑并持续写 `/tmp/r134-rtest.log`、
+ trace 19:00:09 还在写、`.git/index` 停在 18:56、进程环境里 `ADELIE_SESSION_ID` =
+ `session-2026-10-05-20-32-50-2ee69aba`(`self_evolution` 项目那条长会话)。按第七十四轮「有界地等」的口径
+ 只做只读的事(读 2.2c、5.6、5.10 与 7.x 的条目),没有动一个字节。19:07 它落地 `d162438b` / `39954572`
+ 两笔、全量测试 `EXIT=0`,工作区干净后才开工;此后它转去 `/tmp/rel-0.5.7` 那个独立 worktree 做 0.5.7 的
+ 发布,并往 main 推了 `d80630ec`(版本号)与 `63fa1064`(发布正文)—— 本线在开工后按
+ `git merge --ff-only origin/main` 快进跟上(那两笔只动 `package.json` 与 release 正文,与本次改的文件零重叠)。
+- 待办里能一轮做完的条目仍然没有:**2.2c** 剩下的三处全在桌面壳写侧 / `adelie-app.service` / 非契约项上
+ (本轮明令不碰 desktop),**3.5** / **5.6** / **5.10** 要拍板、**3.6** 要模型 key、**4.1–4.3** 明令不动。
+ 上游这一轮没有核对(另一条线正在打 0.5.7,refs 会被它推着走;本轮改的是界面行为,不依赖上游)。
+- 于是接台账点名的下一站「**插件市场 / 智能体设置 / 定时任务面板里那些带确认的写入**」。实地摸了一遍:
+ 插件市场(`plugins-page.tsx` 的批量更新与 `removePlugin`、`plugin-import-dialog.tsx` 的上传 / URL 两条)
+ 与定时任务面板(`schedule-panel.tsx` 的删除、`schedules-page.tsx`)**早就接了 `refusal` 槽**;只剩
+ **智能体设置概览页那两张确认框**(还原为默认配置 / 更新内核)还是「框留着、原因只进 toast」。这不是新口径,
+ 而是同一操作在两处不一致:智能体列表页的批量内核更新(`agents-page.tsx` 的 `kernelRefusal`)与本页 API
+ 标签页的三张卡都已经是「原因留在框里」,这两张是最后一处没跟上的。
+
+### 改了什么(1 处源码 + 1 个新 spec + 一对 changelog)
+
+- `packages/web/src/features/agents/agent-settings-page.tsx`(`OverviewTab`,+18 −4):
+ - 新增 `resetRefusal` / `kernelRefusal` 两份状态;`runReset()` 与 `runKernelUpdate()` 的 `catch` 不再
+ `toastError`,改为把服务端原话存进去(`toastError` 仍留着 —— 概览页「保存名称 / 描述」那条路径还用它);
+ - 两个 `ConfirmModal` 接上 `refusal` 槽,画法与 API 标签页一致:状态里存原话、画的时候套
+ `S.common.refused` 前缀(`操作被拒绝:…`),因此不需要新文案;
+ - 打开(两个按钮的 `onClick`)与关闭(`onClose`)两条路径都清空它,重新打开不带上一次的原因;
+ - 成功路径一个字节没动:只有写入落地才关框、才刷新(过去就是这样,被拒时框本来就开着,丢的只有原因)。
+- `packages/web/e2e/agent-config-refusal.spec.mjs`(新文件,2 条用例):
+ ① 重置:`page.route` 把 `POST …/config/reset` 拒成 500 + 自有原话 → 原话在框里、通知区里没有它、
+ 框的句子与拒绝前逐字相同、服务端的 `config.systemPrompt` 没被改写 → 取消后重开不带旧原因 → 放行后
+ 在同一个框上重试:框关掉、写入 2 次;② 内核:把配置读取里的 `kernelOutdated` 改成 true(开发数据根里
+ 默认智能体本来就是最新的,更新按钮是置灰的),同一套断言,外加请求落点必须是 `…/config/kernel-update`。
+- changelog 一对 `changelog/unreleased/2026-10-26-agent-config-refusal{,.zh}.md`。
+
+### 验证(都不是推测)
+
+- 六包 `typecheck` **`EXIT=0`**(六个 `Done`;`gen:ifaces` 报 **`src/ifaces.json unchanged`**,195 接口 /
+ 590 类型 —— 本笔不动服务契约)。
+- `npx oxlint` 两个改动文件 **0 警告 0 错误**;四个改动文件 `prettier --check` 干净(新 spec 首跑一条,
+ `--write` 后复检);`git diff --check` 干净。
+- 逐包 test **`EXIT=0`、0 失败**:core **69 通过文件 + 1 跳过 / 1421 通过 / 6 跳过** · ui **130 文件 /
+ 1053 通过** · cli **38 文件 / 561 通过** · server **204 文件 / 2990 通过 / 4 跳过** · web **267 文件 /
+ 3272 通过 / 2 跳过**。**两处 5 秒超时如实记**:首跑 core 的 `path-prepend.test.ts`「the child environment
+ alone does not decide it」、复跑 web 的 `control-size.test.ts`「is never spelled on a call site's
+ className」都超时 —— 都是扫全仓 / 起 shell 的用例,当时本机正与另一条线的 0.5.7 发布测试并行;单独复跑
+ 分别 **15 / 15 通过(891 ms)** 与 **6 / 6 通过(1759 ms)**,与本笔改动零交集。
+- **真服务 + 真浏览器单 spec**(`/root/adelie-fork-data/r135-e2e`,服务 8950、mock 8951,`packages/{core,
+ server,web}/dist` 都是本轮新构建的):新 spec **2 passed(9.1s)**。
+- **反证(同一份 spec,两种产物)**:把这一处源码 `git stash push -- packages/web/src/features/agents/
+ agent-settings-page.tsx`(只带这一个路径)、重建 web 到 `r135/before-dist`、另起一台服务端(8960,
+ `/root/adelie-fork-data/r135-before`)→ **2 failed(17.2 s / 17.1 s)**,都死在
+ `dialog.getByText("agent state is read-only")` 的 `element(s) not found`(改前框里根本没有这句);
+ `git stash pop` 后重建即回到 2 / 2。
+- **两态实测真看一眼**(探针 `r135/probe.mjs`,两态各跑一次、两张框各测一遍,同一个 `page.route` 500,
+ 1440×900,读数取被拒后 1.5 s 与 6.5 s 两次):
+ - 改前:两张框都是 `{cardVisible:true, alertInCard:0, noticeHasReason:true}` → 6.5 s 后
+ `noticeHasReason:false` —— 截图 `r135/before/shots/reset-2-six-seconds-later.png` 里正是「框还在、
+ 框里一个字都不解释」;
+ - 改后:`{cardVisible:true, alertInCard:1, noticeHasReason:false}`,6.5 s 后原样还在 —— 截图
+ `r135/after/shots/reset-2-six-seconds-later.png` 里框的句子下面就有那行「操作被拒绝:agent state is
+ read-only」;
+ - 两态 console 里的 error 只有既有的 `/machines` 403(普通成员读机器列表)与刻意造的 500,无 `pageerror`。
+- **整套浏览器 e2e**(`SKIP_BUILD=1 bash e2e/run.sh`,自带 mock 与 `mktemp` 数据根):
+ **167 passed(11.9m)、0 failed、`EXIT=0`**(第一百三十三轮整套是 164,+ 本笔 2 + 另一条线视频那 1)。
+- 端口只用了 8950 / 8951 / 8960(单 spec 与两态)与整套的 8930 / 8931,跑完都已停;3003 / 3004 / 4000 /
+ 7364 / 7369 一个没碰;数据只落在 `/root/adelie-fork-data/r135-{e2e,before}` 与 scratchpad 的 `r135/` 下
+ (`packages/*/dist`、`packages/web/test-results/` 都是产物,未 `git add`)。
+- 没有切版本号、没发 npm、没发安装包、没发发布汇总(0.5.7 的版本号与正文是另一条线推上来的,本线只
+ `merge --ff-only` 跟上)。
+
+### 台账
+
+- 7.48 的清单条目与「已完成的轮次」表行都是本轮新写的;表行里的提交号写「见本行提交」,因为台账与代码
+ 同一笔提交(照 `9864a187` 那一轮的写法)。
+
+### 没做 / 还差什么
+
+- 概览页「保存名称 / 描述」的写入仍然只弹通知:它没有确认框,字段里的输入本来就留着,但「为什么没存进去」
+ 几秒后就找不到了。要接 `refusal` 得改 `SaveFn` / `useSaveConfirm` 的返回口径(一次改一整排设置页),
+ 不是这一条的量,留给后面的轮次。
+- 「点击即关、失败只弹 toast」那条扫描线在**插件市场 / 智能体设置 / 定时任务面板**这三处到此清完;
+ 台账里还点过名的其它面(对话停靠栏、终端、工作区浏览器、内置浏览器、消息绑定的几张框)只在确认框上是
+ 两态齐全或未逐处摸过 —— 下一轮若仍自选,先按「真服务 + 真浏览器拒一次写入」量清楚再决定做哪处。
+- 报到渠道:本轮 csu 邮箱仍不通(`mail.py check` 超时 `RC=124`,`smtp/imap.csu.edu.cn` 端口探测同样挂住,
+ 与第 117 轮同因),汇报改走飞书,正文留底在 scratchpad 的 `report.md`。
diff --git a/packages/web/e2e/agent-config-refusal.spec.mjs b/packages/web/e2e/agent-config-refusal.spec.mjs
new file mode 100644
index 00000000..8bbede4b
--- /dev/null
+++ b/packages/web/e2e/agent-config-refusal.spec.mjs
@@ -0,0 +1,181 @@
+/**
+ * Regression: the two questions the Agent settings overview asks about the config file — restore
+ * the defaults, and advance the kernel — keep the reason inside the card the server refused it
+ * from, instead of only a toast that dismisses itself above the card the user is still reading.
+ *
+ * Both cards already stayed open on a refusal (they close on a landed write only), so the loss was
+ * the reason alone: a notification that vanished after six seconds while the card sat there. The
+ * same slot is already used by the Agents list's batch kernel update and by the API tab's three
+ * cards, and this page's two now report the same way: `ConfirmModal`'s `refusal` strip, under the
+ * sentence, next to the button that retries it — cleared on open and on close, never carried over.
+ *
+ * Every write is the page's own, refused at `page.route`; the config the page reads is the
+ * server's own with the one field the kernel gate looks at edited in (a development data root
+ * ships the default Agent up to date, so its update button is disabled).
+ */
+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";
+
+/** What each refused write answers: its own words prove the reason came back into the card. */
+const REFUSAL = { code: "agent_state_read_only", message: "agent state is read-only" };
+
+const configPath = (projectId) => `/api/projects/${projectId}/agents/${AGENT}/config`;
+
+/** The notification region: a refusal must not be announced there (that is the old toast). */
+const notifications = (page) => page.getByRole("region", { name: "通知" });
+
+/**
+ * Provision the user and give the Project a model (the onboarding overlay covers the page without
+ * one), returning the Project id and a reader for the Agent's config as the server holds it.
+ */
+async function projectWithModel(page, user) {
+ 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 stored = async () =>
+ await (await page.request.get(`${BASE}${configPath(projectId)}`)).json();
+ return { projectId, stored };
+}
+
+/**
+ * Serve the Agent config the page reads with one field edited in: `kernelOutdated` raises the
+ * kernel section's trail and enables its update button, exactly as an install behind the current
+ * defaults generation renders it. Everything else stays the server's own answer.
+ */
+async function stubConfig(page, projectId, edit) {
+ const body = await (await page.request.get(`${BASE}${configPath(projectId)}`)).json();
+ edit(body);
+ await page.route(`**${configPath(projectId)}`, async (route) => {
+ if (route.request().method() !== "GET") return route.fallback();
+ await route.fulfill({
+ status: 200,
+ contentType: "application/json",
+ body: JSON.stringify(body),
+ });
+ });
+}
+
+/**
+ * Take over one write: every request is counted, and while `state.refuse` is set it is answered
+ * with the server's refusal instead of reaching the real route.
+ */
+async function interceptWrite(page, suffix, state) {
+ await page.route(`**/api/projects/*/agents/*/config/${suffix}`, async (route) => {
+ if (route.request().method() !== "POST") return route.fallback();
+ state.seen.push(route.request().url());
+ if (!state.refuse) return route.fallback();
+ await route.fulfill({
+ status: 500,
+ contentType: "application/json",
+ body: JSON.stringify({ error: REFUSAL }),
+ });
+ });
+}
+
+/** The card's own text with the refusal line dropped — the only thing a refusal may change. */
+async function cardText(card) {
+ return (await card.innerText()).replace(/\n操作被拒绝:[^\n]*/, "");
+}
+
+test("a refused config reset keeps the card, its sentence, and says why", async ({ page }) => {
+ const { projectId, stored } = await projectWithModel(page, "r135reset");
+ const before = await stored();
+
+ const state = { seen: [], refuse: true };
+ await interceptWrite(page, "reset", state);
+
+ await page.goto(`/agents/${AGENT}`);
+ const openButton = page.getByRole("button", { name: "还原为默认配置", exact: true });
+ await expect(openButton).toBeVisible();
+ await openButton.click();
+ const dialog = page.getByRole("dialog", { name: "还原为默认配置" });
+ await expect(dialog).toBeVisible();
+ const sentence = await cardText(dialog);
+
+ await dialog.getByRole("button", { name: "还原为默认配置", exact: true }).click();
+
+ // The reason is in the card that asked, and it is not a toast.
+ await expect(dialog.getByText(REFUSAL.message)).toBeVisible();
+ await expect(notifications(page).getByRole("button")).toHaveCount(0);
+ expect(state.seen).toHaveLength(1);
+ await expect(dialog).toBeVisible();
+ // The card still asks the question it asked: the sentence is untouched by the refusal.
+ expect(await cardText(dialog)).toBe(sentence);
+ // Nothing was rewritten on the server either.
+ expect((await stored()).config.systemPrompt).toBe(before.config.systemPrompt);
+
+ // Closing the card decides nothing, and opening it again does not carry the old reason over.
+ await dialog.getByRole("button", { name: "取消" }).click();
+ await expect(dialog).toHaveCount(0);
+ await openButton.click();
+ const reopened = page.getByRole("dialog", { name: "还原为默认配置" });
+ await expect(reopened).toBeVisible();
+ await expect(reopened.getByText(REFUSAL.message)).toHaveCount(0);
+
+ // The retry is the same card; this time the write lands and the card closes.
+ state.refuse = false;
+ await reopened.getByRole("button", { name: "还原为默认配置", exact: true }).click();
+ await expect(reopened).toHaveCount(0);
+ expect(state.seen).toHaveLength(2);
+});
+
+test("a refused kernel update keeps the card, its sentence, and says why", async ({ page }) => {
+ const { projectId } = await projectWithModel(page, "r135kernel");
+ await stubConfig(page, projectId, (body) => {
+ body.config.kernelOutdated = true;
+ });
+
+ const state = { seen: [], refuse: true };
+ await interceptWrite(page, "kernel-update", state);
+
+ await page.goto(`/agents/${AGENT}`);
+ // The outdated dot folds "· 内核有更新" into the button's accessible name, after its label.
+ const openButton = page.getByRole("button", { name: /^更新内核 ·/ });
+ await expect(openButton).toBeVisible();
+ await openButton.click();
+ const dialog = page.getByRole("dialog", { name: "更新内核" });
+ await expect(dialog).toBeVisible();
+ const sentence = await cardText(dialog);
+
+ await dialog.getByRole("button", { name: "更新内核", exact: true }).click();
+
+ await expect(dialog.getByText(REFUSAL.message)).toBeVisible();
+ await expect(notifications(page).getByRole("button")).toHaveCount(0);
+ expect(state.seen).toHaveLength(1);
+ expect(state.seen[0].endsWith(configPath(projectId) + "/kernel-update")).toBe(true);
+ await expect(dialog).toBeVisible();
+ expect(await cardText(dialog)).toBe(sentence);
+
+ // Closing and reopening drops the reason; the retry on the fresh card lands and closes it.
+ await dialog.getByRole("button", { name: "取消" }).click();
+ await expect(dialog).toHaveCount(0);
+ await openButton.click();
+ const reopened = page.getByRole("dialog", { name: "更新内核" });
+ await expect(reopened).toBeVisible();
+ await expect(reopened.getByText(REFUSAL.message)).toHaveCount(0);
+
+ state.refuse = false;
+ await reopened.getByRole("button", { name: "更新内核", exact: true }).click();
+ await expect(reopened).toHaveCount(0);
+ expect(state.seen).toHaveLength(2);
+});
diff --git a/packages/web/src/features/agents/agent-settings-page.tsx b/packages/web/src/features/agents/agent-settings-page.tsx
index d6f556a5..e8b19608 100644
--- a/packages/web/src/features/agents/agent-settings-page.tsx
+++ b/packages/web/src/features/agents/agent-settings-page.tsx
@@ -374,8 +374,15 @@ function OverviewTab({
const [conflict, setConflict] = useState<string | null>(null);
const [resetOpen, setResetOpen] = useState(false);
const [resetting, setResetting] = useState(false);
+ // A reset / kernel update the server refused keeps its card (it only ever closed on a landed
+ // write) and reports inside it, next to the button that retries it — the same slot the Agents
+ // list's batch update and this page's API tab already use. A toast said the same thing, but it
+ // dismissed itself while the card that asked was still on screen. Cleared on open and on close,
+ // so reopening never carries the previous attempt's reason.
+ const [resetRefusal, setResetRefusal] = useState<string | null>(null);
const [kernelOpen, setKernelOpen] = useState(false);
const [kernelUpdating, setKernelUpdating] = useState(false);
+ const [kernelRefusal, setKernelRefusal] = useState<string | null>(null);
/** Last kernel update's merge report (kept fields listed under the section until the next full reload). */
const [kernelResult, setKernelResult] = useState<AgentKernelUpdateResponse | null>(null);
const { requestSave, element: saveConfirm } = useSaveConfirm();
@@ -388,7 +395,8 @@ function OverviewTab({
setResetOpen(false);
onConfigReset();
} catch (e) {
- toastError(apiErrorText(e));
+ // The card asked, so the card says why; the retry is the same button (see resetRefusal).
+ setResetRefusal(apiErrorText(e));
} finally {
setResetting(false);
}
@@ -404,7 +412,7 @@ function OverviewTab({
toastSuccess(S.agent.kernelUpdateDone(res.kernelVersion, res.advanced.length));
onKernelUpdated();
} catch (e) {
- toastError(apiErrorText(e));
+ setKernelRefusal(apiErrorText(e));
} finally {
setKernelUpdating(false);
}
@@ -568,7 +576,10 @@ function OverviewTab({
size="sm"
className="relative"
disabled={kernelUpdating || !data.config.kernelOutdated}
- onClick={() => setKernelOpen(true)}
+ onClick={() => {
+ setKernelRefusal(null);
+ setKernelOpen(true);
+ }}
>
{S.agent.kernelUpdateAction}
{data.config.kernelOutdated && (
@@ -585,7 +596,10 @@ function OverviewTab({
size="sm"
variant="danger"
disabled={resetting}
- onClick={() => setResetOpen(true)}
+ onClick={() => {
+ setResetRefusal(null);
+ setResetOpen(true);
+ }}
>
{S.agent.resetConfigAction}
</Button>
@@ -655,10 +669,14 @@ function OverviewTab({
title={S.agent.kernelUpdateTitle}
busy={kernelUpdating}
tone="primary"
- onClose={() => setKernelOpen(false)}
+ onClose={() => {
+ setKernelOpen(false);
+ setKernelRefusal(null);
+ }}
onConfirm={() => void runKernelUpdate()}
confirmLabel={S.agent.kernelUpdateAction}
cancelLabel={S.common.cancel}
+ refusal={kernelRefusal === null ? undefined : S.common.refused(kernelRefusal)}
>
<p className="text-sm text-gray-600 dark:text-gray-300">
{S.agent.kernelUpdateConfirmBody}
@@ -670,10 +688,14 @@ function OverviewTab({
open={resetOpen}
title={S.agent.resetConfigTitle}
busy={resetting}
- onClose={() => setResetOpen(false)}
+ onClose={() => {
+ setResetOpen(false);
+ setResetRefusal(null);
+ }}
onConfirm={() => void runReset()}
confirmLabel={S.agent.resetConfigAction}
cancelLabel={S.common.cancel}
+ refusal={resetRefusal === null ? undefined : S.common.refused(resetRefusal)}
>
<p className="text-sm text-gray-600 dark:text-gray-300">{S.agent.resetConfigConfirmBody}</p>
</ConfirmModal>