feat(shipping-notice): 新增通用解析能力,优化性能并清理遗留废弃代码

This commit is contained in:
hugo committed 2026-08-23 00:27:18 +08:00
1 parent 935bf26fa6
commit 7cfd5d167e
230 files changed
+9337 -10989

No files matched your search

@@ -37,21 +37,15 @@ describe('useChat user attachment snapshots', () => {
});
});
const buildBatchUiStateEvent = (
const buildTaskUiStateEvent = (
taskNo: string,
batchNo: string,
actionId: string,
checkpoint = 'ready_export',
) => ({
event: 'shipping_ui_state',
batch_no: batchNo,
batch_ui_state: {
batch_no: batchNo,
current_focus_task_no: taskNo,
tasks: [],
focus_task_ui_state: {
task_no: taskNo,
ui_state: {
task_no: taskNo,
batch_no: batchNo,
checkpoint,
match_status: 'matched',
review_status: null,
@@ -73,7 +67,6 @@ const buildBatchUiStateEvent = (
},
],
updated_at: '2026-07-01T10:00:00+08:00',
},
},
});
@@ -81,38 +74,38 @@ describe('useChat shipping_ui_state SSE', () => {
it('hydrates ui_state for notifications and never attaches chat fulfillment actions', () => {
const message: ChatMessage = {
role: 'assistant',
content: '当前正在处理批次任务',
content: '当前正在处理任务',
type: 'shipping-match-result',
payload: { action_buttons: [{ id: 'legacy' }] },
};
const batchEvent = buildBatchUiStateEvent('SN-UNIT-001', 'SB-UNIT-001', 'generate_excel');
const taskEvent = buildTaskUiStateEvent('SN-UNIT-001', 'generate_excel');
applyShippingUiStateToMessage(message, batchEvent);
applyShippingUiStateToMessage(message, taskEvent);
expect(message.shipping_ui_state?.task_no).toBe('SN-UNIT-001');
expect(message.shipping_actions).toBeUndefined();
expect((message.payload as { action_buttons?: unknown[] }).action_buttons).toBeUndefined();
expect((message.payload as { shipping_batch_ui_state?: { batch_no?: string } }).shipping_batch_ui_state?.batch_no).toBe('SB-UNIT-001');
expect((message.payload as { shipping_ui_state?: { task_no?: string } }).shipping_ui_state?.task_no).toBe('SN-UNIT-001');
});
it('updates ui_state when batch focus task changes without remounting action buttons', () => {
it('updates ui_state when task changes without remounting action buttons', () => {
const message: ChatMessage = {
role: 'assistant',
content: '请继续处理当前批次',
content: '请继续处理当前任务',
payload: { action_buttons: [] },
};
applyShippingUiStateToMessage(message, buildBatchUiStateEvent('SN-FOCUS-A', 'SB-FOCUS-001', 'generate_excel'));
applyShippingUiStateToMessage(message, buildTaskUiStateEvent('SN-FOCUS-A', 'generate_excel'));
expect(message.shipping_ui_state?.task_no).toBe('SN-FOCUS-A');
expect(message.shipping_actions).toBeUndefined();
applyShippingUiStateToMessage(message, buildBatchUiStateEvent('SN-FOCUS-B', 'SB-FOCUS-001', 'retry_upload'));
applyShippingUiStateToMessage(message, buildTaskUiStateEvent('SN-FOCUS-B', 'retry_upload'));
expect(message.shipping_ui_state?.task_no).toBe('SN-FOCUS-B');
expect(message.shipping_actions).toBeUndefined();
expect((message.payload as { shipping_batch_ui_state?: { current_focus_task_no?: string } }).shipping_batch_ui_state?.current_focus_task_no)
expect((message.payload as { shipping_ui_state?: { task_no?: string } }).shipping_ui_state?.task_no)
.toBe('SN-FOCUS-B');
});
});