MCPcopy
hub / github.com/OpenCoworkAI/open-codesign / createSnapshot

Function createSnapshot

apps/desktop/src/main/snapshots-db.ts:372–395  ·  view source on GitHub ↗
(db: Database, input: SnapshotCreateInput)

Source from the content-addressed store, hash-verified

370}
371
372export function createSnapshot(db: Database, input: SnapshotCreateInput): DesignSnapshot {
373 return mutateStore(db, (data) => {
374 requireDesignIndex(data, input.designId);
375 const now = nowIso();
376 const snapshot: DesignSnapshot = {
377 schemaVersion: 1,
378 id: crypto.randomUUID(),
379 designId: input.designId,
380 parentId: input.parentId,
381 type: input.type,
382 prompt: input.prompt,
383 artifactType: input.artifactType,
384 artifactSource: input.artifactSource,
385 createdAt: now,
386 ...(input.message !== undefined ? { message: input.message } : {}),
387 };
388 data.snapshots.push(snapshot);
389 const designIdx = requireDesignIndex(data, input.designId);
390 const design = data.designs[designIdx];
391 if (design === undefined) throw new Error(`Design not found: ${input.designId}`);
392 data.designs[designIdx] = { ...design, updatedAt: now };
393 return snapshot;
394 });
395}
396
397export function listSnapshots(db: Database, designId: string): DesignSnapshot[] {
398 return readStore(db)

Callers 3

registerSnapshotsIpcFunction · 0.90

Calls 3

mutateStoreFunction · 0.85
requireDesignIndexFunction · 0.85
nowIsoFunction · 0.85

Tested by

no test coverage detected