fix(shipping-notice): 修复模板签名误杀 Qty.Req 并加固订单抽取链路

收紧动态 token 过滤避免列名被剔除;同步表区裁剪、物理表门禁、邮件补充合并与对话附件折叠展示。
This commit is contained in:
hugo committed 2026-09-08 14:06:27 +08:00
1 parent e40743871c
commit 5ce9221476
29 files changed
+1702 -108

No files matched your search

@@ -409,6 +409,167 @@ describe('useShippingOrderExtractionRuns lifecycle', () => {
expect(api.getRun).toHaveBeenCalledWith('SNER-LATEST', expect.any(AbortSignal));
harness.runs.stopPolling();
});
it('restores the submission primary instead of a newer sibling Run without client_submission_id', async () => {
const sibling = Object.assign(run({
run_no: 'SNER-SIBLING',
conversation_id: 'conv-1',
status: 'processing',
created_at: '2026-09-07T11:25:47Z',
}), { client_submission_id: null, upload_batch_id: null });
const primary = Object.assign(run({
run_no: 'SNER-PRIMARY',
conversation_id: 'conv-1',
status: 'processing',
created_at: '2026-09-07T10:54:34Z',
}), { client_submission_id: 'SUB-ONCE', upload_batch_id: null });
// 模拟后端会话短列表:sibling 虽更新,但 primary 排前(或至少出现在列表中)。
api.listRuns.mockResolvedValue({ items: [sibling, primary] });
api.getRun.mockResolvedValue(primary);
const harness = createHarness();
harness.conversationId.value = 'conv-1';
await harness.runs.restoreForConversation('conv-1');
expect(api.getRun).toHaveBeenCalledWith('SNER-PRIMARY', expect.any(AbortSignal));
expect(harness.runs.getActiveRunNo()).toBe('SNER-PRIMARY');
expect(harness.messages.value.filter((item) => item.shipping_order_extraction_state)).toHaveLength(1);
expect(harness.messages.value[0]?.payload).toMatchObject({
order_extraction_run_no: 'SNER-PRIMARY',
shipping_order_extraction_client_submission_id: 'SUB-ONCE',
});
harness.runs.stopPolling();
});
it('keeps an existing primary progress card instead of upserting a sibling on restore', async () => {
const primary = Object.assign(run({
run_no: 'SNER-PRIMARY',
conversation_id: 'conv-1',
status: 'partially_completed',
}), { client_submission_id: 'SUB-ONCE', upload_batch_id: null });
const sibling = Object.assign(run({
run_no: 'SNER-SIBLING',
conversation_id: 'conv-1',
status: 'partially_completed',
}), { client_submission_id: null, upload_batch_id: null });
api.listRuns.mockResolvedValue({ items: [sibling] });
api.getRun.mockResolvedValue(primary);
const harness = createHarness();
harness.conversationId.value = 'conv-1';
harness.messages.value = [{
role: 'assistant',
type: 'text',
content: '',
local_id: 'existing-primary-card',
shipping_order_extraction_state: {
status: 'partially_completed',
runNo: 'SNER-PRIMARY',
clientSubmissionId: 'SUB-ONCE',
uploadBatchId: null,
summary: {
totalDocuments: 22,
pendingDocuments: 0,
processingDocuments: 0,
completedDocuments: 15,
reviewRequiredDocuments: 7,
failedDocuments: 0,
cancelledDocuments: 0,
candidateCount: 0,
},
availableActions: [],
terminal: true,
refreshFailed: false,
},
payload: {
formId: 'shipping-order-extraction-run:SNER-PRIMARY',
order_extraction_run_no: 'SNER-PRIMARY',
shipping_order_extraction_client_submission_id: 'SUB-ONCE',
},
}];
await harness.runs.restoreForConversation('conv-1');
// sibling 不在已有卡列表命中时,仍应直拉已有卡 run_no,而不是 list[0] sibling。
expect(api.getRun).toHaveBeenCalledWith('SNER-PRIMARY', expect.any(AbortSignal));
expect(harness.messages.value.filter((item) => item.shipping_order_extraction_state)).toHaveLength(1);
expect(harness.messages.value[0]?.payload?.order_extraction_run_no).toBe('SNER-PRIMARY');
});
it('prunes an orphan sibling progress card when restoring a submission primary', async () => {
const primary = Object.assign(run({
run_no: 'SNER-PRIMARY',
conversation_id: 'conv-1',
status: 'partially_completed',
}), { client_submission_id: 'SUB-ONCE', upload_batch_id: null });
api.listRuns.mockResolvedValue({ items: [primary] });
api.getRun.mockResolvedValue(primary);
const harness = createHarness();
harness.conversationId.value = 'conv-1';
harness.messages.value = [
{
role: 'assistant',
type: 'text',
content: '',
local_id: 'primary-card',
shipping_order_extraction_state: {
status: 'partially_completed',
runNo: 'SNER-PRIMARY',
clientSubmissionId: 'SUB-ONCE',
summary: {
totalDocuments: 1,
pendingDocuments: 0,
processingDocuments: 0,
completedDocuments: 1,
reviewRequiredDocuments: 0,
failedDocuments: 0,
cancelledDocuments: 0,
candidateCount: 0,
},
availableActions: [],
terminal: true,
refreshFailed: false,
},
payload: {
formId: 'shipping-order-extraction-run:SNER-PRIMARY',
order_extraction_run_no: 'SNER-PRIMARY',
shipping_order_extraction_client_submission_id: 'SUB-ONCE',
},
},
{
role: 'assistant',
type: 'text',
content: '',
local_id: 'orphan-sibling-card',
shipping_order_extraction_state: {
status: 'partially_completed',
runNo: 'SNER-SIBLING',
summary: {
totalDocuments: 1,
pendingDocuments: 0,
processingDocuments: 0,
completedDocuments: 1,
reviewRequiredDocuments: 0,
failedDocuments: 0,
cancelledDocuments: 0,
candidateCount: 0,
},
availableActions: [],
terminal: true,
refreshFailed: false,
},
payload: {
formId: 'shipping-order-extraction-run:SNER-SIBLING',
order_extraction_run_no: 'SNER-SIBLING',
},
},
];
await harness.runs.restoreForConversation('conv-1');
const cards = harness.messages.value.filter((item) => item.shipping_order_extraction_state);
expect(cards).toHaveLength(1);
expect(cards[0]?.payload?.order_extraction_run_no).toBe('SNER-PRIMARY');
});
});