Long-run chat: persist user turns, recover from proxy disconnects
Three defects surfaced by a 13-minute, 31-document project-chat review that ended in a bare "Sorry, something went wrong" while the answer sat finished in the database. 1. No user message was ever saved. Both chat routes inserted a `workflow` field into chat_messages, which has no such column; PostgREST rejected every insert and the unchecked result hid it. Drop the field and check the error. Reloaded chats now show the questions, not just the answers. 2. Cloudflare caps a proxied request at ~10 minutes no matter how often the SSE heartbeat fires, so a long agentic run loses its client while the backend keeps going and persists the turn. The client now says so and polls the saved chat until the answer lands, instead of leaving a dead error in place. 3. The client ignored the SSE `error` event entirely, so a server-side failure ended the stream as a blank assistant turn. Surface it (and send the real message rather than "Stream error"). Also add start/disconnect/finish logging to the project chat route, which had none - the reason this run left almost no trace.
| Repository | emileriksenkeev/sydOS |
|---|---|
| Author | emileriksenkeev <emil@keev.co> |
| Authored | |
| Parents | 39c86e4f |
| Stats | 3 files changed , +167 , -24 |
| Part of | Agentic chat run reliability and long-run streaming |
Capture this commit into my fork
Download a Markdown prompt that tells Claude how to port this
exact commit into your working tree. Run it via
claude -p < capture-commit-fe464fe8.md
from inside the repo you want the change in.