feat(file-check): 新增文件资产管理与清理功能,支持上传、查询、删除及下载

This commit is contained in:
hugo committed 2026-07-14 09:14:44 +08:00
1 parent 143e054d86
commit 729546a7b7
52 files changed
+3420 -34

No files matched your search

@@ -18,6 +18,7 @@ import { agentUsesWorkspaceStepperProgress, isShippingNoticeAgent as resolveShip
import type { AgentRegistryFields } from '@/shared/utils/agent-registry.utils';
import { hasActiveRunningChatRun } from '../shipping/shippingActionBusy';
import { useShippingNoticeIntakes } from '../shipping/useShippingNoticeIntakes';
import {
createShippingActionsRefresher,
createShippingConversationHelpers,
@@ -40,6 +41,8 @@ import {
shippingActionButtonClass,
} from '../shipping';
import { reportShippingDebugEvent } from '../shipping/shippingDebugReporter';
import { classifyShippingUploadFile } from '../shipping/shippingUploadPrompt';
import { extractExt } from '../constants/shipping';
import {
getWorkspaceShippingConversationBatches,
getWorkspaceShippingBatch,
@@ -657,6 +660,13 @@ export function useChatShipping(options: UseChatShippingOptions) {
msg,
});
const shippingIntakes = useShippingNoticeIntakes({
attachments,
conversationId,
msg,
t,
});
const {
handleShippingAutoUploadFile,
handleShippingAutoUploadNoticeBatch,
@@ -689,6 +699,8 @@ export function useChatShipping(options: UseChatShippingOptions) {
getActiveShippingTaskId,
startChatTurn,
refreshShippingActions,
getParsedIntakeNos: shippingIntakes.getParsedIntakeNos,
clearConsumedNoticeAttachments: shippingIntakes.clearConsumedAttachments,
msg,
t,
});
@@ -741,6 +753,9 @@ export function useChatShipping(options: UseChatShippingOptions) {
handleShippingAutoUploadFile,
handleShippingAutoUploadNoticeBatch,
isShippingNoticeBatchSubmitting,
hasBlockingNoticeIntake: () => shippingIntakes.hasBlockingUploadOrParse.value,
hasNoticeIntakeFailures: () => shippingIntakes.hasParseFailures.value,
getParsedIntakeNos: shippingIntakes.getParsedIntakeNos,
refreshShippingActions,
shippingSuggestedPrompt,
isShippingShortageQueryIntent,
@@ -782,6 +797,10 @@ export function useChatShipping(options: UseChatShippingOptions) {
const onConversationIdChanging = (nextId: string, prevId: string | null | undefined) => {
onNoticeBatchConversationChanging(nextId, prevId);
shippingIntakes.stopPolling();
if (nextId && nextId !== prevId) {
void shippingIntakes.restoreForConversation(nextId);
}
if (prevId !== nextId) {
resolvedShippingTaskId.value = '';
if (!shippingBatchNoFromQuery.value) {
@@ -855,6 +874,33 @@ export function useChatShipping(options: UseChatShippingOptions) {
}
};
const handleShippingLocalFilesSelected = (event: Event): boolean => {
if (!isShippingNoticeAgent.value) return false;
const inputEl = event.target as HTMLInputElement | null;
const files = inputEl?.files ? Array.from(inputEl.files) : [];
if (!files.length) return false;
const noticeFiles = files.filter((file) => classifyShippingUploadFile(file, extractExt) === 'notice');
const otherFiles = files.filter((file) => classifyShippingUploadFile(file, extractExt) !== 'notice');
if (noticeFiles.length) {
void shippingIntakes.enqueueNoticeFiles(noticeFiles);
}
// 同一次选择中的库存/其他文件直接落入本地附件,避免清空 input 后通用 handler 丢失 FileList
for (const file of otherFiles) {
const kind = classifyShippingUploadFile(file, extractExt);
attachments.value = [
...attachments.value,
{
id: `${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
kind: 'local',
file,
type: kind === 'inventory' ? 'document' : 'document',
},
];
}
if (inputEl) inputEl.value = '';
return true;
};
const onConversationLoadedEmpty = async () => {
if (!isShippingNoticeAgent.value || !shippingTaskIdFromQuery.value || isShippingActionBusy.value) return;
const nextQuery: Record<string, string> = { task_id: shippingTaskIdFromQuery.value };
@@ -1017,6 +1063,10 @@ export function useChatShipping(options: UseChatShippingOptions) {
shippingActionButtonClass,
shippingSuggestedPrompt,
useShippingSuggestedPrompt,
enqueueShippingNoticeFiles: shippingIntakes.enqueueNoticeFiles,
handleShippingLocalFilesSelected,
removeShippingNoticeAttachment: shippingIntakes.removeNoticeAttachment,
retryShippingNoticeAttachment: shippingIntakes.retryNoticeAttachment,
tryHandleShippingAttachmentAutoFlow,
tryHandleShippingSend,
onConversationIdChanging,