fix: session persistence, multi-turn memory, OCR pipeline, download UX (v7)
- graph.stream() state fix: agent_state now properly accumulates node updates - atomic session save (tempfile + os.replace) - uploaded_file_path injection for OcrExtractor + annotation_detector - download section always visible; refreshFromApi auto-reloads after generation - node_start/complete unfiltered for full progress visibility - modification_request without status=='pass' check
This commit is contained in:
@@ -262,3 +262,42 @@ validation_service/ (FastAPI, 端口 8001) — 不变
|
||||
- `ProcessSection.vue` 渲染步骤编号/标签/耗时/内容(XML 代码高亮)
|
||||
|
||||
**Fix 5 — 消息耗时显示**: `api_server.py` `agent_complete` 事件新增 `total_duration_ms`,`SummaryCard.vue` 显示总耗时,`chat.ts` 暴露 `lastDurationMs` + `formatDuration()`
|
||||
|
||||
|
||||
## 更新 (v7 — 2026-05-22)
|
||||
|
||||
### 会话持久化 & 多轮对话记忆修复
|
||||
|
||||
**原子写入** (`backend/session.py`): `save_session` 改用 tempfile + os.replace 原子写入,防止进程崩溃时 JSON 截断导致会话损坏。
|
||||
|
||||
**graph.stream 状态修复** (`api_server.py`): LangGraph 的 `graph.stream()`
|
||||
只产出事件,不修改传入的 `agent_state`。`_run_graph_sync` 改为手动收集每个节点的
|
||||
返回 dict 并 `agent_state.update()`,确保 done 事件到达时 agent_state 已是完整状态。
|
||||
此修复解决了第二次请求时 `current_jrxml` 为空、导致多轮对话"失忆"的问题。
|
||||
|
||||
**save_session 调用时机**: 从 `stream_and_save` 末尾移至 `_sse_generator` 中 done 分支
|
||||
(yield `agent_complete` 之前),消除前端 `refreshFromApi()` 的竞态。
|
||||
|
||||
### OCR 管线打通
|
||||
|
||||
**uploaded_file_path 传递** (`api_server.py`): `_process_files` 返回的 `uploaded_paths`
|
||||
注入 `agent_state["uploaded_file_path"]`,使 `process_input` 节点的 `OcrExtractor` 字段
|
||||
精确提取和 `annotation_detector` 批注检测得以触发。此前 `uploaded_file_path` 始终为空,
|
||||
第二层 OCR 从未执行。
|
||||
|
||||
### 前端体验改进
|
||||
|
||||
**下载区常驻** (`Sidebar.vue`): 下载区域始终可见,无文件时显示灰色"暂无下载文件",
|
||||
生成完成后自动出现下载链接。
|
||||
|
||||
**侧边栏自动刷新** (`stores/session.ts`, `App.vue`): 新增 `refreshFromApi()` 方法,
|
||||
`agent_complete` 后自动从 API 重新加载会话状态,下载按钮无需手动刷新即可出现。
|
||||
|
||||
**节点进度完整展示** (`api_server.py`): 移除 `node_complete` 事件的 SKIP_NODES 过滤,
|
||||
所有节点(包括加载会话等内部节点)的 start/complete 事件均正常发送,前端可看到
|
||||
完整流转(running → done)。
|
||||
|
||||
### modification_request 宽松化
|
||||
|
||||
原有 `status == "pass"` 条件去除:只要 `current_jrxml` 存在即设置
|
||||
`user_modification_request`,确保修改意图的请求能携带完整上下文。
|
||||
|
||||
Reference in New Issue
Block a user