Architecture: How to scope chat sessions to specific features (Studio, pag...

Documentation for Sessions

🏗️ Architecture: How to scope chat sessions to specific features (Studio, pag...

Date: 2026-03-06
Time: 15:28:48 UTC
Session: gspace1-182.6
Agent: angular
Confidence: 90%
Status: ✅ Documented


📋 Decision Context

Question:

How to scope chat sessions to specific features (Studio, page-builder, etc.)?

Task: Session 183: Context-scoped chat sessions for Vitto Studio


🎯 Decision Made

Chosen:

Added VittoSessionContext to VittoChatSession — { type, route, spaceSlug, universeSlug, label }. Sessions with context are filtered via activeContextFilter signal on VittoChatPersistenceService. createSession() accepts optional context. findSessionsByContext() queries by type+filters. StudioSessionService uses this to create/find/scope sessions per universe.

Options Considered:

  1. localStorage key per universe (previous attempt — sidebar still showed all sessions)
  2. VittoSessionContext on session + activeContextFilter on persistence (chosen)
  3. Separate IndexedDB store per context (over-engineering)

💭 Reasoning

The session system was flat — no way to scope sessions to features. The localStorage hack (previous attempt) didn't work because it only mapped IDs without filtering the sidebar. The proper fix adds context to the session data model itself. This is backward-compatible (context is optional — existing sessions have none and work as before). The activeContextFilter signal drives the sessionList computed, which the sidebar already consumes. When Studio sets the filter, only Studio sessions appear. When Studio unmounts (ngOnDestroy), the filter clears and all sessions return.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation