feat(chat): 更新发货任务处理逻辑和界面文本
- 移除不必要的状态引用 - 更新上传处理提示文本,使用国际化支持 - 扩展发货任务摘要接口,增加错误信息和短缺信息 - 更新多语言支持的文本,改善用户体验 - 增加批次工作区的汇总信息和操作提示
This commit is contained in:
1 parent
0b083cfdbd
commit
1fc9976ca3
60 files changed
+3876
-639
No files matched your search
@@ -38,13 +38,20 @@ import {
|
||||
shippingActionButtonClass,
|
||||
} from '../shipping';
|
||||
import {
|
||||
getWorkspaceShippingConversationBatches,
|
||||
getWorkspaceShippingBatch,
|
||||
getWorkspaceShippingTask,
|
||||
switchWorkspaceShippingBatchFocusTask,
|
||||
type ShippingBatchSummary,
|
||||
type ShippingConversationWorkspace,
|
||||
type ShippingTaskDetail,
|
||||
type ShippingTaskSummary,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import {
|
||||
buildShortageDetailsMessage,
|
||||
hasShortageLines,
|
||||
isShippingShortageQueryIntent,
|
||||
} from '../shipping/shippingShortageDetails';
|
||||
|
||||
import type { ChatMessage, ChatSessionItem } from '../types/chat.types';
|
||||
import type { ChatUploadFileSpec, PendingAttachment } from '../types/shipping.types';
|
||||
@@ -75,6 +82,8 @@ export interface UseChatShippingOptions {
|
||||
agentId: number,
|
||||
kb: string,
|
||||
files: ChatUploadFileSpec[],
|
||||
context?: { task_id?: string; batch_no?: string; display_query?: string },
|
||||
hooks?: { onAssistantMessageFinished?: (message: ChatMessage, runMessages: ChatMessage[]) => void | Promise<void> },
|
||||
) => Promise<void>;
|
||||
buildFileSpecsForSend: () => Promise<ChatUploadFileSpec[]>;
|
||||
loadConversation: (id: string, options?: { force?: boolean }) => Promise<void>;
|
||||
@@ -114,9 +123,9 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
createNewChatView,
|
||||
} = options;
|
||||
|
||||
let invokeHandleSend: (() => Promise<void>) | null = null;
|
||||
const shippingBindSend = (fn: () => Promise<void>) => {
|
||||
invokeHandleSend = fn;
|
||||
const shippingBindSend = (_fn: () => Promise<void>) => {
|
||||
void _fn;
|
||||
// 保留旧绑定入口,续办链路已改为直接调用 sendMessage 以支持 display_query 上下文。
|
||||
};
|
||||
|
||||
// ── 功能开关与 UI refs ────────────────────────────────────
|
||||
@@ -147,16 +156,52 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
});
|
||||
const resolvedShippingTaskId = ref('');
|
||||
const resolvedShippingBatchNo = ref('');
|
||||
const activeShippingBatchNo = ref('');
|
||||
const focusedShippingTaskNo = ref('');
|
||||
const shippingConversationWorkspace = ref<ShippingConversationWorkspace | null>(null);
|
||||
const shippingBatchSummary = ref<ShippingBatchSummary | null>(null);
|
||||
const shippingBatchTasks = ref<ShippingTaskSummary[]>([]);
|
||||
const shippingBatchTasksExpanded = ref(false);
|
||||
const shippingWorkspaceOpen = ref(false);
|
||||
const retryingShippingPendingTasks = ref(false);
|
||||
const activeShippingTaskDetail = ref<ShippingTaskDetail | null>(null);
|
||||
const shippingFocusReason = ref('');
|
||||
const shippingConversationTaskIdCache = ref<Record<string, string>>({});
|
||||
const shippingInventorySchemaPreviewCache = ref<Record<string, unknown>>({});
|
||||
const autoResumedShippingTasks = ref<Record<string, boolean>>({});
|
||||
const lastConversationSyncKey = ref('');
|
||||
let shippingStatusPollTimer: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
const applyShippingBatchDetail = (
|
||||
detail: ShippingBatchSummary & { tasks?: ShippingTaskSummary[]; focus_task?: ShippingTaskSummary | null },
|
||||
fallbackBatchNo: string,
|
||||
) => {
|
||||
const normalizedBatchNo = detail.batch_no || fallbackBatchNo;
|
||||
resolvedShippingBatchNo.value = normalizedBatchNo;
|
||||
if (!activeShippingBatchNo.value || activeShippingBatchNo.value === fallbackBatchNo) {
|
||||
activeShippingBatchNo.value = normalizedBatchNo;
|
||||
}
|
||||
shippingBatchTasks.value = Array.isArray(detail.tasks) ? detail.tasks : [];
|
||||
shippingBatchSummary.value = {
|
||||
id: detail.id,
|
||||
batch_no: detail.batch_no,
|
||||
conversation_id: detail.conversation_id,
|
||||
current_focus_task_no: detail.focus_task?.task_no || detail.current_focus_task_no || null,
|
||||
file_count: detail.file_count,
|
||||
process_summary: detail.process_summary || null,
|
||||
created_at: detail.created_at,
|
||||
updated_at: detail.updated_at,
|
||||
};
|
||||
const preferredTaskNo = String(
|
||||
detail.focus_task?.task_no
|
||||
|| detail.process_summary?.current_task_no
|
||||
|| detail.current_focus_task_no
|
||||
|| '',
|
||||
).trim();
|
||||
if (preferredTaskNo) {
|
||||
resolvedShippingTaskId.value = preferredTaskNo;
|
||||
}
|
||||
};
|
||||
|
||||
const syncShippingBatchSummary = async (batchNo: string) => {
|
||||
const normalized = String(batchNo || '').trim();
|
||||
if (!normalized) {
|
||||
@@ -166,38 +211,48 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
}
|
||||
try {
|
||||
const detail = await getWorkspaceShippingBatch(normalized);
|
||||
resolvedShippingBatchNo.value = detail.batch_no || normalized;
|
||||
shippingBatchTasks.value = Array.isArray(detail.tasks) ? detail.tasks : [];
|
||||
shippingBatchSummary.value = {
|
||||
id: detail.id,
|
||||
batch_no: detail.batch_no,
|
||||
conversation_id: detail.conversation_id,
|
||||
current_focus_task_no: detail.focus_task?.task_no || detail.current_focus_task_no || null,
|
||||
file_count: detail.file_count,
|
||||
process_summary: detail.process_summary || null,
|
||||
created_at: detail.created_at,
|
||||
updated_at: detail.updated_at,
|
||||
};
|
||||
const preferredTaskNo = String(
|
||||
detail.focus_task?.task_no
|
||||
|| detail.process_summary?.current_task_no
|
||||
|| detail.current_focus_task_no
|
||||
|| '',
|
||||
).trim();
|
||||
if (preferredTaskNo) {
|
||||
resolvedShippingTaskId.value = preferredTaskNo;
|
||||
}
|
||||
applyShippingBatchDetail(detail, normalized);
|
||||
} catch {
|
||||
// ignore summary refresh failure in chat flow
|
||||
}
|
||||
};
|
||||
|
||||
const applyConversationWorkspaceFocus = (workspace: ShippingConversationWorkspace) => {
|
||||
const batches = Array.isArray(workspace.batches) ? workspace.batches : [];
|
||||
if (!batches.length) return;
|
||||
const queryBatchNo = String(shippingBatchNoFromQuery.value || '').trim();
|
||||
const currentBatchNo = String(activeShippingBatchNo.value || resolvedShippingBatchNo.value || queryBatchNo || '').trim();
|
||||
const selectedBatch = batches.find((item) => item.batch_no === currentBatchNo)
|
||||
|| (queryBatchNo ? batches.find((item) => item.batch_no === queryBatchNo) : null)
|
||||
|| batches.find((item) => item.focus_task?.task_no)
|
||||
|| batches[0];
|
||||
if (!selectedBatch) return;
|
||||
applyShippingBatchDetail(selectedBatch, selectedBatch.batch_no);
|
||||
};
|
||||
|
||||
const syncShippingConversationWorkspace = async () => {
|
||||
const localConversationId = String(conversationId.value || '').trim();
|
||||
if (!localConversationId || !isShippingNoticeAgent.value) {
|
||||
shippingConversationWorkspace.value = null;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const workspace = await getWorkspaceShippingConversationBatches(localConversationId);
|
||||
shippingConversationWorkspace.value = workspace;
|
||||
applyConversationWorkspaceFocus(workspace);
|
||||
} catch {
|
||||
shippingConversationWorkspace.value = null;
|
||||
}
|
||||
};
|
||||
|
||||
const switchShippingFocusTask = async (taskNo: string) => {
|
||||
const batchNo = getActiveShippingBatchNo();
|
||||
const normalizedTaskNo = String(taskNo || '').trim().toUpperCase();
|
||||
if (!batchNo || !normalizedTaskNo) return false;
|
||||
await switchWorkspaceShippingBatchFocusTask(batchNo, normalizedTaskNo);
|
||||
resolvedShippingTaskId.value = normalizedTaskNo;
|
||||
focusedShippingTaskNo.value = normalizedTaskNo;
|
||||
shippingFocusReason.value = t('chat.shippingNoticeUi.currentFocusDefaultReason');
|
||||
if (shippingBatchSummary.value) {
|
||||
shippingBatchSummary.value = {
|
||||
...shippingBatchSummary.value,
|
||||
@@ -205,11 +260,42 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
};
|
||||
}
|
||||
await syncShippingBatchSummary(batchNo);
|
||||
await syncShippingConversationWorkspace();
|
||||
await syncActiveShippingTaskDetail(normalizedTaskNo);
|
||||
await refreshShippingActions();
|
||||
return true;
|
||||
};
|
||||
|
||||
const clearShippingFocus = () => {
|
||||
focusedShippingTaskNo.value = '';
|
||||
shippingFocusReason.value = '';
|
||||
};
|
||||
|
||||
const switchShippingBatch = async (batchNo: string) => {
|
||||
const normalizedBatchNo = String(batchNo || '').trim();
|
||||
if (!normalizedBatchNo) return false;
|
||||
activeShippingBatchNo.value = normalizedBatchNo;
|
||||
resolvedShippingBatchNo.value = normalizedBatchNo;
|
||||
const workspaceBatch = shippingConversationWorkspace.value?.batches.find((item) => item.batch_no === normalizedBatchNo);
|
||||
if (workspaceBatch) {
|
||||
applyShippingBatchDetail(workspaceBatch, normalizedBatchNo);
|
||||
} else {
|
||||
await syncShippingBatchSummary(normalizedBatchNo);
|
||||
}
|
||||
const nextTaskNo = String(
|
||||
shippingBatchSummary.value?.current_focus_task_no
|
||||
|| shippingBatchSummary.value?.process_summary?.current_task_no
|
||||
|| shippingBatchTasks.value[0]?.task_no
|
||||
|| '',
|
||||
).trim();
|
||||
if (nextTaskNo) {
|
||||
resolvedShippingTaskId.value = nextTaskNo;
|
||||
await syncActiveShippingTaskDetail(nextTaskNo);
|
||||
}
|
||||
await refreshShippingActions();
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 清空当前聊天页绑定的发货任务上下文。
|
||||
*
|
||||
@@ -224,9 +310,14 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
shippingInventorySelectionTaskId.value = '';
|
||||
resolvedShippingTaskId.value = '';
|
||||
resolvedShippingBatchNo.value = '';
|
||||
activeShippingBatchNo.value = '';
|
||||
focusedShippingTaskNo.value = '';
|
||||
shippingFocusReason.value = '';
|
||||
shippingConversationWorkspace.value = null;
|
||||
shippingBatchSummary.value = null;
|
||||
shippingBatchTasks.value = [];
|
||||
shippingBatchTasksExpanded.value = false;
|
||||
shippingWorkspaceOpen.value = false;
|
||||
retryingShippingPendingTasks.value = false;
|
||||
activeShippingTaskDetail.value = null;
|
||||
shippingConversationTaskIdCache.value = {};
|
||||
shippingInventorySchemaPreviewCache.value = {};
|
||||
@@ -240,16 +331,31 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
|| '';
|
||||
|
||||
const getActiveShippingBatchNo = () =>
|
||||
resolvedShippingBatchNo.value
|
||||
activeShippingBatchNo.value
|
||||
|| resolvedShippingBatchNo.value
|
||||
|| shippingBatchNoFromQuery.value
|
||||
|| String(shippingBatchSummary.value?.batch_no || '').trim()
|
||||
|| '';
|
||||
|
||||
const getCurrentShippingChatContext = () => ({
|
||||
task_id: getActiveShippingTaskId(),
|
||||
task_id: getActiveBatchTaskId() || getActiveShippingTaskId(),
|
||||
batch_no: getActiveShippingBatchNo(),
|
||||
});
|
||||
|
||||
const getCurrentShippingChatContextWithDisplay = (displayQuery: string) => ({
|
||||
...getCurrentShippingChatContext(),
|
||||
display_query: displayQuery,
|
||||
});
|
||||
|
||||
const getActiveBatchTaskId = () => String(
|
||||
shippingBatchSummary.value?.current_focus_task_no
|
||||
|| shippingBatchSummary.value?.process_summary?.current_task_no
|
||||
|| shippingBatchTasks.value[0]?.task_no
|
||||
|| focusedShippingTaskNo.value
|
||||
|| resolvedShippingTaskId.value
|
||||
|| '',
|
||||
).trim();
|
||||
|
||||
const hasRunningShippingBatchTasks = () =>
|
||||
shippingBatchTasks.value.some(
|
||||
(task) => !['uploaded', 'completed', 'closed', 'rejected'].includes(String(task.process_status || '').trim()),
|
||||
@@ -269,10 +375,15 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
}
|
||||
try {
|
||||
const detail = await getWorkspaceShippingTask(normalized);
|
||||
const detailBatchNo = String(detail.batch_no || '').trim();
|
||||
const activeBatchNo = String(activeShippingBatchNo.value || '').trim();
|
||||
if (activeBatchNo && detailBatchNo && detailBatchNo !== activeBatchNo) {
|
||||
return;
|
||||
}
|
||||
activeShippingTaskDetail.value = detail;
|
||||
const batchNo = String(detail.batch_no || '').trim();
|
||||
if (batchNo && resolvedShippingBatchNo.value !== batchNo) {
|
||||
resolvedShippingBatchNo.value = batchNo;
|
||||
if (detailBatchNo && resolvedShippingBatchNo.value !== detailBatchNo) {
|
||||
resolvedShippingBatchNo.value = detailBatchNo;
|
||||
activeShippingBatchNo.value = activeShippingBatchNo.value || detailBatchNo;
|
||||
}
|
||||
} catch {
|
||||
activeShippingTaskDetail.value = null;
|
||||
@@ -313,6 +424,16 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
return '';
|
||||
};
|
||||
|
||||
const lastAssistantShippingActions = () => {
|
||||
for (let i = messages.value.length - 1; i >= 0; i -= 1) {
|
||||
const item = messages.value[i];
|
||||
if (item?.role === 'assistant' && Array.isArray(item.shipping_actions)) {
|
||||
return item.shipping_actions;
|
||||
}
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
const { refreshShippingActions } = createShippingActionsRefresher({
|
||||
isShippingNoticeAgent,
|
||||
messages,
|
||||
@@ -330,6 +451,64 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
saveLocalMessageToBackend,
|
||||
});
|
||||
|
||||
/**
|
||||
* Dify SSE 完成后立即净化最后一条回复,并同步后端动作按钮。
|
||||
*
|
||||
* 核心逻辑:流式过程中只做展示层净化;终态事件到达后消息对象已经完整,
|
||||
* 此时调用统一 refreshShippingActions,把 action_buttons 回写到当前 assistant 气泡。
|
||||
*/
|
||||
const finalizeShippingAssistantMessage = async () => {
|
||||
if (!isShippingNoticeAgent.value) return;
|
||||
await refreshShippingActions();
|
||||
};
|
||||
|
||||
/**
|
||||
* 为“查询缺口明细”定位任务事实来源。
|
||||
*
|
||||
* 核心逻辑:优先使用显式任务号或当前聚焦任务,再从批次摘要/当前详情中读取;
|
||||
* 摘要缺少逐行缺口时补拉既有任务详情接口,确保聊天回复只基于后端事实数据。
|
||||
*/
|
||||
const resolveShippingTaskForShortageQuery = async (taskNo?: string) => {
|
||||
const normalizedTaskNo = String(
|
||||
taskNo
|
||||
|| focusedShippingTaskNo.value
|
||||
|| getActiveBatchTaskId()
|
||||
|| getActiveShippingTaskId()
|
||||
|| '',
|
||||
).trim().toUpperCase();
|
||||
if (!normalizedTaskNo) return null;
|
||||
const summaryTask = shippingBatchTasks.value.find(
|
||||
(item) => String(item.task_no || '').trim().toUpperCase() === normalizedTaskNo,
|
||||
);
|
||||
if (summaryTask && hasShortageLines(summaryTask)) return summaryTask;
|
||||
const detail = activeShippingTaskDetail.value;
|
||||
if (String(detail?.task_no || '').trim().toUpperCase() === normalizedTaskNo && hasShortageLines(detail)) {
|
||||
return detail;
|
||||
}
|
||||
try {
|
||||
return await getWorkspaceShippingTask(normalizedTaskNo);
|
||||
} catch {
|
||||
return summaryTask || null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 在聊天流中输出确定性的缺口明细。
|
||||
*
|
||||
* 核心逻辑:追加一条本地用户意图消息和一条本地助手事实回复,不转发给 Dify,
|
||||
* 避免大模型复述或重新计算预订单、料号与缺口数量。
|
||||
*/
|
||||
const queryShippingShortageDetails = async (taskNo?: string, displayText?: string) => {
|
||||
const task = await resolveShippingTaskForShortageQuery(taskNo);
|
||||
if (!task) {
|
||||
msg.warning(t('chat.shippingNoticeMissingTaskId'));
|
||||
return true;
|
||||
}
|
||||
await pushShippingLocalUserMessage(displayText || t('chat.shippingNoticeUi.queryShortageDetails'));
|
||||
await pushShippingLocalAssistantMessage(buildShortageDetailsMessage(task, t));
|
||||
return true;
|
||||
};
|
||||
|
||||
const { sendShippingMenuMessage } = createShippingConversationHelpers({
|
||||
conversationId,
|
||||
history,
|
||||
@@ -410,7 +589,6 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
resolvedShippingBatchNo,
|
||||
shippingBatchSummary,
|
||||
shippingBatchTasks,
|
||||
shippingBatchTasksExpanded,
|
||||
shippingInventorySelectionActive,
|
||||
shippingInventorySelectionTaskId,
|
||||
shippingInventorySchemaPreviewCache,
|
||||
@@ -422,7 +600,7 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
t,
|
||||
});
|
||||
|
||||
const { handleShippingActionClick } = createShippingMenuHandlers({
|
||||
const { handleShippingMenuAction, handleShippingActionClick } = createShippingMenuHandlers({
|
||||
isThinking,
|
||||
getActiveShippingTaskId,
|
||||
messages,
|
||||
@@ -455,6 +633,7 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
attachmentPolicy,
|
||||
getActiveShippingTaskId,
|
||||
lastAssistantMessageContent,
|
||||
lastAssistantShippingActions,
|
||||
sendMessage,
|
||||
buildFileSpecsForSend,
|
||||
loadHistory,
|
||||
@@ -464,10 +643,13 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
openShippingInventoryPicker,
|
||||
executeShippingDecision,
|
||||
executeShippingManualUpload,
|
||||
handleShippingMenuAction,
|
||||
handleShippingAutoUploadFile,
|
||||
handleShippingAutoUploadNoticeBatch,
|
||||
refreshShippingActions,
|
||||
shippingSuggestedPrompt,
|
||||
isShippingShortageQueryIntent,
|
||||
queryShippingShortageDetails,
|
||||
msg,
|
||||
t,
|
||||
});
|
||||
@@ -492,8 +674,15 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
return;
|
||||
}
|
||||
autoResumedShippingTasks.value[taskId] = true;
|
||||
input.value = t('chat.shippingNoticeContinue', { taskId });
|
||||
await invokeHandleSend?.();
|
||||
const displayText = t('chat.shippingNoticeUi.retrySingleTaskMessage', { taskId });
|
||||
await sendMessage(
|
||||
t('chat.shippingNoticeContinue', { taskId }),
|
||||
currentAgentId.value,
|
||||
selectedKb.value,
|
||||
[],
|
||||
getCurrentShippingChatContextWithDisplay(displayText),
|
||||
);
|
||||
await loadHistory();
|
||||
};
|
||||
|
||||
const onConversationIdChanging = (nextId: string, prevId: string | null | undefined) => {
|
||||
@@ -510,8 +699,8 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
/**
|
||||
* 续办指定任务,并把聊天上下文切到该任务继续推进。
|
||||
*
|
||||
* 核心逻辑:先切换批次焦点任务,再复用既有“请继续处理发货任务”提示词触发一次发送,
|
||||
* 让 Agent 基于最新 task_id/batch_no 返回下一步动作。
|
||||
* 核心逻辑:先切换批次焦点任务,再把内部续办指令发给 Agent;
|
||||
* 前端和历史只展示业务端可理解的简短重试话术,避免暴露工具名。
|
||||
* @param taskNo - 需要续办的任务编号
|
||||
* @returns 是否已成功触发续办
|
||||
*/
|
||||
@@ -520,11 +709,39 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
if (!normalizedTaskNo || !isShippingNoticeAgent.value || isThinking.value) return false;
|
||||
const switched = await switchShippingFocusTask(normalizedTaskNo);
|
||||
if (!switched) return false;
|
||||
input.value = t('chat.shippingNoticeContinue', { taskId: normalizedTaskNo });
|
||||
await invokeHandleSend?.();
|
||||
const displayText = t('chat.shippingNoticeUi.retrySingleTaskMessage', { taskId: normalizedTaskNo });
|
||||
await sendMessage(
|
||||
t('chat.shippingNoticeContinue', { taskId: normalizedTaskNo }),
|
||||
currentAgentId.value,
|
||||
selectedKb.value,
|
||||
[],
|
||||
getCurrentShippingChatContextWithDisplay(displayText),
|
||||
);
|
||||
await loadHistory();
|
||||
await refreshShippingActions();
|
||||
return true;
|
||||
};
|
||||
|
||||
const retryCurrentShippingBatchPendingTasks = async () => {
|
||||
const batchNo = getActiveShippingBatchNo();
|
||||
if (!batchNo || retryingShippingPendingTasks.value) return false;
|
||||
retryingShippingPendingTasks.value = true;
|
||||
try {
|
||||
const { retryWorkspaceShippingBatchPending } = await import('@/features/chat/api/shipping.api');
|
||||
const result = await retryWorkspaceShippingBatchPending(batchNo);
|
||||
msg.success(result.message || t('chat.shippingNoticeUi.retryPendingDone'));
|
||||
await syncShippingConversationWorkspace();
|
||||
await syncShippingBatchSummary(batchNo);
|
||||
await refreshShippingActions();
|
||||
return true;
|
||||
} catch (error) {
|
||||
msg.error(error instanceof Error ? error.message : t('chat.shippingNoticeUi.retryFailed'));
|
||||
return false;
|
||||
} finally {
|
||||
retryingShippingPendingTasks.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const onConversationLoadedEmpty = async () => {
|
||||
if (!isShippingNoticeAgent.value || !shippingTaskIdFromQuery.value || isThinking.value) return;
|
||||
const nextQuery: Record<string, string> = { task_id: shippingTaskIdFromQuery.value };
|
||||
@@ -538,8 +755,15 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
const nextQuery: Record<string, string> = { task_id: shippingTaskIdFromQuery.value };
|
||||
if (shippingBatchNoFromQuery.value) nextQuery.batch_no = shippingBatchNoFromQuery.value;
|
||||
void router.replace({ path: route.path, query: nextQuery });
|
||||
input.value = t('chat.shippingNoticeContinue', { taskId: shippingTaskIdFromQuery.value });
|
||||
await invokeHandleSend?.();
|
||||
const displayText = t('chat.shippingNoticeUi.retrySingleTaskMessage', { taskId: shippingTaskIdFromQuery.value });
|
||||
await sendMessage(
|
||||
t('chat.shippingNoticeContinue', { taskId: shippingTaskIdFromQuery.value }),
|
||||
currentAgentId.value,
|
||||
selectedKb.value,
|
||||
[],
|
||||
getCurrentShippingChatContextWithDisplay(displayText),
|
||||
);
|
||||
await loadHistory();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -555,15 +779,16 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
}
|
||||
if (!isShippingNoticeAgent.value) return;
|
||||
const batchNo = getActiveShippingBatchNo();
|
||||
const taskId = getActiveShippingTaskId();
|
||||
const taskId = getActiveBatchTaskId();
|
||||
if (!batchNo && !taskId) return;
|
||||
|
||||
shippingStatusPollTimer = setInterval(() => {
|
||||
if (!isShippingNoticeAgent.value) return;
|
||||
const nextBatchNo = getActiveShippingBatchNo();
|
||||
const nextTaskId = getActiveShippingTaskId();
|
||||
const nextTaskId = getActiveBatchTaskId();
|
||||
if (!nextBatchNo && !nextTaskId) return;
|
||||
void (async () => {
|
||||
await syncShippingConversationWorkspace();
|
||||
if (nextBatchNo) await syncShippingBatchSummary(nextBatchNo);
|
||||
if (nextTaskId) {
|
||||
await syncActiveShippingTaskDetail(nextTaskId);
|
||||
@@ -591,7 +816,7 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
});
|
||||
watch([shippingActionsWatchKey, isThinking, isShippingNoticeAgent, () => currentAgent.value?.name], () => {
|
||||
void refreshShippingActions().then(async () => {
|
||||
const taskId = getActiveShippingTaskId();
|
||||
const taskId = getActiveBatchTaskId() || getActiveShippingTaskId();
|
||||
await Promise.all([
|
||||
syncShippingParseReviewCard(taskId),
|
||||
syncActiveShippingTaskDetail(taskId),
|
||||
@@ -599,14 +824,17 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
await syncConversationMessagesIfNeeded(taskId);
|
||||
});
|
||||
});
|
||||
watch([resolvedShippingBatchNo, shippingBatchNoFromQuery], ([batchNo, queryBatchNo]) => {
|
||||
const nextBatchNo = String(batchNo || queryBatchNo || '').trim();
|
||||
watch([activeShippingBatchNo, shippingBatchNoFromQuery, resolvedShippingBatchNo], ([activeBatchNo, queryBatchNo, batchNo]) => {
|
||||
const nextBatchNo = String(activeBatchNo || queryBatchNo || batchNo || '').trim();
|
||||
if (!nextBatchNo) {
|
||||
shippingBatchSummary.value = null;
|
||||
return;
|
||||
}
|
||||
void syncShippingBatchSummary(nextBatchNo);
|
||||
}, { immediate: true });
|
||||
watch([conversationId, isShippingNoticeAgent], () => {
|
||||
void syncShippingConversationWorkspace();
|
||||
}, { immediate: true });
|
||||
watch(
|
||||
[isShippingNoticeAgent, conversationId, resolvedShippingBatchNo, shippingBatchNoFromQuery, resolvedShippingTaskId, shippingTaskIdFromQuery, isThinking],
|
||||
() => {
|
||||
@@ -634,14 +862,23 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
shippingTaskIdFromQuery,
|
||||
shippingBatchNoFromQuery,
|
||||
resolvedShippingBatchNo,
|
||||
activeShippingBatchNo,
|
||||
focusedShippingTaskNo,
|
||||
shippingFocusReason,
|
||||
shippingConversationWorkspace,
|
||||
shippingBatchSummary,
|
||||
shippingBatchTasks,
|
||||
shippingBatchTasksExpanded,
|
||||
shippingWorkspaceOpen,
|
||||
retryingShippingPendingTasks,
|
||||
activeShippingTaskDetail,
|
||||
getCurrentShippingChatContext,
|
||||
getActiveShippingBatchNo,
|
||||
switchShippingBatch,
|
||||
switchShippingFocusTask,
|
||||
clearShippingFocus,
|
||||
resumeShippingTask,
|
||||
retryCurrentShippingBatchPendingTasks,
|
||||
queryShippingShortageDetails,
|
||||
resetShippingConversationState,
|
||||
resumeShippingTaskFromQuery,
|
||||
normalizeShippingHeaderForDisplay,
|
||||
@@ -658,6 +895,7 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
removeShippingParseReviewLine,
|
||||
handleShippingActionClick,
|
||||
handleShippingInventorySelected,
|
||||
finalizeShippingAssistantMessage,
|
||||
selectShippingInventoryUploadTask,
|
||||
cancelShippingInventoryTaskSelection,
|
||||
shippingActionButtonClass,
|
||||
|
||||
Reference in new issue
Block a user