Canvas AI: In-progress chat messages disappear when editing page metadata during an active run
Follow-up to #3558257. ### Problem While the AI agent is running, editing the page title or meta description removes the in-progress status messages from the chat UI. ### Steps to reproduce 1. Install Canvas AI on Drupal CMS 2 (starter recipe). 2. Open a new page and open the chatbot. 3. Prompt: `Add an "Our Plans" section for SportsFlix, a sports streaming platform`. 4. While it is still running, type in the description or title field. 5. The in-progress messages disappear from the chat UI. ### Root cause The in-progress status bubble is added imperatively in `startPolling()` via `chatEl.addMessage()` and `chatEl.updateMessage(html, pollingMessageIndex)` in `ui/src/components/aiExtension/AiWizard.tsx`. It lives only in DeepChat's internal message list. Only the final message is written to `historyStore`. Editing metadata changes `pageData`, which re-renders `AiWizard`. DeepChat re-applies its `history` prop, which does not contain the imperative bubble, so it is dropped. The typed prompt survives because it lives in the input box, which is preserved separately from the message list. ### Proposed resolution Route the in-progress message through `historyStore` (the source of truth for the `history` prop) so re-renders reproduce it: - Add an in-memory live-message slot to `historyStore`: `upsertLiveMessage(html)` (add once, then update in place) and `finalizeLiveMessage()`. - Keep the live entry out of IndexedDB persistence; persist only on finalize, so a reload does not restore a stale loader. - In `startPolling()`, replace `addMessage`/`updateMessage`/`pollingMessageIndex` with `historyStore.upsertLiveMessage(buildHtmlContent())`, and finalize on completion. - Retain auto-scroll via an effect keyed on the live message. ### Verification - Reproduce the steps above; confirm in-progress messages persist after a metadata edit. - Add a Playwright case in `tests/src/Playwright/tests/isolatedPerTest/ai.spec.ts` mirroring the existing "Typed prompt survives page metadata edits" test.
issue