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
This commit is contained in:
Waleed
2026-01-20 00:24:50 -08:00
committed by GitHub
parent 84691fc873
commit e4ad31bb6b
2 changed files with 7 additions and 12 deletions

View File

@@ -538,15 +538,11 @@ export function Document({
},
{
onSuccess: (result) => {
if (operation === 'delete') {
if (operation === 'delete' || result.errorCount > 0) {
refreshChunks()
} else {
result.results.forEach((opResult) => {
if (opResult.operation === operation) {
opResult.chunkIds.forEach((chunkId: string) => {
updateChunk(chunkId, { enabled: operation === 'enable' })
})
}
chunks.forEach((chunk) => {
updateChunk(chunk.id, { enabled: operation === 'enable' })
})
}
logger.info(`Successfully ${operation}d ${result.successCount} chunks`)

View File

@@ -755,12 +755,11 @@ export interface BulkChunkOperationParams {
}
export interface BulkChunkOperationResult {
operation: string
successCount: number
failedCount: number
results: Array<{
operation: string
chunkIds: string[]
}>
errorCount: number
processed: number
errors: string[]
}
export async function bulkChunkOperation({