- 会话命名:新增业务命名纯函数,新建抽取会话按附件内容派生标题,仅新建不回填不改名 - 批次中心常驻主区域并展示会话标题:移除关闭入口、隐藏对话列、去除面板外壳与折叠/钉住徽标 - 清理对话流打开批次中心的冗余链路 - 新增设计文档与实施计划,同步功能清单说明
35 KiB
货代批次进度中心优先 + 会话业务命名 实施计划
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组件整体保留,仅删除「打开批次进度中心」按钮与compactProgressprop。- 注释遵循 AGENTS.md §5:文件层块注释(用途/依赖/逻辑)、函数层 docstring/JSDoc;改动逻辑必须同步更新受影响注释。
- 提交信息遵循 Conventional Commits:
<type>(<scope>): 中文祈使句≤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:
"""
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:
"""
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: 提交
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:
"""
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 并列):
from app.services.shipping_notice.conversation_title import derive_order_extraction_title
3b. 在 _resolve_conversation 定义之前新增模块级辅助函数:
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 均已在文件顶部导入:
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: 提交
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(保持原函数名不变):
function mountTimeline(
processing: ConversationProcessingProjection | null,
workItems: ShippingProcessingProjection[],
extraProps: Record<string, unknown> = {},
) {
return mount(ShippingWorkflowTimeline, {
attachTo: document.body,
props: { conversationId: 'conv-1', controller: buildController(processing, workItems), ...extraProps },
global: { plugins: [i18n], stubs: { teleport: true } },
});
}
1b. describe 内新增用例:
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 之后)新增:
/** 当前会话标题;父级从侧栏历史匹配传入,中心头部直接复用(无新增接口)。 */
conversationTitle?: string | null;
3b. defineEmits 中删除 close: [];;随后 grep emit( 确认组件内无其余 emit 调用后,整体删除 const emit = defineEmits<...>(); 块。
3c. 头部模板删除 × 关闭按钮整块:
<button
type="button"
class="shrink-0 rounded-md p-1.5 text-muted hover:bg-surface-muted hover:text-primary"
data-testid="shipping-workflow-close"
:title="t('chat.shippingProcessing.closeWorkbench')"
@click="emit('close')"
>
×
</button>
3d. 标题行(panelTitle 文本所在的 flex items-center gap-1.5 div 内、panelTitle div 之后)新增:
<span
v-if="conversationTitle"
class="min-w-0 truncate rounded bg-surface-muted px-1.5 py-0.5 text-xs text-secondary"
data-testid="shipping-workflow-conversation-title"
:title="conversationTitle"
>{{ conversationTitle }}</span>
3e. 同步文件顶部块注释「标题栏仅保留批次名称、加载与截断提示」→「标题栏保留批次名称、会话标题、加载与截断提示;中心常驻不可关闭(方案 A)」。
- Step 4: 运行确认通过
Run: cd frontend && npx vitest run src/features/chat/components/shipping/ShippingWorkflowTimeline.spec.ts
Expected: 全部 PASS(含既有用例)
- Step 5: 提交
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 的
conversationTitleprop;页面上下文已有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-progressprop(Task 5 清理子组件侧)。 -
Step 1: 写纯判定函数的失败测试
创建 frontend/src/features/chat/shipping/shippingWorkbenchLayout.spec.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:
/**
* 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 区新增:
import { shouldShowShippingWorkbench } from '@/features/chat/shipping/shippingWorkbenchLayout';
5b. 将 script 中 121-152 行整块(batchWorkbenchOpen、showShippingWorkflowTimeline、compactShippingProgress、openBatchWorkbench、closeBatchWorkbench、「批次中心只服务于用户主动打开时所在的会话」watcher)替换为:
/**
* 货代发货会话主区域规则(方案 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):
<ShippingWorkflowTimeline
v-if="showShippingWorkflowTimeline"
:conversation-id="activeShippingConversationId"
:conversation-title="activeShippingConversationTitle"
:refresh-trigger="page.workflowRefreshTrigger"
:controller="shippingProcessing"
/>
5d. 模板 476-478 行两个包裹 div 移除工作台条件 class(中心 flex-1 自然占满,无需压缩列):
<div v-else class="flex min-h-0 min-w-0 flex-1">
<div class="flex min-h-0 min-w-0 flex-1 flex-col">
5e. 删除 <ChatMessageList> 上的 :compact-shipping-progress="compactShippingProgress"(558 行)与 @open-batch-workbench="openBatchWorkbench"(580 行)两行。
5f. 删除文件底部 <style scoped> 中 @media (min-width: 1024px) 整块(.shipping-workbench-layout / .shipping-chat-column);若 style 块因此为空则连 <style scoped> 标签一并删除。
5g. 文件头块注释(9-11 行)「右侧『本次处理』由 conversationId 驱动…」改写为「货代会话主区域:有会话即全屏批次进度中心(常驻),无会话为欢迎页+输入框;会话标题取自侧栏历史并传给中心」。
- Step 6: 类型与测试门禁
Run: cd frontend && npx vitest run src/features/chat/shipping/shippingWorkbenchLayout.spec.ts src/features/chat/components/shipping/ShippingWorkflowTimeline.spec.ts && npm run build
Expected: 测试全绿、build 通过(此时 ChatMessageList 仍声明但无人传 compact-shipping-progress、open-batch-workbench,属合法中间态,Task 5 清理)
- Step 7: 提交
git add frontend/src/features/chat/shipping/shippingWorkbenchLayout.ts frontend/src/features/chat/shipping/shippingWorkbenchLayout.spec.ts frontend/src/features/chat/components/ChatViewContent.vue
git commit -m "feat(shipping-notice): 货代会话主区域切换为批次中心常驻"
Task 5: 移除 open-batch-workbench / compactShippingProgress 冗余链路
Files:
- Modify:
frontend/src/features/chat/components/ChatMessageList.vue(props 57 行、emits 71 行、模板 210/220 行) - Modify:
frontend/src/features/chat/components/messages/ChatMessageBubble.vue(props 78 行、emits 92 行、模板 750/754 行) - Modify:
frontend/src/features/chat/components/shipping/ShippingOrderExtractionCard.vue(propscompactProgress约 50-52 行、emits 约 55 行、lucide import 15 行、CTA 模板块约 947-960 行) - Test:
frontend/src/features/chat/components/shipping/ShippingOrderExtractionCard.spec.ts(77、111-124、829、917、959 行附近)
Interfaces:
-
Consumes: Task 4 已移除父级监听/传参。
-
Produces:
ShippingOrderExtractionCard对外不再有open-batch-workbench事件与compactProgressprop;消息链不再透传两者。组件其余能力(状态卡渲染/重试/刷新/取消)全部保留。 -
Step 1: 更新卡片测试(先失败)
ShippingOrderExtractionCard.spec.ts:
1a. 77、829、917、959 行四处 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);
1b. 删除用例 collapses file-level progress when the batch workbench is open(约 111-124 行,compactProgress prop 已不存在,紧凑模式语义随之移除)。
- Step 2: 运行确认失败
Run: cd frontend && npx vitest run src/features/chat/components/shipping/ShippingOrderExtractionCard.spec.ts
Expected: 1a 改动后的四处断言 FAIL(按钮仍渲染)
- Step 3: 删除链路实现
3a. ShippingOrderExtractionCard.vue:
- 删除 CTA 整块(外层
div.flex.justify-end.border-t.border-default.bg-brand-50\/60.p-3连同内部「打开批次进度中心」按钮,约 947-960 行); - emits 定义删除
'open-batch-workbench': [];;props 删除compactProgress?: boolean;及其注释行; - 文件内 grep
ArrowRight:仅按钮在用时从 lucide import 中移除; - 文件头块注释「唯一主 CTA、查看详情」与「批次工作台打开后切换为紧凑摘要」改为「无对话流 CTA(批次中心常驻,方案 A)」。
3b. ChatMessageBubble.vue:props 删除 compactShippingProgress?: boolean;(78 行);emits 删除 'open-batch-workbench': [];(92 行);模板删除 :compact-progress="compactShippingProgress"(750 行)与 @open-batch-workbench="emit('open-batch-workbench')"(754 行)。
3c. ChatMessageList.vue:props 删除 compactShippingProgress?: boolean;(57 行);emits 删除 'open-batch-workbench': [];(71 行);模板删除 :compact-shipping-progress="compactShippingProgress"(210 行)与 @open-batch-workbench="emit('open-batch-workbench')"(220 行)。
3d. 三处文件头块注释若提及 CTA/紧凑模式,同步为「对话流仅保留状态卡渲染(历史兜底),批次中心入口已移除(方案 A)」。
- Step 4: 运行确认通过
Run: cd frontend && npx vitest run src/features/chat/components/shipping/ShippingOrderExtractionCard.spec.ts && npm run build
Expected: 卡片 spec 全绿;build 通过(无未使用变量/导入的 TS 报错)
- Step 5: 相关组件回归
Run: cd frontend && npx vitest run src/features/chat
Expected: chat 域全部 spec 通过(重点:ChatMessageList 相关、ShippingConversationProcessingCard.spec.ts、ChatViewContent 无既有 spec 不受影响)
- Step 6: 提交
git add frontend/src/features/chat/components/ChatMessageList.vue frontend/src/features/chat/components/messages/ChatMessageBubble.vue frontend/src/features/chat/components/shipping/ShippingOrderExtractionCard.vue frontend/src/features/chat/components/shipping/ShippingOrderExtractionCard.spec.ts
git commit -m "refactor(shipping-notice): 移除对话流打开批次中心冗余链路"
Task 6: 文档同步与全量门禁
Files:
- Modify:
docs/funclist.md(货代发货功能清单小节) - Modify:
docs/features/shipping-notice/technical.md(交互链路章节)
Interfaces:
-
Consumes: Task 1-5 的最终行为。
-
Produces: 与代码一致的文档(AGENTS.md §9 强制)。
-
Step 1: 更新
docs/funclist.md
grep -n "货代发货" docs/funclist.md 定位小节;grep -n "打开批次进度中心\|批次进度" docs/funclist.md 找到既有相关行。在该小节新增两行(沿用本文件既有条目格式,列表或表格随原文):
- 货代发货会话主区域为批次进度中心:有会话即全屏常驻展示(不可关闭),无会话显示欢迎页与附件提交入口;历史会话点击直达中心
- 新建订单抽取会话自动按首个附件文件名命名(剥离邮件前缀 + 等 N 个文件 + 日期后缀);存量会话名不变
既有「打开批次进度中心」相关条目改为「(已下线对话流入口,批次中心为会话主区域)」措辞,不删除历史行文风格。
- Step 2: 更新
docs/features/shipping-notice/technical.md
grep -n "批次进度中心\|openBatchWorkbench\|batchWorkbenchOpen" docs/features/shipping-notice/technical.md 定位相关章节,更新/新增如下要点(跟随原文档章节结构,不另起重复章节):
### 会话主区域与批次进度中心(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 裁决逻辑不变)。
- Step 3: 全量门禁
Run: cd frontend && npm run build
Expected: 构建通过
Run: cd backend && python -m pytest tests/test_shipping_conversation_title.py tests/test_shipping_order_extraction_conversation_title.py tests/test_shipping_order_extraction_runs.py -v
Expected: 全部 PASS
- Step 4: 提交
git add docs/funclist.md docs/features/shipping-notice/technical.md
git commit -m "docs(shipping-notice): 同步批次中心优先与会话命名说明"
验收核对(对照 spec §8)
- 新会话发附件 → 提交成功后全屏批次进度中心,无对话卡、无关闭按钮(Task 3/4);
- 历史会话点击 → 直达该会话中心(Task 4 规则天然覆盖);
- 新批次会话名形如
PO#6075309 for HOXIN 等 2 个文件 09-15;存量名不变(Task 1/2); - 普通智能体零变化;前端 build 与后端相关 pytest 全绿(Task 4-6)。