Feature Request: Persistent Conversation History for Anonymous Users
## Summary <!-- Briefly describe the feature or improvement you are proposing. --> ## Problem The AI chatbot currently stores conversation history in Drupal's PrivateTempStore, which is tied to the anonymous user's session. On sites with reverse proxy caching (Varnish, Fastly, Lagoon), session cookies are frequently stripped or not forwarded on cached pages, causing the tempstore lookup to fail. The result is that anonymous users lose their entire conversation history on every page navigation. ## Possible solution (provided by Claude Code) **Stable anonymous identifier** — Generate a UUID on first chatbot interaction, stored in a long-lived cookie (not session-tied). This becomes the persistent conversation key. **Database-backed conversation storage** — Add an optional database table (ai_chatbot_conversations) alongside the existing tempstore. Schema would include: conversation_id, assistant_id, thread_id, role, message, timestamp. **Session restoration** — On page load, if tempstore is empty but a conversation UUID cookie exists, fetch the stored history from the database and replay it into the tempstore thread before the user's next message. This restores both visible history AND AI context. **Cron cleanup** — Garbage collect conversations older than a configurable threshold (default 24 hours, matching current tempstore behavior). **Configurable** — A per-chatbot-block toggle: "Enable persistent conversations" defaulting to off. Optionally configurable retention period. ## Workaround *(optional)* ## Affected modules / components (provided by Claude Code) Key Files - AiAssistantApiRunner.php — addMessageToSession(), getMessageHistory(), resetThread() — primary storage layer to extend - DeepChatApi.php — session initialization endpoint, restoration hook - DeepChatFormBlock.php — historicalMessages() — where restored history feeds into drupalSettings - deepchat-init.js — frontend conversation UUID cookie management > Significantly produced by Claude Code. I attempted to create a shallow front-end submodule for personal use, but this type of feature runs too deep. Getting AI context to be persistent across page reloads was too complex for my comfort level.
issue