feat(chat-workflow): persist assistant message per step
Merged
AR
5mo ago+251+251+012345678901234567890123456789-283-283-012345678901234567890123456789
Summary
Upgrades the success-only assistant persist to per-step persistence, so a stopped or crashed turn keeps the partial reply instead of dropping it. Rebased on current test; keeps the per-turn credit charge and the stable assistant message id, and bumps last_assistant_message_at on every persist so partial replies still surface as unread.
Test plan
- Send a chat turn, refresh — the assistant reply persists.
- Stop a turn mid-stream, refresh — the partial reply persists and the chat shows unread.
- Confirm the turn is still billed (credits deducted once).
Summary by CodeRabbit
- Improvements
- Assistant messages are now persisted during streaming rather than after completion, reducing the risk of data loss.
- Messages can be incrementally updated as they stream for improved real-time visibility.
- Enhanced message storage logic to support more flexible conflict handling when saving chat messages.