Bugfix: Why can't Vitto remember user details across sessions/browse...
Documentation for Sessions
🐛 Bugfix: Why can't Vitto remember user details across sessions/browse...
Date: 2026-02-11
Time: 23:56:58 UTC
Session: gspace1-106.15
Agent: angular
Confidence: 95%
Status: ✅ Documented
📋 Decision Context
Question:
Why can't Vitto remember user details across sessions/browsers?
Task: Fix Vitto memory persistence - userId never reaches backend as valid ObjectId
🎯 Decision Made
Chosen:
Fix the entire auth chain from frontend to backend
Options Considered:
- Fix only the backend memory extraction
- Fix only the frontend userId resolution
- Fix the entire auth chain from frontend to backend
💭 Reasoning
Root cause analysis revealed that Vitto's memory system was fundamentally broken because the userId reaching the backend was NEVER a valid MongoDB ObjectId. The auth chain had three broken links: (1) AIPanelComponent used getOrCreateLocalUserId() which generates 'dev-xxx' strings instead of reading AuthService.user().id — the real MongoDB ObjectId from JWT login. (2) The gograb-ai app had provideHttpClient() with NO authInterceptor, so JWT tokens were never sent with /ai-api/* requests — the backend always saw anonymous users. (3) VittoChatEngineService used UserContextService which defaults to 'anonymous' and no component ever set the real userId from auth. Combined, UserAgentService.saveMemory() validated ObjectId format and correctly rejected all save attempts, but silently (the WARN logs were never visible because the backend was running old code). Fixing all three ensures the real MongoDB ObjectId flows from AuthService → request body + JWT header → backend → UserAgentService → MongoDB.
📁 Files Involved
libs/libs-ai/vitto-hub/src/lib/components/ai-panel/ai-panel.component.tsapps/gograb-ai/src/app/app.config.tsapps/gograb-ai/src/app/pages/extension-panel/extension-panel.component.tslibs/libs-ai/vitto-chat/src/lib/services/vitto-chat-engine.service.tsapis/backend-ai-api/src/app/chat/chat.controller.ts
🔗 Related
- Decision ID:
dev_1770854218853_6tc9zaf - Session: 106
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation