MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / pollDataSourceUpdates

Function pollDataSourceUpdates

src/stores/apiServer.ts:413–433  ·  view source on GitHub ↗
(sourceId: string, sessionIds: string[], maxAttempts = 24, intervalMs = 5000)

Source from the content-addressed store, hash-verified

411 }
412
413 function pollDataSourceUpdates(sourceId: string, sessionIds: string[], maxAttempts = 24, intervalMs = 5000) {
414 let attempt = 0
415 const timer = setInterval(async () => {
416 attempt++
417 await Promise.all([fetchDataSources(), fetchSyncProgress()])
418 const ds = dataSources.value.find((s) => s.id === sourceId)
419 const pending = sessionIds.filter((id) => {
420 const sess = ds?.sessions.find((s) => s.id === id)
421 return sess && sess.lastStatus === 'idle'
422 })
423 if (pending.length === 0 || attempt >= maxAttempts) {
424 for (const id of sessionIds) {
425 pullingIds.value.delete(id)
426 syncProgress.value.delete(id)
427 }
428 pullingIds.value = new Set(pullingIds.value)
429 syncProgress.value = new Map(syncProgress.value)
430 clearInterval(timer)
431 }
432 }, intervalMs)
433 }
434
435 async function fetchSyncProgress() {
436 if (!isWebMode.value) return

Callers 1

addImportSessionsFunction · 0.85

Calls 4

fetchDataSourcesFunction · 0.85
fetchSyncProgressFunction · 0.85
allMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected