useChat exposes reset() which calls setMessages(opts.initialMessages),
and the AI page passes initialLive.current as initialMessages — a ref
captured once on mount from localStorage.
resetAndClear was calling reset() then clearLive(). Sequence problem:
reset() → setMessages(initialLive.current) // populated old array
clearLive() → localStorage.removeItem(LIVE_KEY) // does nothing to memory
The ref still held the original messages, so reset re-seeded them and
the conversation appeared to "come back" the moment you typed anything
(or sometimes immediately, depending on render timing).
Fix: blank the ref, clear localStorage, and call setMessages([])
directly. reset() is no longer needed at this call site so it's been
dropped from the useChat destructure.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>