docs: update dev-log - AIOps停止生成按钮
This commit is contained in:
1 parent
ca8ebb1634
commit
94e40ebd3f
1 file changed
+28
@@ -1754,3 +1754,31 @@ cd ~/devops/aiops
|
||||
- 用户消息气泡中【平台实时数据】块较长,可考虑折叠展示(默认收起,点击展开)
|
||||
- 多会话支持(当前单用户单历史,可扩展多命名会话切换)
|
||||
- 流式中支持"停止生成"按钮(AbortController 中断 fetch,后端 ctx.Done() 自动停止)
|
||||
|
||||
|
||||
## 2026-06-18 06:00 自动推进(cron)— AIOps 智能助手"停止生成"按钮
|
||||
|
||||
- **任务**: 为 AIOps 智能助手流式输出增加"停止生成"能力,用户可在 LLM 回复中途点击停止,中止请求并保留已生成的部分内容
|
||||
- **背景**: 上次 cron 完成 SSE 流式输出后,dev-log 下一步建议第 4 项明确列出"流式中支持停止生成按钮(AbortController 中断 fetch,后端 ctx.Done() 自动停止)"。后端 ChatStream 已实现 ctx.Done() 断连检测(不污染历史),前端 api.ts chatStream 已接收 signal 参数,本次只需前端接线
|
||||
- **实现(前端 AIOpsAssistant.tsx 单文件,+53/-14 行)**:
|
||||
- 新增 `abortRef` (useRef<AbortController>) — 持有当前流式请求的控制器
|
||||
- 新增组件卸载清理 useEffect,离开页面时中止进行中的流,避免 setState on unmounted
|
||||
- sendMessage 重构: 每次发送创建新 AbortController,传 controller.signal 给 aiApi.chatStream(history, onChunk, signal)
|
||||
- catch 块新增中止分支: controller.signal.aborted 时保留已生成部分内容(空则显示"(已停止生成)"),标记 isStopped:true;非中止错误走原错误处理(红色气泡)。finally 中复位 abortRef
|
||||
- Message 接口新增 isStopped?: boolean 字段
|
||||
- UI: 流式进行中(isLoading)时在发送按钮右侧显示红色描边"停止"按钮(Square 图标,title="停止生成"),onClick 调 abortRef.current?.abort()
|
||||
- UI: 被停止的助手消息时间戳行追加淡灰色"(已停止)"提示,告知用户输出被截断
|
||||
- **结果**:
|
||||
- 前端 npx tsc --noEmit 零错误;npm run build 通过(3.15s)
|
||||
- ./run.sh restart 后 /health 正常 + 前端 200
|
||||
- 端到端验证(mock 慢速 SSE 服务器 0.8s/chunk x 8 chunks):
|
||||
- 发送消息 -> 流式开始 -> 红色停止按钮立即出现
|
||||
- 点击停止 -> 流立即中止(停止后内容不再增长,grewBy=0)-> 已生成的部分内容保留 -> "(已停止)"提示出现 -> 停止按钮自动隐藏 -> 发送按钮恢复可用
|
||||
- console 零 JS 错误
|
||||
- 测试后清理: LLM config 恢复 disabled + 清空 chat_histories + 停掉 mock server
|
||||
- git push 成功 (commit ca8ebb1)
|
||||
- **下一步建议**:
|
||||
- 用户消息气泡中【平台实时数据】块较长,可折叠展示(默认收起,点击展开)
|
||||
- 多会话支持(当前单用户单历史,可扩展多命名会话切换)
|
||||
- 快捷操作可扩展更多数据源(容量预测接入 agent history 时序/K8s 集群健康/云账单分析)
|
||||
- 前端组件拆分候选: TopologyView.tsx(576)、ExcelServerImport.tsx(549)、DomainManager.tsx(492)
|
||||
Reference in new issue
Block a user