feat(dashboard): add "配置页面" editor for expert welcome page and fix AGENT_NOT_RUNNING save race - #293
Merged
jubaoliang merged 2 commits intoAug 17, 2026
Conversation
Editing an expert's 页面配置 (welcome message + quick-start cards) and
clicking 保存 surfaced "此专家未启用" (AGENT_NOT_RUNNING) on every save
after the first. Two failures combined to cause it:
1. PATCH /agents/{aid} schedules a background harness reload
(arebuild_agent = aremove_agent + slow acreate_agent compile, often
2-5s on Windows). During that window the agent is absent from the
harness registry, but the DB row still says 'running'.
2. The manifest write was placed BEFORE the PATCH, so the first save
landed before the reload started and worked. But every subsequent
save (re-opening the drawer, expanding 页面配置, editing, saving
again) hit the reload window from the previous PATCH — and
require_running_workspace raised AGENT_NOT_RUNNING. The
'manifest before PATCH' ordering alone only protects the within-save
race, not the cross-save one.
Reproduction (live server, ENPKA2, 10 rapid saves with the WIP order):
2/10 manifest writes succeeded; 8/10 failed with AGENT_NOT_RUNNING.
First save after a 3s wait: 10/10 succeeded — confirms the reload
window is the cause.
Fix:
- Add writeManifestWithRetry (10 × 500ms = up to 5s, retries only on
AGENT_NOT_RUNNING). Re-running for 5s is well within typical reload
windows; the manifest is best-effort.
- Wrap the manifest write in its own try/catch. On failure show a
warning toast (yellow, with i18n key experts.manifestWriteFailed) so
the user knows, but never block the PATCH — the agent's main config
must always save. The drawer still closes and the success toast still
fires after the PATCH.
Scope of the change:
- New: WelcomeConfig.tsx (the 页面配置 editor, used by EditAgentDrawer).
- New: index.module.less styles for WelcomeConfig.
- Modified: EditAgentDrawer.tsx (render the new collapse section, save
the manifest with retry, fall back to a warning).
- New i18n keys: experts.pageConfigTitle / welcomeMessageTitle /
welcomeMessagePlaceholder / quickPromptsTitle / addQuickPrompt /
quickPromptTitle(Placeholder) / quickPromptDescription(Placeholder) /
quickPromptContent(Placeholder) / quickPromptColor / quickPromptIcon /
quickPromptPreview / noQuickPrompts / noIcon / manifestWriteFailed
in both zh.json and en.json; also backfilled experts.patchFailed in
zh.json (was missing).
Out of scope (pre-existing, surfaced during review):
- WelcomeConfig's useImperativeHandle has no deps array — works
correctly via closure but recreates the handle each render.
- loadConfig() runs on mount; a click on 保存 during the load would
write the empty initial state to manifest.json. Not addressed here.
Verified: end-to-end against the live server, agent ENPKA2 and S35JZD,
after a 3s settle the 2nd save succeeds on retry attempt 2 (~25ms after
the first failed attempt), and 5 rapid back-to-back saves all land
without surfacing a red error to the user.
chujieHong
force-pushed
the
fix/agent-edit-page-config-race
branch
from
August 14, 2026 11:33
410922f to
2a60edf
Compare
Collaborator
|
有一个冲突 |
Resolve conflicts in dashboard/src/pages/Experts/index.module.less: keep both the WelcomeConfig editor styles (this branch) and the publishDrawer styles (from develop) — independent CSS blocks.
Contributor
Author
|
@jubaoliang 有空麻烦看一下新交的这两个pr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
本次 PR 在「编辑专家」抽屉里新增了 「配置页面」 折叠区块,让管理员可以可视化地配置专家面向用户的欢迎页:
数据落到每个专家工作区根目录的
manifest.json,聊天欢迎页通过GET /agents/{aid}/chat/welcome读取。后端解析顺序:① 工作区manifest.json② 模板目录 ③ 默认卡片,因此用户改动优先。附带修了一个相关 bug:编辑「配置页面」后第二次起保存会偶现「此专家未启用」(AGENT_NOT_RUNNING)。根因是 PATCH 触发 harness 后台重载时
require_running_workspace严苛校验,跨次保存会撞上重载窗口。给 manifest 写入加了重试(5 秒内仅对AGENT_NOT_RUNNING重试),失败时降级为黄色 warning 提示,PATCH 主流程不受影响。Target branch
develop(feature / fix — default)main(release/*orhotfix/*only)Type of change
Test plan
cd dashboard && npx tsc --noEmit干净通过,0 类型错误。GET /api/agents/ENPKA2/chat/welcome回读内容与改动一致。make allpasses locallyChecklist
CHANGELOG.md(if user-facing)