feat(chat): AI 回复和工具输出都能原地改,同一轮的工具卡连成一组

调试上下文时经常要把某条历史改掉再看模型怎么反应。用户消息的编辑是「覆盖式重发」
(删掉该条之后的全部历史再跑一轮),AI 回复和工具回执需要的只是改字面、直接入库、
不触发重跑。

- engine.patchMessageContent:只 UPDATE content,不删后续历史、不重跑;运行中 409。
  改的是历史中间一行,末尾行 id 没变、锚点查不出差异,所以主动 invalidateContext,
  下一轮发 X-Context-Reset 全量重建,否则 relay 缓存里还是改之前的文本。
- PATCH /api/sessions/:id/messages/:mid 暴露给前端,不限 role(assistant / tool 都走它)。
- 前端 AI 气泡和工具卡各加一个铅笔(title 都写明「直接入库,不重跑」),点击回填
  底部输入框,editingRole 区分 assistant / tool,保存后只重绘那一个气泡或那张卡。
  工具卡编辑前要求已展开加载全文,否则只有「执行中…」占位。
- 修流式收尾漏传 aiEdit:刚答完那条没有编辑按钮、刷新一下才有。
- 同一轮的多个工具调用包进 .tool-group(左侧竖线连起来):一条 assistant 消息可以带
  2~6 个 tool_calls,以前几张卡看不出是同一轮还是两轮。单调用不套壳。
This commit is contained in:
2026-11-23 08:38:31 +08:00
parent f55df51088
commit f0eb71d9ed
6 changed files with 156 additions and 7 deletions
+8
View File
@@ -472,6 +472,7 @@ main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
margin: 0 0 6px; padding: 3px 9px; border-radius: 6px;
background: var(--bg-fff8c5); color: var(--fg-9a6700); font-size: 12px;
}
/* 工具卡时间行 */
/* 用户气泡:右侧,浅色背景,圆角矩形 */
.bubble-user {
@@ -1372,6 +1373,13 @@ body.voice-active .scroll-bottom-btn { display: none; }
padding: 8px 12px; font-size: 13px; color: var(--fg-6b5b2a);
margin-bottom: 10px;
}
/* 同一轮的多个工具卡:左侧竖线连成一组,一眼看出是同一个响应的并行调用 */
.tool-group {
display: flex; flex-direction: column;
border-left: 2px solid var(--bd-eadfc4); padding-left: 8px; margin-bottom: 10px;
}
.tool-group .tool-card { margin-bottom: 6px; }
.tool-group .tool-card:last-child { margin-bottom: 0; }
.tool-card .tool-name { font-weight: 600; }
.tool-card summary { cursor: pointer; list-style: none; display: flex; gap: 8px; align-items: center; }
.tool-card summary::-webkit-details-marker { display: none; }