MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / syncTaskMetadataPreview

Function syncTaskMetadataPreview

projects/openade-module/src/yjsMutation.ts:353–390  ·  view source on GitHub ↗
(
    storage: OpenADEYjsMutationStorageAdapter,
    taskId: string,
    taskDoc: Y.Doc,
    updatedAt: string,
    usage?: unknown
)

Source from the content-addressed store, hash-verified

351}
352
353async function syncTaskMetadataPreview(
354 storage: OpenADEYjsMutationStorageAdapter,
355 taskId: string,
356 taskDoc: Y.Doc,
357 updatedAt: string,
358 usage?: unknown
359): Promise<void> {
360 const meta = taskDoc.getMap("task:meta")
361 const repoId = stringValue(meta.get("repoId"))
362 if (!repoId) throw new Error(`Task ${taskId} is missing repoId`)
363
364 const reposDoc = await loadDoc(storage, "code:repos")
365 try {
366 const repoMap = findRepoMap(reposDoc, repoId)
367 if (!repoMap) throw new Error(`Repository ${repoId} not found`)
368 const lastNonSnapshot = getLastNonSnapshotEvent(taskDoc)
369 const lastEventAt = typeof meta.get("lastEventAt") === "string" ? (meta.get("lastEventAt") as string) : undefined
370 const lastEvent = lastNonSnapshot ? getNonSnapshotEventPreview(lastNonSnapshot, lastEventAt ?? stringValue(lastNonSnapshot.get("createdAt"), updatedAt)) : undefined
371 reposDoc.transact(() => {
372 updateTaskPreview(
373 repoMap,
374 taskId,
375 {
376 title: stringValue(meta.get("title"), "Untitled task"),
377 closed: meta.get("closed"),
378 lastViewedAt: meta.get("lastViewedAt"),
379 lastEventAt,
380 lastEvent,
381 ...(usage !== undefined ? { usage } : {}),
382 },
383 updatedAt
384 )
385 })
386 await saveDoc(storage, "code:repos", reposDoc)
387 } finally {
388 reposDoc.destroy()
389 }
390}
391
392async function syncActionEventPreview(
393 storage: OpenADEYjsMutationStorageAdapter,

Callers 2

setupTaskEnvironmentFunction · 0.85
updateTaskMetadataFunction · 0.85

Calls 9

findRepoMapFunction · 0.85
getLastNonSnapshotEventFunction · 0.85
destroyMethod · 0.80
stringValueFunction · 0.70
loadDocFunction · 0.70
updateTaskPreviewFunction · 0.70
saveDocFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected