feat(chat): 优化发货相关消息处理逻辑

- 在列出聊天消息时,过滤掉类型为'shipping-parse-review'的消息
- 移除不再使用的shippingConversationTaskIdCache
- 更新发货决策处理逻辑,简化保存消息的参数
- 添加发货动作按钮刷新时的任务定位优先级逻辑
- 移除解析复核消息的展示逻辑,统一处理到轻量工作台
- 增加单元测试,验证发货动作按钮刷新时的任务定位优先级
This commit is contained in:
hugo committed 2026-07-01 08:57:36 +08:00
1 parent 9f5493185d
commit 6a0a51313f
18 files changed
+1230 -199

No files matched your search

+33 -1
View File
@@ -56,7 +56,7 @@ def test_chat_history_with_query_param(client):
# 1. Test without agent_id (Should fail with 400)
res = client.get('/api/chat/sessions', headers=headers)
assert res.status_code == 400
assert 'agent_id is required' in res.get_json()['error']
assert res.get_json()['error']['message'] == 'agent_id is required'
# 2. Test with agent_id in query string (Should succeed)
res = client.get('/api/chat/sessions?agent_id=1', headers=headers)
@@ -86,6 +86,38 @@ def test_chat_messages_history(client):
assert msgs[1]['content'] == 'Hello'
def test_local_assistant_message_query_does_not_duplicate_user_bubble(client):
"""助手本地消息即使误传 query,历史回放也不能多生成一条用户确认。"""
headers = get_headers(client)
user_res = client.post('/api/chat/messages/local?agent_id=1', headers=headers, json={
'conversation_id': 'conv-local-confirm',
'role': 'user',
'type': 'text',
'content': '确认\n任务编号:SN-001',
'query': '确认',
})
assert user_res.status_code == 200
assistant_res = client.post('/api/chat/messages/local?agent_id=1', headers=headers, json={
'conversation_id': 'conv-local-confirm',
'role': 'assistant',
'type': 'text',
'content': '已确认,进入下一步。',
'query': '确认',
})
assert assistant_res.status_code == 200
res = client.get('/api/chat/messages?conversation_id=conv-local-confirm&agent_id=1', headers=headers)
assert res.status_code == 200
msgs = res.get_json()
user_messages = [item for item in msgs if item['role'] == 'user']
assert len(user_messages) == 1
assert user_messages[0]['content'] == '确认'
assert msgs[-1]['role'] == 'assistant'
assert msgs[-1]['content'] == '已确认,进入下一步。'
def test_chat_sessions_keep_latest_non_empty_query_as_title(client):
headers = get_headers(client)