diff --git a/src/work/EvidenceSidebar.tsx b/src/work/EvidenceSidebar.tsx
index 6a6731c..8bda2f4 100644
--- a/src/work/EvidenceSidebar.tsx
+++ b/src/work/EvidenceSidebar.tsx
@@ -104,6 +104,22 @@ function annotationOrderKey(annotation: Annotation | null): number {
return docOrderKey(annotation.selectors);
}
+const FILTER_MIN_CHARS = 3;
+
+function matchesEvidenceFilter(
+ query: string,
+ quote: string,
+ commentary: string | undefined,
+ status: string,
+): boolean {
+ const q = query.trim();
+ if (q.length < FILTER_MIN_CHARS) return true;
+ const needle = q.toLowerCase();
+ return [quote, commentary ?? "", status].some((p) =>
+ p.toLowerCase().includes(needle),
+ );
+}
+
export function EvidenceSidebar(props: EvidenceSidebarProps) {
const engine = useEngine();
const { document } = useActiveDocument();
@@ -117,6 +133,8 @@ export function EvidenceSidebar(props: EvidenceSidebarProps) {
const annotationUpdateTick = useEngineEventTick("AnnotationUpdated");
const revision = useEngineRevision();
+ const [filterQuery, setFilterQuery] = useState("");
+
// Build the sorted view-model: each item gets its order key + the
// first annotation up-front so the render below doesn't have to
// re-resolve them inside the map.
@@ -139,6 +157,17 @@ export function EvidenceSidebar(props: EvidenceSidebarProps) {
revision,
]);
+ const filteredItems = useMemo(() => {
+ return sortedItems.filter(({ item, annotation }) =>
+ matchesEvidenceFilter(
+ filterQuery,
+ annotation?.quote ?? "",
+ item.commentary,
+ item.status,
+ ),
+ );
+ }, [sortedItems, filterQuery]);
+
const pendingOrder = useMemo
+ No matches. +
+ )}