mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-12 08:27:27 +02:00
Introduce a production-quality session management system for AI chat: Architecture: - ChatSessionManager singleton manages all active chat sessions - Sessions keyed by conversationId (not window) for multi-window support - Multiple windows viewing same conversation share streaming state - Reference counting with delayed cleanup for quick tab switching Features: - RxJS BehaviorSubject for reactive session state - Subject streams for events (streaming, messages, errors) - Automatic usage and cost tracking per session - Resume functionality when generation is interrupted - Proper abort handling with partial message saving React Integration: - useChatSession(conversationId) - main hook combining Dexie + session state - useChatActions() - stable action functions - useConversations() - reactive conversation list - useStreamingContent() - lightweight streaming-only subscription Migrated AIViewer to use new hooks, significantly simplifying the component by removing direct DB operations and complex state management. https://claude.ai/code/session_01HqtD9R33oqfB14Gu1V5wHC