feat(shipping-notice): 货代会话主区域切换为批次中心常驻并按附件派生会话标题

- 会话命名:新增业务命名纯函数,新建抽取会话按附件内容派生标题,仅新建不回填不改名
- 批次中心常驻主区域并展示会话标题:移除关闭入口、隐藏对话列、去除面板外壳与折叠/钉住徽标
- 清理对话流打开批次中心的冗余链路
- 新增设计文档与实施计划,同步功能清单说明
This commit is contained in:
hugo committed 2026-09-17 15:54:47 +08:00
1 parent d396371020
commit e472abc4e3
21 files changed
+1198 -206

No files matched your search

@@ -54,7 +54,6 @@ const {
pinMessagesToBottom?: boolean;
/** 供父级滚动逻辑绑定 main 元素 */
scrollContainerHolder: { el: Ref<HTMLElement | null> };
compactShippingProgress?: boolean;
}>();
const emit = defineEmits<{
@@ -68,7 +67,6 @@ const emit = defineEmits<{
'maintenance-edit-record': [record: MaintenanceRecord];
'maintenance-view-record-history': [device: MaintenanceDevice];
'maintenance-create-record-for-device': [device: MaintenanceDevice];
'open-batch-workbench': [];
/** 在途仓自动调拨:业务流激活时向上冒泡,父级据此隐藏聊天输入框。 */
'transfer-flow-active': [active: boolean];
}>();
@@ -207,7 +205,6 @@ const hasFollowingShippingProgressCard = (items: ChatMessage[], index: number):
:leave-handlers="leaveHandlers"
:shipping-handlers="shippingHandlers"
:training-handlers="trainingHandlers"
:compact-shipping-progress="compactShippingProgress"
:attachment-summary-only="hasFollowingShippingProgressCard(messages, index)"
@copy="emit('copy', { message: msg, index })"
@edit="emit('edit', $event)"
@@ -217,7 +214,6 @@ const hasFollowingShippingProgressCard = (items: ChatMessage[], index: number):
@maintenance-edit-record="emit('maintenance-edit-record', $event)"
@maintenance-view-record-history="emit('maintenance-view-record-history', $event)"
@maintenance-create-record-for-device="emit('maintenance-create-record-for-device', $event)"
@open-batch-workbench="emit('open-batch-workbench')"
/>
<ToolRunProgressCard
v-if="shouldRenderMessage(msg) && shouldShowToolRunProgressAfterMessage(msg, index)"
@@ -7,7 +7,7 @@
* 依赖:ChatSidebar、ChatMessageList、ChatInputBar、ShippingWorkflowTimeline、chat.context。
* 逻辑:本文件只做页面结构编排;货代 Chat 仅上传/进度通知,履约写操作不在本页;
* 右侧「本次处理」由 conversationId 驱动 Workflow projection,extractionRunNo 仅作进度装饰;
* 货代会话主区域:有会话即全屏批次进度中心(常驻),无会话为欢迎页+输入框;会话标题取自侧栏历史并传给中心;
* 订单复核工作台异步分包,避免普通对话首屏拉取 PDF.js。
*/
@@ -34,6 +34,8 @@ import ChatBrowserPanel from '@/features/chat/components/ChatBrowserPanel.vue';
import ShippingWorkflowTimeline from '@/features/chat/components/shipping/ShippingWorkflowTimeline.vue';
import { shouldShowShippingWorkbench } from '@/features/chat/shipping/shippingWorkbenchLayout';
import TrainingWorkspacePanel from '@/features/chat/components/TrainingWorkspacePanel.vue';
import LedgerConfigPanel from '@/features/maintenance/components/LedgerConfigPanel.vue';
@@ -118,38 +120,19 @@ const isInTransitTransferAgent = computed(() => resolveAgentCode(page.currentAge
const transferFlowActive = ref(false);
watch(isInTransitTransferAgent, (isTransfer) => { if (!isTransfer) transferFlowActive.value = false; });
/** 批次进度工作台按需打开;关闭时不占用对话区右侧布局。 */
const batchWorkbenchOpen = ref(false);
const showShippingWorkflowTimeline = computed(() => (
page.isShippingNoticeAgent
&& batchWorkbenchOpen.value
&& Boolean(activeShippingConversationId.value)
));
const compactShippingProgress = computed(() => batchWorkbenchOpen.value);
function openBatchWorkbench() {
batchWorkbenchOpen.value = true;
}
function closeBatchWorkbench() {
batchWorkbenchOpen.value = false;
}
/**
* 批次中心只服务于用户主动打开时所在的会话。切换历史会话或 Agent 后必须关闭,
* 否则旧会话的右侧投影会短暂占用新会话的对话区并造成“本次处理”串批错觉。
* 货代发货会话主区域规则(方案 A):
* 有会话 ID → 全屏批次进度中心(常驻不可关闭);无会话 → 欢迎页 + 输入框(唯一提交入口)。
*/
watch(
() => [activeShippingConversationId.value, Number(page.currentAgentId || 0)] as const,
(next, previous) => {
if (!previous || next[0] === previous[0] && next[1] === previous[1]) return;
batchWorkbenchOpen.value = false;
},
);
const showShippingWorkflowTimeline = computed(() => shouldShowShippingWorkbench({
isShippingNoticeAgent: page.isShippingNoticeAgent,
conversationId: activeShippingConversationId.value,
}));
/** 侧栏历史项中的会话标题;批次中心头部直接复用,保持侧栏与中心一致。 */
const activeShippingConversationTitle = computed(() => (
page.displayHistory.find((item) => item.conversation_id === activeShippingConversationId.value)?.title || ''
));
const embeddedIframeSrc = computed(() => {
@@ -473,9 +456,10 @@ watch(() => page.currentAgentId, () => {
<ShippingOrderReviewView v-if="isOrderReviewMode" />
<div v-else class="flex min-h-0 min-w-0 flex-1" :class="showShippingWorkflowTimeline ? 'shipping-workbench-layout' : ''">
<div v-else class="flex min-h-0 min-w-0 flex-1">
<div class="flex min-h-0 min-w-0 flex-1 flex-col" :class="showShippingWorkflowTimeline ? 'shipping-chat-column' : ''">
<!-- 中心展示时对话列整体隐藏(含输入框),新文件提交走新建对话(spec 方案 A 硬性决策)。 -->
<div v-show="!showShippingWorkflowTimeline" class="flex min-h-0 min-w-0 flex-1 flex-col">
<TrainingWorkspacePanel
@@ -555,8 +539,6 @@ watch(() => page.currentAgentId, () => {
:scroll-container-holder="page.scrollContainerHolder"
:compact-shipping-progress="compactShippingProgress"
@copy="page.copyToClipboard($event.message, $event.index)"
@edit="page.input = $event"
@@ -577,8 +559,6 @@ watch(() => page.currentAgentId, () => {
@maintenance-create-record-for-device="openMaintenanceRecordCreate"
@open-batch-workbench="openBatchWorkbench"
@transfer-flow-active="transferFlowActive = $event"
/>
@@ -667,10 +647,9 @@ watch(() => page.currentAgentId, () => {
<ShippingWorkflowTimeline
v-if="showShippingWorkflowTimeline"
:conversation-id="activeShippingConversationId"
:conversation-title="activeShippingConversationTitle"
:refresh-trigger="page.workflowRefreshTrigger"
:controller="shippingProcessing"
@close="closeBatchWorkbench"
/>
@@ -821,16 +800,3 @@ watch(() => page.currentAgentId, () => {
</template>
<style scoped>
/** 打开批次工作台后,左侧对话保留为压缩入口,右侧取得主工作区宽度。 */
@media (min-width: 1024px) {
.shipping-workbench-layout {
min-width: 0;
}
.shipping-chat-column {
flex: 0 0 clamp(360px, 32vw, 520px);
}
}
</style>
@@ -75,7 +75,6 @@ const {
leaveHandlers: LeaveMessageHandlers;
shippingHandlers: ShippingMessageHandlers;
trainingHandlers: TrainingHandlers;
compactShippingProgress?: boolean;
/** 下方已有货代进度卡时,用户气泡附件只显示摘要。 */
attachmentSummaryOnly?: boolean;
}>();
@@ -89,7 +88,6 @@ const emit = defineEmits<{
'maintenance-edit-record': [record: MaintenanceRecord];
'maintenance-view-record-history': [device: MaintenanceDevice];
'maintenance-create-record-for-device': [device: MaintenanceDevice];
'open-batch-workbench': [];
}>();
const authStore = useAuthStore();
@@ -747,11 +745,9 @@ function handleInlineDownload(file: InlineDownloadFile): void {
:retrying="retryingOrderExtraction"
:refreshing="refreshingOrderExtraction"
:cancelling="cancellingOrderExtraction"
:compact-progress="compactShippingProgress"
@retry="retryShippingOrderExtraction"
@refresh="refreshShippingOrderExtraction"
@cancel="cancelShippingOrderExtraction"
@open-batch-workbench="emit('open-batch-workbench')"
/>
<LeaveMessageBlock
v-if="isLeaveMessage"
@@ -74,7 +74,8 @@ describe('ShippingOrderExtractionCard', () => {
},
});
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false);
});
it('does not present historical handling items or CTA as current work when the live projection exists', () => {
@@ -115,16 +116,6 @@ describe('ShippingOrderExtractionCard', () => {
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false);
});
it('collapses file-level progress when the batch workbench is open', () => {
const wrapper = mount(ShippingOrderExtractionCard, {
props: { state: buildState(), runNo: 'SNER-COMPACT', compactProgress: true },
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: { processingWorkItems: ref([]) } } },
});
expect(wrapper.find('[data-testid="shipping-order-extraction-status-groups"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false);
});
it('uses unified EML aggregation and keeps candidate creation out of completed', async () => {
const aggregate = {
workItemType: 'order_task', workItemNo: 'INTAKE:SNI-1', sourceType: 'eml', rootOrderTaskNo: 'OT-1',
@@ -643,7 +634,8 @@ describe('ShippingOrderExtractionCard', () => {
expect(wrapper.text()).toContain('3 个文件');
expect(wrapper.text()).toContain('系统处理中');
expect(wrapper.text()).toContain('处理时间偏长');
expect(wrapper.text()).toContain('打开批次进度中心');
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
expect(wrapper.text()).not.toContain('打开批次进度中心');
expect(wrapper.text()).not.toContain('刷新状态');
expect(wrapper.text()).not.toContain('取消本次识别');
expect(wrapper.text()).not.toContain('PO-450003.pdf');
@@ -731,7 +723,8 @@ describe('ShippingOrderExtractionCard', () => {
});
expect(wrapper.text()).toContain('订单候选已生成');
expect(wrapper.text()).toContain('候选待人工确认 · 2 项');
expect(wrapper.text()).toContain('打开批次进度中心');
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
expect(wrapper.text()).not.toContain('打开批次进度中心');
expect(wrapper.text()).not.toContain('部分附件需人工处理');
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(0);
});
@@ -826,7 +819,8 @@ describe('ShippingOrderExtractionCard', () => {
});
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-order-extraction-view-details"]').exists()).toBe(false);
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false);
});
it('does not render multi-OT ChatProgressSummary list', () => {
@@ -914,7 +908,8 @@ describe('ShippingOrderExtractionCard', () => {
global: { plugins: [i18n] },
});
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false);
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false);
});
it('does not render the removed view details link', () => {
@@ -956,7 +951,8 @@ describe('ShippingOrderExtractionCard', () => {
},
},
});
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false);
expect(wrapper.text()).toContain('共 1 个文件');
});
@@ -1,14 +1,14 @@
/**
* features/chat/components/shipping/ShippingOrderExtractionCard.vue
* 用途:聊天主区「本次订单文件处理」摘要卡——标题、文件数+状态、一行 handling 摘要、唯一主 CTA、查看详情。
* 用途:聊天主区「本次订单文件处理」摘要卡——标题、文件数+状态、一行 handling 摘要、无对话流 CTA(批次中心常驻,方案 A)。
* 依赖:订单抽取 Run 状态卡 DTO、shipping.api 文档/进度接口、ShippingOrderExtractionDetailsDrawer、vue-router、vue-i18n。
* 逻辑:对话区默认展示状态-EML 聚合;批次工作台打开后切换为紧凑摘要,长进度/Gate/刷新取消由工作台承接。
* 逻辑:对话区默认展示状态-EML 聚合;无对话流 CTA(批次中心常驻,方案 A),长进度/Gate/刷新取消由工作台承接。
*/
<script setup lang="ts">
import { computed, inject, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import { AlertCircle, ArrowRight, CheckCircle2, ChevronDown, CircleX, FileText, LoaderCircle, Mail, RefreshCw, TriangleAlert } from 'lucide-vue-next';
import { AlertCircle, CheckCircle2, ChevronDown, CircleX, FileText, LoaderCircle, Mail, RefreshCw, TriangleAlert } from 'lucide-vue-next';
import type {
ShippingOrderExtractionHandlingItemState,
ShippingOrderExtractionFileState,
@@ -44,15 +44,12 @@ const props = defineProps<{
readonlyReason?: string | null;
/** 可选统一投影;摘要卡不再渲染进度,仅保留 prop 兼容宿主。 */
processingProjection?: ShippingProcessingProjection | null;
/** 批次工作台打开时,左侧只保留摘要,避免与工作台重复展示文件明细。 */
compactProgress?: boolean;
}>();
const emit = defineEmits<{
retry: [];
refresh: [];
cancel: [reason?: string];
'open-batch-workbench': [];
}>();
const { t, te } = useI18n();
@@ -425,7 +422,6 @@ const hasAnyStatusGroupTask = computed(() => (
*/
const recognizingPlaceholderVisible = computed(() => (
hasConversationStatusGroups.value
&& !props.compactProgress
&& !hasAnyStatusGroupTask.value
&& (submittedFileCount.value ?? 0) > 0
));
@@ -850,7 +846,7 @@ async function onPrimaryChatAction() {
<div v-if="handlingSummaryLine && !hasConversationStatusGroups" class="mt-1 text-sm text-secondary">{{ handlingSummaryLine }}</div>
</div>
<div v-if="hasConversationStatusGroups && !compactProgress" class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30" data-testid="shipping-order-extraction-status-groups">
<div v-if="hasConversationStatusGroups" class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30" data-testid="shipping-order-extraction-status-groups">
<div v-if="recognizingPlaceholderVisible" class="flex items-center gap-2 rounded-lg border border-default bg-surface p-3 text-sm text-muted">
<LoaderCircle class="h-4 w-4 animate-spin text-brand-500" />
<span data-testid="shipping-order-extraction-recognizing-placeholder">{{ t('chat.shippingProcessing.recognizingAttachments') }}</span>
@@ -899,7 +895,7 @@ async function onPrimaryChatAction() {
</section>
</template>
</div>
<div v-else-if="!compactProgress && emlAggregate" class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30" data-testid="shipping-order-extraction-eml-aggregate">
<div v-else-if="emlAggregate" class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30" data-testid="shipping-order-extraction-eml-aggregate">
<article class="overflow-hidden rounded-lg border border-default bg-surface shadow-sm">
<div class="flex items-start gap-3 border-b border-default bg-surface-soft p-3 dark:bg-slate-950/30">
<Mail class="mt-0.5 h-5 w-5 text-brand-500" />
@@ -926,7 +922,7 @@ async function onPrimaryChatAction() {
</div>
</article>
</div>
<div v-else-if="!compactProgress" class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30">
<div v-else class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30">
<div v-for="row in activeEmailRows" :key="row.unitId" class="overflow-hidden rounded-lg border border-default bg-surface shadow-sm">
<div class="flex items-start gap-3 border-b border-default bg-surface-soft p-3 dark:bg-slate-950/30"><Mail class="mt-0.5 h-5 w-5 text-brand-500" /><div class="min-w-0 flex-1"><div class="flex items-center justify-between gap-3"><span class="font-medium">{{ t('chat.shippingProcessing.emailPrefix') }}{{ row.fileName }}</span><span class="rounded border px-2 py-0.5 text-xs" :class="isFailedParseRow(row) || emailHasFailedChild(row) ? 'border-rose-200 bg-rose-100/70 text-rose-600' : emailIsCompleted(row) ? 'border-emerald-200 bg-emerald-100/70 text-emerald-600' : 'border-brand-200 bg-brand-100/70 text-brand-600'">{{ isFailedParseRow(row) || emailHasFailedChild(row) ? t('chat.shippingProcessing.batchException') : emailIsCompleted(row) ? t('chat.shippingProcessing.batchExtracted') : t('chat.shippingProcessing.parsingAttachments') }}</span></div><span class="mt-1 block font-mono text-xs text-muted">{{ t('chat.shippingProcessing.emailMeta') }}</span></div></div>
<div class="mx-4 my-2 flex flex-col gap-2 border-l-2 border-default bg-surface-soft p-3 pl-4 dark:border-slate-700 dark:bg-slate-950/30"><div v-for="child in childRows(row)" :key="`child-${child.unitId}`" class="flex items-center justify-between gap-3 text-sm"><span class="flex min-w-0 items-center gap-2"><CheckCircle2 v-if="child.status === 'candidate_ready'" class="h-4 w-4 text-emerald-500" /><LoaderCircle v-else-if="!isFailedParseRow(child)" class="h-4 w-4 animate-spin text-brand-500" /><AlertCircle v-else class="h-4 w-4 text-rose-500" /><span class="truncate">{{ child.fileName }}</span></span><span :class="rowStatusClass(child)">{{ rowStatusLabel(child) }}</span></div></div>
@@ -936,20 +932,6 @@ async function onPrimaryChatAction() {
<div v-for="row in failedRows" :key="`failed-${row.unitId}`" class="rounded-lg border border-rose-200 bg-rose-50 p-3 dark:border-rose-800 dark:bg-rose-950/30"><div class="flex items-center justify-between text-rose-600"><span class="flex items-center gap-2 font-medium"><AlertCircle class="h-5 w-5" />{{ row.fileName }}</span><span class="rounded bg-rose-100 px-2 py-0.5 text-xs">{{ t('chat.shippingProcessing.batchException') }}</span></div><p class="mt-2 pl-7 text-sm">{{ row.explainability?.message || t('chat.shippingProcessing.batchManualVerify') }}</p></div>
</div>
<div class="flex justify-end border-t border-default bg-brand-50/60 p-3 dark:bg-brand-950/20">
<div class="flex items-center gap-3">
<button
v-if="!compactProgress && (hasConversationStatusGroups || String(props.runNo || '').trim())"
type="button"
class="inline-flex items-center gap-2 rounded-lg bg-brand-600 px-5 py-2.5 text-sm font-medium text-white shadow-sm hover:bg-brand-700"
data-testid="shipping-order-extraction-open-batch-workbench"
@click="emit('open-batch-workbench')"
>
{{ t('chat.shippingProcessing.openBatchWorkbench') }}
<ArrowRight class="h-4 w-4" />
</button>
</div>
</div>
<div v-if="false" class="flex items-start gap-3">
<CircleX class="mt-0.5 h-4 w-4 shrink-0" />
<div class="min-w-0 flex-1">
@@ -104,10 +104,11 @@ function buildController(
function mountTimeline(
processing = processingProjection(),
workItems: ShippingProcessingProjection[] = [],
extraProps: Record<string, unknown> = {},
) {
return mount(ShippingWorkflowTimeline, {
attachTo: document.body,
props: { conversationId: 'conv-1', controller: buildController(processing, workItems) },
props: { conversationId: 'conv-1', controller: buildController(processing, workItems), ...extraProps },
global: { plugins: [i18n], stubs: { teleport: true } },
});
}
@@ -124,6 +125,24 @@ describe('ShippingWorkflowTimeline', () => {
gateRecovery.submitPrimaryAction.mockClear();
});
it('has no close button and reuses the conversation title in the header', () => {
const wrapper = mountTimeline(processingProjection(), [], { conversationTitle: 'PO#6075309 09-15' });
// 中心常驻不可关闭(方案 A):关闭按钮必须消失。
expect(wrapper.find('[data-testid="shipping-workflow-close"]').exists()).toBe(false);
// 会话标题直接复用侧栏命名,保持两处一致。
const titleNode = wrapper.find('[data-testid="shipping-workflow-conversation-title"]');
expect(titleNode.exists()).toBe(true);
expect(titleNode.text()).toContain('PO#6075309 09-15');
});
it('omits the title node when no conversation title is provided', () => {
const wrapper = mountTimeline(processingProjection(), []);
expect(wrapper.find('[data-testid="shipping-workflow-conversation-title"]').exists()).toBe(false);
});
it('prefers backend five-stage lifecycle nodes and shows the authorized download toolbar in freight upload', async () => {
const processing = processingProjection({
lifecycle_nodes: [
@@ -205,25 +224,6 @@ describe('ShippingWorkflowTimeline', () => {
expect(wrapper.find('[data-testid="shipping-processing-file-DOC-9"]').exists()).toBe(true);
});
it('labels a manually actionable batch as action needed instead of processing', async () => {
const task = { ...processingProjection().processing[0], group: 'needs_action' };
const processing = processingProjection({
summary: { total_files: 1, processing_files: 0, completed_files: 0, waiting_human_files: 1, failed_files: 0 },
needs_action: [task], processing: [],
status_groups: { failed: [], waiting_human: [task], processing: [], completed: [], cancelled: [], archived: [] },
} as Partial<ConversationProcessingProjection>);
const wrapper = mountTimeline(processing, [fileProjection({
uiState: {
status: 'waiting_human', stage: 'order_review', lifecycleStage: 'order_review',
lifecycleEntries: [], blocking_reason: null, primary_action: null, secondary_actions: [],
},
})]);
await flushPromises();
// 关键断言:锁定表示仍有待办,不得与「处理中 0」形成视觉矛盾。
expect(wrapper.get('[data-testid="shipping-workflow-panel-pinned"]').text()).toBe('待处理');
});
it('navigates only through the backend lifecycle entry', async () => {
const file = fileProjection({
uiState: {
@@ -3,7 +3,7 @@
* 用途:聊天页右侧「批次进度中心」——后端批次投影、五阶段进度和文件行操作。
* 依赖:vue-i18n、useMessage、useShippingNoticeWorkflow、ShippingConversationProcessingCard、
* ReasonDialog、ProcessGateRecoveryCard。
* 逻辑:顶层以 OT / ShippingProcessing 为主路径;标题栏仅保留批次名称、加载与截断提示,
* 逻辑:顶层以 OT / ShippingProcessing 为主路径;标题栏保留批次名称、会话标题、加载与截断提示;中心常驻不可关闭(方案 A),
* 文件总览和进度仅消费后端批次 summary;
* 文件清单消费后端 conversation_processing.status_groups;work_items 仅用于定位同一
* 展示 DTO 的操作对象;整批操作走 Run API,单文件取消走 Unit API;
@@ -14,7 +14,7 @@
import { computed, inject, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import { ChevronDown, ChevronRight, Lock, RefreshCw } from 'lucide-vue-next';
import { RefreshCw } from 'lucide-vue-next';
import {
downloadWorkspaceShippingExcelFile,
downloadWorkspaceShippingExportArchive,
@@ -59,10 +59,8 @@ const props = defineProps<{
refreshTrigger?: number;
/** 测试或父级注入时可直接传入控制器,跳过自建轮询。 */
controller?: UseShippingNoticeWorkflowReturn | null;
}>();
const emit = defineEmits<{
close: [];
/** 当前会话标题;父级从侧栏历史匹配传入,中心头部直接复用(无新增接口)。 */
conversationTitle?: string | null;
}>();
const { t, te } = useI18n();
@@ -91,11 +89,6 @@ const ctl = computed((): UseShippingNoticeWorkflowReturn => (
props.controller || injected || localController
));
/**
* 侧栏折叠态:默认展开。
* 有处理中/待处理/未查看完成任务时强制展开,仅允许收起文件详情。
*/
const collapsed = ref(false);
/** 复核返回对话时展示的聚焦提示(由 focus_notice 触发一次)。 */
const focusTaskBanner = ref<string | null>(null);
const actionBusyItemNo = ref<string | null>(null);
@@ -249,34 +242,6 @@ const initialLoading = computed(() => Boolean(ctl.value.initialLoading?.value));
const manualRefreshing = computed(() => Boolean(ctl.value.manualRefreshing?.value));
const isRefreshing = computed(() => Boolean(ctl.value.isRefreshing?.value));
const error = computed(() => ctl.value.error.value);
/**
* 右侧仍有用户必须持续可见的任务时,禁止收起整个处理面板。
* 核心逻辑:处理中 / 待处理 / 未查看完成均属活跃可见任务;无此类任务才允许收起侧栏。
*/
const hasPinnedProcessingTasks = computed(() => {
const projection = displayProcessing.value;
if (!projection) return false;
return statusGroupTasks('failed', 'waiting_human', 'processing', 'completed').length > 0;
});
/**
* 切换侧栏折叠:活跃任务存在时强制保持展开。
*/
function togglePanelCollapsed() {
if (hasPinnedProcessingTasks.value) {
collapsed.value = false;
return;
}
collapsed.value = !collapsed.value;
}
watch(
hasPinnedProcessingTasks,
(pinned) => {
if (pinned) collapsed.value = false;
},
{ immediate: true },
);
/**
* 移除右侧常驻「批次与文件列表」长列表抽屉(UI-REFACTOR 方案 7)。
@@ -839,7 +804,6 @@ watch(
return;
}
if (!focusedTaskExists.value) return;
collapsed.value = false;
focusTaskBanner.value = normalized;
// [UI-01/UI-02] 真正选中进度卡,禁止只显示提示条。
await onProcessingFocus(normalized);
@@ -856,31 +820,12 @@ watch(
<template>
<aside
class="flex min-w-0 flex-1 shrink-0 flex-col border-l border-default bg-surface shadow-[-16px_0_40px_rgba(15,23,42,0.10)] transition-[width] duration-200"
:class="collapsed ? '!w-14' : ''"
class="flex min-w-0 flex-1 shrink-0 flex-col bg-surface"
data-testid="shipping-workflow-timeline"
>
<div class="flex w-full items-center gap-1 border-b border-default px-2 py-2">
<button
type="button"
class="shrink-0 rounded-md p-1.5 text-muted hover:bg-surface-muted hover:text-primary"
data-testid="shipping-workflow-close"
:title="t('chat.shippingProcessing.closeWorkbench')"
@click="emit('close')"
>
×
</button>
<component
:is="hasPinnedProcessingTasks ? 'div' : 'button'"
:type="hasPinnedProcessingTasks ? undefined : 'button'"
class="flex min-w-0 flex-1 items-center justify-between gap-2 rounded-md px-1 py-1 text-left"
:class="hasPinnedProcessingTasks
? 'cursor-default'
: 'hover:bg-surface-muted/60'"
data-testid="shipping-workflow-panel-toggle"
@click="togglePanelCollapsed"
>
<div v-if="!collapsed" class="min-w-0">
<div class="flex min-w-0 flex-1 items-center justify-between gap-2 rounded-md px-1 py-1 text-left">
<div class="min-w-0">
<div class="flex items-center gap-1.5">
<div class="text-sm font-semibold text-primary">
{{ te('chat.shippingProcessing.panelTitle')
@@ -888,14 +833,11 @@ watch(
: t('chat.shippingProcessing.title') }}
</div>
<span
v-if="hasPinnedProcessingTasks"
class="inline-flex items-center gap-0.5 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-secondary"
data-testid="shipping-workflow-panel-pinned"
:title="t('chat.shippingProcessing.panelPinnedHint')"
>
<Lock class="h-3 w-3 shrink-0" aria-hidden="true" />
{{ t('chat.shippingProcessing.panelPinnedLabel') }}
</span>
v-if="conversationTitle"
class="min-w-0 truncate rounded bg-surface-muted px-1.5 py-0.5 text-xs text-secondary"
data-testid="shipping-workflow-conversation-title"
:title="conversationTitle"
>{{ conversationTitle }}</span>
</div>
<div class="mt-0.5 space-y-0.5 text-xs text-secondary" data-testid="shipping-workflow-panel-summary">
<template v-if="initialLoading && !displayProcessing">
@@ -918,12 +860,7 @@ watch(
</template>
</div>
</div>
<ChevronDown
v-if="!collapsed && !hasPinnedProcessingTasks"
class="h-4 w-4 shrink-0 text-muted"
/>
<ChevronRight v-else-if="collapsed" class="h-4 w-4 shrink-0 text-muted" />
</component>
</div>
<button
type="button"
class="shrink-0 rounded-md p-1.5 text-muted hover:bg-surface-muted hover:text-primary disabled:opacity-50"
@@ -939,7 +876,7 @@ watch(
</button>
</div>
<div v-if="!collapsed" class="min-h-0 flex-1 overflow-y-auto p-5">
<div class="min-h-0 flex-1 overflow-y-auto p-5">
<div
v-if="initialLoading && !displayProcessing"
class="mb-4 space-y-3"
@@ -0,0 +1,24 @@
/**
* features/chat/shipping/shippingWorkbenchLayout.spec.ts
* 用途:锁定货代会话主区域显隐规则(有会话即全屏批次进度中心,方案 A)。
* 依赖:Vitest、纯函数。
* 逻辑:判定必须同时满足货代智能体与非空会话 ID;普通智能体与新会话一律回落欢迎页。
*/
import { describe, expect, it } from 'vitest';
import { shouldShowShippingWorkbench } from './shippingWorkbenchLayout';
describe('shouldShowShippingWorkbench', () => {
it('renders the workbench for the shipping agent once a conversation exists', () => {
expect(shouldShowShippingWorkbench({ isShippingNoticeAgent: true, conversationId: 'conv-1' })).toBe(true);
});
it('keeps the welcome composer before a conversation is created', () => {
expect(shouldShowShippingWorkbench({ isShippingNoticeAgent: true, conversationId: '' })).toBe(false);
expect(shouldShowShippingWorkbench({ isShippingNoticeAgent: true, conversationId: null })).toBe(false);
});
it('never switches other agents to the workbench', () => {
expect(shouldShowShippingWorkbench({ isShippingNoticeAgent: false, conversationId: 'conv-1' })).toBe(false);
});
});
@@ -0,0 +1,21 @@
/**
* features/chat/shipping/shippingWorkbenchLayout.ts
* 用途:货代发货会话主区域显隐判定(批次进度中心优先,方案 A)。
* 依赖:无(纯函数)。
* 逻辑:货代智能体且存在非空会话 ID 时全屏渲染批次进度中心;
* 否则(新会话欢迎页)显示欢迎页 + 输入框(唯一附件提交入口)。
*/
export interface ShippingWorkbenchLayoutInput {
isShippingNoticeAgent: boolean;
conversationId: string | null | undefined;
}
/**
* 判定是否以批次进度中心作为会话主区域。
* @param input - 智能体身份与当前会话 ID(路由 query 与 page 回填同源优先级)。
* @returns true 表示全屏渲染批次进度中心;false 表示欢迎页 + 输入框。
*/
export function shouldShowShippingWorkbench(input: ShippingWorkbenchLayoutInput): boolean {
return Boolean(input.isShippingNoticeAgent && String(input.conversationId || '').trim());
}