Description
Several performance concerns could impact users with large knowledge bases:
Memory Issues
| Location |
Issue |
App.tsx refreshData |
Calls getAllEntities() + getAllLinks() — loads everything into memory with no pagination |
Editor.tsx |
repository.getAllEntities().then(setAllEntities) for mention menu — no virtualization |
search.ts initSearch |
Bulk-loads ALL entities and claims into Orama index on init — no incremental hydration |
search.ts oramaIdMap |
In-memory Map grows unbounded — no eviction |
@huggingface/transformers |
~80MB model download for embeddings, loaded eagerly |
N+1 Queries
| Location |
Issue |
ExportPanel.tsx |
Sequential getClaimsByEntityId + getNotesByEntityId per entity — classic N+1 |
Unnecessary Re-renders
| Location |
Issue |
GraphView.tsx |
clearEdges() on every update, then re-adds all edges — should diff edges |
Missing Debounce
| Location |
Issue |
Chat.tsx handleSend |
No debounce — rapid submissions could flood search |
Recommended Fix
- Pagination: Add cursor-based pagination to
getAllEntities() and getAllLinks()
- Virtualized mention menu: Use
@tanstack/react-virtual for the entity mention dropdown
- Incremental search init: Load search index progressively, not all at once
- Cache eviction: Add LRU eviction to
oramaIdMap with max size
- Batch queries: Add
getAllClaimsWithNotes() to repository to avoid N+1
- Edge diffing: Diff graph edges instead of clearing and re-adding
- Lazy embeddings: Load
@huggingface/transformers only when semantic search is enabled
- Debounce chat: Add 300ms debounce to Chat submit
Acceptance Criteria
Description
Several performance concerns could impact users with large knowledge bases:
Memory Issues
App.tsx refreshDatagetAllEntities()+getAllLinks()— loads everything into memory with no paginationEditor.tsxrepository.getAllEntities().then(setAllEntities)for mention menu — no virtualizationsearch.ts initSearchsearch.ts oramaIdMap@huggingface/transformersN+1 Queries
ExportPanel.tsxgetClaimsByEntityId+getNotesByEntityIdper entity — classic N+1Unnecessary Re-renders
GraphView.tsxclearEdges()on every update, then re-adds all edges — should diff edgesMissing Debounce
Chat.tsx handleSendRecommended Fix
getAllEntities()andgetAllLinks()@tanstack/react-virtualfor the entity mention dropdownoramaIdMapwith max sizegetAllClaimsWithNotes()to repository to avoid N+1@huggingface/transformersonly when semantic search is enabledAcceptance Criteria
refreshDatasupports paginationoramaIdMaphas max size with eviction@huggingface/transformersloaded lazily