Repository navigation
fix: 修复三个前端缺陷——重复上下文注入、⌘K 编号搜索、聊天需求保存卡片标题 - #1490
Robert0622 wants to merge 7 commits into
Conversation
The workbench merged 补充上下文 into reason and also sent it as context. The engine composes reason + context itself (composeHumanFeedback), so the reworked or retried node got the context twice in its feedback, and a third time in the human-context section of its prompt. The pre-merged copy also skipped the server's 8000-byte context cap. Send reason and context separately, as the 从这里重跑 path already does. Co-Authored-By: Claude Code <noreply@anthropic.com>
⌘K suggests searching by number, but requirement entries only carried the title and the raw priority enum, so LED-2 or #12 found nothing and rows showed "medium". Add the displayed key and the localized priority. Co-Authored-By: Claude Code <noreply@anthropic.com>
issues_save persists title; when the model also put an ignored name (often the requirement ID) in the body, the confirmation card showed that as 名称. Co-Authored-By: Claude Code <noreply@anthropic.com>
The fix to withHumanContext(web/app/approvals.js) now returns
{reason, context} separately instead of pre-merging them.
Update the webtest assertion to match the new contract.
Co-Authored-By: Claude Code <noreply@anthropic.com>
独立 CR + 私有库部署实测(head
|
… carry The retried node's feedback already holds the latest operator note through composeHumanFeedback, so the human-context section repeated it and the node prompt carried it twice. Append only the chunks of run.HumanContext that the rendered prompt lacks; notes accumulated with --- keep reaching nodes whose feedback does not carry them. Co-Authored-By: Claude Code <noreply@anthropic.com>
…edback 1e1a619 skipped every note whose text already appeared somewhere in the prompt. A note that repeats a phrase from the run input or the role prompt then lost its 人工补充上下文 section and the instruction to prefer it. Render the section from Run.HumanContext as before and remove only the copies recordHumanContext folded into the node's feedback, so the 上一轮反馈 line keeps the retry reason and each note appears once, also after successive retries and resumes. Co-Authored-By: Claude Code <noreply@anthropic.com>
P2 复核:已修复(head
|
| 版本 | task-prompt.md 中 CTX16 出现次数 |
|---|---|
main 5c406d25 |
3 次(第 17/20/39 行,反馈里拼了两遍) |
上轮 de2a0012 |
2 次(第 17/36 行) |
本轮 2a411f34 |
1 次(第 33 行;第 14 行「上一轮反馈:人工确认重试本节点」只留原因) |
回归(新 head 重新构建、重启同一套私有库部署):
go build ./...、go vet ./internal/engine/通过go test ./web/ ./internal/domain/ok;engine 聚焦用例(HumanContext / Prompt / Approve / RecordHumanContext)ok,含新增TestPromptRendersEachHumanContextNoteOnce、TestHumanContextReachesTheNodeOnce- chatbot vitest 536/536
- 之前三处修复也重新确认:⌘K 搜 LED-2 命中、保存卡片显示标题、客户端请求只带
context
CI 在 2a411f34 上还有 core / browser / first-run 在跑,其余 13 项已 success;跑完前我按「可合入、待 CI」记。token 是作者本人,仍需一位非作者 Approve。
残留 P2 已修:节点 prompt 里人工补充上下文只出现 1 次head 修法
单测
部署实测(CodeBuddy deepseek-v4.1-flash,私有库
|
crispinhu27
left a comment
There was a problem hiding this comment.
复审(初审判定发布后新 head 的复核):APPROVE
版本:head 2a411f34,base main 5c406d25。本轮先对 de2a0012 完成初审,随后作者推送 1e1a619c、2a411f34 两个提交,均只改 internal/engine 的 prompt / human context 渲染,前端文件与 de2a0012 一致。
三个修复点(在 de2a001 上验证,前端在 2a411f3 上与之一致)
- 重复上下文注入:用前端真实产出的请求体对照,base 会把上下文预拼进
reason与context一起发送,head 只发context;喂给服务端真实engine.Reject/Retry后节点 feedback 内标记次数由 2 降为 1,8000 字节上限重新生效。approve/reject/retry/pass/resume 五条路由都单独读取context,不会丢上下文。 - ⌘K 编号搜索:真实 Chromium 对照,base 搜
LED-2/led-1无匹配,head 均命中并显示LED-2 · 高 · 进行中,标题搜索不变。 - 聊天保存卡片标题:
issues_save只有title字段,卡片改取body.title不丢信息,其它工具仍走name || title,有 vitest 覆盖。
增量 de2a0012..2a411f34(5 文件 +153/−33)
1e1a619c只追加 prompt 尚未携带的备注分片;2a411f34改为「人工补充上下文段总是完整追加 + 从 feedback 行里剥掉重复备注」(feedbackWithoutHumanContext),并补了human_context_prompt_test.go。- 中间版本
1e1a619c存在一个回归:走{{humanContext}}占位符的 prompt 会整段丢掉「请优先采信」说明,且既有用例TestPromptObservabilityAlignAndResumeRemainingBranches确定性失败。在2a411f34上重跑该用例以及其他 prompt / human context 用例全部 PASS,TestPromptRendersEachHumanContextNoteOnce的 6 个子场景(reason+context、仅 context、多次重试、resume 恢复、无上下文保持原样)全部通过,说明每个备注只出现一次且段落不再丢失。 TestApproveWithHumanContextReachesDownstream在本机失败仅因容器不允许非特权 user namespace(bwrap),base 上同样失败,非本次改动引入。
其他验证
go test ./web(含两个新增 node 驱动用例)与go vet ./web通过;新增用例在 base 上失败、head 上通过;webtest 相关 7 文件 36 用例全部通过;chatbot vitest 536/536。- CI:head
2a411f34全部 check 通过(16/16)。
说明(非阻塞)
⌘K结果仍受既有slice(0,12)截断,同前缀编号很多时可能看不到目标项,base 同样如此。- 英文优先级关键字(high/medium)不再命中,属把原始枚举换成中文标签的展示变更。
- 本机未跑 webtest 全量(依赖 CI 的 platform-required,已通过),聊天卡片未做浏览器级渲染。
结论:APPROVE。三个前端缺陷修复经隔离复现与浏览器验证成立,增量在最新 head 上未发现新问题。
|
11-28 04:00 全量走查在真实部署上又复现了这个问题,并验证了与本 PR 相同的修法(只改
建议合入。 用例代码(webtest/tests/approvals.test.mjs)test('rework and retry send the typed reason and the context once, apart', async (t) => {
const app = await loadApp();
t.after(app.close);
const run = {
id: 'rework-run', projectId: 'project-1', status: 'waiting', workflowId: 'flow-rework', createdAt: '2026-10-20T10:00:00Z',
executionContext: { responsibleUserId: 7, projectId: 'project-1' },
workflowSnapshot: {
id: 'flow-rework', name: '交付 LOOP', version: 1, revision: 1,
nodes: [
{ id: 'implement', name: '开发实现', type: 'agent' },
{ id: 'gate', name: '人工验收', type: 'approval', rejectTo: 'implement', taskPrompt: '确认结果' },
],
edges: [{ source: 'implement', target: 'gate' }],
},
nodes: { implement: { status: 'succeeded' }, gate: { status: 'waiting_approval' } },
};
app.router.get('/api/runs/rework-run', run);
app.router.get('/api/runs', [run]);
app.router.get('/api/tasks', []);
app.router.get('/api/issues', []);
app.router.post('/api/runs/rework-run/reject', { ok: true });
app.router.post('/api/runs/rework-run/retry', { ...run, status: 'running' });
app.evaluate(`
state.currentUser={id:7,loginName:'reviewer'};
state.data.runs=${JSON.stringify([run])};
state.data.tasks=[];state.data.issues=[];
window.afPrompt=async()=> '补充 README 后重跑';
`);
await app.evaluate(`renderApprovals(true)`);
const card = app.document.querySelector('#approvalList .ap-card');
card.querySelector('[data-human-context]').value = '同时补充 limit<=3 的示例';
const reject = card.querySelector('[data-reject]');
assert.ok(reject, 'the approval card offers rework to the upstream node');
reject.click();
await settle(8);
const sent = app.router.calls.find(c => c.path === '/api/runs/rework-run/reject');
assert.ok(sent, 'rework posts to the server');
// The server appends "人工补充上下文" itself; a reason that already carried
// the context made the rework note repeat it.
assert.equal(sent.body.reason, '补充 README 后重跑');
assert.equal(sent.body.context, '同时补充 limit<=3 的示例');
assert.equal(sent.body.targetId, 'implement');
app.evaluate(`
const root=document.createElement('div');root.className='human-decision';
root.innerHTML='<textarea data-human-context>先看失败日志</textarea><button id="retry-ctx"></button>';
document.body.append(root);
window.afPrompt=async()=> '重跑当前节点';
`);
await app.evaluate(`retryWaitingNode('rework-run','gate',document.querySelector('#retry-ctx'))`);
const retry = app.router.calls.find(c => c.path === '/api/runs/rework-run/retry');
assert.ok(retry, 'retry posts to the server');
assert.equal(retry.body.context, '先看失败日志');
assert.doesNotMatch(String(retry.body.reason || ''), /人工补充上下文|先看失败日志/);
});🤖 Generated with Claude Code |
…le has it Tencent#1517 moves the requirement key rule into issueKeyFor and makes issueKeyLabel delegate to it. The palette test slices issueKeyLabel out of the bundle on its own, so once both PRs are on main it throws "issueKeyFor is not defined" and go test ./web fails. Load issueKeyFor too when it exists, so the test passes whichever PR merges first. Co-Authored-By: Claude Code <noreply@anthropic.com>
新 head
|
复核
|
| 合并树 | go test ./web/ |
|---|---|
main + #1517 + #1490 2a411f34 |
FAIL:TestCommandPaletteFindsRequirementsByKey,ReferenceError: issueKeyFor is not defined(复现了这个问题) |
main + #1517 + #1490 c5588626 |
ok;go vet ./web/ 通过;webtest 396/396 通过 |
只有 #1490 c5588626(不含 #1517) |
ok |
结论:可以合入,两边谁先合都不会让 go test ./web 失败。注意:这次推送让 crispinhu27 在 2a411f34 上的 Approve 被 dismiss 了,需要按 c5588626 重新批准。写这条评论时 CI 还有 3 项在跑,其余 12 项都通过。
crispinhu27
left a comment
There was a problem hiding this comment.
APPROVE(复审:仅有一个测试文件的增量)
版本:head c5588626,base 5c406d25。上一次 APPROVE(2a411f34,review 6086409972)因新推送被 dismiss,本轮复审增量 2a411f34..c5588626:仅 web/command_palette_test.js +4/−1。
增量
command_palette_test.js 从 bundle 里切片加载 issueKeyLabel,而 #1517 让 issueKeyLabel 委托新的 issueKeyFor。本提交在 bundle 含 issueKeyFor 时才追加加载它,使两 PR 无论谁先合入 go test ./web 都通过。
实际执行的验证
- head
c5588626单独:go test ./web通过(7.7s)。 - 把 #1517(
45093f42)合进c5588626:go test ./web通过(8.2s)。 - 同一合并放在上一版
2a411f34上复现:go test ./web失败,ReferenceError: issueKeyFor is not defined(web/command_palette_test.js:38)——确认这个增量修的是真实存在的跨 PR 冲突,而不是空改。 - 增量未触碰产品代码,
2a411f34上已完成的三个前端缺陷验证结论不受影响(重复上下文注入、⌘K 编号搜索、聊天保存卡片标题,见 review 6086409972)。
结论:APPROVE。










本次修复概述
全量走查 LoopForge(2026-11-27 14:00),使用 CodeBuddy deepseek-v4.1-flash、智谱 glm-5.3-flash、DeepSeek flash、Cursor grok-4.7-high 四类执行器,对私有库真实跑了两条 LOOP(账本缺陷修复 LOOP、账本功能交付 LOOP),覆盖所有 UI 页面、按钮、场景及聊天工作台。发现并修复了以下三个缺陷。
Bug 1:重试 / 退回时人工补充上下文被重复注入
问题原因
web/app/approvals.js中withHumanContext(payload)函数,在把上下文拼到reason字段里再发给服务端,而服务端的engine.composeHumanFeedback还会把payload.context和payload.reason再次拼接并追加到r.HumanContext。结果是同一段上下文出现 2–3 次,还绕过了 8 000 字节上限。旧代码:
复现过程
LOOP B(run-1795760855825419358)implement 节点失败,通过 UI "补充信息,重跑当前节点" 传入上下文「请把 import_csv 的 ValueError 错误信息改成中文…」。
.agentflow/runtime/implement-2-1/task-prompt.md:上下文出现 3 次修复方案
withHumanContext只保留context字段,不再将其预拼到reason,由服务端统一组合:修复后验证
重启平台(
bin-fix),通过 UI 对 LOOP B mr 节点触发"补充信息,重跑当前节点",传入上下文字符串[CTX-AFTERFIX-MR]…:repro-feedback.py结果:context occurrences = 1 ✅注:implement 节点的 feedback 仍保留旧值(2 次),因为那次重跑发生在部署修复版本之前,属于存量数据,不影响修复后行为。
Bug 2:⌘K 命令面板无法按需求编号搜索
问题原因
web/app/access.js中commandCatalog函数构造 issue 的搜索元数据(meta字段)时,缺少 key 字段,导致搜索时用「LED-2」找不到对应需求,尽管提示语明确写了"可用编号搜索"。旧代码(issue 条目):
meta: `${i.priority || '—'} · ${issueStatusLabel(i.status)}`复现过程
修复方案
在
meta字段中加入issueKeyLabel(i),使 key 参与全文搜索:meta: `${issueKeyLabel(i)} · ${issuePriorityLabel(i.priority)} · ${issueStatusLabel(i.status)}`修复后验证
用「LED-2」、「LED-1」、「split」分别搜索,均可找到对应需求:
Bug 3:AI 工作台聊天保存需求时卡片显示错误字段
问题原因
chatbot/src/operations.js中cardRows函数处理issues_save工具时,使用body.name || body.title显示"名称"行。issues_save实际用title字段保存标题;若 body 里恰好有一个无关的name属性(来自工具参数解析),卡片就会显示name而非标题,造成信息误导。复现过程
通过 AI 工作台发起需求创建「按分类汇总支出并校验 CSV 导入」,工具调用卡片显示「名称 ledger-summary-category-csv」(一个内部文件名),而非需求标题。
修复方案
issues_save工具单独走body.title:修复后验证
重新用 AI 工作台创建需求「月度收支对比图」,卡片正确显示需求标题:
回归测试结果
go vet ./web ./internal/...go test ./web ./internal/httpapiwebtest 中
approvals.test.mjs第 42 行原本断言reason包含人工补充上下文(即旧的预拼行为),随本 PR 一并更新为对新契约的断言。影响面与风险
issues_save的操作卡片展示。仅改工具调用展示层,不影响保存逻辑,风险极低。🤖 Generated with Claude Code