Architecture: How should user identity flow from AI Panel to Vitto chat ba...
Documentation for Sessions
🏗️ Architecture: How should user identity flow from AI Panel to Vitto chat ba...
Date: 2026-02-11
Time: 22:23:17 UTC
Session: gspace1-106.9
Agent: backend
Confidence: 90%
Status: ✅ Documented
📋 Decision Context
Question:
How should user identity flow from AI Panel to Vitto chat backend?
Task: Fix AI Panel identity for Vitto personalization
🎯 Decision Made
Chosen:
Read from TenantContext first, fallback to auth_backup localStorage — pass through to /ai-api/chat
Options Considered:
- Import AuthService directly in AI Panel
- Read from TenantContext + auth_backup localStorage fallback
- Only pass userId and let backend do all profile lookups
💭 Reasoning
The AI Panel (vitto-hub) is designed to work in multiple contexts: Chrome extension, embedded iframe, direct access. AuthService may not be available in all. TenantContext is the established contract between host (ExtensionPanel) and panel. Added userName/userEmail to TenantContext interface so extension hosts can pass it. For direct access (localhost), reading auth_backup from localStorage is the same proven pattern used by admin-role.guard.ts. This two-source approach (TenantContext → localStorage fallback) ensures identity flows regardless of hosting context. The backend then does authoritative profile lookup from MongoDB by userId.
📁 Files Involved
libs/libs-ai/vitto-hub/src/lib/components/ai-panel/ai-panel.component.tslibs/libs-ai/vitto-hub/src/lib/models/vitto-hub.types.tsapps/gograb-ai/src/app/pages/extension-panel/extension-panel.component.ts
🔗 Related
- Decision ID:
dev_1770848597880_3bbzdc1 - Session: 106
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation