Skip to content

Commit 086f646

Browse files
committed
revert(knowledge): drop the stale-deferred Retry action and its wire fields
Restores the document list, contract, serializer, and Retry condition to staging; Retry stays failed-only.
1 parent efd0535 commit 086f646

9 files changed

Lines changed: 1 addition & 158 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/knowledge/[id]/base.tsx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import {
4949
KNOWLEDGE_DOCUMENT_PROCESSING_STALE_THRESHOLD_MS,
5050
} from '@/lib/knowledge/constants'
5151
import {
52-
canRetryDocumentProcessing,
5352
type DocumentSortField,
5453
getDocumentIndexingStatus,
5554
type SortOrder,
@@ -1570,7 +1569,7 @@ export function KnowledgeBase({
15701569
}
15711570
onRetry={
15721571
contextMenuDocument &&
1573-
canRetryDocumentProcessing(contextMenuDocument) &&
1572+
getDocumentIndexingStatus(contextMenuDocument) === 'failed' &&
15741573
selectedDocumentCount === 1 &&
15751574
userPermissions.canEdit
15761575
? () => handleRetryDocument(contextMenuDocument.id)

‎apps/sim/lib/api/contracts/knowledge/documents.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,6 @@ export const documentDataSchema = z
293293
processingOutcome: z.literal('skipped').nullable().default(null),
294294
/** When indexing was last dispatched to a worker, which precedes a worker starting it. */
295295
processingQueuedAt: nullableWireDateSchema.optional(),
296-
/** When a deferred retry of a `pending` document is due. */
297-
processingDeferredUntil: nullableWireDateSchema.optional(),
298296
processingStartedAt: nullableWireDateSchema.optional(),
299297
processingCompletedAt: nullableWireDateSchema.optional(),
300298
processingError: z.string().nullable().optional(),

‎apps/sim/lib/knowledge/api/internal-route.test.ts‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
internalKnowledgeProvenanceUserId,
1414
resolveInternalKnowledgeBillingAttribution,
1515
toInternalKnowledgeConnector,
16-
toInternalKnowledgeDocument,
1716
} from '@/lib/knowledge/api/internal-route'
1817
import { resolveKnowledgeAttributedUserId } from '@/lib/knowledge/application/billing'
1918

@@ -134,30 +133,6 @@ describe('internal Knowledge execution attribution', () => {
134133
})
135134
})
136135

137-
describe('toInternalKnowledgeDocument', () => {
138-
it('presents when a deferred retry is due, so the Retry action can match the API', () => {
139-
const deferredUntil = new Date('2026-09-01T12:00:00.000Z')
140-
const presented = toInternalKnowledgeDocument({
141-
id: 'doc-1',
142-
knowledgeBaseId: 'kb-1',
143-
filename: 'a.txt',
144-
fileUrl: 'https://example.com/a.txt',
145-
fileSize: 1,
146-
mimeType: 'text/plain',
147-
chunkCount: 0,
148-
tokenCount: 0,
149-
characterCount: 0,
150-
processingStatus: 'pending',
151-
enabled: true,
152-
uploadedAt: new Date('2026-08-01T00:00:00.000Z'),
153-
processingQueuedAt: new Date('2026-08-01T00:00:00.000Z'),
154-
processingDeferredUntil: deferredUntil,
155-
})
156-
expect(presented.processingDeferredUntil).toBe(deferredUntil.toISOString())
157-
expect(presented.processingQueuedAt).toBe('2026-08-01T00:00:00.000Z')
158-
})
159-
})
160-
161136
describe('toInternalKnowledgeConnector', () => {
162137
const row = {
163138
id: 'connector-1',

‎apps/sim/lib/knowledge/api/internal-route.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export function toInternalKnowledgeDocument<
8989
T extends {
9090
uploadedAt: Date | string
9191
processingQueuedAt?: Date | string | null
92-
processingDeferredUntil?: Date | string | null
9392
processingStartedAt?: Date | string | null
9493
processingCompletedAt?: Date | string | null
9594
date1?: Date | string | null
@@ -100,7 +99,6 @@ export function toInternalKnowledgeDocument<
10099
...document,
101100
uploadedAt: serializeDate(document.uploadedAt),
102101
processingQueuedAt: serializeNullableDate(document.processingQueuedAt ?? null),
103-
processingDeferredUntil: serializeNullableDate(document.processingDeferredUntil ?? null),
104102
processingStartedAt: serializeNullableDate(document.processingStartedAt ?? null),
105103
processingCompletedAt: serializeNullableDate(document.processingCompletedAt ?? null),
106104
date1: serializeNullableDate(document.date1 ?? null),

‎apps/sim/lib/knowledge/documents/service.test.ts‎

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,38 +35,6 @@ describe('getDocuments pagination', () => {
3535
expect(dbChainMockFns.limit).toHaveBeenCalledWith(5)
3636
})
3737

38-
it('lists when a pending document was queued and when its deferred retry is due', async () => {
39-
const queuedAt = new Date('2026-08-01T00:00:00.000Z')
40-
const deferredUntil = new Date('2026-08-01T00:02:00.000Z')
41-
queueTableRows(document, [{ count: 1 }])
42-
queueTableRows(document, [
43-
{
44-
id: 'document-1',
45-
processingStatus: 'pending',
46-
processingQueuedAt: queuedAt,
47-
processingDeferredUntil: deferredUntil,
48-
},
49-
])
50-
51-
const result = await getDocuments(
52-
'knowledge-1',
53-
{ limit: 5 },
54-
'request-1',
55-
WORKSPACE_ACCESS_SCOPE
56-
)
57-
58-
expect(dbChainMockFns.select).toHaveBeenCalledWith(
59-
expect.objectContaining({
60-
processingQueuedAt: document.processingQueuedAt,
61-
processingDeferredUntil: document.processingDeferredUntil,
62-
})
63-
)
64-
expect(result.documents[0]).toMatchObject({
65-
processingQueuedAt: queuedAt,
66-
processingDeferredUntil: deferredUntil,
67-
})
68-
})
69-
7038
it('reads a newly admitted candidate even when the earlier count admitted no documents', async () => {
7139
const identity: KnowledgeAccessScope = { kind: 'user', userId: 'reader', tokens: [] }
7240
const resolve = vi.fn(async () => identity)

‎apps/sim/lib/knowledge/documents/service.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2771,8 +2771,6 @@ export async function getDocuments(
27712771
characterCount: document.characterCount,
27722772
processingStatus: document.processingStatus,
27732773
processingOutcome: documentProcessingOutcomeSelection(),
2774-
processingQueuedAt: document.processingQueuedAt,
2775-
processingDeferredUntil: document.processingDeferredUntil,
27762774
processingStartedAt: document.processingStartedAt,
27772775
processingCompletedAt: document.processingCompletedAt,
27782776
processingError: document.processingError,
@@ -2889,8 +2887,6 @@ export async function getDocuments(
28892887
characterCount: doc.characterCount,
28902888
processingStatus: doc.processingStatus as DocumentProcessingStatus,
28912889
processingOutcome: doc.processingOutcome,
2892-
processingQueuedAt: doc.processingQueuedAt,
2893-
processingDeferredUntil: doc.processingDeferredUntil,
28942890
processingStartedAt: doc.processingStartedAt,
28952891
processingCompletedAt: doc.processingCompletedAt,
28962892
processingError: doc.processingError,

‎apps/sim/lib/knowledge/documents/types.test.ts‎

Lines changed: 0 additions & 62 deletions
This file was deleted.

‎apps/sim/lib/knowledge/documents/types.ts‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -106,33 +106,6 @@ export function getDocumentIndexingStatus(document: {
106106
return document.processingOutcome ?? document.processingStatus
107107
}
108108

109-
/**
110-
* Whether a user may retry a document's processing: it failed, or it is `pending` behind a
111-
* dispatch or a deferred retry that is more than {@link QUEUED_DISPATCH_GRACE_MS} past due, the
112-
* same cutoff the retry API applies before it replaces a queued generation. The API still makes
113-
* the final call; this only decides whether to offer the action.
114-
*/
115-
export function canRetryDocumentProcessing(
116-
document: {
117-
processingStatus: string
118-
processingOutcome?: DocumentProcessingOutcome
119-
processingQueuedAt?: Date | string | null
120-
processingDeferredUntil?: Date | string | null
121-
uploadedAt: Date | string
122-
},
123-
now: number = Date.now()
124-
): boolean {
125-
const status = getDocumentIndexingStatus(document)
126-
if (status === 'failed') return true
127-
if (status !== 'pending') return false
128-
const cutoff = now - QUEUED_DISPATCH_GRACE_MS
129-
const queuedAt = new Date(document.processingQueuedAt ?? document.uploadedAt).getTime()
130-
const deferredUntil = document.processingDeferredUntil
131-
? new Date(document.processingDeferredUntil).getTime()
132-
: null
133-
return queuedAt < cutoff && (deferredUntil === null || deferredUntil < cutoff)
134-
}
135-
136109
/**
137110
* Narrows a stored `processing_status` onto the union.
138111
*

‎apps/sim/lib/knowledge/types.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ export interface DocumentData {
148148
characterCount: number
149149
processingStatus: DocumentProcessingStatus
150150
processingOutcome?: DocumentProcessingOutcome
151-
processingQueuedAt?: string | null
152-
processingDeferredUntil?: string | null
153151
processingStartedAt?: string | null
154152
processingCompletedAt?: string | null
155153
processingError?: string | null

0 commit comments

Comments
 (0)