Files
wecom_it_smart_desk/docs/02-技术文档/architecture/REQ-坐席-010-sequence-diagram.mermaid
Simon facc04aa65 chore: docs 结构整改 + compose 双目录对齐(合并重建提交)
本提交为 .git 对象库损坏后的重建提交,内容等价于原先三个本地提交
(5e2fd4c2 / 57a53c98 / 5d7e1873)的累积结果,未做任何额外改动。

一、docs 结构整改(整改 #14)
根因:重构时新结构为 untracked 文件,执行 git stash(未带 -u)未纳入,
随后 git reset 拉回 HEAD 旧 tracked 树,导致旧树复活、新旧两棵目录
树并存于 docs/,共 791 文件、双分类体系冲突。

修复动作:
- b2 同名异主题文件改名迁移保全 9 个
- C 类 39 个孤立文件按主题正确归类
- A/B1 类 222 个重复文件删除(新结构已有内容副本)
- 9 个旧独有空目录删除
- 270 处内部引用按 verified 映射改写
- 整改记录 #14 登记于 04-运维文档/部署运维

结果:docs 791 → 569 文件,顶层仅规范 8 类 + 治理文件,单树恢复。
残留:约 20 处指向从未存在文件的陈旧死链,归入独立文档卫生任务。

二、compose 双目录对齐(消除踩坑 A)
- docker-compose.yml:nginx 前端挂载全部由根目录 frontend-*/dist
  改为 src/frontend-*/dist(h5 / agent / admin / terminal)
- docker-compose.dev.yml:dev 服务 build context 与卷同步改 src/
- 效果:本地 docker compose up 不再把根目录 stale dist 挂回,
  与线上一致,分叉隐患消除(已 docker compose config 校验通过)

防复发铁律:
- 重构须提交;仓库修复须 git stash -u 或先 commit
- 新结构须 git add 并提交,避免再次 untracked 复活
- H5 改动只动 src/frontend-h5/,禁改根目录遗留 frontend-*/
2026-08-07 22:31:32 +08:00

74 lines
3.4 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
%% REQ-坐席-010 AI回复三态开关 — 时序图②:路径B 员工发消息在三态下的门控与推送分支
%% (时序图①「坐席切换 mode 调用链」见 技术方案-REQ-坐席-010-AI回复三态开关.md §4.1
%% 架构师 高见远(Gao 2026-08-04
sequenceDiagram
autonumber
actor Emp as 员工(H5)
participant H5 as api/h5.py<br/>send_message
participant DB as conversations / messages
participant Gate as ai_reply_gate
participant Task as tasks/h5_ai_task.py<br/>process_h5_ai_reply
participant Dify as Dify
participant WS as ws_manager
actor AgentUI as 坐席工作台
Emp->>H5: POST /api/h5/.../messages {content}
H5->>DB: 查/建 conversation(新建 status=ai_handling
H5->>DB: INSERT message(sender_type=employee)
H5->>WS: broadcast(new_message, sender=employee)
WS-->>AgentUI: 员工消息(不受本开关影响,始终可见)
H5->>DB: COMMIT(保证后台任务读得到)
rect rgb(255, 244, 230)
Note over H5,Gate: 门控必须在 asyncio.create_task 之前(h5.py:939 / ws.py:472
H5->>Gate: can_ai_auto_reply_path_b(conversation)
Gate->>Gate: status in {ai_handling, queued}?<br/>AND ai_reply_mode != "off"?
end
alt mode == "off"
Gate-->>H5: False
H5->>H5: logger.info("AI自动回复已关闭,跳过")
H5-->>Emp: 200 {user_message, ai_reply:null}
Note over Task: 后台任务从未创建 → 零 DB session / 零 Dify 调用
else status == "serving"(本次修复的缺口)
Gate-->>H5: False
H5->>H5: logger.info("坐席已接管,跳过AI自动回复")
H5-->>Emp: 200 {user_message, ai_reply:null}
Note over AgentUI: 坐席独占对话,AI 不再抢话(PRD G2 / US2
else 允许触发
Gate-->>H5: True
H5->>Task: asyncio.create_task(process_h5_ai_reply(...))
H5-->>Emp: 200(立即返回,AI 回复走 WS 异步推)
Task->>DB: _step_load_conversation
Task->>Dify: _step_call_dify
Note over Task,WS: ai_thinking 坐席广播(h5_ai_task.py:1603<br/>同样受 should_push_to_agent 门控
Task->>Gate: should_push_to_agent(conversation)
alt mode == employee_and_agent
Task->>WS: broadcast(ai_thinking)
WS-->>AgentUI: AI 思考中…
end
Dify-->>Task: AIReplyResult
Task->>DB: _persist_and_push*INSERT message(sender_type=ai)
Task->>WS: broadcast_to_employees([emp], ai_reply)
WS-->>Emp: AI 回复(三态下只要触发就必推员工)
rect rgb(232, 245, 233)
Note over Task,Gate: 坐席广播门控(4 处:L482 / L749 / L891 / L1603
Task->>Gate: should_push_to_agent(conversation)
end
alt mode == "employee_and_agent"
Gate-->>Task: True
Task->>WS: broadcast(new_message, sender_type=ai)
Task->>WS: broadcast(conversation_updated)
WS-->>AgentUI: 坐席同步看到 AI 回复内容(P0-7 / US3
else mode == "employee_only"(默认)
Gate-->>Task: False
Note over Task,AgentUI: 行为变更:不再广播坐席<br/>员工-AI 会话对坐席不可见
end
end
Note over H5,Task: ADR-6:切 off / 转 serving 不 cancel 已提交的在途 task<br/>让其自然结束(PRD P1-4,避免半截消息)