refactor(agent): prevent creating autofill and embedding tasks for audio assets

This commit is contained in:
yiling
2026-07-05 16:31:14 +08:00
parent 73aa374b2b
commit 8ad25215dd
3 changed files with 25 additions and 20 deletions
@@ -300,7 +300,9 @@ describe('Agent Autofill Workflow', () => {
},
})
await expect(agentAutofillMedia(task)).rejects.toThrow('unsupported media type for autofill: audio/mp3')
await expect(agentAutofillMedia(task)).rejects.toThrow(
'unsupported media type for autofill: audio/mp3',
)
// Verify task failed status
expect(mockActivities.updateTaskStatusActivity).toHaveBeenCalledWith({
+5 -4
View File
@@ -294,7 +294,11 @@ export class UploadService {
},
})
if (autofillAgent) {
const isVideo = asset.mediaType?.startsWith('video/')
const isImage = asset.mediaType?.startsWith('image/')
const isAudio = asset.mediaType?.startsWith('audio/')
if (autofillAgent && (isVideo || isImage)) {
await tx.workflowTask.create({
data: {
assetId: asset.id,
@@ -310,9 +314,6 @@ export class UploadService {
})
}
const isVideo = asset.mediaType?.startsWith('video/')
const isImage = asset.mediaType?.startsWith('image/')
const isAudio = asset.mediaType?.startsWith('audio/')
if (!isVideo && !isImage && !isAudio) {
await tx.asset.update({
where: { id: asset.id },
+17 -15
View File
@@ -582,23 +582,25 @@ export interface CreateEmbeddingTaskIfEnabledParams {
export async function createEmbeddingTaskIfEnabledActivity(
params: CreateEmbeddingTaskIfEnabledParams,
): Promise<void> {
let teamId = params.teamId
let projectId = params.projectId
// Resolve teamId and projectId from asset if missing
if (!teamId || !projectId) {
const asset = await prisma.asset.findUnique({
where: { id: params.assetId },
include: {
project: true,
},
})
if (asset) {
projectId = projectId || asset.projectId
teamId = teamId || asset.project?.teamId || null
}
const asset = await prisma.asset.findUnique({
where: { id: params.assetId },
include: {
project: true,
},
})
if (!asset) {
return
}
const isVideo = asset.mediaType?.startsWith('video/')
const isImage = asset.mediaType?.startsWith('image/')
if (!isVideo && !isImage) {
return
}
const teamId = params.teamId || asset.project?.teamId || null
const projectId = params.projectId || asset.projectId
if (!teamId) {
return
}