Skip to content

Commit 0215e19

Browse files
committed
fix(web,ui): filter technical metadata from bookmark notes display
Add provenance line filtering to both sidebar BookmarkCard and main BookmarkListItem components. Lines matching "TYPE from SOURCE" pattern (e.g., "AUTHOR from OpenAlex Tags:") are now filtered out alongside URL:, Title:, and Tags: prefixes. This ensures users only see their actual notes, not internal metadata.
1 parent 99c3d0e commit 0215e19

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

apps/web/src/components/layout/BookmarkCard.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,22 @@ export const BookmarkCard = ({ bookmark, onClose, onDeleted }: BookmarkCardProps
138138
});
139139
};
140140

141-
// Filter out technical metadata (URL, Title, Tags) from notes for display
141+
// Filter out technical metadata from notes for display
142+
// This includes URL:, Title:, Tags: prefixes and provenance lines like "AUTHOR from OpenAlex Tags:"
142143
const notesDisplay = bookmark.notes
143144
?.split('\n')
144-
.filter(line => !line.startsWith('URL:') && !line.startsWith('Title:') && !line.startsWith('Tags:'))
145+
.filter(line => {
146+
const trimmed = line.trim();
147+
// Filter standard metadata prefixes
148+
if (trimmed.startsWith('URL:') || trimmed.startsWith('Title:') || trimmed.startsWith('Tags:')) {
149+
return false;
150+
}
151+
// Filter provenance lines: "TYPE from SOURCE" pattern (e.g., "AUTHOR from OpenAlex Tags: ...")
152+
if (/^[A-Z]+\s+from\s+\S+/i.test(trimmed)) {
153+
return false;
154+
}
155+
return true;
156+
})
145157
.map(line => line.trim())
146158
.filter(Boolean)
147159
.join('\n') || undefined;

packages/ui/src/bookmarks/BookmarkListItem.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ const getEntityTypeLabel = (entityType: EntityType): string => entityType.charAt
5353
*/
5454
const TECHNICAL_NOTE_PREFIXES = ["URL:", "Title:", "Tags:"] as const;
5555

56+
/**
57+
* Pattern for provenance lines like "AUTHOR from OpenAlex Tags: ..."
58+
* These are technical metadata about entity source, not user-entered notes
59+
*/
60+
const PROVENANCE_LINE_PATTERN = /^[A-Z]+\s+from\s+\S+/i;
61+
5662
/**
5763
* Filter out technical metadata lines from notes for user-friendly display
5864
* @param notes - Raw notes string
@@ -62,7 +68,18 @@ const filterNotesForDisplay = (notes: string | undefined): string | undefined =>
6268
if (!notes) return undefined;
6369
const filteredLines = notes
6470
.split("\n")
65-
.filter(line => !TECHNICAL_NOTE_PREFIXES.some(prefix => line.startsWith(prefix)))
71+
.filter(line => {
72+
const trimmed = line.trim();
73+
// Filter standard metadata prefixes
74+
if (TECHNICAL_NOTE_PREFIXES.some(prefix => trimmed.startsWith(prefix))) {
75+
return false;
76+
}
77+
// Filter provenance lines: "TYPE from SOURCE" pattern
78+
if (PROVENANCE_LINE_PATTERN.test(trimmed)) {
79+
return false;
80+
}
81+
return true;
82+
})
6683
.map(line => line.trim())
6784
.filter(Boolean);
6885
return filteredLines.length > 0 ? filteredLines.join("\n") : undefined;

0 commit comments

Comments
 (0)