feat(shipping-notice): 实现对话级批量重试自动推进功能,优化库存与PDF匹配逻辑
- 新增对话级批量重试自动推进的完整链路:后端服务、API、数据投影逻辑 - 前端新增对话级重试按钮、多语言国际化支持与API类型定义 - 优化行级库存重试控制,新增retryable字段统一管控重试按钮展示,清理废弃的view_fulfillment_detail动作,标准化前端动作码排序逻辑 - 修复PDF坐标匹配的fail-close防护逻辑,避免生成伪精确匹配分数 - 调整订单确认后流程,提前进入库存获取阶段,移除冗余的确认建单按钮,优化用户流转体验 - 新增对应单元测试用例覆盖核心业务逻辑
This commit is contained in:
1 parent
fd6a23f870
commit
1008911a7e
41 files changed
+3956
-1256
No files matched your search
@@ -12,6 +12,7 @@ import type {
|
||||
ShippingProcessingActionIntent,
|
||||
ShippingProcessingProjection,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import { normalizeActionCodes } from '@/features/chat/shipping/conversationProcessingProjection';
|
||||
import type { ActionPresentation, ActionPresentationItem, ActionPresentationSurface } from './types';
|
||||
import type { WorkbenchPanelAvailability } from './workbenchActionRegistry';
|
||||
import {
|
||||
@@ -65,6 +66,10 @@ const ACTION_CODE_TO_INTENT: Record<string, ShippingProcessingActionIntent> = {
|
||||
};
|
||||
|
||||
const AUTOMATING_STATUSES = new Set(['processing', 'automating', 'queued']);
|
||||
const NEEDS_ACTION_STATUSES = new Set([
|
||||
'blocked', 'waiting_review', 'pending_review', 'failed', 'reparse_failed',
|
||||
'manual_upload_pending', 'upload_rpa_failed',
|
||||
]);
|
||||
/** 永不升为主 CTA 的动作码(仍可作次要/溢出)。 */
|
||||
const NEVER_PRIMARY_CODES = new Set(['cancel_task', 'cancel_run', 'view_details']);
|
||||
|
||||
@@ -213,7 +218,9 @@ export function resolveProcessingActionPresentation(
|
||||
};
|
||||
|
||||
pushCode(projection.currentGate?.nextActionCode);
|
||||
for (const action of projection.availableActions || []) {
|
||||
// [ORDER-STABLE] 对 availableActions 标准化(去重 + 字典序排序),确保后端返回顺序不影响前端按钮顺序。
|
||||
const normalizedAvailableActions = normalizeActionCodes(projection.availableActions || []);
|
||||
for (const action of normalizedAvailableActions) {
|
||||
pushCode(action);
|
||||
}
|
||||
|
||||
@@ -243,6 +250,12 @@ export function resolveConversationTaskActionPresentation(
|
||||
if (!task) return empty;
|
||||
|
||||
const surface = options?.surface || 'right';
|
||||
const status = String(task.status_label || '').trim().toLowerCase();
|
||||
const isNeedsAction = task.group === 'needs_action' || NEEDS_ACTION_STATUSES.has(status);
|
||||
const isProcessing = task.group === 'processing' || AUTOMATING_STATUSES.has(status);
|
||||
if (task.group === 'history' || status === 'cancelled') {
|
||||
return empty;
|
||||
}
|
||||
const items: ActionPresentationItem[] = [];
|
||||
const seen = new Set<string>();
|
||||
|
||||
@@ -258,16 +271,27 @@ export function resolveConversationTaskActionPresentation(
|
||||
};
|
||||
|
||||
pushCode(task.primary_action);
|
||||
for (const action of task.available_actions || []) {
|
||||
// [ORDER-STABLE] 对 available_actions 标准化排序,确保后端顺序变化不影响按钮渲染顺序。
|
||||
const normalizedTaskActions = normalizeActionCodes(task.available_actions || []);
|
||||
for (const action of normalizedTaskActions) {
|
||||
pushCode(action);
|
||||
}
|
||||
|
||||
// 无正式业务入口时,默认提供查看进度(focus_task)。
|
||||
// 人工待办禁止伪造查看进度;无明确动作时进入订单处理作为安全兜底。
|
||||
if (isNeedsAction && !items.some((item) => !NEVER_PRIMARY_CODES.has(String(item.actionCode || '').trim().toLowerCase()))) {
|
||||
pushCode('open_order_processing');
|
||||
}
|
||||
// 只有系统处理中才允许显示查看进度,且只能作为次要文字链。
|
||||
if (isProcessing && !items.length) pushCode('focus_task');
|
||||
const hasPrimaryCandidate = items.some(
|
||||
(item) => !NEVER_PRIMARY_CODES.has(String(item.actionCode || '').trim().toLowerCase()),
|
||||
);
|
||||
if (!hasPrimaryCandidate) {
|
||||
pushCode('focus_task');
|
||||
if (!hasPrimaryCandidate && !isProcessing) {
|
||||
return empty;
|
||||
}
|
||||
if (isProcessing) {
|
||||
const progress = items.find((item) => String(item.actionCode).toLowerCase() === 'focus_task');
|
||||
return { primary: null, secondary: progress || null, overflow: [] };
|
||||
}
|
||||
|
||||
return partitionActionItems(items);
|
||||
|
||||
Reference in new issue
Block a user