The floating AI chat rendered NOTHING for the assistant turn (user bubble + "thinking" dots showed, but the streamed text and tool-call cards never appeared) even though the agent ran server-side. The parts DID arrive in `useChat.messages` — this was purely a render freeze. Root cause: the MessageItem `React.memo` comparator (#182) decided whether to re-render by recomputing `messageSignature(prev.message)` vs `messageSignature(next.message)` inside `arePropsEqual` (plus a `prev.message === next.message` fast path). But the AI SDK (ai@6 / @ai-sdk/react@3) streams a turn by MUTATING the same `parts` in place and handing back a message wrapper that SHARES those mutated parts. So inside the comparator both `prev.message` and `next.message` already reflect the latest content — the two signatures are ALWAYS equal — and the memo skipped every post-mount render. The assistant row therefore froze at its initial empty (null) render; reasoning-first providers (e.g. z.ai/GLM) start with a non-visible reasoning part, so the whole answer + tool cards never showed. Fix: snapshot the signature in the PARENT (MessageList) at render time and pass it to MessageItem as an immutable `signature` string prop; `arePropsEqual` now compares that prop. A captured string is immutable, so `prev.signature` holds the previous render's content and `next.signature` the new content — they differ as the turn streams in and the row re-renders. Drop the now-incorrect `prev.message === next.message` fast path (same-ref-but-mutated must still re-render). MarkdownPart's per-part memo is unaffected (it already keys on the primitive `text`). Verified end-to-end against a real OpenAI-compatible provider: the assistant turn (reasoning + streamed text + tool-call card) now renders live and on finish. Regression tests added (render + comparator) that fail before / pass after. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
11 KiB
11 KiB