Files
syops/frontend/src/features/chat/components/shipping/ShippingConversationProcessingCard.vue
T
hugo c94d173f92 feat(shipping-notice): 完成货代发货通知全门禁恢复MVP收口
完成全门禁恢复MVP版本交付:调整自动上传与重试配置,重构正式执行链路;修复多处代码bug,新增测试与审计工具;更新全流程文档与契约规范。
2026-08-11 14:04:39 +08:00

934 lines
38 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* features/chat/components/shipping/ShippingConversationProcessingCard.vue
* 用途:右侧「本次处理中」顶层任务卡——needs_action / processing / 处理记录。
* 依赖:vue-i18n、ConversationProcessingProjection、conversationProcessingState、
* conversationProcessingDisplay、actionPresentation、shippingProcessingLabels、SidebarProgressInline。
* 逻辑:由 ShippingWorkflowTimeline 嵌入;只消费统一 projection / workItems;
* 统一「订单识别任务」+ 主文件副标题;处理记录默认折叠(已完成/历史版本/已取消);
* UI-02:有文件对象时次要入口仅为「展开文件详情」,无文件对象时才「查看详情」;
* 有 workItem 时由其统一 Gate / Action 投影常驻渲染人工恢复按钮;
* 点击/展开任务只更新本地焦点与详情,不写服务端 viewed/focus 审计,不得改变同一 Gate 的按钮可见性;
* UI-03:history 截断时折叠标题显示「还有 N 条」,展开底部显示明细截断文案。
*/
<script setup lang="ts">
import { computed, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { ChevronDown, ChevronRight } from 'lucide-vue-next';
import type {
ConversationProcessingProjection,
ConversationProcessingUserTask,
ShippingProcessingProjection,
} from '@/features/chat/types/shipping.api.types';
import { getPrimaryDocumentName } from '@/features/chat/shipping/conversationProcessingDisplay';
import {
createConversationProcessingUiState,
focusTaskManually,
resetConversationProcessingUiState,
resolveFocusedTask,
shouldExpandTaskDetails,
toggleTaskDetails,
} from '@/features/chat/shipping/conversationProcessingState';
import {
resolveShippingProcessingMessage,
resolveShippingProcessingStatusLabel,
shippingProcessingSourceTypeKey,
shippingProcessingStageKey,
} from '@/features/chat/shipping/shippingProcessingLabels';
import { resolveConversationTaskActionPresentation } from '@/features/shipping-progress/actionPresentation';
import SidebarProgressInline from '@/features/shipping-progress/components/SidebarProgressInline.vue';
import type { ActionPresentation, ActionPresentationItem } from '@/features/shipping-progress/types';
const props = defineProps<{
projection: ConversationProcessingProjection | null;
/** 统一 ShippingProcessing work_items(含 order_intake) */
workItems?: ShippingProcessingProjection[] | null;
/** 当前会话 ID;切换时重置本地焦点/展开状态 */
conversationId?: string | null;
/** 后端截断提示:history 还有未返回内容时在处理记录底部展示 */
hasMoreHistory?: boolean;
}>();
const emit = defineEmits<{
/** 请求展开某任务下的文件列表(由 Timeline 按 OT objects 合成) */
expandFiles: [task: ConversationProcessingUserTask];
/** 收起文件详情:父级应清空过滤并隐藏文件列表 */
collapseFiles: [];
/** 任务级权威操作(后端 available_actions) */
taskAction: [payload: { task: ConversationProcessingUserTask; action: string }];
/** Intake 级统一投影动作(如 retry_parse) */
intakeAction: [payload: { item: ShippingProcessingProjection; action: string }];
/** OT 卡内统一进度动作。 */
projectionAction: [payload: { projection: ShippingProcessingProjection; item: ActionPresentationItem }];
}>();
const { t, te } = useI18n();
const uiState = createConversationProcessingUiState();
/** 处理记录整组默认折叠。 */
const historySectionExpanded = ref(false);
/** 唯一进度源:统一 conversation_processing / work_items 合成投影。 */
const activeProjection = computed((): ConversationProcessingProjection | null => (
props.projection || null
));
/** 尚未建 OT、仍应展示在「待处理材料」的 Intake 工作项。 */
const pendingIntakeItems = computed((): ShippingProcessingProjection[] => {
const items = Array.isArray(props.workItems) ? props.workItems : [];
return items.filter((item) => {
if (item.workItemType !== 'order_intake') return false;
return !['completed', 'cancelled'].includes(String(item.status || ''));
});
});
const hasContent = computed(() => Boolean(
activeProjection.value
|| pendingIntakeItems.value.length,
));
const completedTasks = computed(() => activeProjection.value?.completed || []);
const historyTasks = computed(() => activeProjection.value?.history || []);
/** history 中非取消 →「历史版本」。 */
const historyVersionTasks = computed(() => historyTasks.value.filter(
(task) => String(task.status_label || '').trim().toLowerCase() !== 'cancelled',
));
/** history 中明确 cancelled →「已取消」。 */
const cancelledHistoryTasks = computed(() => historyTasks.value.filter(
(task) => String(task.status_label || '').trim().toLowerCase() === 'cancelled',
));
/** 处理记录标题计数:当前返回的 completed + history。 */
const recordTaskCount = computed(() => (
completedTasks.value.length + historyTasks.value.length
));
/**
* history 未返回条数:summary.history - 当前 history[];不可靠时为 0(不猜数)。
*/
const hiddenHistoryCount = computed(() => {
const summaryTotal = Number(activeProjection.value?.summary?.history || 0);
if (!Number.isFinite(summaryTotal) || summaryTotal <= 0) return 0;
return Math.max(0, summaryTotal - historyTasks.value.length);
});
const focusedTaskNo = computed(() => resolveFocusedTask(uiState, {
serverFocusedTaskNo: activeProjection.value?.focused_task_no,
recentTaskNo: activeProjection.value?.recent_task_no,
}));
/** 按权威 OT 编号取得卡片自己的统一进度投影。 */
function projectionForTask(task: ConversationProcessingUserTask): ShippingProcessingProjection | null {
const taskNo = String(task.user_task_no || '').trim();
if (!taskNo) return null;
const items = Array.isArray(props.workItems) ? props.workItems : [];
return items.find((item) => (
item.workItemType === 'order_task'
&& String(item.workItemNo || '').trim() === taskNo
)) || null;
}
/**
* 切会话时重置本地焦点/展开,避免跨会话残留。
*/
watch(
() => String(props.conversationId || '').trim(),
(next, prev) => {
if (next === prev) return;
resetConversationProcessingUiState(uiState);
historySectionExpanded.value = false;
},
);
/**
* 点击任务卡:仅本地聚焦,不标记正式 viewed、不强制展开文件、也不写 focus 审计。
*/
function onSelectTask(task: ConversationProcessingUserTask) {
const taskNo = String(task.user_task_no || '').trim();
if (!taskNo) return;
focusTaskManually(uiState, taskNo, { expandDetails: false });
}
/**
* 切换文件详情展开;展开时通知父级过滤,收起时清空过滤。
* viewed 会回写 Run.seen_at 并重算业务投影,右侧纯展示不得调用。
*/
function onToggleDetails(task: ConversationProcessingUserTask) {
const taskNo = String(task.user_task_no || '').trim();
if (!taskNo) return;
toggleTaskDetails(uiState, taskNo);
if (uiState.expandedDetailTaskNo === taskNo) {
emit('expandFiles', task);
} else {
emit('collapseFiles');
}
}
/**
* 是否为多 PDF 任务卡(禁止用首个文件名伪装单文件任务)。
*/
function isMultiDocumentTask(task: ConversationProcessingUserTask): boolean {
if (String(task.display_kind || '').trim() === 'multi_document_task') return true;
if (Number(task.file_count || 0) > 1) return true;
return Array.isArray(task.document_names) && task.document_names.length > 1;
}
/**
* 是否展示「展开文件详情」:单 PDF/单对象时隐藏,避免空抽屉。
*/
function canExpandFileDetails(task: ConversationProcessingUserTask): boolean {
if (isMultiDocumentTask(task)) return true;
const objects = Array.isArray(task.objects) ? task.objects : [];
return objects.length > 0;
}
/**
* 活跃卡进度:人工待办始终完整展示 Gate 动作;处理中聚焦全量 / 未聚焦紧凑;
* 处理记录(completed/history)永不展实时进度。
*/
function progressModeForTask(task: ConversationProcessingUserTask): 'full' | 'compact' | 'hidden' {
if (!projectionForTask(task)) return 'hidden';
const group = String(task.group || '').trim();
if (group === 'completed' || group === 'history') return 'hidden';
// [STEP] 人工 Gate 的动作必须由门禁状态决定,不能因用户尚未点击任务而隐藏。
if (group === 'needs_action') return 'full';
const focused = focusedTaskNo.value === task.user_task_no;
if (focused) return 'full';
return 'compact';
}
/**
* 任务主标题:统一「订单识别任务」;禁止用 filename / task.title / OT 编号。
*/
function taskLabel(_task: ConversationProcessingUserTask): string {
return t('chat.shippingProcessing.multiPdfTaskTitle');
}
/**
* 主文件副标题:有主文件名时渲染「主文件:{name}」。
*/
function primaryFileLabel(task: ConversationProcessingUserTask): string {
const name = getPrimaryDocumentName(task);
if (!name) return '';
return t('chat.shippingProcessing.primaryFile', { name });
}
/**
* 文件数量文案:多 PDF 用「N 个 PDF」,单文件仍用「N 个文件」。
*/
function fileCountLabel(task: ConversationProcessingUserTask): string {
const count = Number(task.file_count || 0);
if (count <= 0) return '';
if (isMultiDocumentTask(task)) {
return t('chat.shippingProcessing.taskPdfCount', { count });
}
return t('chat.shippingProcessing.taskFiles', { count });
}
/**
* 任务状态文案:优先统一 shippingProcessing,回退 shippingWorkflow。
*/
function statusLabel(task: ConversationProcessingUserTask): string {
return resolveShippingProcessingStatusLabel(String(task.status_label || ''), te, t);
}
/**
* 是否高亮 needs_action 任务。
*/
function isNeedsActionHighlight(task: ConversationProcessingUserTask): boolean {
return task.group === 'needs_action';
}
/**
* 是否展开该任务的文件详情区。
*/
function isDetailsExpanded(task: ConversationProcessingUserTask): boolean {
return shouldExpandTaskDetails(uiState, task.user_task_no, {
focusedTaskNo: focusedTaskNo.value,
forceExpand: false,
});
}
/**
* 解析任务卡 ActionPresentation(cancel/view_details 不作主 CTA)。
*/
function taskActionPresentation(task: ConversationProcessingUserTask): ActionPresentation {
return resolveConversationTaskActionPresentation(task, { surface: 'right' });
}
/**
* 唯一主 CTA(实心按钮);处理记录只读卡不调用。
*/
function primaryActionItem(task: ConversationProcessingUserTask): ActionPresentationItem | null {
return taskActionPresentation(task).primary;
}
/** needs_action 的用户语义提示:不重复主按钮文案。 */
function currentNeedLabel(task: ConversationProcessingUserTask): string {
if (task.group !== 'needs_action') return '';
const typedTask = task as ConversationProcessingUserTask & {
primaryAction?: { code?: string } | null;
};
const action = String(
typedTask.primaryAction?.code
?? task.primary_action
?? task.available_actions?.[0]
?? '',
).trim().toLowerCase();
const labels: Record<string, string> = {
confirm_customer: 'chat.shippingProcessing.currentNeed.confirmCustomer',
resolve_field_conflicts: 'chat.shippingProcessing.currentNeed.resolveFieldConflicts',
open_inventory_match_review: 'chat.shippingProcessing.currentNeed.inventoryMatch',
open_order_processing: 'chat.shippingProcessing.currentNeed.orderDraft',
retry: 'chat.shippingProcessing.currentNeed.retry',
retry_parse: 'chat.shippingProcessing.currentNeed.retry',
};
const key = labels[action];
return key && te(key) ? t(key) : t('chat.shippingProcessing.currentNeed.generic');
}
/**
* 次要文字链:有文件对象时可展开 → 不返回 view_details(改由展开文件入口承载);
* 无文件对象时优先 view_details,否则取非 cancel 的 presentation.secondary。
*/
function secondaryActionItem(_task: ConversationProcessingUserTask): ActionPresentationItem | null {
return null;
}
/**
* 低频溢出动作:排除已展示的主/次 CTA 与 view_details。
*/
function overflowActionItems(task: ConversationProcessingUserTask): ActionPresentationItem[] {
const presentation = taskActionPresentation(task);
const shown = new Set(
[primaryActionItem(task)?.actionCode, secondaryActionItem(task)?.actionCode]
.map((code) => String(code || '').trim().toLowerCase())
.filter(Boolean),
);
shown.add('view_details');
return [presentation.secondary, ...presentation.overflow]
.filter((item): item is ActionPresentationItem => Boolean(item))
.filter((item) => {
const code = String(item.actionCode || '').trim().toLowerCase();
return Boolean(code) && !shown.has(code);
});
}
/**
* 是否展示低频溢出:有文件对象时仅展开后显示;无文件对象时直接挂在卡上(如取消)。
* 有 workItem 时不渲染任务级溢出(动作由进度条负责)。
*/
function shouldShowOverflowActions(_task: ConversationProcessingUserTask): boolean {
return false;
}
/**
* 是否渲染任务级主/次动作区(不含「展开文件详情」文件控制)。
*/
function shouldShowTaskLevelActions(task: ConversationProcessingUserTask): boolean {
if (projectionForTask(task)) return false;
return Boolean(primaryActionItem(task) || secondaryActionItem(task));
}
/**
* 处理记录只读卡:仅保留 view_details 文字链(无主 CTA / 取消 / 重解析)。
*/
function recordViewDetailsItem(task: ConversationProcessingUserTask): ActionPresentationItem | null {
if (String(task.status_label || '').trim().toLowerCase() === 'cancelled') return null;
const presentation = taskActionPresentation(task);
const candidates = [
presentation.primary,
presentation.secondary,
...presentation.overflow,
].filter((item): item is ActionPresentationItem => Boolean(item));
return candidates.find((item) => {
const code = String(item.actionCode || '').trim().toLowerCase();
return code === 'view_details' || code === 'view_result';
}) || (String(task.group || '') === 'completed'
? { intent: 'view_result', actionCode: 'view_result', labelKey: 'chat.shippingProcessing.action.view_result' }
: null);
}
/**
* 动作按钮文案:优先 presentation labelKey;多 PDF 取消明确为「取消整个任务」。
*/
function presentationActionLabel(task: ConversationProcessingUserTask, item: ActionPresentationItem): string {
const code = String(item.actionCode || '').trim();
if (
(code === 'cancel_task' || code === 'cancel_run')
&& isMultiDocumentTask(task)
) {
return t('chat.shippingProcessing.cancelEntireTask');
}
const key = String(item.labelKey || '').trim();
if (key && te(key)) return t(key);
const extractionKey = `chat.shippingOrderExtractionAction.${code}`;
if (te(extractionKey)) return t(extractionKey);
return code;
}
/**
* 执行任务级动作:view_details / focus_task 本地聚焦;其余交给父级。
* focus / view_details 仅影响右侧 UI;禁止写 viewed 审计,避免重算任务分组。
*/
function onTaskAction(task: ConversationProcessingUserTask, action: string) {
const code = String(action || '').trim();
if (!code) return;
if (code === 'view_details' || code === 'focus_task') {
focusTaskManually(uiState, task.user_task_no, { expandDetails: code === 'view_details' });
if (code === 'view_details') {
emit('expandFiles', task);
}
return;
}
emit('taskAction', { task, action: code });
}
/**
* 切换处理记录整组折叠。
*/
function toggleHistorySection() {
historySectionExpanded.value = !historySectionExpanded.value;
}
/**
* Intake 材料标题:文件名 / 邮件主题 / Intake 编号。
*/
function intakeTitle(item: ShippingProcessingProjection): string {
return String(
item.sourceSummary?.filename
|| item.sourceSummary?.emailSubject
|| item.workItemNo
|| '',
).trim() || item.workItemNo;
}
/**
* Intake 状态文案。
*/
function intakeStatusLabel(item: ShippingProcessingProjection): string {
return resolveShippingProcessingStatusLabel(item.status, te, t);
}
/**
* Intake 阶段文案。
*/
function intakeStageLabel(item: ShippingProcessingProjection): string {
const key = shippingProcessingStageKey(item.stage);
return te(key) ? t(key) : String(item.stage || '');
}
/**
* Intake 来源类型文案。
*/
function intakeSourceLabel(item: ShippingProcessingProjection): string {
const key = shippingProcessingSourceTypeKey(item.sourceType);
return te(key) ? t(key) : String(item.sourceType || '');
}
/**
* Intake / OT 门禁与失败恢复元信息(Gate / Attempt / 资产状态)。
*/
function intakeRecoveryMeta(item: ShippingProcessingProjection): string[] {
const parts: string[] = [];
const gate = item.currentGate;
const reason = String(
gate?.blockingReasonCode
|| item.sourceSummary?.failureReasonCode
|| '',
).trim();
if (reason) {
parts.push(t('chat.shippingProcessing.failureReason', { code: reason }));
}
const attempt = gate?.attemptNo ?? item.sourceSummary?.parseAttemptCount;
if (attempt != null && Number(attempt) > 0) {
parts.push(t('chat.shippingProcessing.parseAttempt', { count: Number(attempt) }));
}
const assetStatus = String(item.sourceSummary?.assetStatus || '').trim();
if (assetStatus) {
const key = `chat.shippingProcessing.assetStatus.${assetStatus}`;
parts.push(te(key) ? t(key) : t('chat.shippingProcessing.assetStatusLabel', { status: assetStatus }));
}
if (gate?.gateCode) {
parts.push(t('chat.shippingProcessing.gateCode', { code: gate.gateCode }));
}
return parts;
}
/**
* Intake 可见动作(仅展示 retry_parse)。
*/
function visibleIntakeActions(item: ShippingProcessingProjection): string[] {
const actions = Array.isArray(item.availableActions) ? item.availableActions : [];
return actions.filter((code) => code === 'retry_parse');
}
/**
* Intake 动作文案。
*/
function intakeActionLabel(action: string): string {
if (action === 'retry_parse') return t('chat.shippingProcessing.retryFromFailure');
return action;
}
/**
* 触发 Intake 级动作。
*/
function onIntakeAction(item: ShippingProcessingProjection, action: string) {
const code = String(action || '').trim();
if (!code) return;
emit('intakeAction', { item, action: code });
}
</script>
<template>
<div
v-if="hasContent"
class="space-y-3"
data-testid="shipping-conversation-processing-card"
>
<section
v-if="pendingIntakeItems.length"
data-testid="shipping-processing-group-order-intake"
>
<div class="mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-violet-700 dark:text-violet-300">
{{ t('chat.shippingProcessing.pendingMaterials') }}
· {{ pendingIntakeItems.length }}
</div>
<div class="space-y-2">
<article
v-for="item in pendingIntakeItems"
:key="item.workItemNo"
class="rounded-lg border border-default bg-surface px-2.5 py-2"
:data-testid="`shipping-processing-intake-${item.workItemNo}`"
:data-source-type="item.sourceType"
:data-status="item.status"
>
<div class="text-sm font-semibold text-primary">
{{ intakeTitle(item) }}
</div>
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
<span>{{ intakeSourceLabel(item) }}</span>
<span>{{ intakeStatusLabel(item) }}</span>
<span v-if="intakeStageLabel(item)">{{ intakeStageLabel(item) }}</span>
</div>
<div
v-if="intakeRecoveryMeta(item).length"
class="mt-1 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-rose-700 dark:text-rose-300"
data-testid="shipping-processing-intake-recovery"
>
<span
v-for="(meta, idx) in intakeRecoveryMeta(item)"
:key="`${item.workItemNo}-meta-${idx}`"
>{{ meta }}</span>
</div>
<div
v-if="visibleIntakeActions(item).length"
class="mt-1.5 flex flex-wrap gap-1.5"
data-testid="shipping-processing-intake-actions"
>
<button
v-for="action in visibleIntakeActions(item)"
:key="`${item.workItemNo}-${action}`"
type="button"
class="rounded-md border border-default bg-surface px-2 py-0.5 text-[11px] text-secondary hover:text-primary"
:data-testid="`shipping-processing-intake-action-${action}`"
@click="onIntakeAction(item, action)"
>
{{ intakeActionLabel(action) }}
</button>
</div>
</article>
</div>
</section>
<section
v-if="activeProjection?.needs_action.length"
data-testid="shipping-processing-group-needs_action"
>
<div class="mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-amber-700 dark:text-amber-300">
{{ resolveShippingProcessingMessage('groupNeedsAction', te, t, { count: activeProjection.needs_action.length }) }}
</div>
<div class="space-y-2">
<article
v-for="task in activeProjection.needs_action"
:key="task.user_task_no"
class="rounded-lg border px-2.5 py-2 transition"
:class="[
isNeedsActionHighlight(task)
? 'border-amber-400 bg-amber-50/80 dark:border-amber-700 dark:bg-amber-950/30'
: 'border-default bg-surface',
focusedTaskNo === task.user_task_no ? 'ring-1 ring-brand-400' : '',
]"
:data-testid="`shipping-processing-task-${task.user_task_no}`"
:data-focused="focusedTaskNo === task.user_task_no ? '1' : '0'"
>
<button
type="button"
class="w-full text-left"
@click="onSelectTask(task)"
>
<div class="text-sm font-semibold text-primary">
{{ resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
</div>
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
<span>{{ statusLabel(task) }}</span>
</div>
<div
v-if="primaryFileLabel(task)"
class="mt-0.5 truncate text-[11px] text-muted"
data-testid="shipping-processing-task-primary-file"
>
{{ primaryFileLabel(task) }}
</div>
<div
v-if="task.recent_append_count"
class="mt-1 text-[11px] font-medium text-brand-700 dark:text-brand-300"
>
{{ resolveShippingProcessingMessage('justAppended', te, t, { count: task.recent_append_count }) }}
</div>
<div
v-else-if="task.recently_created"
class="mt-1 text-[11px] font-medium text-brand-700 dark:text-brand-300"
>
{{ resolveShippingProcessingMessage('justCreated', te, t) }}
</div>
</button>
<div
v-if="task.group === 'needs_action' && currentNeedLabel(task)"
class="mt-1 text-[11px] text-secondary"
data-testid="shipping-processing-current-need"
>
{{ t('chat.shippingProcessing.progress.currentNeedLabel') }}{{ currentNeedLabel(task) }}
</div>
<SidebarProgressInline
v-if="progressModeForTask(task) !== 'hidden' && projectionForTask(task)"
class="mt-1.5 border-t border-current/10 pt-1.5"
:projection="projectionForTask(task)!"
:compact="progressModeForTask(task) === 'compact'"
@action="(item) => emit('projectionAction', { projection: projectionForTask(task)!, item })"
/>
<div
v-if="shouldShowTaskLevelActions(task) || (!projectionForTask(task) && canExpandFileDetails(task))"
class="mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1"
data-testid="shipping-processing-task-actions"
>
<button
v-if="!projectionForTask(task) && primaryActionItem(task)"
type="button"
class="rounded-md border border-brand-300 bg-brand-600 px-2.5 py-1 text-[11px] font-medium text-white hover:bg-brand-700 dark:border-brand-700 dark:bg-brand-700 dark:hover:bg-brand-600"
:data-testid="`shipping-processing-action-${primaryActionItem(task)!.actionCode}`"
@click="onTaskAction(task, primaryActionItem(task)!.actionCode)"
>
{{ presentationActionLabel(task, primaryActionItem(task)!) }}
</button>
<span v-if="task.group === 'needs_action'" class="sr-only">{{ currentNeedLabel(task) }}</span>
</div>
</article>
</div>
</section>
<section
v-if="activeProjection?.processing.length"
data-testid="shipping-processing-group-processing"
>
<div class="mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-sky-700 dark:text-sky-300">
{{ resolveShippingProcessingMessage('groupProcessing', te, t, { count: activeProjection.processing.length }) }}
</div>
<div class="space-y-2">
<article
v-for="task in activeProjection.processing"
:key="task.user_task_no"
class="rounded-lg border border-default bg-surface px-2.5 py-2"
:class="focusedTaskNo === task.user_task_no
? 'ring-1 ring-brand-400'
: ''"
:data-testid="`shipping-processing-task-${task.user_task_no}`"
:data-focused="focusedTaskNo === task.user_task_no ? '1' : '0'"
>
<button
type="button"
class="w-full text-left"
@click="onSelectTask(task)"
>
<div class="text-sm font-semibold text-primary">
{{ resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
</div>
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
<span>{{ statusLabel(task) }}</span>
</div>
<div
v-if="primaryFileLabel(task)"
class="mt-0.5 truncate text-[11px] text-muted"
data-testid="shipping-processing-task-primary-file"
>
{{ primaryFileLabel(task) }}
</div>
<div
v-if="task.recent_append_count"
class="mt-1 text-[11px] font-medium text-brand-700 dark:text-brand-300"
>
{{ resolveShippingProcessingMessage('justAppended', te, t, { count: task.recent_append_count }) }}
</div>
<div
v-else-if="task.recently_created"
class="mt-1 text-[11px] font-medium text-brand-700 dark:text-brand-300"
>
{{ resolveShippingProcessingMessage('justCreated', te, t) }}
</div>
</button>
<SidebarProgressInline
v-if="progressModeForTask(task) !== 'hidden' && projectionForTask(task)"
class="mt-1.5 border-t border-current/10 pt-1.5"
:projection="projectionForTask(task)!"
:compact="progressModeForTask(task) === 'compact'"
@action="(item) => emit('projectionAction', { projection: projectionForTask(task)!, item })"
/>
<div
v-if="shouldShowTaskLevelActions(task) || (!projectionForTask(task) && canExpandFileDetails(task))"
class="mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1"
data-testid="shipping-processing-task-actions"
>
<button
v-if="!projectionForTask(task) && primaryActionItem(task)"
type="button"
class="rounded-md border border-brand-300 bg-brand-600 px-2.5 py-1 text-[11px] font-medium text-white hover:bg-brand-700 dark:border-brand-700 dark:bg-brand-700 dark:hover:bg-brand-600"
:data-testid="`shipping-processing-action-${primaryActionItem(task)!.actionCode}`"
@click="onTaskAction(task, primaryActionItem(task)!.actionCode)"
>
{{ presentationActionLabel(task, primaryActionItem(task)!) }}
</button>
<button
v-if="canExpandFileDetails(task)"
type="button"
class="inline-flex items-center gap-1 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
data-testid="shipping-processing-expand-files"
@click="onToggleDetails(task)"
>
<ChevronDown v-if="isDetailsExpanded(task)" class="h-3 w-3" />
<ChevronRight v-else class="h-3 w-3" />
{{ isDetailsExpanded(task)
? t('chat.shippingProcessing.collapseFileDetails')
: t('chat.shippingProcessing.expandFileDetails') }}
</button>
<button
v-else-if="secondaryActionItem(task)"
type="button"
class="text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
:data-testid="`shipping-processing-action-${secondaryActionItem(task)!.actionCode}`"
@click="onTaskAction(task, secondaryActionItem(task)!.actionCode)"
>
{{ presentationActionLabel(task, secondaryActionItem(task)!) }}
</button>
</div>
<button
v-else-if="canExpandFileDetails(task)"
type="button"
class="mt-1.5 inline-flex items-center gap-1 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
data-testid="shipping-processing-expand-files"
@click="onToggleDetails(task)"
>
<ChevronDown v-if="isDetailsExpanded(task)" class="h-3 w-3" />
<ChevronRight v-else class="h-3 w-3" />
{{ isDetailsExpanded(task)
? t('chat.shippingProcessing.collapseFileDetails')
: t('chat.shippingProcessing.expandFileDetails') }}
</button>
<div
v-if="shouldShowOverflowActions(task)"
class="mt-1.5 flex flex-wrap gap-x-3 gap-y-1"
data-testid="shipping-processing-task-overflow-actions"
>
<button
v-for="item in overflowActionItems(task)"
:key="`${task.user_task_no}-overflow-${item.actionCode}`"
type="button"
class="text-[11px] text-muted underline-offset-2 hover:text-secondary hover:underline"
:data-testid="`shipping-processing-action-${item.actionCode}`"
@click="onTaskAction(task, item.actionCode)"
>
{{ presentationActionLabel(task, item) }}
</button>
</div>
</article>
</div>
</section>
<section
v-if="recordTaskCount > 0"
data-testid="shipping-processing-group-history"
>
<button
type="button"
class="mb-1.5 flex w-full items-center justify-between gap-2 text-left text-[11px] font-semibold uppercase tracking-wide text-slate-600 dark:text-slate-300"
data-testid="shipping-processing-history-toggle"
@click="toggleHistorySection"
>
<span class="inline-flex min-w-0 items-center gap-1">
<ChevronDown v-if="historySectionExpanded" class="h-3 w-3 shrink-0" />
<ChevronRight v-else class="h-3 w-3 shrink-0" />
<span>{{ resolveShippingProcessingMessage('groupProcessingRecords', te, t, { count: recordTaskCount }) }}</span>
</span>
<span
v-if="hiddenHistoryCount > 0"
class="shrink-0 font-medium normal-case tracking-normal text-muted"
data-testid="shipping-processing-history-more"
>
{{ t('chat.shippingProcessing.historyMoreCount', { count: hiddenHistoryCount }) }}
</span>
</button>
<div
v-if="historySectionExpanded"
class="space-y-3"
data-testid="shipping-processing-history-body"
>
<div
v-if="completedTasks.length"
data-testid="shipping-processing-history-completed"
>
<div class="mb-1 text-[11px] font-medium text-emerald-700 dark:text-emerald-300">
{{ resolveShippingProcessingMessage('groupRecordCompleted', te, t) }}
</div>
<div class="space-y-2">
<article
v-for="task in completedTasks"
:key="task.user_task_no"
class="rounded-lg border border-default bg-surface/80 px-2.5 py-2"
:data-testid="`shipping-processing-task-${task.user_task_no}`"
data-record="1"
>
<div class="text-sm font-semibold text-primary">
{{ resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
</div>
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
<span>{{ statusLabel(task) }}</span>
</div>
<div
v-if="primaryFileLabel(task)"
class="mt-0.5 truncate text-[11px] text-muted"
data-testid="shipping-processing-task-primary-file"
>
{{ primaryFileLabel(task) }}
</div>
<button
v-if="recordViewDetailsItem(task)"
type="button"
class="mt-1.5 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
:data-testid="`shipping-processing-action-${recordViewDetailsItem(task)!.actionCode}`"
@click="onTaskAction(task, recordViewDetailsItem(task)!.actionCode)"
>
{{ presentationActionLabel(task, recordViewDetailsItem(task)!) }}
</button>
</article>
</div>
</div>
<div
v-if="historyVersionTasks.length"
data-testid="shipping-processing-history-versions"
>
<div class="mb-1 text-[11px] font-medium text-slate-600 dark:text-slate-300">
{{ resolveShippingProcessingMessage('groupRecordHistoryVersions', te, t) }}
</div>
<div class="space-y-2">
<article
v-for="task in historyVersionTasks"
:key="task.user_task_no"
class="rounded-lg border border-default bg-surface/80 px-2.5 py-2"
:data-testid="`shipping-processing-task-${task.user_task_no}`"
data-record="1"
>
<div class="text-sm font-semibold text-primary">
{{ resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
</div>
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
<span>{{ statusLabel(task) }}</span>
</div>
<div
v-if="primaryFileLabel(task)"
class="mt-0.5 truncate text-[11px] text-muted"
data-testid="shipping-processing-task-primary-file"
>
{{ primaryFileLabel(task) }}
</div>
<button
v-if="recordViewDetailsItem(task)"
type="button"
class="mt-1.5 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
:data-testid="`shipping-processing-action-${recordViewDetailsItem(task)!.actionCode}`"
@click="onTaskAction(task, recordViewDetailsItem(task)!.actionCode)"
>
{{ presentationActionLabel(task, recordViewDetailsItem(task)!) }}
</button>
</article>
</div>
</div>
<div
v-if="cancelledHistoryTasks.length"
data-testid="shipping-processing-history-cancelled"
>
<div class="mb-1 text-[11px] font-medium text-slate-500 dark:text-slate-400">
{{ resolveShippingProcessingMessage('groupRecordCancelled', te, t) }}
</div>
<div class="space-y-2">
<article
v-for="task in cancelledHistoryTasks"
:key="task.user_task_no"
class="rounded-lg border border-dashed border-default bg-surface/60 px-2.5 py-2 opacity-90"
:data-testid="`shipping-processing-task-${task.user_task_no}`"
data-record="1"
>
<div class="text-sm font-semibold text-primary">
{{ resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
</div>
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
<span>{{ statusLabel(task) }}</span>
</div>
<div
v-if="primaryFileLabel(task)"
class="mt-0.5 truncate text-[11px] text-muted"
data-testid="shipping-processing-task-primary-file"
>
{{ primaryFileLabel(task) }}
</div>
<button
v-if="recordViewDetailsItem(task)"
type="button"
class="mt-1.5 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
:data-testid="`shipping-processing-action-${recordViewDetailsItem(task)!.actionCode}`"
@click="onTaskAction(task, recordViewDetailsItem(task)!.actionCode)"
>
{{ presentationActionLabel(task, recordViewDetailsItem(task)!) }}
</button>
</article>
</div>
</div>
<div
v-if="hiddenHistoryCount > 0"
class="text-[11px] text-muted"
data-testid="shipping-processing-history-truncated"
>
{{ t('chat.shippingProcessing.historyTruncatedDetail', {
shown: historyTasks.length,
hidden: hiddenHistoryCount,
}) }}
</div>
<div
v-else-if="hasMoreHistory"
class="text-[11px] text-muted"
data-testid="shipping-processing-history-truncated"
>
{{ t('chat.shippingProcessing.summaryTruncatedHint') }}
</div>
</div>
</section>
</div>
</template>