Skip to content

Commit e4ad31b

Browse files
authored
fix(kb): align bulk chunk operation with API response (#2899)
* fix(kb): align bulk chunk operation with API response * fix(kb): skip local state update for failed chunks * fix(kb): correct errors type and refresh on partial failure
1 parent 84691fc commit e4ad31b

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -538,15 +538,11 @@ export function Document({
538538
},
539539
{
540540
onSuccess: (result) => {
541-
if (operation === 'delete') {
541+
if (operation === 'delete' || result.errorCount > 0) {
542542
refreshChunks()
543543
} else {
544-
result.results.forEach((opResult) => {
545-
if (opResult.operation === operation) {
546-
opResult.chunkIds.forEach((chunkId: string) => {
547-
updateChunk(chunkId, { enabled: operation === 'enable' })
548-
})
549-
}
544+
chunks.forEach((chunk) => {
545+
updateChunk(chunk.id, { enabled: operation === 'enable' })
550546
})
551547
}
552548
logger.info(`Successfully ${operation}d ${result.successCount} chunks`)

apps/sim/hooks/queries/knowledge.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -755,12 +755,11 @@ export interface BulkChunkOperationParams {
755755
}
756756

757757
export interface BulkChunkOperationResult {
758+
operation: string
758759
successCount: number
759-
failedCount: number
760-
results: Array<{
761-
operation: string
762-
chunkIds: string[]
763-
}>
760+
errorCount: number
761+
processed: number
762+
errors: string[]
764763
}
765764

766765
export async function bulkChunkOperation({

0 commit comments

Comments
 (0)