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

Function syncActionEventPreview

projects/openade-module/src/yjsMutation.ts:392–425  ·  view source on GitHub ↗
(
    storage: OpenADEYjsMutationStorageAdapter,
    taskId: string,
    taskDoc: Y.Doc,
    event: Y.Map<unknown>,
    at: string
)

Source from the content-addressed store, hash-verified

390}
391
392async function syncActionEventPreview(
393 storage: OpenADEYjsMutationStorageAdapter,
394 taskId: string,
395 taskDoc: Y.Doc,
396 event: Y.Map<unknown>,
397 at: string
398): Promise<void> {
399 const meta = taskDoc.getMap("task:meta")
400 const repoId = stringValue(meta.get("repoId"))
401 if (!repoId) throw new Error(`Task ${taskId} is missing repoId`)
402
403 const reposDoc = await loadDoc(storage, "code:repos")
404 try {
405 const repoMap = findRepoMap(reposDoc, repoId)
406 if (!repoMap) throw new Error(`Repository ${repoId} not found`)
407 reposDoc.transact(() => {
408 updateTaskPreview(
409 repoMap,
410 taskId,
411 {
412 title: stringValue(meta.get("title"), "Untitled task"),
413 closed: meta.get("closed"),
414 lastViewedAt: meta.get("lastViewedAt"),
415 lastEventAt: meta.get("lastEventAt"),
416 lastEvent: getEventPreview(event, at),
417 },
418 stringValue(meta.get("updatedAt"), at)
419 )
420 })
421 await saveDoc(storage, "code:repos", reposDoc)
422 } finally {
423 reposDoc.destroy()
424 }
425}
426
427export function createOpenADEYjsWriter(storage: OpenADEYjsMutationStorageAdapter, options: OpenADEYjsWriterOptions = {}): OpenADEYjsWriter {
428 const createId = options.createId ?? createFallbackId

Callers 4

completeActionEventFunction · 0.85
errorActionEventFunction · 0.85
stoppedActionEventFunction · 0.85

Calls 8

findRepoMapFunction · 0.85
getEventPreviewFunction · 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