Commit Graph

1 Commits (main)

Author SHA1 Message Date
AstonKrss 12e3e49d80
fix(chat): persist failed quick-answer turns so errors survive refresh (#4306)
* fix(chat): persist failed quick-answer turns so errors survive refresh

A KnowledgeQA (fast-answer/RAG) turn that failed left the assistant row
empty and incomplete forever. The pipeline error was already surfaced
live as an SSE error event (bubble text + toast), but nothing ever
completed the turn: no content was saved, is_completed stayed false, and
the SSE stream never published its completion event, so a refresh
rendered a blank bubble and the connection polled until the client hung
up (issue #4145).

Register an EventError handler for the quick-answer mode that completes
the turn through the same path as a streamed answer:

- persist the error text on the assistant message (appending to a
  partial answer instead of replacing it), falling back to a fixed
  explanation when the error carries no message
- mark the row completed, release the turn lease and publish the SSE
  completion so the stream closes cleanly
- skip chat-history indexing, follow-up suggestions and memory writes
  for the failed turn by completing with an empty query

A late error after a fallback already completed the turn is ignored via
the shared completion guard.

* test: wrap over-length fixture error string to satisfy lll
2026-10-16 17:50:14 +08:00