From e472abc4e387005dc38f79ac35cc01e860c36f92 Mon Sep 17 00:00:00 2001 From: caohuipeng Date: Thu, 17 Sep 2026 15:54:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(shipping-notice):=20=E8=B4=A7=E4=BB=A3?= =?UTF-8?q?=E4=BC=9A=E8=AF=9D=E4=B8=BB=E5=8C=BA=E5=9F=9F=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E4=B8=BA=E6=89=B9=E6=AC=A1=E4=B8=AD=E5=BF=83=E5=B8=B8=E9=A9=BB?= =?UTF-8?q?=E5=B9=B6=E6=8C=89=E9=99=84=E4=BB=B6=E6=B4=BE=E7=94=9F=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 会话命名:新增业务命名纯函数,新建抽取会话按附件内容派生标题,仅新建不回填不改名 - 批次中心常驻主区域并展示会话标题:移除关闭入口、隐藏对话列、去除面板外壳与折叠/钉住徽标 - 清理对话流打开批次中心的冗余链路 - 新增设计文档与实施计划,同步功能清单说明 --- .../shipping_notice/conversation_title.py | 59 ++ .../order_extraction_run_service.py | 14 +- .../tests/test_shipping_conversation_title.py | 37 + ...ing_order_extraction_conversation_title.py | 87 +++ docs/features/shipping-notice/technical.md | 15 + docs/funclist.md | 2 + .../2026-09-17-shipping-batch-center-first.md | 724 ++++++++++++++++++ ...9-17-shipping-batch-center-first-design.md | 146 ++++ .../chat/components/ChatMessageList.vue | 4 - .../chat/components/ChatViewContent.vue | 70 +- .../components/messages/ChatMessageBubble.vue | 4 - .../ShippingOrderExtractionCard.spec.ts | 28 +- .../shipping/ShippingOrderExtractionCard.vue | 30 +- .../shipping/ShippingWorkflowTimeline.spec.ts | 40 +- .../shipping/ShippingWorkflowTimeline.vue | 91 +-- .../shipping/shippingWorkbenchLayout.spec.ts | 24 + .../chat/shipping/shippingWorkbenchLayout.ts | 21 + frontend/src/locales/en/chat.json | 2 - frontend/src/locales/th/chat.json | 2 - frontend/src/locales/zh-CN/chat.json | 2 - frontend/src/locales/zh-TW/chat.json | 2 - 21 files changed, 1198 insertions(+), 206 deletions(-) create mode 100644 backend/app/services/shipping_notice/conversation_title.py create mode 100644 backend/tests/test_shipping_conversation_title.py create mode 100644 backend/tests/test_shipping_order_extraction_conversation_title.py create mode 100644 docs/superpowers/plans/2026-09-17-shipping-batch-center-first.md create mode 100644 docs/superpowers/specs/2026-09-17-shipping-batch-center-first-design.md create mode 100644 frontend/src/features/chat/shipping/shippingWorkbenchLayout.spec.ts create mode 100644 frontend/src/features/chat/shipping/shippingWorkbenchLayout.ts diff --git a/backend/app/services/shipping_notice/conversation_title.py b/backend/app/services/shipping_notice/conversation_title.py new file mode 100644 index 00000000..2983de68 --- /dev/null +++ b/backend/app/services/shipping_notice/conversation_title.py @@ -0,0 +1,59 @@ +""" +backend/app/services/shipping_notice/conversation_title.py + +用途:为订单抽取**新建**会话推导业务化标题,替代写死的「订单抽取」。 +依赖:仅标准库(datetime/pathlib/re);禁止引入 Flask/DB 依赖,保持可单测。 +逻辑:取首个非空附件文件名去扩展名 → 循环剥离邮件前缀 → 截断 24 字符 → + 多文件追加「等 N 个文件」→ 追加 MM-DD 日期消歧 → 全空回退「订单抽取」。 + 仅新建会话时调用;存量会话标题一律不改(设计决策见 2026-09-17 spec)。 +""" + +from __future__ import annotations + +import re +from datetime import datetime +from pathlib import PureWindowsPath + +_FALLBACK_TITLE = '订单抽取' +_NAME_MAX_CHARS = 24 +_TITLE_MAX_CHARS = 60 +# re:/fw:/fwd: 为半角冒号且大小写不敏感;回复/转发为全角冒号。循环剥离以支持多层嵌套。 +_MAIL_PREFIX_PATTERN = re.compile(r'^\s*(?:re|fw|fwd)\s*:|^\s*(?:回复|转发):', re.IGNORECASE) + + +def _strip_mail_prefixes(name: str) -> str: + """循环剥离单个文件名开头的邮件前缀(Re:/Fw:/Fwd:/回复:/转发:)。""" + current = name.strip() + while True: + stripped = _MAIL_PREFIX_PATTERN.sub('', current, count=1).lstrip() + if stripped == current: + return current + current = stripped + + +def derive_order_extraction_title(filenames: list[str], created_at: datetime) -> str: + """ + 按首个附件文件名推导订单抽取会话标题。 + + Args: + filenames: 本次冻结 Intake 对应的资产原始文件名,按 Intake 顺序; + 允许包含空串占位(保持计数口径)。 + created_at: 会话创建时间(服务器 UTC,不做时区换算),提供 MM-DD 消歧后缀。 + Returns: + 形如「PO#6075309 等 11 个文件 09-15」的标题;文件名全空时回退「订单抽取」; + 末尾做 60 字符防御性钳制(24 字主名约束下正常不可达)。 + """ + ordered = [str(name or '').strip() for name in filenames] + usable = [name for name in ordered if name] + if not usable: + return _FALLBACK_TITLE + # PureWindowsPath 同时把 '/' 与 '\' 视为目录分隔符,兼容两类上传来源的路径写法。 + stem = PureWindowsPath(usable[0]).stem + base = _strip_mail_prefixes(stem)[:_NAME_MAX_CHARS].strip() + if not base: + return _FALLBACK_TITLE + parts = [base] + if len(ordered) > 1: + parts.append(f'等 {len(ordered)} 个文件') + parts.append(f'{created_at.month:02d}-{created_at.day:02d}') + return ' '.join(parts)[:_TITLE_MAX_CHARS] diff --git a/backend/app/services/shipping_notice/order_extraction_run_service.py b/backend/app/services/shipping_notice/order_extraction_run_service.py index ef32d206..10dba00f 100644 --- a/backend/app/services/shipping_notice/order_extraction_run_service.py +++ b/backend/app/services/shipping_notice/order_extraction_run_service.py @@ -56,6 +56,7 @@ from app.models import ( ShippingOrderSchemaVersion, User, ) +from app.services.shipping_notice.conversation_title import derive_order_extraction_title from app.services.shipping_notice.order_extraction_route_contract import ( PARSER_ENGINE_VERSION, PARSER_POLICY_VERSION, @@ -697,6 +698,16 @@ def _load_intakes( return rows +def _intake_filenames(intakes: list[ShippingOrderIntake]) -> list[str]: + """按 Intake 顺序取资产原始文件名;无资产或资产缺失以空串占位,保持计数口径。""" + asset_ids = [int(intake.asset_id) for intake in intakes if intake.asset_id] + if not asset_ids: + return [] + rows = db.session.query(FileAsset.id, FileAsset.original_filename).filter(FileAsset.id.in_(asset_ids)).all() + filename_by_id = {row[0]: str(row[1] or '') for row in rows} + return [filename_by_id.get(int(intake.asset_id), '') for intake in intakes if intake.asset_id] + + def _resolve_conversation( *, user_id: int, @@ -713,6 +724,7 @@ def _resolve_conversation( intakes: 已按用户锁定且通过业务资格校验的 Intake。 Returns: 已存在或本事务新建的 ChatSession;调用方负责最终提交。 + 新建会话的 title 由 conversation_title 按首个 Intake 文件名派生;已存在会话不改动标题。 Raises: ConflictError: 所选 Intake 已分属不同会话,或与显式会话不一致。 """ @@ -737,7 +749,7 @@ def _resolve_conversation( session_id=uuid.uuid4().hex, user_id=user_id, agent_id=agent_id, - title='订单抽取', + title=derive_order_extraction_title(_intake_filenames(intakes), datetime.utcnow()), status='running', created_at=datetime.utcnow(), updated_at=datetime.utcnow(), diff --git a/backend/tests/test_shipping_conversation_title.py b/backend/tests/test_shipping_conversation_title.py new file mode 100644 index 00000000..78c4f057 --- /dev/null +++ b/backend/tests/test_shipping_conversation_title.py @@ -0,0 +1,37 @@ +""" +backend/tests/test_shipping_conversation_title.py + +用途:验证订单抽取会话标题纯函数的派生规则(前缀剥离/截断/计数后缀/日期/回退)。 +依赖:纯函数,无 Flask/DB 夹具。 +逻辑:命名是内容派生的确定性函数,用逐条断言锁定规则,防止后续误改口径。 +""" + +from __future__ import annotations + +from datetime import datetime + +from app.services.shipping_notice.conversation_title import derive_order_extraction_title + + +def test_strips_leading_mail_prefixes_and_appends_date(): + """首个文件名循环剥离 Re/Fw/Fwd/回复/转发 前缀,末尾追加 MM-DD。""" + title = derive_order_extraction_title(['回复:转发:FWD: PO#6075309.eml'], datetime(2026, 9, 15)) + assert title == 'PO#6075309 09-15' + + +def test_multi_files_appends_count_suffix(): + """文件总数大于 1 时追加「等 N 个文件」,N 按传入文件名总数计。""" + title = derive_order_extraction_title(['PO#6075309.eml', 'invoice.pdf', 'list.pdf'], datetime(2026, 9, 15)) + assert title == 'PO#6075309 等 3 个文件 09-15' + + +def test_truncates_long_name_to_24_chars(): + """主名超过 24 字符截断,且不吞掉日期后缀。""" + title = derive_order_extraction_title(['A' * 30 + '.pdf'], datetime(2026, 12, 31)) + assert title == 'A' * 24 + ' 12-31' + + +def test_blank_filenames_fall_back_to_default(): + """文件名全空(含空列表与纯空白项)回退写死标题「订单抽取」。""" + assert derive_order_extraction_title([], datetime(2026, 9, 15)) == '订单抽取' + assert derive_order_extraction_title(['', ' '], datetime(2026, 9, 15)) == '订单抽取' diff --git a/backend/tests/test_shipping_order_extraction_conversation_title.py b/backend/tests/test_shipping_order_extraction_conversation_title.py new file mode 100644 index 00000000..8f75fb39 --- /dev/null +++ b/backend/tests/test_shipping_order_extraction_conversation_title.py @@ -0,0 +1,87 @@ +""" +backend/tests/test_shipping_order_extraction_conversation_title.py + +用途:验证订单抽取新建会话按 Intake 资产文件名派生标题,且已存在会话标题一律不动。 +依赖:全局 Flask/SQLite 测试夹具(app)、Run service 的会话解析内部函数。 +逻辑:新建分支走 conversation_title 派生;追加归属等存量路径保持原标题(含「订单抽取」)。 +""" + +from __future__ import annotations + +from app import db +from app.models import Agent, ChatSession, FileAsset, ShippingOrderIntake, User +from app.services.shipping_notice.order_extraction_run_service import _resolve_conversation + + +def _seed_user_agent(suffix: str) -> tuple[User, Agent]: + """构造用户与货代 Agent;suffix 保证同文件内多用例数据隔离。""" + user = User(username=f'title-user-{suffix}', email=f'title-{suffix}@example.com', password_hash='x') + agent = Agent( + name=f'Title Agent {suffix}', + agent_code='shipping_notice', + runtime_provider='hybrid', + dify_app_id=f'title-agent-{suffix}', + dify_api_key='test-key', + is_active=True, + ) + user.agents.append(agent) + db.session.add_all([user, agent]) + db.session.flush() + return user, agent + + +def _seed_intake(suffix: str, user: User, filename: str, conversation_id: str | None = None) -> ShippingOrderIntake: + """构造带资产文件名的已解析 Intake。""" + asset = FileAsset( + asset_no=f'FA-TITLE-{suffix}', + owner_user_id=user.id, + original_filename=filename, + storage_provider='minio', + storage_bucket='test', + storage_key=f'temporary/{user.id}/{filename}', + content_hash=(suffix.lower() * 64)[:64], + file_size=10, + mime_type='application/pdf', + upload_status='ready', + lifecycle_status='temporary', + ) + db.session.add(asset) + db.session.flush() + intake = ShippingOrderIntake( + intake_no=f'SNI-TITLE-{suffix}', + asset_id=asset.id, + user_id=user.id, + conversation_id=conversation_id, + purpose='shipping_notice', + parse_status='parsed', + parser_version='test', + ) + db.session.add(intake) + db.session.flush() + return intake + + +def test_new_session_title_derives_from_intake_filenames(app): + """新建会话:标题 = 首个文件名(剥离邮件前缀)+ 等 N 个文件 + 日期后缀。""" + user, agent = _seed_user_agent('NEW') + first = _seed_intake('NEW1', user, 'RE: PO#6075309 for HOXIN.eml') + second = _seed_intake('NEW2', user, 'invoice.pdf') + + session = _resolve_conversation(user_id=user.id, agent_id=agent.id, conversation_id='', intakes=[first, second]) + + # 日期后缀来自 utcnow,断言前缀避免对当天日期产生脆弱依赖。 + assert session.title.startswith('PO#6075309 for HOXIN 等 2 个文件 ') + + +def test_existing_session_title_stays_untouched(app): + """已存在会话:即便标题仍是写死的「订单抽取」,Intake 归属也不改标题。""" + user, agent = _seed_user_agent('KEEP') + session = ChatSession(session_id='title-session-keep', user_id=user.id, agent_id=agent.id, title='订单抽取') + db.session.add(session) + db.session.flush() + intake = _seed_intake('KEEP1', user, 'RE: PO#6075309.eml', conversation_id=session.session_id) + + resolved = _resolve_conversation(user_id=user.id, agent_id=agent.id, conversation_id='', intakes=[intake]) + + assert resolved.session_id == session.session_id + assert resolved.title == '订单抽取' diff --git a/docs/features/shipping-notice/technical.md b/docs/features/shipping-notice/technical.md index 339ad09a..965a1aa0 100644 --- a/docs/features/shipping-notice/technical.md +++ b/docs/features/shipping-notice/technical.md @@ -2590,6 +2590,21 @@ Task 工作台 = 非主界面,仅保留备用深链 - **自动建单安全**:分类置信度与 LLM 字段置信度缺失 fail-closed;阈值来源写入 `confidence_policy`(schema / key_field / default_fallback)。 - **货代上传**:`SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED` 默认 `false`(须显式开启);开启时启动/触发前校验 Worker(`freight_upload`)、凭据、共享目录与环境隔离。RPA 进行中投影 `display_lifecycle_status=upload_rpa_pending` 且 `is_waiting_manual_upload=false`,不得仅凭 lifecycle 显示为待人工上传。 +### 会话主区域与批次进度中心(2026-09 方案 A) + +- 货代发货智能体主区域规则:`isShippingNoticeAgent && conversation_id 非空` → 全屏渲染批次进度中心 + (`ShippingWorkflowTimeline`,常驻无关闭按钮);否则渲染欢迎页 + 输入框(唯一附件提交入口)。 + 判定纯函数:`frontend/src/features/chat/shipping/shippingWorkbenchLayout.ts`。 +- 提交链路不变:`startRun` 成功 → 路由写回 `conversation_id` → 中心出现;对话流不再出现 + 「本次订单文件处理」卡片入口,`open-batch-workbench` / `compact-shipping-progress` 链路已移除; + `ShippingOrderExtractionCard` 保留为历史消息兜底渲染。 +- 中心头部复用会话标题(父级从侧栏 `displayHistory` 按 conversation_id 匹配传入 `conversation-title`)。 +- 新建抽取会话命名:`backend/app/services/shipping_notice/conversation_title.py` + `derive_order_extraction_title(filenames, created_at)` —— 首个非空文件名去扩展名、剥离 + Re:/Fw:/Fwd:/回复:/转发:前缀、截 24 字、多文件追加「等 N 个文件」、追加 MM-DD; + 全空回退「订单抽取」。仅在 `_resolve_conversation` 新建分支调用;存量会话标题一律不改。 +- 同批次追加附件:中心不提供入口,通过「新建对话」重新提交(后端 append/create 裁决逻辑不变)。 + #### 1.6.0a Gate 统一用户动作裁决(2026-08-19) 为避免“页面按 checkpoint、状态或 action code 猜按钮位置”导致展示与执行漂移,正式履约任务采用以下职责边界: diff --git a/docs/funclist.md b/docs/funclist.md index 849a23a2..252b6cb7 100644 --- a/docs/funclist.md +++ b/docs/funclist.md @@ -24,6 +24,8 @@ - 货代上传:下载 Excel、RPA 上传、按发货通知单号人工确认已上传、失败恢复和未知结果核对;未知结果禁止自动重试。 - 通知完成:只读展示已核验的上传成功证据;仅 Task 聚合、全部预约单与成功 Upload Attempt 同时满足时显示并计入完成。 - 通知完成:上传通知或登记上传回执;仅服务端确认的上传 Attempt 成功后显示完成结果。 +- 货代发货会话主区域为批次进度中心:有会话即全屏常驻展示(不可关闭),无会话显示欢迎页与附件提交入口;历史会话点击直达中心 +- 新建订单抽取会话自动按首个附件文件名命名(剥离邮件前缀 + 等 N 个文件 + 日期后缀);存量会话名不变 - 平台把文本提交给 Dify 后,会继续确认 Dify 的 `indexing_status`;只有 `completed` 才展示“同步:已完成”。 - Dify 返回 `error/failed` 或 60 秒内未完成索引时,同步任务、同步记录和文档卡片会显示失败原因;再次同步会重新提交失败文档。 - 管理端“知识库配置 → Dify 设置”支持配置新建 Dataset 的默认检索模型(检索方式、重排序、Top K、相似度阈值开关及阈值),以及文档同步的自定义分段参数(最大 Token 数、重叠 Token 数);保存仅更新 HXOPS 运行时配置,不自动回写已创建的 Dify Dataset。 diff --git a/docs/superpowers/plans/2026-09-17-shipping-batch-center-first.md b/docs/superpowers/plans/2026-09-17-shipping-batch-center-first.md new file mode 100644 index 00000000..f5dd2d49 --- /dev/null +++ b/docs/superpowers/plans/2026-09-17-shipping-batch-center-first.md @@ -0,0 +1,724 @@ +# 货代批次进度中心优先 + 会话业务命名 实施计划 + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** 货代发货智能体主区域改为「有会话即全屏批次进度中心、无会话显示欢迎页+输入框」,移除对话流「打开批次进度中心」冗余链路;新建抽取会话按首个附件文件名自动派生业务标题。 + +**Architecture:** 后端新增纯函数命名模块并在 `_resolve_conversation` 新建会话时调用;前端把 `ChatViewContent` 的 `batchWorkbenchOpen` 状态机坍缩为 `isShippingNoticeAgent && conversationId` 的纯判定,`ShippingWorkflowTimeline` 常驻主区域(移除关闭按钮、新增会话标题 prop),逐层移除 `open-batch-workbench` / `compact-shipping-progress` prop/emit 链。 + +**Tech Stack:** Flask + SQLAlchemy(后端纯函数 + service 接入);Vue 3 Composition API + Vitest(前端);pytest。 + +**Spec:** `docs/superpowers/specs/2026-09-17-shipping-batch-center-first-design.md`(执行前先读 spec) + +## Global Constraints + +- 禁止新增第三方依赖;无数据库结构变更(无 Alembic 迁移);无环境变量变更;无新增 i18n 文案。 +- 存量会话标题一律不改:`_resolve_conversation` 只在**新建**分支派生标题;不做惰性回填;不做手动改名 API。 +- `ShippingOrderExtractionCard` 组件整体保留,仅删除「打开批次进度中心」按钮与 `compactProgress` prop。 +- 注释遵循 AGENTS.md §5:文件层块注释(用途/依赖/逻辑)、函数层 docstring/JSDoc;改动逻辑必须同步更新受影响注释。 +- 提交信息遵循 Conventional Commits:`(): 中文祈使句≤100字符`。 +- ⚠️ 当前分支 `hugo-shipping-notice` 存在大量与本计划无关的未提交改动:每次提交只 `git add` 本任务明确列出的文件,禁止 `git add -A` / `git add .`。 +- 前端文件顶部如已有块注释被改动逻辑影响,必须同步更新。 + +--- + +### Task 1: 后端纯函数 `derive_order_extraction_title` + +**Files:** +- Create: `backend/app/services/shipping_notice/conversation_title.py` +- Test: `backend/tests/test_shipping_conversation_title.py` + +**Interfaces:** +- Consumes: 无(纯函数,仅标准库)。 +- Produces: `derive_order_extraction_title(filenames: list[str], created_at: datetime) -> str`——Task 2 在 `_resolve_conversation` 中调用。规则:取首个非空文件名去扩展名(`/`、`\` 均视为目录分隔符)→ 循环剥离邮件前缀 `Re:` `Fw:` `Fwd:` `回复:` `转发:`(大小写不敏感)→ 主名截断 24 字符 → 文件总数 > 1 追加 `等 N 个文件`(N 为传入列表长度)→ 追加 ` MM-DD`(`created_at` 月份/日期,不换算时区)→ 全空回退 `订单抽取` → 最终长度钳制 ≤ 60(防御性,正常输入不可达)。 + +- [ ] **Step 1: 写失败测试** + +创建 `backend/tests/test_shipping_conversation_title.py`: + +```python +""" +backend/tests/test_shipping_conversation_title.py + +用途:验证订单抽取会话标题纯函数的派生规则(前缀剥离/截断/计数后缀/日期/回退)。 +依赖:纯函数,无 Flask/DB 夹具。 +逻辑:命名是内容派生的确定性函数,用逐条断言锁定规则,防止后续误改口径。 +""" + +from __future__ import annotations + +from datetime import datetime + +from app.services.shipping_notice.conversation_title import derive_order_extraction_title + + +def test_strips_leading_mail_prefixes_and_appends_date(): + """首个文件名循环剥离 Re/Fw/Fwd/回复/转发 前缀,末尾追加 MM-DD。""" + title = derive_order_extraction_title(['回复:转发:FWD: PO#6075309.eml'], datetime(2026, 9, 15)) + assert title == 'PO#6075309 09-15' + + +def test_multi_files_appends_count_suffix(): + """文件总数大于 1 时追加「等 N 个文件」,N 按传入文件名总数计。""" + title = derive_order_extraction_title(['PO#6075309.eml', 'invoice.pdf', 'list.pdf'], datetime(2026, 9, 15)) + assert title == 'PO#6075309 等 3 个文件 09-15' + + +def test_truncates_long_name_to_24_chars(): + """主名超过 24 字符截断,且不吞掉日期后缀。""" + title = derive_order_extraction_title(['A' * 30 + '.pdf'], datetime(2026, 12, 31)) + assert title == 'A' * 24 + ' 12-31' + + +def test_blank_filenames_fall_back_to_default(): + """文件名全空(含空列表与纯空白项)回退写死标题「订单抽取」。""" + assert derive_order_extraction_title([], datetime(2026, 9, 15)) == '订单抽取' + assert derive_order_extraction_title(['', ' '], datetime(2026, 9, 15)) == '订单抽取' +``` + +- [ ] **Step 2: 运行确认失败** + +Run: `cd backend && python -m pytest tests/test_shipping_conversation_title.py -v` +Expected: FAIL(`ModuleNotFoundError` 或 `ImportError: cannot import name 'derive_order_extraction_title'`) + +- [ ] **Step 3: 最小实现** + +创建 `backend/app/services/shipping_notice/conversation_title.py`: + +```python +""" +backend/app/services/shipping_notice/conversation_title.py + +用途:为订单抽取**新建**会话推导业务化标题,替代写死的「订单抽取」。 +依赖:仅标准库(datetime/pathlib/re);禁止引入 Flask/DB 依赖,保持可单测。 +逻辑:取首个非空附件文件名去扩展名 → 循环剥离邮件前缀 → 截断 24 字符 → + 多文件追加「等 N 个文件」→ 追加 MM-DD 日期消歧 → 全空回退「订单抽取」。 + 仅新建会话时调用;存量会话标题一律不改(设计决策见 2026-09-17 spec)。 +""" + +from __future__ import annotations + +import re +from datetime import datetime +from pathlib import PureWindowsPath + +_FALLBACK_TITLE = '订单抽取' +_NAME_MAX_CHARS = 24 +_TITLE_MAX_CHARS = 60 +# re:/fw:/fwd: 为半角冒号且大小写不敏感;回复/转发为全角冒号。循环剥离以支持多层嵌套。 +_MAIL_PREFIX_PATTERN = re.compile(r'^\s*(?:re|fw|fwd)\s*:|^\s*(?:回复|转发):', re.IGNORECASE) + + +def _strip_mail_prefixes(name: str) -> str: + """循环剥离单个文件名开头的邮件前缀(Re:/Fw:/Fwd:/回复:/转发:)。""" + current = name.strip() + while True: + stripped = _MAIL_PREFIX_PATTERN.sub('', current, count=1).lstrip() + if stripped == current: + return current + current = stripped + + +def derive_order_extraction_title(filenames: list[str], created_at: datetime) -> str: + """ + 按首个附件文件名推导订单抽取会话标题。 + + Args: + filenames: 本次冻结 Intake 对应的资产原始文件名,按 Intake 顺序; + 允许包含空串占位(保持计数口径)。 + created_at: 会话创建时间(服务器 UTC,不做时区换算),提供 MM-DD 消歧后缀。 + Returns: + 形如「PO#6075309 等 11 个文件 09-15」的标题;文件名全空时回退「订单抽取」; + 末尾做 60 字符防御性钳制(24 字主名约束下正常不可达)。 + """ + ordered = [str(name or '').strip() for name in filenames] + usable = [name for name in ordered if name] + if not usable: + return _FALLBACK_TITLE + # PureWindowsPath 同时把 '/' 与 '\' 视为目录分隔符,兼容两类上传来源的路径写法。 + stem = PureWindowsPath(usable[0]).stem + base = _strip_mail_prefixes(stem)[:_NAME_MAX_CHARS].strip() + if not base: + return _FALLBACK_TITLE + parts = [base] + if len(ordered) > 1: + parts.append(f'等 {len(ordered)} 个文件') + parts.append(f'{created_at.month:02d}-{created_at.day:02d}') + return ' '.join(parts)[:_TITLE_MAX_CHARS] +``` + +- [ ] **Step 4: 运行确认通过** + +Run: `cd backend && python -m pytest tests/test_shipping_conversation_title.py -v` +Expected: 4 passed + +- [ ] **Step 5: 提交** + +```bash +git add backend/app/services/shipping_notice/conversation_title.py backend/tests/test_shipping_conversation_title.py +git commit -m "feat(shipping-notice): 新增订单抽取会话业务命名纯函数" +``` + +--- + +### Task 2: `_resolve_conversation` 新建会话接入业务标题 + +**Files:** +- Modify: `backend/app/services/shipping_notice/order_extraction_run_service.py`(`_resolve_conversation`,约 700-757 行;import 区) +- Test: `backend/tests/test_shipping_order_extraction_conversation_title.py`(新建) + +**Interfaces:** +- Consumes: Task 1 的 `derive_order_extraction_title(filenames: list[str], created_at: datetime) -> str`。 +- Produces: 无对外新接口;`_resolve_conversation` 新建分支产生的 `ChatSession.title` 变为业务标题(Task 4 的中心头部经由侧栏历史间接消费该标题)。 + +- [ ] **Step 1: 写失败测试** + +创建 `backend/tests/test_shipping_order_extraction_conversation_title.py`: + +```python +""" +backend/tests/test_shipping_order_extraction_conversation_title.py + +用途:验证订单抽取新建会话按 Intake 资产文件名派生标题,且已存在会话标题一律不动。 +依赖:全局 Flask/SQLite 测试夹具(app)、Run service 的会话解析内部函数。 +逻辑:新建分支走 conversation_title 派生;追加归属等存量路径保持原标题(含「订单抽取」)。 +""" + +from __future__ import annotations + +from app import db +from app.models import Agent, ChatSession, FileAsset, ShippingOrderIntake, User +from app.services.shipping_notice.order_extraction_run_service import _resolve_conversation + + +def _seed_user_agent(suffix: str) -> tuple[User, Agent]: + """构造用户与货代 Agent;suffix 保证同文件内多用例数据隔离。""" + user = User(username=f'title-user-{suffix}', email=f'title-{suffix}@example.com', password_hash='x') + agent = Agent( + name=f'Title Agent {suffix}', + agent_code='shipping_notice', + runtime_provider='hybrid', + dify_app_id=f'title-agent-{suffix}', + dify_api_key='test-key', + is_active=True, + ) + user.agents.append(agent) + db.session.add_all([user, agent]) + db.session.flush() + return user, agent + + +def _seed_intake(suffix: str, user: User, filename: str, conversation_id: str | None = None) -> ShippingOrderIntake: + """构造带资产文件名的已解析 Intake。""" + asset = FileAsset( + asset_no=f'FA-TITLE-{suffix}', + owner_user_id=user.id, + original_filename=filename, + storage_provider='minio', + storage_bucket='test', + storage_key=f'temporary/{user.id}/{filename}', + content_hash=(suffix.lower() * 64)[:64], + file_size=10, + mime_type='application/pdf', + upload_status='ready', + lifecycle_status='temporary', + ) + db.session.add(asset) + db.session.flush() + intake = ShippingOrderIntake( + intake_no=f'SNI-TITLE-{suffix}', + asset_id=asset.id, + user_id=user.id, + conversation_id=conversation_id, + purpose='shipping_notice', + parse_status='parsed', + parser_version='test', + ) + db.session.add(intake) + db.session.flush() + return intake + + +def test_new_session_title_derives_from_intake_filenames(app): + """新建会话:标题 = 首个文件名(剥离邮件前缀)+ 等 N 个文件 + 日期后缀。""" + user, agent = _seed_user_agent('NEW') + first = _seed_intake('NEW1', user, 'RE: PO#6075309 for HOXIN.eml') + second = _seed_intake('NEW2', user, 'invoice.pdf') + + session = _resolve_conversation(user_id=user.id, agent_id=agent.id, conversation_id='', intakes=[first, second]) + + # 日期后缀来自 utcnow,断言前缀避免对当天日期产生脆弱依赖。 + assert session.title.startswith('PO#6075309 for HOXIN 等 2 个文件 ') + + +def test_existing_session_title_stays_untouched(app): + """已存在会话:即便标题仍是写死的「订单抽取」,Intake 归属也不改标题。""" + user, agent = _seed_user_agent('KEEP') + session = ChatSession(session_id='title-session-keep', user_id=user.id, agent_id=agent.id, title='订单抽取') + db.session.add(session) + db.session.flush() + intake = _seed_intake('KEEP1', user, 'RE: PO#6075309.eml', conversation_id=session.session_id) + + resolved = _resolve_conversation(user_id=user.id, agent_id=agent.id, conversation_id='', intakes=[intake]) + + assert resolved.session_id == session.session_id + assert resolved.title == '订单抽取' +``` + +注意:若运行时报 `ShippingOrderIntake` 存在其他非空字段缺省不足(以 `app/models/shipping.py:304` 为准),按既有 `tests/test_shipping_order_extraction_runs.py` 的 `_seed_run_input`(188 行起)补齐同款字段,不得改模型。 + +- [ ] **Step 2: 运行确认失败** + +Run: `cd backend && python -m pytest tests/test_shipping_order_extraction_conversation_title.py -v` +Expected: `test_new_session_title_derives_from_intake_filenames` FAIL(实际 title == '订单抽取');`test_existing_session_title_stays_untouched` PASS + +- [ ] **Step 3: 最小实现** + +`backend/app/services/shipping_notice/order_extraction_run_service.py`: + +3a. import 区新增(与既有顶层 import 并列): + +```python +from app.services.shipping_notice.conversation_title import derive_order_extraction_title +``` + +3b. 在 `_resolve_conversation` 定义之前新增模块级辅助函数: + +```python +def _intake_filenames(intakes: list[ShippingOrderIntake]) -> list[str]: + """按 Intake 顺序取资产原始文件名;无资产或资产缺失以空串占位,保持计数口径。""" + asset_ids = [int(intake.asset_id) for intake in intakes if intake.asset_id] + if not asset_ids: + return [] + rows = db.session.query(FileAsset.id, FileAsset.original_filename).filter(FileAsset.id.in_(asset_ids)).all() + filename_by_id = {row[0]: str(row[1] or '') for row in rows} + return [filename_by_id.get(int(intake.asset_id), '') for intake in intakes if intake.asset_id] +``` + +3c. `_resolve_conversation` 的 `else:` 新建分支(原 736-747 行附近)把写死的 `title='订单抽取',` 替换为派生调用,`FileAsset`/`datetime` 均已在文件顶部导入: + +```python + else: + session = ChatSession( + session_id=uuid.uuid4().hex, + user_id=user_id, + agent_id=agent_id, + title=derive_order_extraction_title(_intake_filenames(intakes), datetime.utcnow()), + status='running', + created_at=datetime.utcnow(), + updated_at=datetime.utcnow(), + last_active_at=datetime.utcnow(), + ) +``` + +3d. 同步注释:`_resolve_conversation` docstring 的 Returns 行后补一句「新建会话的 title 由 conversation_title 按首个 Intake 文件名派生;已存在会话不改动标题。」;函数头文件顶部块注释如提及标题逻辑则同步(先 grep `订单抽取` 确认)。 + +- [ ] **Step 4: 运行确认通过** + +Run: `cd backend && python -m pytest tests/test_shipping_order_extraction_conversation_title.py tests/test_shipping_conversation_title.py -v` +Expected: 6 passed + +- [ ] **Step 5: 回归既有 Run 用例** + +Run: `cd backend && python -m pytest tests/test_shipping_order_extraction_runs.py tests/test_shipping_order_extraction_concurrency.py -v` +Expected: 全部 PASS(既有用例若断言了 `title == '订单抽取'`,仅允许把该断言放宽为「非空标题」并注明「标题已业务化」,其余逻辑禁改) + +- [ ] **Step 6: 提交** + +```bash +git add backend/app/services/shipping_notice/order_extraction_run_service.py backend/tests/test_shipping_order_extraction_conversation_title.py +git commit -m "feat(shipping-notice): 新建抽取会话按附件内容派生标题" +``` + +--- + +### Task 3: 批次进度中心移除关闭入口 + 会话标题展示 + +**Files:** +- Modify: `frontend/src/features/chat/components/shipping/ShippingWorkflowTimeline.vue`(props/emits 定义约 71-75 行;头部模板约 861-890 行) +- Test: `frontend/src/features/chat/components/shipping/ShippingWorkflowTimeline.spec.ts` + +**Interfaces:** +- Consumes: 无。 +- Produces: 新 prop `conversationTitle?: string | null`(Task 4 传入);移除 `close` 事件(Task 4 同步移除监听);新增测试锚点 `data-testid="shipping-workflow-conversation-title"`。 + +- [ ] **Step 1: 更新/新增组件测试(先失败)** + +在 `ShippingWorkflowTimeline.spec.ts` 中: + +1a. 现有 mount 封装函数(返回 `mount(ShippingWorkflowTimeline, {...})`,约 104-113 行)改为支持透传额外 props(保持原函数名不变): + +```ts +function mountTimeline( + processing: ConversationProcessingProjection | null, + workItems: ShippingProcessingProjection[], + extraProps: Record = {}, +) { + return mount(ShippingWorkflowTimeline, { + attachTo: document.body, + props: { conversationId: 'conv-1', controller: buildController(processing, workItems), ...extraProps }, + global: { plugins: [i18n], stubs: { teleport: true } }, + }); +} +``` + +1b. `describe` 内新增用例: + +```ts +it('has no close button and reuses the conversation title in the header', () => { + const wrapper = mountTimeline(processingProjection(), [], { conversationTitle: 'PO#6075309 09-15' }); + + // 中心常驻不可关闭(方案 A):关闭按钮必须消失。 + expect(wrapper.find('[data-testid="shipping-workflow-close"]').exists()).toBe(false); + + // 会话标题直接复用侧栏命名,保持两处一致。 + const titleNode = wrapper.find('[data-testid="shipping-workflow-conversation-title"]'); + expect(titleNode.exists()).toBe(true); + expect(titleNode.text()).toContain('PO#6075309 09-15'); +}); + +it('omits the title node when no conversation title is provided', () => { + const wrapper = mountTimeline(processingProjection(), []); + + expect(wrapper.find('[data-testid="shipping-workflow-conversation-title"]').exists()).toBe(false); +}); +``` + +(若现有封装函数的参数名/默认 props 与上文不同,保持既有行为语义不变,仅追加 `extraProps` 透传能力。) + +- [ ] **Step 2: 运行确认失败** + +Run: `cd frontend && npx vitest run src/features/chat/components/shipping/ShippingWorkflowTimeline.spec.ts` +Expected: 新增第一个用例 FAIL(`shipping-workflow-close` 仍存在、`shipping-workflow-conversation-title` 不存在) + +- [ ] **Step 3: 组件实现** + +`ShippingWorkflowTimeline.vue`: + +3a. props 定义(`conversationId` / `refreshTrigger` / `controller` 之后)新增: + +```ts + /** 当前会话标题;父级从侧栏历史匹配传入,中心头部直接复用(无新增接口)。 */ + conversationTitle?: string | null; +``` + +3b. `defineEmits` 中删除 `close: [];`;随后 grep `emit(` 确认组件内无其余 emit 调用后,整体删除 `const emit = defineEmits<...>();` 块。 + +3c. 头部模板删除 × 关闭按钮整块: + +```html + +``` + +3d. 标题行(`panelTitle` 文本所在的 `flex items-center gap-1.5` div 内、`panelTitle` div 之后)新增: + +```html + {{ conversationTitle }} +``` + +3e. 同步文件顶部块注释「标题栏仅保留批次名称、加载与截断提示」→「标题栏保留批次名称、会话标题、加载与截断提示;中心常驻不可关闭(方案 A)」。 + +- [ ] **Step 4: 运行确认通过** + +Run: `cd frontend && npx vitest run src/features/chat/components/shipping/ShippingWorkflowTimeline.spec.ts` +Expected: 全部 PASS(含既有用例) + +- [ ] **Step 5: 提交** + +```bash +git add frontend/src/features/chat/components/shipping/ShippingWorkflowTimeline.vue frontend/src/features/chat/components/shipping/ShippingWorkflowTimeline.spec.ts +git commit -m "feat(shipping-notice): 批次进度中心移除关闭入口并展示会话标题" +``` + +--- + +### Task 4: `ChatViewContent` 规则坍缩为中心常驻 + +**Files:** +- Create: `frontend/src/features/chat/shipping/shippingWorkbenchLayout.ts` +- Modify: `frontend/src/features/chat/components/ChatViewContent.vue`(script 121-152 行、474-478 行、558/580 行、667-674 行、style 824-835 行、文件头注释 9-11 行) +- Test: `frontend/src/features/chat/shipping/shippingWorkbenchLayout.spec.ts`(新建) + +**Interfaces:** +- Consumes: Task 3 的 `conversationTitle` prop;页面上下文已有 `page.displayHistory`(`DisplayHistoryItem[]`,含 `conversation_id` / `title` 字段,来自 `useChatSessions.ts:86`)。 +- Produces: `shouldShowShippingWorkbench(input: { isShippingNoticeAgent: boolean; conversationId: string | null | undefined }): boolean`;`ChatViewContent` 不再暴露 `open-batch-workbench` 监听与 `compact-shipping-progress` prop(Task 5 清理子组件侧)。 + +- [ ] **Step 1: 写纯判定函数的失败测试** + +创建 `frontend/src/features/chat/shipping/shippingWorkbenchLayout.spec.ts`: + +```ts +/** + * features/chat/shipping/shippingWorkbenchLayout.spec.ts + * 用途:锁定货代会话主区域显隐规则(有会话即全屏批次进度中心,方案 A)。 + * 依赖:Vitest、纯函数。 + * 逻辑:判定必须同时满足货代智能体与非空会话 ID;普通智能体与新会话一律回落欢迎页。 + */ +import { describe, expect, it } from 'vitest'; + +import { shouldShowShippingWorkbench } from './shippingWorkbenchLayout'; + +describe('shouldShowShippingWorkbench', () => { + it('renders the workbench for the shipping agent once a conversation exists', () => { + expect(shouldShowShippingWorkbench({ isShippingNoticeAgent: true, conversationId: 'conv-1' })).toBe(true); + }); + + it('keeps the welcome composer before a conversation is created', () => { + expect(shouldShowShippingWorkbench({ isShippingNoticeAgent: true, conversationId: '' })).toBe(false); + expect(shouldShowShippingWorkbench({ isShippingNoticeAgent: true, conversationId: null })).toBe(false); + }); + + it('never switches other agents to the workbench', () => { + expect(shouldShowShippingWorkbench({ isShippingNoticeAgent: false, conversationId: 'conv-1' })).toBe(false); + }); +}); +``` + +- [ ] **Step 2: 运行确认失败** + +Run: `cd frontend && npx vitest run src/features/chat/shipping/shippingWorkbenchLayout.spec.ts` +Expected: FAIL(模块不存在) + +- [ ] **Step 3: 实现纯判定函数** + +创建 `frontend/src/features/chat/shipping/shippingWorkbenchLayout.ts`: + +```ts +/** + * features/chat/shipping/shippingWorkbenchLayout.ts + * 用途:货代发货会话主区域显隐判定(批次进度中心优先,方案 A)。 + * 依赖:无(纯函数)。 + * 逻辑:货代智能体且存在非空会话 ID 时全屏渲染批次进度中心; + * 否则(新会话欢迎页)显示欢迎页 + 输入框(唯一附件提交入口)。 + */ + +export interface ShippingWorkbenchLayoutInput { + isShippingNoticeAgent: boolean; + conversationId: string | null | undefined; +} + +/** + * 判定是否以批次进度中心作为会话主区域。 + * @param input - 智能体身份与当前会话 ID(路由 query 与 page 回填同源优先级)。 + * @returns true 表示全屏渲染批次进度中心;false 表示欢迎页 + 输入框。 + */ +export function shouldShowShippingWorkbench(input: ShippingWorkbenchLayoutInput): boolean { + return Boolean(input.isShippingNoticeAgent && String(input.conversationId || '').trim()); +} +``` + +- [ ] **Step 4: 运行确认通过** + +Run: `cd frontend && npx vitest run src/features/chat/shipping/shippingWorkbenchLayout.spec.ts` +Expected: 3 passed + +- [ ] **Step 5: `ChatViewContent.vue` 接线** + +5a. script 顶部 import 区新增: + +```ts +import { shouldShowShippingWorkbench } from '@/features/chat/shipping/shippingWorkbenchLayout'; +``` + +5b. 将 script 中 121-152 行整块(`batchWorkbenchOpen`、`showShippingWorkflowTimeline`、`compactShippingProgress`、`openBatchWorkbench`、`closeBatchWorkbench`、「批次中心只服务于用户主动打开时所在的会话」watcher)替换为: + +```ts +/** + * 货代发货会话主区域规则(方案 A): + * 有会话 ID → 全屏批次进度中心(常驻不可关闭);无会话 → 欢迎页 + 输入框(唯一提交入口)。 + */ +const showShippingWorkflowTimeline = computed(() => shouldShowShippingWorkbench({ + isShippingNoticeAgent: page.isShippingNoticeAgent, + conversationId: activeShippingConversationId.value, +})); + +/** 侧栏历史项中的会话标题;批次中心头部直接复用,保持侧栏与中心一致。 */ +const activeShippingConversationTitle = computed(() => ( + page.displayHistory.find((item) => item.conversation_id === activeShippingConversationId.value)?.title || '' +)); +``` + +(原 watcher 的「切换会话关闭工作台」职责由中心自身按 `conversation-id` prop 重新加载数据取代,删除后无需替代逻辑。) + +5c. 模板中 `ShippingWorkflowTimeline`(667-674 行)改为(删除 `@close`、新增标题 prop): + +```html + +``` + +5d. 模板 476-478 行两个包裹 div 移除工作台条件 class(中心 `flex-1` 自然占满,无需压缩列): + +```html +
+``` + +```html +
+``` + +5e. 删除 `` 上的 `:compact-shipping-progress="compactShippingProgress"`(558 行)与 `@open-batch-workbench="openBatchWorkbench"`(580 行)两行。 + +5f. 删除文件底部 ` - diff --git a/frontend/src/features/chat/components/messages/ChatMessageBubble.vue b/frontend/src/features/chat/components/messages/ChatMessageBubble.vue index 610927f5..fa06c1bf 100644 --- a/frontend/src/features/chat/components/messages/ChatMessageBubble.vue +++ b/frontend/src/features/chat/components/messages/ChatMessageBubble.vue @@ -75,7 +75,6 @@ const { leaveHandlers: LeaveMessageHandlers; shippingHandlers: ShippingMessageHandlers; trainingHandlers: TrainingHandlers; - compactShippingProgress?: boolean; /** 下方已有货代进度卡时,用户气泡附件只显示摘要。 */ attachmentSummaryOnly?: boolean; }>(); @@ -89,7 +88,6 @@ const emit = defineEmits<{ 'maintenance-edit-record': [record: MaintenanceRecord]; 'maintenance-view-record-history': [device: MaintenanceDevice]; 'maintenance-create-record-for-device': [device: MaintenanceDevice]; - 'open-batch-workbench': []; }>(); const authStore = useAuthStore(); @@ -747,11 +745,9 @@ function handleInlineDownload(file: InlineDownloadFile): void { :retrying="retryingOrderExtraction" :refreshing="refreshingOrderExtraction" :cancelling="cancellingOrderExtraction" - :compact-progress="compactShippingProgress" @retry="retryShippingOrderExtraction" @refresh="refreshShippingOrderExtraction" @cancel="cancelShippingOrderExtraction" - @open-batch-workbench="emit('open-batch-workbench')" /> { }, }); - expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true); + // 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。 + expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false); }); it('does not present historical handling items or CTA as current work when the live projection exists', () => { @@ -115,16 +116,6 @@ describe('ShippingOrderExtractionCard', () => { expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false); }); - it('collapses file-level progress when the batch workbench is open', () => { - const wrapper = mount(ShippingOrderExtractionCard, { - props: { state: buildState(), runNo: 'SNER-COMPACT', compactProgress: true }, - global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: { processingWorkItems: ref([]) } } }, - }); - - expect(wrapper.find('[data-testid="shipping-order-extraction-status-groups"]').exists()).toBe(false); - expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false); - }); - it('uses unified EML aggregation and keeps candidate creation out of completed', async () => { const aggregate = { workItemType: 'order_task', workItemNo: 'INTAKE:SNI-1', sourceType: 'eml', rootOrderTaskNo: 'OT-1', @@ -643,7 +634,8 @@ describe('ShippingOrderExtractionCard', () => { expect(wrapper.text()).toContain('3 个文件'); expect(wrapper.text()).toContain('系统处理中'); expect(wrapper.text()).toContain('处理时间偏长'); - expect(wrapper.text()).toContain('打开批次进度中心'); + // 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。 + expect(wrapper.text()).not.toContain('打开批次进度中心'); expect(wrapper.text()).not.toContain('刷新状态'); expect(wrapper.text()).not.toContain('取消本次识别'); expect(wrapper.text()).not.toContain('PO-450003.pdf'); @@ -731,7 +723,8 @@ describe('ShippingOrderExtractionCard', () => { }); expect(wrapper.text()).toContain('订单候选已生成'); expect(wrapper.text()).toContain('候选待人工确认 · 2 项'); - expect(wrapper.text()).toContain('打开批次进度中心'); + // 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。 + expect(wrapper.text()).not.toContain('打开批次进度中心'); expect(wrapper.text()).not.toContain('部分附件需人工处理'); expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(0); }); @@ -826,7 +819,8 @@ describe('ShippingOrderExtractionCard', () => { }); expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false); expect(wrapper.find('[data-testid="shipping-order-extraction-view-details"]').exists()).toBe(false); - expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true); + // 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。 + expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false); }); it('does not render multi-OT ChatProgressSummary list', () => { @@ -914,7 +908,8 @@ describe('ShippingOrderExtractionCard', () => { global: { plugins: [i18n] }, }); expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false); - expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true); + // 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。 + expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false); }); it('does not render the removed view details link', () => { @@ -956,7 +951,8 @@ describe('ShippingOrderExtractionCard', () => { }, }, }); - expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true); + // 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。 + expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false); expect(wrapper.text()).toContain('共 1 个文件'); }); diff --git a/frontend/src/features/chat/components/shipping/ShippingOrderExtractionCard.vue b/frontend/src/features/chat/components/shipping/ShippingOrderExtractionCard.vue index 4d938e20..d9eae55b 100644 --- a/frontend/src/features/chat/components/shipping/ShippingOrderExtractionCard.vue +++ b/frontend/src/features/chat/components/shipping/ShippingOrderExtractionCard.vue @@ -1,14 +1,14 @@ /** * features/chat/components/shipping/ShippingOrderExtractionCard.vue - * 用途:聊天主区「本次订单文件处理」摘要卡——标题、文件数+状态、一行 handling 摘要、唯一主 CTA、查看详情。 + * 用途:聊天主区「本次订单文件处理」摘要卡——标题、文件数+状态、一行 handling 摘要、无对话流 CTA(批次中心常驻,方案 A)。 * 依赖:订单抽取 Run 状态卡 DTO、shipping.api 文档/进度接口、ShippingOrderExtractionDetailsDrawer、vue-router、vue-i18n。 - * 逻辑:对话区默认展示状态-EML 聚合;批次工作台打开后切换为紧凑摘要,长进度/Gate/刷新取消由工作台承接。 + * 逻辑:对话区默认展示状态-EML 聚合;无对话流 CTA(批次中心常驻,方案 A),长进度/Gate/刷新取消由工作台承接。 */