MCPcopy
hub / github.com/benjitaylor/agentation / addAnnotation

Function addAnnotation

mcp/src/server/sqlite.ts:390–451  ·  view source on GitHub ↗
(
      sessionId: string,
      data: Omit<Annotation, "id" | "sessionId" | "status" | "createdAt">
    )

Source from the content-addressed store, hash-verified

388
389 // Annotations
390 addAnnotation(
391 sessionId: string,
392 data: Omit<Annotation, "id" | "sessionId" | "status" | "createdAt">
393 ): Annotation | undefined {
394 const session = this.getSession(sessionId);
395 if (!session) return undefined;
396
397 const annotation: Annotation = {
398 ...data,
399 id: generateId(),
400 sessionId,
401 status: "pending",
402 createdAt: new Date().toISOString(),
403 };
404
405 // Build extra JSON for structured data (placement/rearrange)
406 let extraJson: string | null = null;
407 if (annotation.placement) {
408 extraJson = JSON.stringify({ placement: annotation.placement });
409 } else if (annotation.rearrange) {
410 extraJson = JSON.stringify({ rearrange: annotation.rearrange });
411 }
412
413 stmts.insertAnnotation.run({
414 id: annotation.id,
415 sessionId: annotation.sessionId,
416 x: annotation.x,
417 y: annotation.y,
418 comment: annotation.comment,
419 element: annotation.element,
420 elementPath: annotation.elementPath,
421 timestamp: annotation.timestamp,
422 selectedText: annotation.selectedText ?? null,
423 boundingBox: annotation.boundingBox ? JSON.stringify(annotation.boundingBox) : null,
424 nearbyText: annotation.nearbyText ?? null,
425 cssClasses: annotation.cssClasses ?? null,
426 nearbyElements: annotation.nearbyElements ?? null,
427 computedStyles: annotation.computedStyles ?? null,
428 fullPath: annotation.fullPath ?? null,
429 accessibility: annotation.accessibility ?? null,
430 isMultiSelect: annotation.isMultiSelect ? 1 : 0,
431 isFixed: annotation.isFixed ? 1 : 0,
432 reactComponents: annotation.reactComponents ?? null,
433 url: annotation.url ?? null,
434 intent: annotation.intent ?? null,
435 severity: annotation.severity ?? null,
436 status: annotation.status ?? "pending",
437 thread: annotation.thread ? JSON.stringify(annotation.thread) : null,
438 createdAt: annotation.createdAt ?? new Date().toISOString(),
439 updatedAt: null,
440 resolvedAt: null,
441 resolvedBy: null,
442 authorId: annotation.authorId ?? null,
443 kind: annotation.kind ?? "feedback",
444 extra: extraJson,
445 });
446
447 const event = eventBus.emit("annotation.created", sessionId, annotation);

Callers

nothing calls this directly

Calls 4

persistEventFunction · 0.85
getSessionMethod · 0.80
emitMethod · 0.80
generateIdFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…