Skip to content

Feature/annotation log#109

Open
XanderVertegaal wants to merge 7 commits into
developfrom
feature/annotation-log
Open

Feature/annotation log#109
XanderVertegaal wants to merge 7 commits into
developfrom
feature/annotation-log

Conversation

@XanderVertegaal
Copy link
Copy Markdown
Contributor

Closes #69

This PR adds a simple list of annotations to each problem, so users can see when annotations were added/removed and by whom.

image

The annotations are sorted by date from most to least recent. As a bonus, I've added some frontend filtering. We can always add backend filtering, sorting, pagination and other fancy list goodies if/when they are requested.

@XanderVertegaal XanderVertegaal added the enhancement New feature or request label May 25, 2026
@XanderVertegaal XanderVertegaal marked this pull request as ready for review May 26, 2026 07:16
Copy link
Copy Markdown
Contributor

@jgonggrijp jgonggrijp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed the code and the screenshot (which looks nice!), but did not try the changes locally. Based on the code, I wonder whether it is possible to see both additions and removals but only for labels, or only removals but both for labels and KB items. Other than that, the functionality looks very nice.

Comment on lines +79 to +81
@for (event of events; track $index) {
@let added = event.eventKind === "added";
@let isLabel = event.annotationKind === "label";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the @for and @let statements deserve to be at different indentation levels. Maybe keep the @for with the <ul> above? What do the conventions say?

Comment on lines +15 to +54
type AnnotationEventKind = "added" | "removed";
type AnnotationKind = "label" | "knowledgeBase";

export interface AnnotationEvent {
eventKind: AnnotationEventKind;
annotationKind: AnnotationKind;
timestamp: string;
actor: string;
description: string;
}

const relationshipSymbols: Record<KnowledgeBaseRelationship, string> = {
[KnowledgeBaseRelationship.EQUAL]: "=",
[KnowledgeBaseRelationship.NOT_EQUAL]: "≠",
[KnowledgeBaseRelationship.SUBSET]: "⊂",
[KnowledgeBaseRelationship.SUPERSET]: "⊃",
};

function annotationToEvent(annotation: LabelAnnotation | KnowledgeBaseAnnotation): AnnotationEvent[] {
const isLabelAnnotation = "label" in annotation;
const description = isLabelAnnotation ? annotation.label.text : `${annotation.entity1} ${relationshipSymbols[annotation.relationship]} ${annotation.entity2}`;
const annotationKind: AnnotationKind = isLabelAnnotation ? "label" : "knowledgeBase";
const events: AnnotationEvent[] = [{
eventKind: "added",
annotationKind,
timestamp: annotation.createdAt,
actor: annotation.createdBy,
description,
}];
if (annotation.removedAt && annotation.removedBy) {
events.push({
eventKind: "removed",
annotationKind,
timestamp: annotation.removedAt,
actor: annotation.removedBy,
description,
});
}
return events;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is model-level logic. Maybe it deserves living in a dedicated module?

Comment on lines +93 to +94
(e.eventKind === "added" ? this.showAdded() : this.showRemoved()) &&
(e.annotationKind === "label" ? this.showLabels() : this.showKB())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that you can either see all events, or filter by event kind and annotation kind at the same time, but not filter only by event kind or only by annotation kind?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Annotation log

2 participants