From 339d4153226ade5a1cee847ccde69c75d7c23034 Mon Sep 17 00:00:00 2001 From: panda <1415243231@qq.com> Date: Fri, 22 May 2026 00:01:54 +0800 Subject: [PATCH] fix: crash 'list' object has no attribute 'keys' on image upload, output disappearing on error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: layout_schema.regions is a list of region dicts, not a dict. _log_ocr_layers() was calling .keys() on it, causing agent_error. Also fixed: ProcessSection now stays visible after streaming ends (error or completion), so generated content is not lost. Header shows ✓/✕/pulse indicators. Error handler now refreshes session state for partial JRXML download. --- agent/nodes.py | 5 ++-- frontend/src/App.vue | 1 + frontend/src/components/ProcessSection.vue | 28 +++++++++++++++++++--- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/agent/nodes.py b/agent/nodes.py index 12b2f14..952c76d 100644 --- a/agent/nodes.py +++ b/agent/nodes.py @@ -565,8 +565,9 @@ def _log_ocr_layers(state: AgentState) -> None: # ── 位置层:布局 schema(行/列/区域)── layout = state.get("layout_schema") if isinstance(layout, dict) and layout.get("total_rows", 0) > 0: - regions = layout.get("regions", {}) - region_names = list(regions.keys()) if regions else [] + region_list = layout.get("regions", []) + _rn = {"title": "标题", "header": "表头", "data": "数据", "footer": "表尾"} + region_names = [_rn.get(r["type"], r["type"]) for r in region_list] if isinstance(region_list, list) else [] cols = layout.get("total_columns", 0) rows = layout.get("total_rows", 0) regions_label = ", ".join(region_names) if region_names else "标题/表头/数据/表尾" diff --git a/frontend/src/App.vue b/frontend/src/App.vue index a9bf234..5afe3bc 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -103,6 +103,7 @@ async function handleSend(text: string, files: File[]) { onAgentError(data) { chat.setError(data.error) chat.addMessage({ role: 'assistant', content: `执行异常: ${data.error}`, type: 'error' }) + setTimeout(() => session.refreshFromState({}), 500) }, }) } catch (e: any) { diff --git a/frontend/src/components/ProcessSection.vue b/frontend/src/components/ProcessSection.vue index 35aa7f0..8d29ed4 100644 --- a/frontend/src/components/ProcessSection.vue +++ b/frontend/src/components/ProcessSection.vue @@ -15,10 +15,20 @@ function isXmlLike(text: string): boolean {