Issue #3591731: Keep in-progress AI chat messages when page metadata is edited mid-run
Follow-up to #3558257.
Summary
While the AI agent runs, editing the page title or meta description removed the in-progress status messages from the chat. The in-progress bubble was added imperatively to DeepChat (chatEl.addMessage/updateMessage) and lived only in DeepChat's internal message list. Editing metadata re-renders the panel, DeepChat re-applies its history prop, and the bubble was dropped.
This routes the in-progress message through historyStore:
historyStoregains a transientliveMessageslot (setLiveMessage/clearLiveMessage). It is part of thegetSnapshot()value but is never written to IndexedDB, so a reload does not restore a stale loader.startPollingupdates the in-progress message viahistoryStore.setLiveMessage(...)instead of imperative DeepChat calls. ThepollingMessageIndex/hasAddedInitialMessagetracking is removed.- On completion the live message is replaced by the persisted final message; on error or stop it is cleared.
Testing
-
npm run lint(eslint, prettier, tsc, cspell) passes. - Playwright:
npm run test:playwright -- tests/src/Playwright/tests/isolatedPerTest/ai.spec.tspasses, including the new case "In-progress messages survive page metadata edits". - Manual: start an AI run; while it is running, edit the title or meta description; confirm the in-progress messages stay visible. Confirm no flicker on a normal run, and that the final message renders once.
AI usage disclosure
Per the Drupal.org AI policy: an AI assistant helped diagnose the root cause, write the change, and draft this description. A human reviewed the diff and reasoning before pushing. Local static checks (eslint, prettier, tsc, cspell) passed; the Playwright run is left to CI.