Margin
{showSettings && (
{(['light', 'dark', 'system'] as const).map((t) => (
))}
Page Overlay
Show highlights and annotations on pages
)}
{(['page', 'bookmarks', 'highlights', 'collections'] as Tab[]).map((tab) => {
const icons = {
page: Icons.globe,
bookmarks: Icons.bookmark,
highlights: Icons.highlighter,
collections: Icons.folder,
};
const labels = {
page: 'Page',
bookmarks: 'Bookmarks',
highlights: 'Highlights',
collections: 'Collections',
};
return (
);
})}
{activeTab === 'page' && (
{currentUrl ? (

{
(e.target as HTMLImageElement).style.display = 'none';
(e.target as HTMLImageElement).nextElementSibling?.classList.remove(
'hidden'
);
}}
/>
) : null}
{Icons.globe}
{currentTitle || 'Untitled'}
{currentUrl ? new URL(currentUrl).hostname : ''}
Activity
{annotations.length + pageHighlights.length}
{(['all', 'annotations', 'highlights'] as const).map((key) => (
))}
{loadingAnnotations ? (
) : annotations.length + pageHighlights.length === 0 ? (
{Icons.sparkles}
No activity yet
Be the first to annotate or highlight
) : (
{(pageFilter === 'all' || pageFilter === 'annotations') &&
annotations.map((item) => (
openCollectionModal(item.uri || item.id || '')}
onConverted={loadAnnotations}
/>
))}
{(pageFilter === 'all' || pageFilter === 'highlights') &&
pageHighlights.map((item) => (
openCollectionModal(item.uri || item.id || '')}
onConverted={loadAnnotations}
/>
))}
{((pageFilter === 'annotations' && annotations.length === 0) ||
(pageFilter === 'highlights' && pageHighlights.length === 0)) && (
No {pageFilter === 'annotations' ? 'annotations' : 'highlights'} on this page
)}
)}
)}
{activeTab === 'bookmarks' && (
{loadingBookmarks ? (
) : bookmarks.length === 0 ? (
{Icons.bookmark}
No bookmarks yet
Save pages to read later
) : (
{bookmarks.map((item) => (
))}
)}
)}
{activeTab === 'highlights' && (
{loadingHighlights ? (
) : highlights.length === 0 ? (
{Icons.highlighter}
No highlights yet
Select text on any page to highlight
) : (
{highlights.map((item) => (
openCollectionModal(item.uri || item.id || '')}
onConverted={loadHighlights}
/>
))}
)}
)}
{activeTab === 'collections' && (
{loadingCollections ? (
) : collections.length === 0 ? (
{Icons.folder}
No collections yet
Organize your bookmarks into collections
) : (
{collections.map((item) => (
))}
)}
)}
{collectionModalItem && (
setCollectionModalItem(null)}
>
e.stopPropagation()}
>
Add to Collection
{collections.length === 0 ? (
No collections yet
Create a collection on the web app first
) : (
collections.map((col) => {
const colUri = col.uri || col.id || '';
const isAdding = addingToCollection === colUri;
const isInCollection = containingCollections.has(colUri);
return (
);
})
)}
)}
);
}
function AnnotationCard({
item,
sessionDid,
formatDate,
onAddToCollection,
onConverted,
}: {
item: Annotation;
sessionDid?: string;
formatDate: (d?: string) => string;
onAddToCollection?: () => void;
onConverted?: () => void;
}) {
const [noteInput, setNoteInput] = useState('');
const [showNoteInput, setShowNoteInput] = useState(false);
const [converting, setConverting] = useState(false);
const author = item.author || item.creator || {};
const handle = author.handle || 'User';
const text = item.body?.value || item.text || '';
const selector = item.target?.selector;
const quote = selector?.exact || '';
const isHighlight = (item as any).type === 'Highlight';
const isOwned = sessionDid && author.did === sessionDid;
const highlightColor = item.color || (isHighlight ? '#fbbf24' : 'var(--accent)');
async function handleConvert() {
if (!noteInput.trim()) return;
setConverting(true);
try {
const result = await sendMessage('convertHighlightToAnnotation', {
highlightUri: item.uri || item.id || '',
url: item.target?.source || '',
text: noteInput.trim(),
selector: item.target?.selector,
});
if (result.success) {
setShowNoteInput(false);
setNoteInput('');
onConverted?.();
} else {
console.error('Convert failed:', result.error);
}
} catch (error) {
console.error('Convert error:', error);
} finally {
setConverting(false);
}
}
return (