A captured stream ended complete(272 chars) → image → attachment_saved
→ end, all under one message id. complete emptied the accumulation, the
attachment marker re-accumulated onto it, and end emitted a second
completion for the same message whose body was the marker alone. The
client assigns completed content over the existing message, so 272
characters of reply were replaced by an image tag — the reply visibly
vanished behind a broken image placeholder.
Mark a message as completed when its completion is emitted, and open a
new message on the next delta rather than reusing the finished id. The
reopened id carries a #part- suffix so the client reads it as a separate
message; frame comparisons use the base id so a later frame bearing the
server's original id is not treated as a different message.
The regression test replays the captured frame order and was checked
against a mutation that drops the completed flag, where it fails with
the attachment reusing the finished id.
Refs: F-32 (audit P2-17), which predicted this as "content arriving
after complete overwrites the full text".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>