[Bug] Knowledge Base shows persistent "36 unvectorized" count after restart - Frontend using mock data instead of backend API
Bug Description
After restarting AutoBot, the Knowledge Base UI displays the same "36 unvectorized documents" count in all categories, even after vectorization. This count never changes and doesn't reflect actual vectorization state from Redis/ChromaDB.
<button class="unvectorized-badge" title="Click to vectorize 36 documents">
<i class="fas fa-exclamation-circle"></i> 36 unvectorized
<i class="fas fa-play-circle"></i>
</button>
Root Cause
Location: autobot-vue/src/composables/useKnowledgeVectorization.ts:64-74
The getDocumentStatus() function uses MOCK DATA instead of querying the actual backend:
const getDocumentStatus = (documentId: string): VectorizationStatus => {
const state = documentStates.value.get(documentId)
if (!state) {
// MOCK DATA - Replace with actual backend call ⚠️ BUG HERE
const mockStatus = getMockStatus(documentId)
setDocumentStatus(documentId, mockStatus)
return mockStatus
}
return state.status
}
The getMockStatus() function (lines 349-361) generates deterministic fake statuses based on document ID hash:
- 60% always show as "vectorized"
- 25% always show as "pending" (shows as "unvectorized" in UI)
- 10% always show as "unknown"
- 5% always show as "failed"
Since it's hash-based, the same documents always show as unvectorized across all restarts.
Expected Behavior
The frontend should query the backend's POST /api/knowledge_base/vectorization_status endpoint (knowledge.py:416-522), which:
- Checks actual Redis vectorization status using
llama_index/vector_{fact_id}keys - Uses efficient Redis pipelines (single roundtrip for 1000 facts)
- Returns real vectorization state with caching support
Impact
- User confusion: UI shows incorrect vectorization counts
- Wasted effort: Users re-vectorize already-vectorized documents
- Loss of trust: System appears broken after restart
- Performance: No benefit from vectorization caching
Reproduction Steps
- Start AutoBot and navigate to Knowledge Base
- Note the "X unvectorized" count in any category
- Click to vectorize all documents
- Wait for completion
- Restart AutoBot
- Navigate back to Knowledge Base
- BUG: Same "X unvectorized" count appears (e.g., always shows "36")
Proposed Solution
Replace mock data with real API calls in useKnowledgeVectorization.ts:
const getDocumentStatus = async (documentId: string): Promise<VectorizationStatus> => {
const state = documentStates.value.get(documentId)
if (!state) {
// Query actual backend status
const response = await apiClient.post('/api/knowledge_base/vectorization_status', {
fact_ids: [documentId],
use_cache: true
})
const data = typeof response.json === 'function' ? await response.json() : response
const status = data?.statuses?.[documentId]?.vectorized ? 'vectorized' : 'pending'
setDocumentStatus(documentId, status)
return status
}
return state.status
}
Files Affected
autobot-vue/src/composables/useKnowledgeVectorization.ts(PRIMARY)autobot-vue/src/components/knowledge/TreeNodeComponent.vue(uses getDocumentStatus)autobot-vue/src/components/knowledge/KnowledgeBrowser.vue(uses getDocumentStatus)backend/api/knowledge.py:416-522(backend endpoint - already correct)
Related Issues
- See also: ApiClient response handling inconsistency (#TBD)
- Backend endpoint is working correctly, only frontend needs fixing
Labels
bug, frontend, knowledge-base, high-priority, user-experience
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗