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:

  1. Fix only the backend memory extraction
  2. Fix only the frontend userId resolution
  3. 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


🔗 Related


Auto-generated by MCP Smart Consolidation